feat(operationLog): 添加操作日志注解

- 在多个控制器的方法上添加 @OperationLogAnnotation 注解
- 注解内容包括操作类型(如新建、更新、删除)和操作对象(如附件、公告、部门等)
- 此修改涉及多个模块,包括附件、公告、部门、菜单、操作日志、产品、属性、角色、用户、用户通知等
This commit is contained in:
zhuangtianxiang 2025-03-13 19:35:09 +08:00
parent 8746fea3cc
commit 1215e94c78
13 changed files with 56 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package com.zsc.edu.gateway.modules.attachment.controller;
import com.zsc.edu.gateway.exception.StorageException; import com.zsc.edu.gateway.exception.StorageException;
import com.zsc.edu.gateway.modules.attachment.entity.Attachment; import com.zsc.edu.gateway.modules.attachment.entity.Attachment;
import com.zsc.edu.gateway.modules.attachment.service.AttachmentService; import com.zsc.edu.gateway.modules.attachment.service.AttachmentService;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.http.ContentDisposition; import org.springframework.http.ContentDisposition;
@ -37,6 +38,7 @@ public class AttachmentController {
* @return 附件信息 * @return 附件信息
*/ */
@PostMapping() @PostMapping()
@OperationLogAnnotation(content = "'附件上传'", operationType = "新建")
public Attachment upload( public Attachment upload(
@RequestParam(required = false, defaultValue = "其他") Attachment.Type type, @RequestParam(required = false, defaultValue = "其他") Attachment.Type type,
@RequestParam("file") MultipartFile file @RequestParam("file") MultipartFile file
@ -84,6 +86,7 @@ public class AttachmentController {
* 批量上传附件 * 批量上传附件
*/ */
@PostMapping("multipartFile") @PostMapping("multipartFile")
@OperationLogAnnotation(content = "'附件批量上传'", operationType = "新建")
public List<Attachment> uploadMultipleFiles( public List<Attachment> uploadMultipleFiles(
@RequestParam(defaultValue = "其他") Attachment.Type type, @RequestParam(defaultValue = "其他") Attachment.Type type,
@RequestParam("files") List<MultipartFile> files @RequestParam("files") List<MultipartFile> files
@ -101,6 +104,7 @@ public class AttachmentController {
* 根据附件ID删除附件信息 * 根据附件ID删除附件信息
*/ */
@DeleteMapping("delete/{id}") @DeleteMapping("delete/{id}")
@OperationLogAnnotation(content = "'附件'", operationType = "删除")
public Boolean delete(@PathVariable("id") String id) { public Boolean delete(@PathVariable("id") String id) {
return service.delete(id); return service.delete(id);
} }

View File

@ -15,6 +15,7 @@ import com.zsc.edu.gateway.modules.iot.device.service.DeviceService;
import com.zsc.edu.gateway.modules.iot.device.vo.DeviceVo; import com.zsc.edu.gateway.modules.iot.device.vo.DeviceVo;
import com.zsc.edu.gateway.modules.iot.record.entity.RecordData; import com.zsc.edu.gateway.modules.iot.record.entity.RecordData;
import com.zsc.edu.gateway.modules.iot.record.service.RecordDataService; import com.zsc.edu.gateway.modules.iot.record.service.RecordDataService;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -45,6 +46,7 @@ public class DeviceController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('iot:device:create')") @PreAuthorize("hasAuthority('iot:device:create')")
@OperationLogAnnotation(content = "'设备'", operationType = "新建")
public Device create(@RequestBody DeviceDto deviceDto) { public Device create(@RequestBody DeviceDto deviceDto) {
return service.create(deviceDto); return service.create(deviceDto);
} }
@ -55,6 +57,7 @@ public class DeviceController {
*/ */
@PostMapping("batch") @PostMapping("batch")
@PreAuthorize("hasAuthority('iot:device:create')") @PreAuthorize("hasAuthority('iot:device:create')")
@OperationLogAnnotation(content = "'批量设备'", operationType = "新建")
public List<Device> batchCreate(@RequestBody BatchDeviceDto batchDeviceDto) { public List<Device> batchCreate(@RequestBody BatchDeviceDto batchDeviceDto) {
return service.batchCreate(batchDeviceDto); return service.batchCreate(batchDeviceDto);
} }
@ -65,6 +68,7 @@ public class DeviceController {
*/ */
@PatchMapping("{id}") @PatchMapping("{id}")
@PreAuthorize("hasAuthority('iot:device:update')") @PreAuthorize("hasAuthority('iot:device:update')")
@OperationLogAnnotation(content = "'设备'", operationType = "更新")
public Device update(@RequestBody DeviceDto deviceDto, @PathVariable("id") Long id) { public Device update(@RequestBody DeviceDto deviceDto, @PathVariable("id") Long id) {
return service.update(deviceDto, id); return service.update(deviceDto, id);
} }
@ -85,6 +89,7 @@ public class DeviceController {
*/ */
@DeleteMapping("{id}") @DeleteMapping("{id}")
@PreAuthorize("hasAuthority('iot:device:delete')") @PreAuthorize("hasAuthority('iot:device:delete')")
@OperationLogAnnotation(content = "'设备'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
return service.removeById(id); return service.removeById(id);
} }
@ -105,6 +110,7 @@ public class DeviceController {
*/ */
@PostMapping("serve") @PostMapping("serve")
@PreAuthorize("hasAuthority('iot:device:create')") @PreAuthorize("hasAuthority('iot:device:create')")
@OperationLogAnnotation(content = "'手动触发事件'", operationType = "新建")
public ResponseEntity<String> serve(@RequestBody DeviceServeDto dto) { public ResponseEntity<String> serve(@RequestBody DeviceServeDto dto) {
if (service.serve(dto)) { if (service.serve(dto)) {
return ResponseEntity.ok("服务执行成功"); return ResponseEntity.ok("服务执行成功");
@ -156,6 +162,7 @@ public class DeviceController {
* 下发命令 * 下发命令
*/ */
@PostMapping("/send") @PostMapping("/send")
@OperationLogAnnotation(content = "'设备命令下发'", operationType = "新建")
public String send(Long deviceId, Integer qos, @RequestBody JSONObject paras) throws JSONException { public String send(Long deviceId, Integer qos, @RequestBody JSONObject paras) throws JSONException {
return service.send(deviceId, qos, paras); return service.send(deviceId, qos, paras);
} }

View File

@ -10,6 +10,7 @@ import com.zsc.edu.gateway.modules.iot.product.query.ProductQuery;
import com.zsc.edu.gateway.modules.iot.product.service.ProductService; import com.zsc.edu.gateway.modules.iot.product.service.ProductService;
import com.zsc.edu.gateway.modules.iot.product.service.impl.ProductServiceImpl; import com.zsc.edu.gateway.modules.iot.product.service.impl.ProductServiceImpl;
import com.zsc.edu.gateway.modules.iot.product.vo.ProductStatusVo; import com.zsc.edu.gateway.modules.iot.product.vo.ProductStatusVo;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -46,6 +47,7 @@ public class ProductController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('iot:product:create')") @PreAuthorize("hasAuthority('iot:product:create')")
@OperationLogAnnotation(content = "'产品'", operationType = "新建")
public Product create(@RequestBody ProductDto dto) { public Product create(@RequestBody ProductDto dto) {
return service.create(dto); return service.create(dto);
} }
@ -58,6 +60,7 @@ public class ProductController {
*/ */
@PatchMapping("{id}") @PatchMapping("{id}")
@PreAuthorize("hasAuthority('iot:product:update')") @PreAuthorize("hasAuthority('iot:product:update')")
@OperationLogAnnotation(content = "'产品'", operationType = "更新")
public Product update(@RequestBody ProductDto dto, @PathVariable("id") Long id) { public Product update(@RequestBody ProductDto dto, @PathVariable("id") Long id) {
return service.update(dto, id); return service.update(dto, id);
} }
@ -97,6 +100,7 @@ public class ProductController {
*/ */
@DeleteMapping("{id}") @DeleteMapping("{id}")
@PreAuthorize("hasAuthority('iot:product:delete')") @PreAuthorize("hasAuthority('iot:product:delete')")
@OperationLogAnnotation(content = "'产品'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
return service.delete(id); return service.delete(id);
} }

View File

@ -9,6 +9,7 @@ import com.zsc.edu.gateway.modules.iot.tsl.entity.EventLog;
import com.zsc.edu.gateway.modules.iot.tsl.query.EventQuery; import com.zsc.edu.gateway.modules.iot.tsl.query.EventQuery;
import com.zsc.edu.gateway.modules.iot.tsl.repo.EventLogRepository; import com.zsc.edu.gateway.modules.iot.tsl.repo.EventLogRepository;
import com.zsc.edu.gateway.modules.iot.tsl.service.EventService; import com.zsc.edu.gateway.modules.iot.tsl.service.EventService;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -34,6 +35,7 @@ public class EventController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('iot:event:create')") @PreAuthorize("hasAuthority('iot:event:create')")
@OperationLogAnnotation(content = "'事件'", operationType = "新建")
public Event create(@RequestBody EventDto dto) { public Event create(@RequestBody EventDto dto) {
return service.create(dto); return service.create(dto);
} }
@ -46,6 +48,7 @@ public class EventController {
*/ */
@PatchMapping("{id}") @PatchMapping("{id}")
@PreAuthorize("hasAuthority('iot:event:update')") @PreAuthorize("hasAuthority('iot:event:update')")
@OperationLogAnnotation(content = "'事件'", operationType = "更新")
public Event update(@RequestBody EventDto dto, @PathVariable("id") Long id) { public Event update(@RequestBody EventDto dto, @PathVariable("id") Long id) {
return service.update(dto, id); return service.update(dto, id);
} }
@ -86,6 +89,7 @@ public class EventController {
*/ */
@DeleteMapping("{id}") @DeleteMapping("{id}")
@PreAuthorize("hasAuthority('iot:event:delete')") @PreAuthorize("hasAuthority('iot:event:delete')")
@OperationLogAnnotation(content = "'事件'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
return service.delete(id); return service.delete(id);
} }

View File

@ -5,6 +5,7 @@ import com.zsc.edu.gateway.modules.iot.tsl.dto.PropertyDto;
import com.zsc.edu.gateway.modules.iot.tsl.entity.Property; import com.zsc.edu.gateway.modules.iot.tsl.entity.Property;
import com.zsc.edu.gateway.modules.iot.tsl.query.PropertyQuery; import com.zsc.edu.gateway.modules.iot.tsl.query.PropertyQuery;
import com.zsc.edu.gateway.modules.iot.tsl.service.PropertyService; import com.zsc.edu.gateway.modules.iot.tsl.service.PropertyService;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -30,6 +31,7 @@ public class PropertyController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('iot:property:create')") @PreAuthorize("hasAuthority('iot:property:create')")
@OperationLogAnnotation(content = "'属性'", operationType = "新建")
public Property create(@RequestBody PropertyDto dto) { public Property create(@RequestBody PropertyDto dto) {
return service.create(dto); return service.create(dto);
} }
@ -42,6 +44,7 @@ public class PropertyController {
*/ */
@PatchMapping("{id}") @PatchMapping("{id}")
@PreAuthorize("hasAuthority('iot:property:update')") @PreAuthorize("hasAuthority('iot:property:update')")
@OperationLogAnnotation(content = "'属性'", operationType = "更新")
public Property update(@RequestBody PropertyDto dto, @PathVariable("id") Long id) { public Property update(@RequestBody PropertyDto dto, @PathVariable("id") Long id) {
return service.update(dto, id); return service.update(dto, id);
} }
@ -67,6 +70,7 @@ public class PropertyController {
*/ */
@DeleteMapping("{id}") @DeleteMapping("{id}")
@PreAuthorize("hasAuthority('iot:property:delete')") @PreAuthorize("hasAuthority('iot:property:delete')")
@OperationLogAnnotation(content = "'属性'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
return service.removeById(id); return service.removeById(id);
} }

View File

@ -6,6 +6,7 @@ import com.zsc.edu.gateway.modules.iot.tsl.dto.ServeDto;
import com.zsc.edu.gateway.modules.iot.tsl.entity.Serve; import com.zsc.edu.gateway.modules.iot.tsl.entity.Serve;
import com.zsc.edu.gateway.modules.iot.tsl.query.ServeQuery; import com.zsc.edu.gateway.modules.iot.tsl.query.ServeQuery;
import com.zsc.edu.gateway.modules.iot.tsl.service.ServeService; import com.zsc.edu.gateway.modules.iot.tsl.service.ServeService;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -30,6 +31,7 @@ public class ServeController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAnyAuthority('iot:serve:create')") @PreAuthorize("hasAnyAuthority('iot:serve:create')")
@OperationLogAnnotation(content = "'服务'", operationType = "新建")
public Serve create(@RequestBody ServeDto dto) { public Serve create(@RequestBody ServeDto dto) {
return serveService.create(dto); return serveService.create(dto);
} }
@ -42,6 +44,7 @@ public class ServeController {
*/ */
@PatchMapping("{id}") @PatchMapping("{id}")
@PreAuthorize("hasAnyAuthority('iot:serve:update')") @PreAuthorize("hasAnyAuthority('iot:serve:update')")
@OperationLogAnnotation(content = "'服务'", operationType = "更新")
public Serve update(@RequestBody ServeDto dto, @PathVariable("id") Long id) { public Serve update(@RequestBody ServeDto dto, @PathVariable("id") Long id) {
return serveService.update(dto, id); return serveService.update(dto, id);
} }
@ -68,6 +71,7 @@ public class ServeController {
*/ */
@DeleteMapping("{id}") @DeleteMapping("{id}")
@PreAuthorize("hasAnyAuthority('iot:serve:delete')") @PreAuthorize("hasAnyAuthority('iot:serve:delete')")
@OperationLogAnnotation(content = "'服务'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
return serveService.delete(id); return serveService.delete(id);
} }

View File

@ -8,6 +8,7 @@ import com.zsc.edu.gateway.modules.message.entity.Bulletin;
import com.zsc.edu.gateway.modules.message.query.BulletinQuery; import com.zsc.edu.gateway.modules.message.query.BulletinQuery;
import com.zsc.edu.gateway.modules.message.service.BulletinService; import com.zsc.edu.gateway.modules.message.service.BulletinService;
import com.zsc.edu.gateway.modules.message.vo.BulletinVo; import com.zsc.edu.gateway.modules.message.vo.BulletinVo;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal;
@ -84,6 +85,7 @@ public class BulletinController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('message:bulletin:create')") @PreAuthorize("hasAuthority('message:bulletin:create')")
@OperationLogAnnotation(content = "'公告'", operationType = "新建")
public Bulletin create(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody BulletinDto dto) { public Bulletin create(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody BulletinDto dto) {
return service.create(userDetails, dto); return service.create(userDetails, dto);
} }
@ -98,6 +100,7 @@ public class BulletinController {
*/ */
@PatchMapping("/{id}") @PatchMapping("/{id}")
@PreAuthorize("hasAuthority('message:bulletin:update')") @PreAuthorize("hasAuthority('message:bulletin:update')")
@OperationLogAnnotation(content = "'公告'", operationType = "更新")
public Boolean update(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody BulletinDto dto, @PathVariable("id") Long id) { public Boolean update(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody BulletinDto dto, @PathVariable("id") Long id) {
return service.update(userDetails, dto, id); return service.update(userDetails, dto, id);
} }
@ -110,6 +113,7 @@ public class BulletinController {
*/ */
@PatchMapping("/{id}/toggle-top") @PatchMapping("/{id}/toggle-top")
@PreAuthorize("hasAuthority('message:bulletin:update')") @PreAuthorize("hasAuthority('message:bulletin:update')")
@OperationLogAnnotation(content = "'公告置顶状态'", operationType = "更新")
public Boolean toggleTop(@PathVariable("id") Long id) { public Boolean toggleTop(@PathVariable("id") Long id) {
return service.toggleTop(id); return service.toggleTop(id);
} }
@ -123,6 +127,7 @@ public class BulletinController {
*/ */
@PatchMapping("/publish") @PatchMapping("/publish")
@PreAuthorize("hasAuthority('message:bulletin:update')") @PreAuthorize("hasAuthority('message:bulletin:update')")
@OperationLogAnnotation(content = "'发布公告状态'", operationType = "更新")
public Boolean publish(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody List<Long> ids) { public Boolean publish(@AuthenticationPrincipal UserDetailsImpl userDetails, @RequestBody List<Long> ids) {
return service.publish(userDetails, ids); return service.publish(userDetails, ids);
} }
@ -136,6 +141,7 @@ public class BulletinController {
*/ */
@PatchMapping("/{id}/toggleClose") @PatchMapping("/{id}/toggleClose")
@PreAuthorize("hasAuthority('message:bulletin:update')") @PreAuthorize("hasAuthority('message:bulletin:update')")
@OperationLogAnnotation(content = "'关闭公告状态'", operationType = "更新")
public Boolean toggleClose(@AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable("id") Long id) { public Boolean toggleClose(@AuthenticationPrincipal UserDetailsImpl userDetails, @PathVariable("id") Long id) {
return service.close(userDetails, id); return service.close(userDetails, id);
} }
@ -148,6 +154,7 @@ public class BulletinController {
*/ */
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@PreAuthorize("hasAuthority('message:bulletin:delete')") @PreAuthorize("hasAuthority('message:bulletin:delete')")
@OperationLogAnnotation(content = "'公告'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
return service.delete(id); return service.delete(id);
} }

View File

@ -10,6 +10,7 @@ import com.zsc.edu.gateway.modules.message.query.UserNoticeQuery;
import com.zsc.edu.gateway.modules.message.service.UserNoticeService; import com.zsc.edu.gateway.modules.message.service.UserNoticeService;
import com.zsc.edu.gateway.modules.message.vo.AdminNoticeVo; import com.zsc.edu.gateway.modules.message.vo.AdminNoticeVo;
import com.zsc.edu.gateway.modules.message.vo.UserNoticeVo; import com.zsc.edu.gateway.modules.message.vo.UserNoticeVo;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.annotation.AuthenticationPrincipal;
@ -122,6 +123,7 @@ public class UserNoticeController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('message:notice:create')") @PreAuthorize("hasAuthority('message:notice:create')")
@OperationLogAnnotation(content = "'消息'", operationType = "新建")
public Boolean create(@RequestBody UserNoticeDto dto) { public Boolean create(@RequestBody UserNoticeDto dto) {
return service.createByAdmin(dto); return service.createByAdmin(dto);
} }

View File

@ -3,6 +3,7 @@ package com.zsc.edu.gateway.modules.operationLog.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLog; import com.zsc.edu.gateway.modules.operationLog.entity.OperationLog;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import com.zsc.edu.gateway.modules.operationLog.query.OperationLogQuery; import com.zsc.edu.gateway.modules.operationLog.query.OperationLogQuery;
import com.zsc.edu.gateway.modules.operationLog.repo.OperationLogRepository; import com.zsc.edu.gateway.modules.operationLog.repo.OperationLogRepository;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -43,6 +44,7 @@ public class OperationController {
*/ */
@DeleteMapping("/batch") @DeleteMapping("/batch")
@PreAuthorize("hasAuthority('operationLog:delete')") @PreAuthorize("hasAuthority('operationLog:delete')")
@OperationLogAnnotation(content = "'批量操作日志'", operationType = "删除")
public int deleteBatch(@RequestBody List<Long> ids) { public int deleteBatch(@RequestBody List<Long> ids) {
LambdaQueryWrapper<OperationLog> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OperationLog> wrapper = new LambdaQueryWrapper<>();
wrapper.in(OperationLog::getId, ids); wrapper.in(OperationLog::getId, ids);

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zsc.edu.gateway.exception.ConstraintException; import com.zsc.edu.gateway.exception.ConstraintException;
import com.zsc.edu.gateway.framework.mybatisplus.DataPermission; import com.zsc.edu.gateway.framework.mybatisplus.DataPermission;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import com.zsc.edu.gateway.modules.system.dto.DeptDto; import com.zsc.edu.gateway.modules.system.dto.DeptDto;
import com.zsc.edu.gateway.modules.system.entity.Dept; import com.zsc.edu.gateway.modules.system.entity.Dept;
import com.zsc.edu.gateway.modules.system.entity.User; import com.zsc.edu.gateway.modules.system.entity.User;
@ -62,6 +63,7 @@ public class DeptController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('system:dept:create')") @PreAuthorize("hasAuthority('system:dept:create')")
@OperationLogAnnotation(content = "'部门'", operationType = "新建")
public Dept create(@RequestBody DeptDto dto) { public Dept create(@RequestBody DeptDto dto) {
return service.create(dto); return service.create(dto);
} }
@ -75,6 +77,7 @@ public class DeptController {
*/ */
@PatchMapping("/{id}") @PatchMapping("/{id}")
@PreAuthorize("hasAuthority('system:dept:update')") @PreAuthorize("hasAuthority('system:dept:update')")
@OperationLogAnnotation(content = "'部门'", operationType = "更新")
public Boolean update(@RequestBody DeptDto dto, @PathVariable("id") Long id) { public Boolean update(@RequestBody DeptDto dto, @PathVariable("id") Long id) {
return service.edit(dto, id); return service.edit(dto, id);
} }
@ -86,6 +89,7 @@ public class DeptController {
*/ */
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@PreAuthorize("hasAuthority('system:dept:delete')") @PreAuthorize("hasAuthority('system:dept:delete')")
@OperationLogAnnotation(content = "'部门'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
// 是否存在用户绑定此部门 // 是否存在用户绑定此部门
boolean hasUser = userService.count(new LambdaQueryWrapper<User>().eq(User::getDeptId, id)) > 0; boolean hasUser = userService.count(new LambdaQueryWrapper<User>().eq(User::getDeptId, id)) > 0;
@ -100,6 +104,7 @@ public class DeptController {
* */ * */
@PatchMapping("/toggle/{id}") @PatchMapping("/toggle/{id}")
@PreAuthorize("hasAuthority('system:dept:update')") @PreAuthorize("hasAuthority('system:dept:update')")
@OperationLogAnnotation(content = "'部门状态'", operationType = "更新")
public Boolean toggle(@PathVariable("id") Long id) { public Boolean toggle(@PathVariable("id") Long id) {
return service.toggle(id); return service.toggle(id);
} }

View File

@ -2,6 +2,7 @@ package com.zsc.edu.gateway.modules.system.controller;
import com.zsc.edu.gateway.framework.mybatisplus.DataPermission; import com.zsc.edu.gateway.framework.mybatisplus.DataPermission;
import com.zsc.edu.gateway.framework.security.UserDetailsImpl; import com.zsc.edu.gateway.framework.security.UserDetailsImpl;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import com.zsc.edu.gateway.modules.system.dto.MenuDto; import com.zsc.edu.gateway.modules.system.dto.MenuDto;
import com.zsc.edu.gateway.modules.system.entity.Menu; import com.zsc.edu.gateway.modules.system.entity.Menu;
import com.zsc.edu.gateway.modules.system.service.MenuService; import com.zsc.edu.gateway.modules.system.service.MenuService;
@ -28,6 +29,7 @@ public class MenuController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('system:menu:create')") @PreAuthorize("hasAuthority('system:menu:create')")
@OperationLogAnnotation(content = "'菜单'", operationType = "新建")
public Menu create(@RequestBody MenuDto dto) { public Menu create(@RequestBody MenuDto dto) {
return service.create(dto); return service.create(dto);
} }
@ -37,6 +39,7 @@ public class MenuController {
*/ */
@PatchMapping("/{id}") @PatchMapping("/{id}")
@PreAuthorize("hasAuthority('system:menu:update')") @PreAuthorize("hasAuthority('system:menu:update')")
@OperationLogAnnotation(content = "'菜单'", operationType = "更新")
public Menu update(@RequestBody MenuDto dto, @PathVariable("id") Long id) { public Menu update(@RequestBody MenuDto dto, @PathVariable("id") Long id) {
return service.update(dto, id); return service.update(dto, id);
} }
@ -46,6 +49,7 @@ public class MenuController {
*/ */
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
@PreAuthorize("hasAuthority('system:menu:delete')") @PreAuthorize("hasAuthority('system:menu:delete')")
@OperationLogAnnotation(content = "'菜单'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
return service.delete(id); return service.delete(id);
} }

View File

@ -2,6 +2,7 @@ package com.zsc.edu.gateway.modules.system.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zsc.edu.gateway.framework.mybatisplus.DataPermission; import com.zsc.edu.gateway.framework.mybatisplus.DataPermission;
import com.zsc.edu.gateway.modules.operationLog.entity.OperationLogAnnotation;
import com.zsc.edu.gateway.modules.system.dto.AuthorityCreateDto; import com.zsc.edu.gateway.modules.system.dto.AuthorityCreateDto;
//import com.zsc.edu.gateway.modules.system.dto.RoleAuthCreateDto; //import com.zsc.edu.gateway.modules.system.dto.RoleAuthCreateDto;
import com.zsc.edu.gateway.modules.system.dto.RoleDto; import com.zsc.edu.gateway.modules.system.dto.RoleDto;
@ -49,6 +50,7 @@ public class RoleController {
*/ */
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('system:role:create')") @PreAuthorize("hasAuthority('system:role:create')")
@OperationLogAnnotation(content = "'角色'", operationType = "新建")
public Role create(@RequestBody RoleDto dto) { public Role create(@RequestBody RoleDto dto) {
return service.create(dto); return service.create(dto);
} }
@ -62,6 +64,7 @@ public class RoleController {
*/ */
@PatchMapping("{id}") @PatchMapping("{id}")
@PreAuthorize("hasAuthority('system:role:update')") @PreAuthorize("hasAuthority('system:role:update')")
@OperationLogAnnotation(content = "'角色'", operationType = "更新")
public Role update(@RequestBody RoleDto dto, @PathVariable("id") Long id) { public Role update(@RequestBody RoleDto dto, @PathVariable("id") Long id) {
return service.edit(dto, id); return service.edit(dto, id);
} }
@ -74,6 +77,7 @@ public class RoleController {
*/ */
@PatchMapping("{id}/toggle") @PatchMapping("{id}/toggle")
@PreAuthorize("hasAuthority('system:role:update')") @PreAuthorize("hasAuthority('system:role:update')")
@OperationLogAnnotation(content = "'角色状态'", operationType = "更新")
public Boolean toggle(@PathVariable("id") Long id) { public Boolean toggle(@PathVariable("id") Long id) {
return service.toggle(id); return service.toggle(id);
} }
@ -98,6 +102,7 @@ public class RoleController {
*/ */
@DeleteMapping("{id}") @DeleteMapping("{id}")
@PreAuthorize("hasAuthority('system:role:delete')") @PreAuthorize("hasAuthority('system:role:delete')")
@OperationLogAnnotation(content = "'角色'", operationType = "删除")
public Boolean delete(@PathVariable Long id) { public Boolean delete(@PathVariable Long id) {
return service.delete(id); return service.delete(id);
} }

View File

@ -147,7 +147,7 @@ public class UserController {
* @return 新建的用户信息 * @return 新建的用户信息
*/ */
@OperationLogAnnotation(operationType = "新建") @OperationLogAnnotation(content = "'用户'", operationType = "新建")
@PostMapping @PostMapping
@PreAuthorize("hasAuthority('system:user:create')") @PreAuthorize("hasAuthority('system:user:create')")
public Boolean create(@RequestBody UserCreateDto dto) { public Boolean create(@RequestBody UserCreateDto dto) {
@ -161,7 +161,7 @@ public class UserController {
* @param id ID * @param id ID
* @return 更新后的用户 * @return 更新后的用户
*/ */
@OperationLogAnnotation(operationType = "更新") @OperationLogAnnotation(content = "'用户'", operationType = "更新")
@PatchMapping("{id}") @PatchMapping("{id}")
@PreAuthorize("hasAuthority('system:user:update')") @PreAuthorize("hasAuthority('system:user:update')")
public Boolean update(@RequestBody UserUpdateDto dto, @PathVariable("id") Long id) { public Boolean update(@RequestBody UserUpdateDto dto, @PathVariable("id") Long id) {
@ -189,15 +189,16 @@ public class UserController {
*/ */
@PatchMapping("{id}/toggle") @PatchMapping("{id}/toggle")
@PreAuthorize("hasAuthority('system:user:delete')") @PreAuthorize("hasAuthority('system:user:delete')")
@OperationLogAnnotation(content = "'用户角色'", operationType = "更新")
public Boolean toggle(@PathVariable("id") Long id) { public Boolean toggle(@PathVariable("id") Long id) {
return service.toggle(id); return service.toggle(id);
} }
/** /**
* 删除用户 hasAuthority('SYSTEM:USER:DELETE') * 删除用户 hasAuthority('SYSTEM:USER:DELETE')
* */ * */
@OperationLogAnnotation(operationType = "删除")
@DeleteMapping("{id}") @DeleteMapping("{id}")
@PreAuthorize("hasAuthority('system:user:delete')") @PreAuthorize("hasAuthority('system:user:delete')")
@OperationLogAnnotation(content = "'用户'", operationType = "删除")
public Boolean delete(@PathVariable("id") Long id) { public Boolean delete(@PathVariable("id") Long id) {
return service.removeById(id); return service.removeById(id);
} }