admin
2021-04-07 35a29882f356542dd9c431714c64d277eb7cad40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.yeshi.buwan.controller.admin.api;
 
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.buwan.domain.Comment2;
import com.yeshi.buwan.service.imp.CommentService;
import com.yeshi.buwan.util.Constant;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.web.tag.PageEntity;
 
import net.sf.json.JSONObject;
 
@Controller
@RequestMapping("admin/new/api/comment")
public class CommentController {
 
    @Resource
    private CommentService commentService;
 
    /**
     * 关键字搜索列表
     * 
     * @return
     */
    @RequestMapping(value = "/commentList", method = RequestMethod.POST)
    public void specialList(int pageIndex, String key, PrintWriter out) {
 
        if (pageIndex == 0)
            pageIndex = 1;
        key = StringUtil.isNullOrEmpty(key) ? "" : key;
 
        List<Comment2> list = commentService.getCommentList(key, pageIndex);
        long count = commentService.getCommentCount(key);
 
        PageEntity pe = new PageEntity();
        pe.setPageIndex(pageIndex);
        pe.setPageSize(Constant.pageCount);
        Map<String, String> map = new HashMap<String, String>();
        map.put("key", key);
        pe.setParams(map);
        pe.setTotalCount((int) count);
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        JSONObject root = new JSONObject();
        root.put("code", "0");
        root.put("pageEntity", pe);
        root.put("commentList", gson.toJson(list));
        System.out.println(root.toString());
        out.print(root);
        return;
    }
 
    @RequestMapping(value = "/delComment", method = RequestMethod.POST)
    public void delSpecial(String ids, PrintWriter out) {
        if (ids != null && !"".equals(ids.trim())) {
            String[] idArr = ids.split(",");
            for (String id : idArr) {
                commentService.deleteComment(id);
            }
            out.print("yes");
        }
    }
 
}