From 34cbd8375f3048a88a1f83c042632b5b19d13270 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 14 二月 2024 19:22:15 +0800
Subject: [PATCH] #
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/controller/RoleController.java | 74 +++++++++++++++++-
zy-asrs-flow/src/pages/system/role/index.jsx | 88 ---------------------
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java | 48 ++++++-----
3 files changed, 98 insertions(+), 112 deletions(-)
diff --git a/zy-asrs-flow/src/pages/system/role/index.jsx b/zy-asrs-flow/src/pages/system/role/index.jsx
index ab1f26e..fe8716b 100644
--- a/zy-asrs-flow/src/pages/system/role/index.jsx
+++ b/zy-asrs-flow/src/pages/system/role/index.jsx
@@ -1,11 +1,10 @@
import React, { useState, useRef, useEffect } from 'react';
-import { useIntl, FormattedMessage, useAccess } from '@umijs/max';
+import { useIntl, FormattedMessage } from '@umijs/max';
import { Button, message, Modal } from 'antd';
import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined, UnlockOutlined } from '@ant-design/icons';
-import { getLogininforList, removeLogininfor, exportLogininfor, unlockLogininfor, cleanLogininfor } from '@/services/monitor/logininfor';
-import { request } from '@umijs/max';
+import { getLogininforList, removeLogininfor, exportLogininfor} from '@/services/monitor/logininfor';
import Http from '@/utils/http'
@@ -29,42 +28,6 @@
} catch (error) {
hide();
message.error('鍒犻櫎澶辫触锛岃閲嶈瘯');
- return false;
- }
-};
-
-const handleClean = async () => {
- const hide = message.loading('璇风◢鍊�');
- try {
- const resp = await cleanLogininfor();
- hide();
- if (resp.code === 200) {
- message.success('娓呯┖鎴愬姛锛屽嵆灏嗗埛鏂�');
- } else {
- message.error(resp.msg);
- }
- return true;
- } catch (error) {
- hide();
- message.error('璇锋眰澶辫触锛岃閲嶈瘯');
- return false;
- }
-};
-
-const handleUnlock = async (userName) => {
- const hide = message.loading('姝e湪瑙i攣');
- try {
- const resp = await unlockLogininfor(userName);
- hide();
- if (resp.code === 200) {
- message.success('瑙i攣鎴愬姛锛屽嵆灏嗗埛鏂�');
- } else {
- message.error(resp.msg);
- }
- return true;
- } catch (error) {
- hide();
- message.error('瑙i攣澶辫触锛岃閲嶈瘯');
return false;
}
};
@@ -209,53 +172,6 @@
>
<DeleteOutlined />
<FormattedMessage id="pages.searchTable.delete" defaultMessage="鍒犻櫎" />
- </Button>,
- <Button
- type="primary"
- key="clean"
- danger
- hidden={selectedRows?.length === 0}
- onClick={async () => {
- Modal.confirm({
- title: '鏄惁纭娓呯┖鎵�鏈夋暟鎹」?',
- icon: <ExclamationCircleOutlined />,
- content: '璇疯皑鎱庢搷浣�',
- async onOk() {
- const success = await handleClean();
- if (success) {
- setSelectedRows([]);
- actionRef.current?.reloadAndRest?.();
- }
- },
- onCancel() { },
- });
- }}
- >
- <DeleteOutlined />
- <FormattedMessage id="pages.searchTable.cleanAll" defaultMessage="娓呯┖" />
- </Button>,
- <Button
- type="primary"
- key="unlock"
- hidden={selectedRows?.length === 0}
- onClick={async () => {
- Modal.confirm({
- title: '鏄惁纭瑙i攣璇ョ敤鎴风殑鏁版嵁椤�?',
- icon: <ExclamationCircleOutlined />,
- content: '璇疯皑鎱庢搷浣�',
- async onOk() {
- const success = await handleUnlock(selectedRows[0].userName);
- if (success) {
- setSelectedRows([]);
- actionRef.current?.reloadAndRest?.();
- }
- },
- onCancel() { },
- });
- }}
- >
- <UnlockOutlined />
- <FormattedMessage id="monitor.logininfor.unlock" defaultMessage="瑙i攣" />
</Button>,
<Button
type="primary"
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
index 54ac18f..33c38d5 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/common/aspect/OperationLogAspect.java
@@ -67,6 +67,20 @@
* 淇濆瓨鎿嶄綔璁板綍
*/
private void saveLog(JoinPoint joinPoint, Object result, Exception e) {
+ // 璁板綍妯″潡鍚嶃�佹搷浣滃姛鑳姐�佽姹傛柟娉曘�佽姹傚弬鏁般�佽繑鍥炵粨鏋�
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+ Method method = signature.getMethod();
+ if (null == method) {
+ return;
+ }
+ OperationLog ol = method.getAnnotation(OperationLog.class);
+ if (null == ol) {
+ return;
+ }
+ String desc = getDescription(method, ol);
+ if (Cools.isEmpty(desc)) {
+ return;
+ }
OperationRecord record = new OperationRecord();
Long endTime = startTime.get();
record.setCreateTime(new Date());
@@ -95,27 +109,19 @@
} else {
record.setResult(1);
}
- // 璁板綍妯″潡鍚嶃�佹搷浣滃姛鑳姐�佽姹傛柟娉曘�佽姹傚弬鏁般�佽繑鍥炵粨鏋�
- MethodSignature signature = (MethodSignature) joinPoint.getSignature();
- Method method = signature.getMethod();
- if (method != null) {
- OperationLog ol = method.getAnnotation(OperationLog.class);
- if (ol != null) {
- // 璁板綍鎿嶄綔鍔熻兘
- record.setNamespace(getDescription(method, ol));
- // 璁板綍澶囨敞
- if (!Cools.isEmpty(ol.comments())) {
- record.setMemo(ol.comments());
- }
- // 璁板綍璇锋眰鍙傛暟
- if (ol.param() && request != null) {
- record.setRequest(Utils.sub(getParams(joinPoint, request), MAX_LENGTH));
- }
- // 璁板綍璇锋眰缁撴灉
- if (ol.result() && result != null) {
- record.setResponse(Utils.sub(JSON.toJSONString(result), MAX_LENGTH));
- }
- }
+ // 璁板綍鎿嶄綔鍔熻兘
+ record.setNamespace(desc);
+ // 璁板綍澶囨敞
+ if (!Cools.isEmpty(ol.comments())) {
+ record.setMemo(ol.comments());
+ }
+ // 璁板綍璇锋眰鍙傛暟
+ if (ol.param() && request != null) {
+ record.setRequest(Utils.sub(getParams(joinPoint, request), MAX_LENGTH));
+ }
+ // 璁板綍璇锋眰缁撴灉
+ if (ol.result() && result != null) {
+ record.setResponse(Utils.sub(JSON.toJSONString(result), MAX_LENGTH));
}
operationRecordService.saveAsync(record);
}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/controller/RoleController.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/controller/RoleController.java
index 1bb4ada..1a7bb53 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/controller/RoleController.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/sys/controller/RoleController.java
@@ -1,5 +1,7 @@
package com.zy.asrs.wcs.sys.controller;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
import com.zy.asrs.wcs.common.annotation.OperationLog;
import com.zy.asrs.wcs.common.domain.BaseParam;
@@ -8,10 +10,9 @@
import com.zy.asrs.wcs.sys.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
/**
* Created by vincent on 2/13/2024
@@ -26,9 +27,72 @@
@PreAuthorize("hasAuthority('sys:role:list')")
@OperationLog
@PostMapping("/role/page")
- public R updateInfo(@RequestBody BaseParam param) {
+ public R page(@RequestBody BaseParam param) {
PageParam<Role, BaseParam> page = new PageParam<>(param);
return R.ok().add(roleService.page(page, page.getWrapper()));
}
+ @PreAuthorize("hasAuthority('sys:role:list')")
+ @OperationLog
+ @PostMapping("/role/list")
+ public R list(@RequestBody BaseParam param) {
+ return R.ok().add(roleService.list());
+ }
+
+ @PreAuthorize("hasAuthority('sys:role:list')")
+ @OperationLog
+ @GetMapping("/role/{id}")
+ public R get(@PathVariable("id") Long id) {
+ return R.ok().add(roleService.getById(id));
+ }
+
+ @PreAuthorize("hasAuthority('sys:role:save')")
+ @OperationLog("娣诲姞瑙掕壊")
+ @PostMapping("/role/save")
+ public R save(@RequestBody Role role) {
+ if (!Cools.isEmpty(role.getName())
+ && roleService.count(new LambdaQueryWrapper<Role>().eq(Role::getName, role.getName())) > 0) {
+ return R.error("瑙掕壊鍚嶇О宸插瓨鍦�");
+ }
+ if (!Cools.isEmpty(role.getCode())
+ && roleService.count(new LambdaQueryWrapper<Role>().eq(Role::getCode, role.getCode())) > 0) {
+ return R.error("瑙掕壊鏍囪瘑宸插瓨鍦�");
+ }
+ if (roleService.save(role)) {
+ return R.ok("娣诲姞鎴愬姛");
+ }
+ return R.error("娣诲姞澶辫触");
+ }
+
+ @PreAuthorize("hasAuthority('sys:role:update')")
+ @OperationLog("淇敼瑙掕壊")
+ @PostMapping("/role/update")
+ public R update(@RequestBody Role role) {
+ if (!Cools.isEmpty(role.getCode()) && roleService.count(new LambdaQueryWrapper<Role>()
+ .eq(Role::getCode, role.getCode())
+ .ne(Role::getId, role.getId())) > 0) {
+ return R.error("瑙掕壊鏍囪瘑宸插瓨鍦�");
+ }
+ if (!Cools.isEmpty(role.getName()) && roleService.count(new LambdaQueryWrapper<Role>()
+ .eq(Role::getName, role.getName())
+ .ne(Role::getId, role.getId())) > 0) {
+ return R.error("瑙掕壊鍚嶇О宸插瓨鍦�");
+ }
+ if (roleService.updateById(role)) {
+ return R.ok("淇敼鎴愬姛");
+ }
+ return R.error("淇敼澶辫触");
+ }
+
+ @PreAuthorize("hasAuthority('sys:role:remove')")
+ @OperationLog("鍒犻櫎瑙掕壊")
+ @PostMapping("/role/remove")
+ public R remove(@RequestBody List<Long> ids) {
+ if (roleService.removeByIds(ids)) {
+ return R.ok("鍒犻櫎鎴愬姛");
+ }
+ return R.error("鍒犻櫎澶辫触");
+ }
+
+
}
--
Gitblit v1.9.1