| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.PoleGroupParam; |
| | | import com.sandu.ximon.admin.param.GroupParam; |
| | | import com.sandu.ximon.admin.param.PoleGroupRelationParam; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.PoleGroupService; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | public class PoleGroupController { |
| | | |
| | | private final PoleGroupService poleGroupService; |
| | | private PermissionConfig permissionConfig; |
| | | |
| | | @GetMapping("/add") |
| | | public ResponseVO<Object> addGroup(@RequestBody @Validated PoleGroupParam param) { |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addGroup(@RequestBody @Validated GroupParam param) { |
| | | if (!permissionConfig.check(MenuEnum.GROUP_ADD.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(poleGroupService.addGroup(param)); |
| | | } |
| | | |
| | | @PostMapping("/update/{groupId}") |
| | | public ResponseVO<Object> updateGroup(@PathVariable Long groupId, @RequestBody @Validated PoleGroupParam param) { |
| | | public ResponseVO<Object> updateGroup(@PathVariable Long groupId, @RequestBody @Validated GroupParam param) { |
| | | if (!permissionConfig.check(MenuEnum.GROUP_UPDATE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(poleGroupService.updateGroup(groupId, param)); |
| | | } |
| | | |
| | | @GetMapping("/delete/{groupId}") |
| | | public ResponseVO<Object> delGroup(@PathVariable Long groupId) { |
| | | return ResponseUtil.success(poleGroupService.deleteGroup(groupId)); |
| | | @PostMapping("/delete") |
| | | public ResponseVO<Object> delGroup(@RequestBody List<Long> groupIds) { |
| | | if (!permissionConfig.check(MenuEnum.GROUP_DELETE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(poleGroupService.deleteGroup(groupIds)); |
| | | } |
| | | |
| | | @PostMapping("/list") |
| | | public ResponseVO<Object> listGroup() { |
| | | return ResponseUtil.success(poleGroupService.groupList()); |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> listGroup(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq) { |
| | | if (!permissionConfig.check(MenuEnum.GROUP_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | return ResponseUtil.success(poleGroupService.groupList(baseConditionVO, keyword, order, seq)); |
| | | } |
| | | |
| | | @PostMapping("/bind/{groupId}") |
| | | public ResponseVO<Object> bindPole(@PathVariable Long groupId, PoleGroupRelationParam param) { |
| | | return ResponseUtil.success(poleGroupService.bindPole(groupId,param.getPoleIdList())); |
| | | public ResponseVO<Object> bindPole(@PathVariable Long groupId, @RequestBody PoleGroupRelationParam param) { |
| | | if (!permissionConfig.check(MenuEnum.GROUP_BINDING_POLE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.success(poleGroupService.bindPole(groupId, param.getPoleIdList())); |
| | | } |
| | | } |