package com.lxzn.nc.controller; import com.lxzn.api.nc.DeviceGroupControllerApi; import com.lxzn.framework.domain.nc.DeviceGroup; import com.lxzn.framework.domain.ucenter.Department; import com.lxzn.framework.model.response.CommonCode; import com.lxzn.framework.model.response.QueryListResponseResult; import com.lxzn.framework.model.response.ResponseResult; import com.lxzn.nc.service.IDeviceGroupService; import org.apache.ibatis.annotations.Delete; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Collections; import java.util.List; @RestController @RequestMapping("/nc/device/group") public class DeviceGroupController implements DeviceGroupControllerApi { @Autowired private IDeviceGroupService deviceGroupService; @Override @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); } @Override @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); } @Override @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); } @Override @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); } @Override @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); } @Override @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); } @Override @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); } }