admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
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
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.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies;
import com.yeshi.fanli.service.inter.redpack.UserTaoLiJinNewbiesService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
 
import net.sf.json.JSONObject;
 
@Controller
@RequestMapping("admin/new/api/v1/tlj")
public class TaoLiJinAdminController {
 
    @Resource
    private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
 
    /**
     * 新人红包查询
     * @param callback
     * @param pageIndex
     * @param key
     * @param order
     * @param out
     */
    @RequestMapping(value = "queryNewbies")
    public void queryNewbies(String callback, Integer pageIndex, String key, Integer order, PrintWriter out) {
        try {
            int pageSize = Constant.PAGE_SIZE;
            
            List<UserTaoLiJinNewbies> list = userTaoLiJinNewbiesService.query(pageIndex, pageSize, key, order);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未查找到相关信息"));
                return;
            }
            
            long count = userTaoLiJinNewbiesService.count(key);
 
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
 
            Gson gson = new GsonBuilder().serializeNulls().setDateFormat("yyyy/MM/dd HH:mm:ss").create();
 
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("result_list", gson.toJson(list));
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        } catch (Exception e) {
            e.printStackTrace();
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("系统异常")));
        }
    }
 
}