修改onefile接口
This commit is contained in:
@@ -1,12 +1,33 @@
|
|||||||
package com.hellogithub.service;
|
package com.hellogithub.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hellogithub.dao.fileDao;
|
import com.hellogithub.dao.fileDao;
|
||||||
import com.hellogithub.entity.fileEntity;
|
import com.hellogithub.entity.fileEntity;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class oneFileService {
|
public class oneFileService {
|
||||||
private fileDao fileDao = new fileDao();
|
private fileDao fileDao = new fileDao();
|
||||||
public List<fileEntity> selectFileEntity(){return fileDao.selectFileEntity(); }
|
public String selectFileEntity(){
|
||||||
|
|
||||||
|
List<fileEntity> fileEntityList =fileDao.selectFileEntity();
|
||||||
|
Map<String,String> dataMap;
|
||||||
|
Map<String,Map<String,String>> daMap2= new HashMap<>();
|
||||||
|
for(int i=0;i<fileEntityList.size();i++)
|
||||||
|
{
|
||||||
|
dataMap = new HashMap<>();
|
||||||
|
fileEntity fileEntity = fileEntityList.get(i);
|
||||||
|
String name = fileEntity.getOneFileName();
|
||||||
|
String language =fileEntity.getLanguage();
|
||||||
|
String description = fileEntity.getDescription();
|
||||||
|
dataMap.put("name",name);
|
||||||
|
dataMap.put("language",language);
|
||||||
|
dataMap.put("description",description);
|
||||||
|
daMap2.put(""+i,dataMap);
|
||||||
|
}
|
||||||
|
return JSONObject.toJSONString(daMap2);
|
||||||
|
}
|
||||||
public fileEntity selectFileEntityById(int id ){return fileDao.selectFileEntityById(id); }
|
public fileEntity selectFileEntityById(int id ){return fileDao.selectFileEntityById(id); }
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ public class selectFileServlet extends HttpServlet {
|
|||||||
resp.setHeader("Access-Control-Max-Age", "3600");
|
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.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
||||||
resp.setContentType("application/json;charset=UTF-8");
|
resp.setContentType("application/json;charset=UTF-8");
|
||||||
String jsonString = JSONObject.toJSONString(oneFileService.selectFileEntity());
|
String jsonString = oneFileService.selectFileEntity();
|
||||||
|
|
||||||
PrintWriter writer = resp.getWriter();
|
PrintWriter writer = resp.getWriter();
|
||||||
writer.println(jsonString);
|
writer.println(jsonString);
|
||||||
|
Reference in New Issue
Block a user