package org.jeecg.modules.dnc.controller; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.aspect.annotation.AutoLog; import org.jeecg.common.system.base.controller.JeecgController; import org.jeecg.modules.dnc.entity.DeviceGroup; import org.jeecg.modules.dnc.response.CommonCode; import org.jeecg.modules.dnc.response.QueryListResponseResult; import org.jeecg.modules.dnc.response.ResponseResult; import org.jeecg.modules.dnc.service.IDeviceGroupService; import org.jeecg.modules.dnc.ucenter.Department; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Collections; import java.util.List; @Slf4j @Api(tags = "设备分组表") @RestController @RequestMapping("/nc/device/group") public class DeviceGroupController extends JeecgController { @Autowired private IDeviceGroupService deviceGroupService; @AutoLog(value = "设备分组表-新增设备分组") @ApiOperation(value = "设备分组表-新增设备分组", notes = "设备分组表-新增设备分组") @PostMapping("/add") public ResponseResult addDeviceGroup(@RequestBody DeviceGroup deviceGroup) { boolean b = deviceGroupService.addDeviceGroup(deviceGroup); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "设备分组表-编辑设备分组") @ApiOperation(value = "设备分组表-编辑设备分组", notes = "设备分组表-编辑设备分组") @PutMapping("/edit/{id}") public ResponseResult editDeviceGroup(@PathVariable("id") String id, @RequestBody DeviceGroup deviceGroup) { boolean b = deviceGroupService.editDeviceGroup(id, deviceGroup); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "设备分组表-删除设备分组") @ApiOperation(value = "设备分组表-删除设备分组", notes = "设备分组表-删除设备分组") @DeleteMapping("/delete") public ResponseResult deleteDeviceGroup(@RequestParam("id") String id) { boolean b = deviceGroupService.deleteDeviceGroup(id); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "设备分组表-获取分组已分配的部门") @ApiOperation(value = "设备分组表-获取分组已分配的部门", notes = "设备分组表-获取分组已分配的部门") @GetMapping("/get/perm/depart/{groupId}") public QueryListResponseResult getDepartPermsList(@PathVariable("groupId") String groupId) { List list = deviceGroupService.getDepartPermsList(groupId); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult<>(CommonCode.SUCCESS, list); } @AutoLog(value = "设备分组表-获取分组未分配的部门") @ApiOperation(value = "设备分组表-获取分组未分配的部门", notes = "设备分组表-获取分组未分配的部门") @GetMapping("/get/non/perm/depart/{groupId}") public QueryListResponseResult getDepartNonPermsList(@PathVariable("groupId") String groupId) { List list = deviceGroupService.getDepartNonPermsList(groupId); if(list == null) list = Collections.emptyList(); return new QueryListResponseResult<>(CommonCode.SUCCESS, list); } @AutoLog(value = "设备分组表-给分组分配部门权限") @ApiOperation(value = "设备分组表-给分组分配部门权限", notes = "设备分组表-给分组分配部门权限") @PostMapping("/assign/add/depart/{groupId}/{relativeFlag}") public ResponseResult assignAddDepartment(@PathVariable("groupId") String groupId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] departmentIds) { boolean b = deviceGroupService.assignAddDepartment(groupId, relativeFlag, departmentIds); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } @AutoLog(value = "设备分组表-移除分组分配部门权限") @ApiOperation(value = "设备分组表-移除分组分配部门权限", notes = "设备分组表-移除分组分配部门权限") @PostMapping("/assign/remove/depart/{groupId}/{relativeFlag}") public ResponseResult assignRemoveDepartment(@PathVariable("groupId") String groupId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] departmentIds) { boolean b = deviceGroupService.assignRemoveDepartment(groupId, relativeFlag, departmentIds); if(b) { return new ResponseResult(CommonCode.SUCCESS); } return new ResponseResult(CommonCode.FAIL); } }