admin
2019-07-30 714da0c87a1b94adf4057858b9cc0a2569fb0a04
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.fanli.controller.admin;
 
import java.io.PrintWriter;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
 
import com.yeshi.fanli.entity.xinge.PushRecord;
import com.yeshi.fanli.service.inter.push.PushRecordService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
 
import net.sf.json.JSONObject;
 
@Controller
@RequestMapping("admin/new/api/v1/pushRecord")
public class PushRecordAdminController {
    
    
    @Resource
    private PushRecordService pushRecordService;
    
    
    /**
     * 推荐记录 -(新后台)
     * @param callback
     * @param key
     * @param type
     * @param pageIndex
     * @param out
     */
    @RequestMapping(value = "getNewPushRecordList")
    public void getNewPushRecordList(String callback, String key, Integer type, Integer pageIndex, PrintWriter out){
        try {
            
            if (pageIndex == null || pageIndex < 0){
                pageIndex = 1;
            }
            
            if (type == null) {
                type = 0;
            }
            
            int pageSize = Constant.PAGE_SIZE;
            
            List<PushRecord> list = pushRecordService.getPushRecordList((pageIndex-1) * pageSize, pageSize, key, type);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无更多数据"));
                return;
            }
            
            long count = pushRecordService.getCount(key, type);
            
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
 
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", list);
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
            e.printStackTrace();
        }
        
    }
    
    
}