添加项目详情

This commit is contained in:
cyk
2023-07-03 10:33:52 +08:00
parent df7d6207eb
commit 68e451ed9e
3 changed files with 25 additions and 0 deletions

View File

@@ -187,4 +187,21 @@ public class projectDao {
}
return projectEntity;
}
/**
* 根据项目ID增加观看量
*/
public int addProjectLookcount(String id ) {
int num;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql = "UPDATE project SET lookcount = lookcount+1 WHERE projectId= ?";
num = runner.update(conn, sql,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
}

View File

@@ -123,4 +123,7 @@ public class projectService {
projectEntity.setCategoryName(categoryEntity.getCategoryName());
return projectEntity;
}
public int addProjectLookcount(String id ){
return projectDao.addProjectLookcount(id);
}
}

View File

@@ -39,9 +39,14 @@ public class selectProByIdServlet extends HttpServlet {
resp.setContentType("application/json;charset=UTF-8");
//按照分类返回期刊
String id = req.getParameter("xxxxxxx");
int num = projectService.addProjectLookcount(id);
PrintWriter writer = resp.getWriter();
String jsonString = JSONObject.toJSONString(projectService.selectProById(id));
writer.println(jsonString);
if(num == 0 ){
setResult(200, "观看量增加失败", writer);
}
writer.close();
}
public void setResult(Integer code, String msg, PrintWriter writer) {