添加项目详情
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -123,4 +123,7 @@ public class projectService {
|
||||
projectEntity.setCategoryName(categoryEntity.getCategoryName());
|
||||
return projectEntity;
|
||||
}
|
||||
public int addProjectLookcount(String id ){
|
||||
return projectDao.addProjectLookcount(id);
|
||||
}
|
||||
}
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user