日志切面功能整合
This commit is contained in:
parent
8d8e338da8
commit
ab5aa954ad
|
|
@ -3,7 +3,7 @@ package com.czg.controller;
|
|||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.log.annotation.LogOperation;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.product.dto.ProductDTO;
|
||||
import com.czg.product.service.ProductService;
|
||||
import com.czg.resp.CzgResult;
|
||||
|
|
@ -33,7 +33,7 @@ public class ProductController {
|
|||
private final ProductService productService;
|
||||
|
||||
@GetMapping("page")
|
||||
@LogOperation("分页")
|
||||
@OperationLog("分页")
|
||||
@SaAdminCheckPermission("prod:product:all")
|
||||
public CzgResult<Page<ProductDTO>> page(@RequestParam Map<String, Object> params) {
|
||||
Page<ProductDTO> data = productService.pageAs(null, null, ProductDTO.class);
|
||||
|
|
@ -41,7 +41,7 @@ public class ProductController {
|
|||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@LogOperation("列表")
|
||||
@OperationLog("列表")
|
||||
@SaAdminCheckPermission("prod:product:all")
|
||||
public CzgResult<List<ProductDTO>> list(@RequestParam Map<String, Object> params) {
|
||||
List<ProductDTO> data = null;
|
||||
|
|
@ -50,7 +50,7 @@ public class ProductController {
|
|||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@LogOperation("信息")
|
||||
@OperationLog("信息")
|
||||
@SaAdminCheckPermission("prod:product:all")
|
||||
public CzgResult<ProductDTO> get(@PathVariable("id") Long id) {
|
||||
ProductDTO data = null;
|
||||
|
|
@ -59,7 +59,7 @@ public class ProductController {
|
|||
}
|
||||
|
||||
@PostMapping
|
||||
@LogOperation("保存")
|
||||
@OperationLog("保存")
|
||||
@SaAdminCheckPermission("prod:product:all")
|
||||
public CzgResult<Void> save(@RequestBody ProductDTO dto) {
|
||||
//效验数据
|
||||
|
|
@ -71,7 +71,7 @@ public class ProductController {
|
|||
}
|
||||
|
||||
@PutMapping
|
||||
@LogOperation("修改")
|
||||
@OperationLog("修改")
|
||||
@SaAdminCheckPermission("prod:product:all")
|
||||
public CzgResult<Void> update(@RequestBody ProductDTO dto) {
|
||||
//效验数据
|
||||
|
|
@ -83,7 +83,7 @@ public class ProductController {
|
|||
}
|
||||
|
||||
@DeleteMapping
|
||||
@LogOperation("删除")
|
||||
@OperationLog("删除")
|
||||
@SaAdminCheckPermission("prod:product:all")
|
||||
public CzgResult<Void> delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.czg.controller;
|
|||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.log.annotation.LogOperation;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.product.dto.ShopProdCategoryDTO;
|
||||
import com.czg.product.service.ShopProdCategoryService;
|
||||
import com.czg.resp.CzgResult;
|
||||
|
|
@ -33,7 +33,7 @@ public class ShopProdCategoryController {
|
|||
private final ShopProdCategoryService shopProdCategoryService;
|
||||
|
||||
@GetMapping("page")
|
||||
@LogOperation("分页")
|
||||
@OperationLog("分页")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<Page<ShopProdCategoryDTO>> page(@RequestParam Map<String, Object> params) {
|
||||
Page<ShopProdCategoryDTO> data = shopProdCategoryService.pageAs(null, null, ShopProdCategoryDTO.class);
|
||||
|
|
@ -41,7 +41,7 @@ public class ShopProdCategoryController {
|
|||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@LogOperation("列表")
|
||||
@OperationLog("列表")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<List<ShopProdCategoryDTO>> list(@RequestParam Map<String, Object> params) {
|
||||
List<ShopProdCategoryDTO> data = null;
|
||||
|
|
@ -50,7 +50,7 @@ public class ShopProdCategoryController {
|
|||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@LogOperation("信息")
|
||||
@OperationLog("信息")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<ShopProdCategoryDTO> get(@PathVariable("id") Long id) {
|
||||
ShopProdCategoryDTO data = null;
|
||||
|
|
@ -59,7 +59,7 @@ public class ShopProdCategoryController {
|
|||
}
|
||||
|
||||
@PostMapping
|
||||
@LogOperation("保存")
|
||||
@OperationLog("保存")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<Void> save(@RequestBody ShopProdCategoryDTO dto) {
|
||||
//效验数据
|
||||
|
|
@ -71,7 +71,7 @@ public class ShopProdCategoryController {
|
|||
}
|
||||
|
||||
@PutMapping
|
||||
@LogOperation("修改")
|
||||
@OperationLog("修改")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<Void> update(@RequestBody ShopProdCategoryDTO dto) {
|
||||
//效验数据
|
||||
|
|
@ -83,7 +83,7 @@ public class ShopProdCategoryController {
|
|||
}
|
||||
|
||||
@DeleteMapping
|
||||
@LogOperation("删除")
|
||||
@OperationLog("删除")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<Void> delete(@RequestBody Long[] ids) {
|
||||
//效验数据
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.czg.controller;
|
||||
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.log.annotation.LogOperation;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.product.dto.ShopProdUnitDTO;
|
||||
import com.czg.product.service.ShopProdUnitService;
|
||||
import com.czg.resp.CzgResult;
|
||||
|
|
@ -33,7 +33,7 @@ public class ShopProdUnitController {
|
|||
private final ShopProdUnitService shopProdUnitService;
|
||||
|
||||
@GetMapping("page")
|
||||
@LogOperation(LOG_PREFIX+"分页")
|
||||
@OperationLog(LOG_PREFIX+"分页")
|
||||
//@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<Page<ShopProdUnitDTO>> page(ShopProdUnitDTO param) {
|
||||
Page<ShopProdUnitDTO> data = shopProdUnitService.page(param);
|
||||
|
|
@ -41,7 +41,7 @@ public class ShopProdUnitController {
|
|||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@LogOperation("列表")
|
||||
@OperationLog("列表")
|
||||
@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<List<ShopProdUnitDTO>> list(ShopProdUnitDTO param) {
|
||||
List<ShopProdUnitDTO> data = shopProdUnitService.list(param);
|
||||
|
|
@ -49,7 +49,7 @@ public class ShopProdUnitController {
|
|||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@LogOperation("信息")
|
||||
@OperationLog("信息")
|
||||
@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<ShopProdUnitDTO> get(@PathVariable("id") Long id) {
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
|
|
@ -58,7 +58,7 @@ public class ShopProdUnitController {
|
|||
}
|
||||
|
||||
@PostMapping
|
||||
@LogOperation("保存")
|
||||
@OperationLog("保存")
|
||||
@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<Void> save(@RequestBody ShopProdUnitDTO dto) {
|
||||
//效验数据
|
||||
|
|
@ -70,7 +70,7 @@ public class ShopProdUnitController {
|
|||
}
|
||||
|
||||
@PutMapping
|
||||
@LogOperation("修改")
|
||||
@OperationLog("修改")
|
||||
@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<Void> update(@RequestBody ShopProdUnitDTO dto) {
|
||||
//效验数据
|
||||
|
|
@ -82,7 +82,7 @@ public class ShopProdUnitController {
|
|||
}
|
||||
|
||||
@PostMapping("disable/{id}")
|
||||
@LogOperation("禁用")
|
||||
@OperationLog("禁用")
|
||||
@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<Void> disable(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
|
|
@ -92,7 +92,7 @@ public class ShopProdUnitController {
|
|||
}
|
||||
|
||||
@PostMapping("enable/{id}")
|
||||
@LogOperation("启用")
|
||||
@OperationLog("启用")
|
||||
@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<Void> enable(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ import java.lang.annotation.*;
|
|||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface LogOperation {
|
||||
public @interface OperationLog {
|
||||
String value() default "";
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ import cn.hutool.extra.servlet.JakartaServletUtil;
|
|||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.log.annotation.LogOperation;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.log.enums.LogTypeEnum;
|
||||
import com.czg.log.enums.OperationStatusEnum;
|
||||
import com.czg.log.producer.LogProducer;
|
||||
|
|
@ -38,12 +38,12 @@ import java.util.Map;
|
|||
*/
|
||||
@Aspect
|
||||
@Component
|
||||
public class LogOperationAspect {
|
||||
public class OperationLogAspect {
|
||||
|
||||
@Resource
|
||||
private LogProducer logProducer;
|
||||
|
||||
@Pointcut("@annotation(com.czg.log.annotation.LogOperation)")
|
||||
@Pointcut("@annotation(com.czg.log.annotation.OperationLog)")
|
||||
public void logPointCut() {
|
||||
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ public class LogOperationAspect {
|
|||
Method method = signature.getMethod();
|
||||
|
||||
Row log = new Row();
|
||||
LogOperation annotation = method.getAnnotation(LogOperation.class);
|
||||
OperationLog annotation = method.getAnnotation(OperationLog.class);
|
||||
if (annotation != null) {
|
||||
//注解上的描述
|
||||
log.set("operation", annotation.value());
|
||||
|
|
@ -22,6 +22,10 @@ public class OperationLogDTO implements Serializable {
|
|||
* id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 日志类型 info-正常日志 error-异常日志
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ public class OperationLog implements Serializable {
|
|||
*/
|
||||
@Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 日志类型 info-正常日志 error-异常日志
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue