添加项目详情

This commit is contained in:
cyk
2023-07-03 10:55:44 +08:00
parent 68e451ed9e
commit 428d030c94
3 changed files with 23 additions and 1 deletions

View File

@@ -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<categoryEntity> retProjectLabel(String id ) {
List<categoryEntity> 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;
}
}

View File

@@ -126,4 +126,7 @@ public class projectService {
public int addProjectLookcount(String id ){
return projectDao.addProjectLookcount(id);
}
public List<categoryEntity> retProjectLabel(String id ){
return projectDao.retProjectLabel(id);
}
}

View File

@@ -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);
}