package com.ekexiu.portal.service; import java.sql.Connection; import java.sql.SQLException; import java.util.Collections; import java.util.List; 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.util.PageQueryResult; import com.ekexiu.portal.dao.PaperAuthorDao; import com.ekexiu.portal.dao.PpaperDao; import com.ekexiu.portal.po.PaperAuthor; import com.ekexiu.portal.po.Ppaper; import com.ekexiu.portal.po.Resource; import com.ekexiu.portal.pojo.AssedPaper; @Path("/ppaper") public class PpaperService { @Autowrie private PpaperDao ppaperDao; @Autowrie private PaperAuthorDao paperAuthorDao; @Autowrie private KeyWordService keyWordService; public KeyWordService getKeyWordService() { return keyWordService; } public void setKeyWordService(KeyWordService keyWordService) { this.keyWordService = keyWordService; } public PpaperDao getPpaperDao() { return ppaperDao; } public void setPpaperDao(PpaperDao ppaperDao) { this.ppaperDao = ppaperDao; } public PaperAuthorDao getPaperAuthorDao() { return paperAuthorDao; } public void setPaperAuthorDao(PaperAuthorDao paperAuthorDao) { this.paperAuthorDao = paperAuthorDao; } @Get @Path("/qo") public Ppaper query(@JdbcConn Connection con, String id) throws SQLException { return this.ppaperDao.query(con, id); } @Get @Path("/qm") public List query(@JdbcConn Connection con, String[] id) throws SQLException { return this.ppaperDao.query(con, id); } @Get @Path("/byProfessor") public PageQueryResult queryByProfessor(@JdbcConn Connection con, String id, @Nullable String name, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException { if (name == null) { name = "%"; } else { name = "%" + name + "%"; } return this.ppaperDao.pageQueryWithProfessor(con, id, name, pageSize, pageNo); } @Get @Path("/byAuthor") public PageQueryResult queryByAuthor(@JdbcConn Connection con, String author, String id, @Nullable String name, @DefaultValue("10") int pageSize, @DefaultValue("1") int pageNo) throws SQLException { if (name == null) { name = "%"; } else { name = "%" + name + "%"; } return this.ppaperDao.pageQueryWithAuthor(con, author, id, name, pageSize, pageNo); } @Get @Path("/authors") public List queryAuthors(@JdbcConn Connection con, String id) throws SQLException { return this.paperAuthorDao.query(con, id); } @Get @Path("/pq") public PageQueryResult pageQuery(@JdbcConn Connection con, @Nullable String qw, @DefaultValue("20") int pageSize, @DefaultValue("1") int pageNo) throws SQLException { return null == qw ? this.ppaperDao.query(con, pageSize, pageNo) : this.ppaperDao.query(con, "%" + qw + "%", pageSize, pageNo); } /** * * @param con * @param uid * 专家ID(用户ID) * @param id * 论文ID * @param author * 作者名称 * @return * @throws SQLException */ @Post @Path("/ass") public int ass(@JdbcConn(true) Connection con, String uid, String id, String author) throws SQLException { return this.paperAuthorDao.update(con, id, uid, author); } /** * * @param con * @param uid * 专家ID(用户ID) * @param id * 论文ID * @return * @throws SQLException */ @Post @Path("/cAss") public int cAss(@JdbcConn(true) Connection con, String uid, String id) throws SQLException { return this.paperAuthorDao.update(con, id, uid); } @Post @Path("/incPageViews") public void incPageViews(@JdbcConn(true) Connection con, String id) throws SQLException { this.ppaperDao.incPageViews(con, id); } @Post @Path("/kw") public void update(@JdbcConn(true) Connection con, String id, @Nullable String keywords) throws SQLException { this.ppaperDao.update(con, id, keywords); this.keyWordService.refreshPaper(con, id, KeyWordService.splitKeyWord(keywords)); } @Get @Path("/byShareId") public Ppaper query(@JdbcConn Connection con,long id) throws SQLException{ return this.ppaperDao.query(con,id); } @Get @Path("/ralatePapers") public List ralatePapers(@JdbcConn Connection con,String paperId,@DefaultValue("10") int rows)throws SQLException{ String[] ids = this.ppaperDao.queryPaperIdWithSameKeyWord(con, paperId, rows); if(ids!=null){ return this.ppaperDao.query(con,ids); } return Collections.emptyList(); } }