No Description

DemandService.java 2.9KB

    package com.ekexiu.console.system.service; import com.ekexiu.console.system.dao.ConsultDao; import com.ekexiu.console.system.dao.DemandDao; import com.ekexiu.console.system.pojo.ConsultInfo; import com.ekexiu.console.system.pojo.DemandInfo; import org.jfw.apt.annotation.Autowrie; import org.jfw.apt.annotation.DefaultValue; import org.jfw.apt.annotation.Nullable; import org.jfw.apt.web.annotation.Path; import org.jfw.apt.web.annotation.operate.Get; import org.jfw.apt.web.annotation.operate.Post; import org.jfw.apt.web.annotation.param.JdbcConn; import org.jfw.apt.web.annotation.param.PathVar; import org.jfw.util.PageQueryResult; import java.sql.Connection; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; /** * Created by TT on 2017/5/8. */ @Path("/demand") public class DemandService { @Autowrie DemandDao demandDao; @Autowrie ConsultDao consultDao; public ConsultDao getConsultDao() { return consultDao; } public void setConsultDao(ConsultDao consultDao) { this.consultDao = consultDao; } public DemandDao getDemandDao() { return demandDao; } public void setDemandDao(DemandDao demandDao) { this.demandDao = demandDao; } @Get @Path("/id/{id}") public DemandInfo query(@JdbcConn Connection con, @PathVar String id)throws SQLException { return this.demandDao.query(con,id); } @Get @Path("/pq") public PageQueryResult<DemandInfo> pageQuery(@JdbcConn Connection con, @Nullable String demandTitle, @Nullable String professorName, @Nullable String demandAim, @Nullable String bt, @Nullable String et, @DefaultValue("5") int pageSize, @DefaultValue("1") int pageNo)throws SQLException { String title =null; if(demandTitle!=null) { title="%"+demandTitle+"%"; } String name =null; if(professorName!=null) { name="%"+professorName+"%"; } String aim =null; if(demandAim!=null) { aim="%"+demandAim+"%"; } if (bt != null) bt = bt + "000000"; if (et != null) et = et + "235959"; return this.demandDao.pageQuery(con,title, name, aim,bt,et, pageNo, pageSize); } @Get @Path("/demandId/{id}") public List<ConsultInfo> queryList(@JdbcConn Connection con, @PathVar String id) throws SQLException { return this.consultDao.queryDemand(con, id); } @Post @Path("/close") public void closeDemand(@JdbcConn(true) Connection con,String demandId,String demandStatus)throws SQLException{ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String closeTime = sdf.format(new Date()); int status = Integer.parseInt(demandStatus); status = (status + 1) % 2; this.demandDao.updateDemandStatus(con, demandId, String.valueOf(status), closeTime); } }