No Description

ProfessorService.java 5.1KB

    package com.ekexiu.console.system.service; import com.ekexiu.console.system.dao.OrgDao; import com.ekexiu.console.system.dao.ProfessorDao; import com.ekexiu.console.system.po.Professor; import com.ekexiu.console.system.pojo.ProfessorInfo; import com.ekexiu.console.system.vo.ConsoleAuthUser; import org.jfw.apt.annotation.Autowrie; import org.jfw.apt.annotation.DefaultValue; import org.jfw.apt.annotation.Nullable; import org.jfw.apt.web.annotation.LoginUser; 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.operate.Put; import org.jfw.apt.web.annotation.param.JdbcConn; import org.jfw.apt.web.annotation.param.PathVar; import org.jfw.apt.web.annotation.param.RequestBody; import org.jfw.util.PageQueryResult; import org.jfw.util.StringUtil; import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; /** * Created by TT on 2017/5/25. */ @Path("/sys/professor") public class ProfessorService { @Autowrie private ProfessorDao professorDao; @Autowrie private OrgDao orgDao; @Autowrie private OrgService orgService; public OrgService getOrgService() { return orgService; } public void setOrgService(OrgService orgService) { this.orgService = orgService; } public OrgDao getOrgDao() { return orgDao; } public void setOrgDao(OrgDao orgDao) { this.orgDao = orgDao; } public ProfessorDao getProfessorDao() { return professorDao; } public void setProfessorDao(ProfessorDao professorDao) { this.professorDao = professorDao; } @Post @Path public String insert(@JdbcConn(true) Connection con, Professor professor, @Nullable String orgName) throws SQLException, IOException { if (professor.getId() == null) { professor.setId(StringUtil.buildUUID()); } if (professor.getOrgId() == null && orgName != null) { if (null != this.orgDao.queryByName(con, orgName)) { professor.setOrgId(this.orgDao.queryByName(con, orgName)); } else { professor.setOrgId(this.orgService.createOrganization(con, orgName)); } } if (professor.getOrgAuth() == null) { professor.setOrgAuth("0"); } this.professorDao.insert(con, professor); return professor.getId(); } @Put @Path public void update(@JdbcConn(true) Connection con, @RequestBody Professor professor) throws SQLException, IOException { this.professorDao.update(con, professor); } @Get @Path("/pq") public PageQueryResult<ProfessorInfo> pageQuery(@JdbcConn Connection con, @Nullable String enter,@Nullable String orgName, @Nullable String name, @Nullable Integer professorState, @Nullable String bt, @Nullable String et, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException { String oName = null; if (orgName != null) { oName = "%" + orgName + "%"; } String pname = null; if (name != null) { pname = "%" + name + "%"; } if (et!=null) { et = et + "235959"; } return this.professorDao.pageQuery(con,enter, oName, pname, professorState, bt, et, pageSize, pageNo); } @Get @Path("/id/{id}") public ProfessorInfo sortFirst(@JdbcConn Connection con,@PathVar String id) throws SQLException { return this.professorDao.query(con, id); } @Post @Path("/sortFirst") public void updateSortFirst(@JdbcConn(true) Connection con,String id,Integer sortFirst)throws SQLException { this.professorDao.updateSortFirst(con, id, sortFirst); } @Get @Path("/pqperson") public PageQueryResult<ProfessorInfo> pageQueryPerson(@JdbcConn Connection con, @LoginUser ConsoleAuthUser cau,@Nullable String orgName, @Nullable String name, @Nullable Integer professorState,@Nullable String bt, @Nullable String et, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException { String oName = null; if (orgName != null) { oName = "%" + orgName + "%"; } String pname = null; if (name != null) { pname = "%" + name + "%"; } if (bt != null) bt = bt + "000000"; if (et != null) et = et + "235959"; return this.professorDao.pageQueryPerson(con,cau.getId(),oName, pname, professorState, bt, et, pageSize, pageNo); } @Post @Path("/check") public void check(@JdbcConn(true) Connection con, String[] ids, Integer professorState, Integer authType, Integer authStatusExpert)throws SQLException { this.professorDao.updateProfessorState(con, ids, professorState); this.professorDao.updateAuthType(con, ids, authType); this.professorDao.updateAuthStatusExpert(con, ids, authStatusExpert); } @Get @Path("/getName/{id}") public String getName(@JdbcConn Connection con,@PathVar String id) throws SQLException { return this.professorDao.queryById(con, id); } }