Skip to content

Commit

Permalink
修正资源页面不能删除的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
huoji555 committed Mar 21, 2018
1 parent 2b3cda4 commit 8702033
Showing 1 changed file with 48 additions and 29 deletions.
77 changes: 48 additions & 29 deletions src/main/java/com/hwj/web/CollectionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,38 @@ public class CollectionController {
* @return
* @throws IOException
*/
@RequestMapping("getCollectionFile.do")
@RequestMapping("/getCollectionFile.do")
@ResponseBody
public String getCollectionFile(@RequestBody String requestJsonBody,HttpServletRequest request) throws IOException{

public String getCollectionFile(HttpServletRequest request)
throws IOException {

HttpSession session = request.getSession();
String userid = String.valueOf(session.getAttribute("username"));

List<FileCollection> list = tryCatchFileCollectionService.getFileCollection("userid", userid);

if(list==null || list.equals(null)){

List<FileCollection> list = tryCatchFileCollectionService
.getFileCollection("userid", userid);

System.out.println(list + "huoji555");
if (list == null || list.equals(null)) {

return statusMap.a("2");
}
//去重
for(int i=0; i<list.size(); i++){
FileCollection fileCollection = list.get(i);
for(int j=i+1; j<list.size(); j++){

for (int i = 0; i < list.size(); i++) {

FileCollection fileCollection1 = list.get(i);
for (int j = i + 1; j < list.size(); j++) {
FileCollection fileCollection2 = list.get(j);
if(fileCollection.getF_id() == fileCollection2.getF_id()){

if (fileCollection1.getF_id().equals(fileCollection2.getF_id())) {
list.remove(j);
}
}

}

return jsonAnalyze.list2Json(list);

}


Expand All @@ -87,25 +92,39 @@ public String getCollectionFile(@RequestBody String requestJsonBody,HttpServletR
* @throws IOException
*/
@RequestMapping("/collectionDelete.do")
@ResponseBody
public String collectionDelete(@RequestBody String requestJsonBody, HttpServletRequest request) throws IOException{

Map<String, Object> map = jsonAnalyze.json2Map(requestJsonBody);

String f_id = String.valueOf(map.get("f_id"));
@ResponseBody
public String collectionDelete(@RequestBody String reuqestBody,
HttpServletRequest request) throws IOException {

// 用来取请求体中的数据
Map<String, Object> map = jsonAnalyze.json2Map(reuqestBody);
String f_id = String.valueOf(map.get("f_id"));
String nodeid = String.valueOf(map.get("nodeid"));
HttpSession session = request.getSession();
String userid = String.valueOf(session.getAttribute("username"));

FileCollection fileCollection = tryCatchFileCollectionService.
getFileCollection("userid", userid, "nodeid", nodeid, "f_id", f_id);

if(tryCatchFileCollectionService.delFileCollection(fileCollection)){
FileCollection fileCollection = new FileCollection();

//不同情况,分别对待
if(nodeid.equals("null")){
System.out.println("到这里了");
fileCollection =tryCatchFileCollectionService.
getFileCollection1("userid", userid, "f_id", f_id);
} else {
fileCollection = tryCatchFileCollectionService
.getFileCollection("userid", userid, "f_id", f_id, "nodeid",
nodeid);
}

System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$"+fileCollection);

if (tryCatchFileCollectionService.delFileCollection(fileCollection)) {
return statusMap.a("1");
} else {
return statusMap.a("2");
}

return statusMap.a("2");


}


Expand Down Expand Up @@ -165,7 +184,7 @@ public String saveCollectionFile(@RequestBody String requestJsonBody,HttpServlet
* @return
* @throws IOException
*/
@RequestMapping("/search.do")
@RequestMapping("/search1.do")
@ResponseBody
public String search(@RequestBody String requestbody,
HttpServletRequest request) throws IOException {
Expand Down

0 comments on commit 8702033

Please sign in to comment.