更新项目详情
This commit is contained in:
@@ -5,7 +5,10 @@ import com.hellogithub.dao.categoryDao;
|
||||
import com.hellogithub.dao.projectDao;
|
||||
import com.hellogithub.entity.categoryEntity;
|
||||
import com.hellogithub.entity.projectEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class projectService {
|
||||
@@ -126,7 +129,14 @@ public class projectService {
|
||||
public int addProjectLookcount(String id ){
|
||||
return projectDao.addProjectLookcount(id);
|
||||
}
|
||||
public List<categoryEntity> retProjectLabel(String id ){
|
||||
return projectDao.retProjectLabel(id);
|
||||
public String retProjectLabel(String id ){
|
||||
Map<String,String > dataMap = new HashMap<>();
|
||||
List<categoryEntity> categoryEntityList = projectDao.retProjectLabel(id);
|
||||
for(int i=0;i<categoryEntityList.size();i++)
|
||||
{
|
||||
categoryEntity categoryEntity=categoryEntityList.get(i);
|
||||
dataMap.put("CategoryName",categoryEntity.getCategoryName());
|
||||
}
|
||||
return dataMap.toString();
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package com.hellogithub.servlet;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hellogithub.service.projectService;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
@@ -37,15 +38,14 @@ public class selectProByIdServlet extends HttpServlet {
|
||||
resp.setHeader("Access-Control-Max-Age", "3600");
|
||||
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("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);
|
||||
String dataMap = projectService.retProjectLabel(id);
|
||||
JSONObject jsonObject = JSON.parseObject(dataMap);
|
||||
jsonObject.put("project",projectService.selectProById(id));
|
||||
writer.println(JSONObject.toJSONString(jsonObject));
|
||||
if(num == 0 ){
|
||||
setResult(200, "观看量增加失败", writer);
|
||||
}
|
||||
|
Reference in New Issue
Block a user