UserMgrController.java 2.58 KB
package com.glsx.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.glsx.model.PlatformUser;
import com.glsx.service.UserMgrService;
import org.oreframework.web.ui.Pagination;
import org.oreframework.web.ui.ResponseEntity;
import org.oreframework.web.ui.ResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/usermgr")
public class UserMgrController {
    /**
     * 日志
     */
    private final static Logger LOGGER = LoggerFactory.getLogger(UserMgrController.class);

    @Autowired
    private UserMgrService userMgrService;

    @RequestMapping(value = "/getUserMgrList", method = RequestMethod.GET)
    @ResponseBody
    public ResponseEntity<PlatformUser> getUserMgrList(Pagination pagination) {
        ResponseEntity<PlatformUser> responseEntity = new ResponseEntity<>();
        //PageHelper注入分页和要分页的查询之前不能有其它查询,不然分页到第一个查询上面
        PageHelper.startPage(pagination.getCurrentPage(), pagination.getPageSize(), true);

        List<PlatformUser> datasyncAnjVerifyAccountsList = userMgrService.getUserMgrList();

        long total = ((Page<PlatformUser>) datasyncAnjVerifyAccountsList).getTotal();

        responseEntity.setData(datasyncAnjVerifyAccountsList);
        responseEntity.setRecordsTotal(total);
        responseEntity.setRecordsFiltered(total);
        return responseEntity;
    }

    @RequestMapping(value = "/reset", method = RequestMethod.GET)
    @ResponseBody
    public ResponseEntity<PlatformUser> reset(Pagination pagination) {
        ResponseEntity<PlatformUser> responseEntity = new ResponseEntity<>();
        //PageHelper注入分页和要分页的查询之前不能有其它查询,不然分页到第一个查询上面
        PageHelper.startPage(pagination.getCurrentPage(), pagination.getPageSize(), true);

        List<PlatformUser> datasyncAnjVerifyAccountsList = userMgrService.getUserMgrList();

        long total = ((Page<PlatformUser>) datasyncAnjVerifyAccountsList).getTotal();

        responseEntity.setData(datasyncAnjVerifyAccountsList);
        responseEntity.setRecordsTotal(total);
        responseEntity.setRecordsFiltered(total);
        return responseEntity;
    }
}