From 52eb3f0befcb397d2fdd645c8d7471d6ee477f87 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期一, 09 五月 2022 16:36:38 +0800
Subject: [PATCH] 权限
---
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java | 91 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 76 insertions(+), 15 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
index e4a1a47..43fd2ce 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -7,6 +7,7 @@
import com.sandu.common.domain.CommonPage;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.object.BaseConditionVO;
+import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.dto.DeviceStatus;
import com.sandu.ximon.admin.param.PoleBindParam;
@@ -24,7 +25,6 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
-import java.sql.Wrapper;
import java.util.List;
/**
@@ -45,16 +45,25 @@
@PostMapping("/add")
public ResponseVO<Object> addPole(@RequestBody @Validated PoleParam param) {
+ if (!permissionConfig.check(MenuEnum.POLE_VIRTUAL_ADD.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
return ResponseUtil.success(poleService.addPole(param));
}
@PostMapping("/update/{poleId}")
public ResponseVO<Object> updatePole(@PathVariable Long poleId, @RequestBody @Validated PoleParam param) {
+ if (!permissionConfig.check(MenuEnum.POLE_UPDATE.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
return ResponseUtil.success(poleService.updatePole(poleId, param));
}
@PostMapping("/delete/{poleId}")
public ResponseVO<Object> deletePole(@PathVariable Long poleId) {
+ if (!permissionConfig.check(MenuEnum.POLE_DELETE.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
return ResponseUtil.success(poleService.deletePole(poleId));
}
@@ -79,6 +88,9 @@
@GetMapping("/listPoleAndState")
public ResponseVO<Object> listPoleAndState(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "groupid", required = false) Long groupid) {
+ if (!permissionConfig.check(MenuEnum.POLE_LIST.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
List<Pole> poles = poleService.queryStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), keyword, groupid);
return ResponseUtil.successPage(poles);
@@ -87,6 +99,7 @@
/**
* 鍦ㄧ嚎鏁伴噺
*/
+ @AnonymousAccess
@GetMapping("/online")
public ResponseVO<Object> online() {
return ResponseUtil.success(poleService.poleCount());
@@ -98,9 +111,10 @@
*/
@PostMapping("/setMac/{baseMac}")
public ResponseVO<Object> setMac(@PathVariable String baseMac) {
- //public ResponseVO<Object> setMac() {
+ if (!permissionConfig.check(MenuEnum.POLE_REAL_ADD.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
return ResponseUtil.success(poleService.setMac(baseMac));
- // return ResponseUtil.success(poleService.setMac());
}
/**
@@ -108,6 +122,9 @@
*/
@PostMapping("/poleReset/{poleId}")
public ResponseVO<Object> poleReset(@PathVariable Long poleId) {
+ if (!permissionConfig.check(MenuEnum.POLE_REAL_RESET.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
return ResponseUtil.success(poleService.poleReset(poleId));
}
@@ -118,9 +135,12 @@
*/
@PostMapping("/bind/{poleId}")
public ResponseVO<Object> bindPole(@PathVariable Long poleId, @RequestBody @Validated PoleBindingParam param) {
+ if (!permissionConfig.check(MenuEnum.BINDING.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
boolean result = poleService.bindPole(poleId, param);
if (result) {
- //璁惧绫诲瀷锛�0璺伅锛�1nove锛�2鍏呯數妗╋紝3澶ф皵鐩戞祴锛�4姘磋川鐩戞祴锛�5ip闊虫煴锛�6lcd骞垮憡鏈猴紝7鎽勫儚澶达紝8鏉嗕綋鍊炬祴锛�9涓�閿晳鍔�, 10鐔欒
+ //璁惧绫诲瀷锛�0璺伅锛�1nove锛�2鍏呯數妗╋紝3澶ф皵鐩戞祴锛�4姘磋川鐩戞祴锛�5ip闊虫煴锛�6lcd骞垮憡鏈猴紝7鎽勫儚澶达紝8鏉嗕綋鍊炬祴锛�9涓�閿晳鍔�, 10鐔欒, 11鍐滆��
switch (param.getDeviceType()) {
case 0:
Pole pole = poleService.getById(poleId);
@@ -152,6 +172,8 @@
break;
case 10:
break;
+ case 11:
+ break;
default:
break;
}
@@ -166,12 +188,20 @@
* 鐏潌缁戝畾璁惧
*/
@PostMapping("/unBind/{poleId}")
- public ResponseVO<Object> unBindPole(@PathVariable Long poleId, @RequestBody PoleBindingParam param) {
+ public ResponseVO<Object> unBindPole(@PathVariable Long poleId, @RequestBody @Validated PoleBindingParam param) {
+ if (!permissionConfig.check(MenuEnum.UNBIND.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
boolean result = poleService.unBindPole(poleId, param.getDeviceCode());
if (result) {
- //璁惧绫诲瀷锛�0璺伅锛�1led灞忓箷锛�2鍏呯數妗╋紝3澶ф皵鐩戞祴锛�4姘磋川鐩戞祴锛�5ip闊虫煴锛�6lcd骞垮憡鏈猴紝7鎽勫儚澶达紝8鏉嗕綋鍊炬祴锛�9涓�閿晳鍔�, 10鐔欒
+ //璁惧绫诲瀷锛�0璺伅锛�1led灞忓箷锛�2鍏呯數妗╋紝3澶ф皵鐩戞祴锛�4姘磋川鐩戞祴锛�5ip闊虫煴锛�6lcd骞垮憡鏈猴紝7鎽勫儚澶达紝8鏉嗕綋鍊炬祴锛�9涓�閿晳鍔�, 10鐔欒, 11鍐滆��
switch (param.getDeviceType()) {
case 0:
+ //鍒犻櫎鐏潌鐨刣evicescode
+ Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, poleId));
+ if (pole != null) {
+ poleService.updateDeviceCode(pole.getId());
+ }
break;
case 1:
break;
@@ -195,6 +225,8 @@
break;
case 10:
break;
+ case 11:
+ break;
default:
break;
}
@@ -207,6 +239,9 @@
@PostMapping("/listStatusByDeviceCode")
public ResponseVO<Object> getStatusById(@RequestBody String[] deviceCodeList) {
+ if (!permissionConfig.check(MenuEnum.GET_STATE_BY_DEVICECODE.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
for (String s : deviceCodeList) {
if (s == null) {
return ResponseUtil.fail("鍙傛暟涓嶈兘涓虹┖");
@@ -222,7 +257,10 @@
@PostMapping("/ClientBindingPole")
public ResponseVO<Object> ClientBindingPole(@RequestBody PoleBindParam param) {
- return ResponseUtil.success(poleService.ClientBindingPole(param.getClientId(), param.getPoleIds()));//////////////
+ if (!permissionConfig.check(MenuEnum.CLIENT_BINDING_POLE.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
+ return ResponseUtil.success(poleService.ClientBindingPole(param.getClientId(), param.getPoleIds()));
}
@@ -232,25 +270,48 @@
@PostMapping("/getOwnerPole/{cilentId}")
public ResponseVO<Object> getOwnerPole(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword
, @PathVariable Long cilentId) {
+ if (!permissionConfig.check(MenuEnum.GET_CLIENT_POLE.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
List<Pole> results = poleService.getOwnerPole(baseConditionVO, keyword, cilentId);
-// CommonPage commonPage = CommonPage.restPage(results);
-// int size = results.size();
-// commonPage.setTotal((long) size);
-// commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1);
-// if (size % baseConditionVO.getPageSize() == 0) {
-// commonPage.setTotalPage(size / baseConditionVO.getPageSize());
-// }
-// return ResponseUtil.success(commonPage);
return ResponseUtil.success(results);
}
/**
* 鏌ョ湅鐏潌缁戝畾鐨勮澶�
*/
+ @AnonymousAccess
@PostMapping("/getPoleBindDevice/{poleId}")
public ResponseVO<Object> getPoleBindDevice(@PathVariable Long poleId) {
+ if (!permissionConfig.check(MenuEnum.GET_POLE_BINDING.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
return ResponseUtil.success(poleService.getBindByPoleId(poleId));
}
+ /**
+ * 鎺ㄩ�佸ぇ姘旇澶囧埌璇虹摝
+ */
+ @AnonymousAccess
+ @GetMapping("/pushAidDataToNova/{poleId}")
+ public ResponseVO<Object> pushAirDataToNova(@PathVariable Long poleId) {
+ if (!permissionConfig.check(MenuEnum.PUSH_AIR_DATA_TO_NOVA.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
+ return ResponseUtil.success(poleService.pushAirDataToNova(poleId));
+ }
+
+ /**
+ * 鎺ㄩ�佸ぇ姘旇澶囧埌鐔欒
+ */
+ @AnonymousAccess
+ @GetMapping("/pushAirDataToXiXun/{poleId}")
+ public ResponseVO<Object> pushAirDataToXiXun(@PathVariable Long poleId) {
+ if (!permissionConfig.check(MenuEnum.PUSH_AIR_DATA_TO_XIXUN.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
+ }
+ return ResponseUtil.success(poleService.pushAirDataToXiXun(poleId));
+ }
+
}
--
Gitblit v1.9.3