DeviceMgrController.java 2.17 KB
package com.glsx.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.glsx.model.PlatformCustomer;
import com.glsx.model.PlatformDevice;
import com.glsx.service.DeviceMgrService;
import com.glsx.vo.DeviceVo;
import com.glsx.vo.R;
import io.swagger.annotations.Api;
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.HashMap;
import java.util.List;

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

    @Autowired
    private DeviceMgrService deviceMgrService;

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

        List<PlatformDevice> deviceMgrList = deviceMgrService.getDeviceMgrList(deviceVo);

        return R.ok().putPageData(page, deviceMgrList);
    }

    @RequestMapping(value = "/getDropDownOptions", method = RequestMethod.GET)
    @ResponseBody
    public R getDropDownOptions() {
        HashMap<String, List<String>> hashMap = new HashMap<>();
        List<String> customerNameList = deviceMgrService.getCustomerNameList();

        List<String> deviceTypeList = deviceMgrService.getDeviceTypeList();

        hashMap.put("customerNameList", customerNameList);
        hashMap.put("deviceTypeList", deviceTypeList);
        return R.ok().data(hashMap);
    }
}