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('正在解锁'); try { const resp = await unlockLogininfor(userName); hide(); if (resp.code === 200) { message.success('解锁成功,即将刷新'); } else { message.error(resp.msg); } return true; } catch (error) { hide(); message.error('解锁失败,请重试'); 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: '是否确认解锁该用户的数据项?', 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="解锁" /> </Button>, <Button type="primary" 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); } 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("删除失败"); } }