diff --git a/src/com/hellogithub/dao/projectDao.java b/src/com/hellogithub/dao/projectDao.java index d35f93c..586602a 100644 --- a/src/com/hellogithub/dao/projectDao.java +++ b/src/com/hellogithub/dao/projectDao.java @@ -1,5 +1,6 @@ package com.hellogithub.dao; +import com.hellogithub.entity.categoryEntity; import com.hellogithub.entity.projectEntity; import com.hellogithub.utils.JdbcUtils; import org.apache.commons.dbutils.QueryRunner; @@ -204,4 +205,20 @@ public class projectDao { } return num; } + /** + * 返回标签 + */ + public List retProjectLabel(String id ) { + List categoryEntityList ; + try { + Connection conn = JdbcUtils.getConnection(); + QueryRunner runner = new QueryRunner(); + String sql = "select categoryName from category where categoryId in( select categoryId from project_category where projectId = ?)"; + categoryEntityList = runner.query(conn, sql,new BeanListHandler<>(categoryEntity.class),id); + conn.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + return categoryEntityList; + } } diff --git a/src/com/hellogithub/service/projectService.java b/src/com/hellogithub/service/projectService.java index 5aa50b8..171cf70 100644 --- a/src/com/hellogithub/service/projectService.java +++ b/src/com/hellogithub/service/projectService.java @@ -126,4 +126,7 @@ public class projectService { public int addProjectLookcount(String id ){ return projectDao.addProjectLookcount(id); } + public List retProjectLabel(String id ){ + return projectDao.retProjectLabel(id); + } } \ No newline at end of file diff --git a/src/com/hellogithub/servlet/selectProByIdServlet.java b/src/com/hellogithub/servlet/selectProByIdServlet.java index 64b89ed..ae47893 100644 --- a/src/com/hellogithub/servlet/selectProByIdServlet.java +++ b/src/com/hellogithub/servlet/selectProByIdServlet.java @@ -38,12 +38,14 @@ public class selectProByIdServlet extends HttpServlet { resp.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With"); resp.setContentType("application/json;charset=UTF-8"); //按照分类返回期刊 - String id = req.getParameter("xxxxxxx"); + String id = req.getParameter("id"); int num = projectService.addProjectLookcount(id); PrintWriter writer = resp.getWriter(); String jsonString = JSONObject.toJSONString(projectService.selectProById(id)); + String jsonString1 = JSONObject.toJSONString(projectService.retProjectLabel(id)); writer.println(jsonString); + writer.println(jsonString1); if(num == 0 ){ setResult(200, "观看量增加失败", writer); }