sgj
5 天以前 8678e9973f5a1d537f1b23fb99eb8d951eb97a91
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
package com.fzzy.sys.controller.security.eventInfo;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fzzy.igds.constant.RespCodeEnum;
import com.fzzy.igds.data.IgdsBaseParam;
import com.fzzy.igds.data.PageResponse;
import com.fzzy.igds.domain.EventInfo;
import com.fzzy.sys.manager.security.eventInfo.EventInfoManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
 
@Slf4j
@Controller
@RequestMapping("/security/eventInfo")
public class EventInfoController {
 
    private static final String prefix = "security/eventInfo";
 
    @Resource
    private EventInfoManager eventInfoManager;
 
    @GetMapping
    public String getEventInfo(
            Model model) {
 
        IgdsBaseParam param = new IgdsBaseParam();
        param.setPage(1);
        param.setLimit(6);
        Page<EventInfo> events = eventInfoManager.pageData(param);
        model.addAttribute("eventInfoList", events.getRecords());
        model.addAttribute("currentPage", events.getCurrent());
        model.addAttribute("totalItems", events.getTotal());
        model.addAttribute("pageSize", events.getSize());
        return prefix + "/eventInfo";
    }
 
    /**
     * 分页获取数据
     *
     * @param param
     * @return
     */
    @RequestMapping("/pageData")
    @ResponseBody
    public PageResponse<Page<EventInfo>> pageData(@RequestBody IgdsBaseParam param) {
        Page<EventInfo> eventInfoPage = eventInfoManager.pageData(param);
        if (null == eventInfoPage.getRecords() || eventInfoPage.getRecords().isEmpty()) {
            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "获取到数据信息为空");
        }
        return new PageResponse<>(RespCodeEnum.CODE_0000, eventInfoPage);
    }
}