Administrator
2018-10-30 7bf6a0582c7c62c90ee2ed8a88654f11d0479092
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.yeshi.fanli.controller.admin;
 
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import net.sf.json.JSONObject;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
import com.yeshi.fanli.entity.bus.recommend.Honest;
import com.yeshi.fanli.service.inter.goods.HonestService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.GsonUtil;
import org.yeshi.utils.JsonUtil;
 
@Controller
@RequestMapping("admin/new/api/v1/honest")
public class HonestAdminController {
    
    @Resource
    private HonestService honestService;
    
    /**
     * 
     * 方法说明: 分页获取圆形图标列表
     * @author mawurui
     * createTime 2018年5月18日 下午4:42:26
     * @param pageIndex
     * @param key
     * @param out
     */
    @RequestMapping(value="/getHonestList",method=RequestMethod.POST)
    public void getHonestList(int pageIndex, String key,PrintWriter out){
        //查询总数
        Integer totalCount = honestService.getCount();
        int totalPage = totalCount % Constant.PAGE_SIZE == 0 ? totalCount
                 / Constant.PAGE_SIZE : totalCount / Constant.PAGE_SIZE + 1;
        PageEntity pageEntity = new PageEntity(pageIndex, Constant.PAGE_SIZE, totalCount,
                 totalPage);
        Map<String, String> map = new HashMap<String, String>();
        map.put("key", key);
        pageEntity.setParams(map);
        //分页查询所有榜单用户
        List<Honest> honestList = honestService.getHonestList(pageIndex-1, key);
        JSONObject data=new JSONObject();
        data.put("pageEntity", JsonUtil.getSimpleGsonWithDate().toJson(pageEntity));
        data.put("honestList", JsonUtil.getSimpleGsonWithDate().toJson(honestList));
        out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功"));
    }
    
    /**
     * 
     * 方法说明: 删除
     * @author mawurui
     * createTime 2018年5月18日 下午5:19:28
     * @param ids
     * @param out
     */
    @RequestMapping(value="/deleteHonest", method=RequestMethod.POST)
    public void deleteHonest(long[] ids, PrintWriter out){
        for (long id : ids) {
            honestService.deleteHonest(id);
        }
        out.print(JsonUtil.loadTrueResult("删除成功"));
    }
    
    /**
     * 
     * 方法说明: 修改
     * @author mawurui
     * createTime 2018年5月22日 下午4:27:28
     * @param honest
     * @param out
     */
    @RequestMapping(value="/updateHonest", method=RequestMethod.POST)
    public void updateHonest(Honest honest , PrintWriter out) {
        honestService.updateHonest(honest);
        out.print(JsonUtil.loadTrueResult("修改成功啦!"));
    }
    
    /**
     * 
     * 方法说明: 页面反显编辑数据
     * @author mawurui
     * createTime 2018年3月30日 上午9:32:52
     * @param id
     * @return
     */
    @RequestMapping(value="/getHonest", method=RequestMethod.POST)
    public void getHonest(long id, PrintWriter out) {
        Honest honest = honestService.getHonest(id);
        JSONObject data = new JSONObject();
        data.put("honest", GsonUtil.toDFJson(honest));
        out.print(JsonUtil.loadTrueResult(0, data));
    }
    
    /**
     * 
     * 方法说明: 添加
     * @author mawurui
     * createTime 2018年5月18日 下午5:32:46
     * @param spreadImg
     * @param url
     * @param out
     */
    @RequestMapping(value="/addHonest", method=RequestMethod.POST)
    public void addHonest(Honest honest, PrintWriter out) {
        honestService.addHonest(honest);
        out.print(JsonUtil.loadTrueResult("添加成功"));
    }
    
 
}