package com.moral.api.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.moral.api.entity.Device; import com.moral.api.entity.ManageAccount; import com.moral.api.entity.Organization; import com.moral.api.entity.User; import com.moral.api.pojo.vo.device.DeviceVO; import com.moral.api.service.DeviceService; import com.moral.api.service.OrganizationService; import com.moral.constant.ResultMessage; import com.moral.util.PageResult; @Slf4j @Api(tags = {"设备管理"}) @RestController @RequestMapping(value = "/device") public class DeviceController { @Autowired private DeviceService deviceService; @Autowired private OrganizationService organizationService; @ApiOperation(value = "添加设备", notes = "添加设备") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") }) @RequestMapping(value = "insert", method = RequestMethod.POST) public ResultMessage insert(@RequestBody Device device) { deviceService.insert(device); return ResultMessage.ok(); } @ApiOperation(value = "维护人列表", notes = "维护人列表") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") }) @RequestMapping(value = "operators", method = RequestMethod.GET) public ResultMessage selectOperators() { List operators = deviceService.selectAllOperator(); return ResultMessage.ok(operators); } @ApiOperation(value = "型号列表", notes = "型号列表") @RequestMapping(value = "versions", method = RequestMethod.GET) public ResultMessage selectVersions() { return null; } @ApiOperation(value = "组织列表", notes = "组织列表") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String") }) @RequestMapping(value = "organizations", method = RequestMethod.GET) public ResultMessage selectOrganizations() { List organizations = deviceService.selectAllOrganization(); return ResultMessage.ok(organizations); } @ApiOperation(value = "分页设备列表", notes = "分页设备列表") @ApiImplicitParams({ @ApiImplicitParam(name = "page", value = "当前页", required = false, paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "order", value = "排序字段", required = false, paramType = "query", dataType = "String"), @ApiImplicitParam(name = "orderType", value = "排序类型,升序:0,降序:1", defaultValue = "0", required = false, paramType = "query", dataType = "String"), @ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"), @ApiImplicitParam(name = "organizationName", value = "组织模糊查询", required = false, paramType = "query", dataType = "String"), @ApiImplicitParam(name = "monitorPointName", value = "站点模糊查询", required = false, paramType = "query", dataType = "String"), @ApiImplicitParam(name = "deviceName", value = "设备名称模糊查询", required = false, paramType = "query", dataType = "String"), @ApiImplicitParam(name = "mac", value = "mac模糊查询", required = false, paramType = "query", dataType = "String"), }) @RequestMapping(value = "select", method = RequestMethod.POST) public ResultMessage select(@RequestBody Map parameters) { Page userPage = deviceService.selectDevices(parameters); PageResult pageResult = new PageResult<>( userPage.getTotal(), userPage.getPages(), userPage.getRecords() ); return ResultMessage.ok(pageResult); } }