Skip to content

Commit 2dd1246

Browse files
committed
refactor: SysLog 改为各服务分别维护 PlgLog
1 parent 08a5d9b commit 2dd1246

14 files changed

Lines changed: 110 additions & 104 deletions

File tree

framework/framework_base/pom.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525

2626
<dependency>
2727
<groupId>com.github.cadecode</groupId>
28-
<artifactId>uni-boot-framework-api</artifactId>
28+
<artifactId>uni-boot-common-core</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>com.github.cadecode</groupId>
32+
<artifactId>uni-boot-common-plugin-cache</artifactId>
2933
</dependency>
3034
<dependency>
3135
<groupId>com.github.cadecode</groupId>
@@ -47,6 +51,10 @@
4751
<groupId>com.github.cadecode</groupId>
4852
<artifactId>uni-boot-common-plugin-log</artifactId>
4953
</dependency>
54+
<dependency>
55+
<groupId>com.github.cadecode</groupId>
56+
<artifactId>uni-boot-framework-api</artifactId>
57+
</dependency>
5058
</dependencies>
5159

5260
</project>

framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java renamed to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgLog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.cadecode.uniboot.framework.svc.bean.po;
1+
package com.github.cadecode.uniboot.framework.base.plugin.bean.po;
22

33
import com.baomidou.mybatisplus.annotation.*;
44
import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler;
@@ -20,7 +20,7 @@
2020
@NoArgsConstructor
2121
@Builder
2222
@TableName(autoResultMap = true)
23-
public class SysLog {
23+
public class PlgLog {
2424

2525
@TableId(type = IdType.ASSIGN_ID)
2626
private Long id;

framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java renamed to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.cadecode.uniboot.framework.svc.bean.vo;
1+
package com.github.cadecode.uniboot.framework.base.plugin.bean.vo;
22

33
import com.github.cadecode.uniboot.common.core.web.response.PageParams;
44
import lombok.Data;
@@ -13,12 +13,11 @@
1313
* @author Cade Li
1414
* @since 2023/5/26
1515
*/
16-
public class SysLogVo {
17-
16+
public class PlgLogVo {
1817

1918
@Data
2019
@EqualsAndHashCode(callSuper = true)
21-
public static class SysLogPageReqVo extends PageParams {
20+
public static class PlgLogPageReqVo extends PageParams {
2221

2322
private Date startTime;
2423
private Date endTime;
@@ -30,7 +29,7 @@ public static class SysLogPageReqVo extends PageParams {
3029
}
3130

3231
@Data
33-
public static class SysLogSaveReqVo {
32+
public static class PlgLogSaveReqVo {
3433

3534
private String logType;
3635

@@ -69,7 +68,7 @@ public static class SysLogSaveReqVo {
6968
}
7069

7170
@Data
72-
public static class SysLogPageResVo {
71+
public static class PlgLogPageResVo {
7372

7473
private Long id;
7574

framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java renamed to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
package com.github.cadecode.uniboot.framework.svc.controller;
1+
package com.github.cadecode.uniboot.framework.base.plugin.controller;
22

33
import cn.hutool.core.util.ObjectUtil;
44
import com.github.cadecode.uniboot.common.core.web.response.PageResult;
55
import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler;
66
import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat;
77
import com.github.cadecode.uniboot.framework.base.annotation.ApiInner;
8-
import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog;
9-
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageResVo;
10-
import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogSaveReqVo;
11-
import com.github.cadecode.uniboot.framework.svc.convert.SysLogConvert;
12-
import com.github.cadecode.uniboot.framework.svc.service.SysLogService;
8+
import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog;
9+
import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo;
10+
import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogPageResVo;
11+
import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogSaveReqVo;
12+
import com.github.cadecode.uniboot.framework.base.plugin.convert.PlgLogConvert;
13+
import com.github.cadecode.uniboot.framework.base.plugin.service.PlgLogService;
1314
import com.github.pagehelper.PageHelper;
1415
import com.github.pagehelper.PageInfo;
1516
import io.swagger.annotations.Api;
@@ -26,8 +27,6 @@
2627
import javax.validation.constraints.NotEmpty;
2728
import java.util.List;
2829

29-
import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageReqVo;
30-
3130
/**
3231
* 日志管理
3332
*
@@ -38,27 +37,27 @@
3837
@Slf4j
3938
@RequiredArgsConstructor
4039
@Api(tags = "日志管理")
41-
@RequestMapping("system/log")
40+
@RequestMapping("plugin/log")
4241
@RestController
4342
@Validated
44-
public class SysLogController {
43+
public class PlgLogController {
4544

46-
private final SysLogService logService;
45+
private final PlgLogService logService;
4746

4847
@ApiOperation("查询列表")
4948
@PostMapping("page")
50-
public PageResult<SysLogPageResVo> page(@RequestBody @Valid SysLogPageReqVo reqVo) {
51-
PageInfo<SysLog> pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize())
49+
public PageResult<PlgLogPageResVo> page(@RequestBody @Valid PlgLogVo.PlgLogPageReqVo reqVo) {
50+
PageInfo<PlgLog> pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize())
5251
.doSelectPageInfo(() -> logService.lambdaQuery()
53-
.ge(ObjectUtil.isNotEmpty(reqVo.getStartTime()), SysLog::getCreateTime, reqVo.getStartTime())
54-
.le(ObjectUtil.isNotEmpty(reqVo.getEndTime()), SysLog::getCreateTime, reqVo.getEndTime())
55-
.in(ObjectUtil.isNotEmpty(reqVo.getLogTypeList()), SysLog::getLogType, reqVo.getLogTypeList())
56-
.likeRight(ObjectUtil.isNotEmpty(reqVo.getAccessUser()), SysLog::getAccessUser, reqVo.getAccessUser())
57-
.like(ObjectUtil.isNotEmpty(reqVo.getUrl()), SysLog::getUrl, reqVo.getUrl())
58-
.eq(ObjectUtil.isNotNull(reqVo.getExceptional()), SysLog::getExceptional, BoolToIntTypeHandler.mapping(reqVo.getExceptional()))
59-
.orderByDesc(SysLog::getCreateTime)
52+
.ge(ObjectUtil.isNotEmpty(reqVo.getStartTime()), PlgLog::getCreateTime, reqVo.getStartTime())
53+
.le(ObjectUtil.isNotEmpty(reqVo.getEndTime()), PlgLog::getCreateTime, reqVo.getEndTime())
54+
.in(ObjectUtil.isNotEmpty(reqVo.getLogTypeList()), PlgLog::getLogType, reqVo.getLogTypeList())
55+
.likeRight(ObjectUtil.isNotEmpty(reqVo.getAccessUser()), PlgLog::getAccessUser, reqVo.getAccessUser())
56+
.like(ObjectUtil.isNotEmpty(reqVo.getUrl()), PlgLog::getUrl, reqVo.getUrl())
57+
.eq(ObjectUtil.isNotNull(reqVo.getExceptional()), PlgLog::getExceptional, BoolToIntTypeHandler.mapping(reqVo.getExceptional()))
58+
.orderByDesc(PlgLog::getCreateTime)
6059
.list());
61-
List<SysLogPageResVo> voList = SysLogConvert.INSTANCE.poToVo(pageInfo.getList());
60+
List<PlgLogPageResVo> voList = PlgLogConvert.INSTANCE.poToVo(pageInfo.getList());
6261
return new PageResult<>((int) pageInfo.getTotal(), voList);
6362
}
6463

@@ -71,8 +70,8 @@ public boolean delete(@RequestBody @NotEmpty List<Long> idList) {
7170
@ApiInner(onlyClient = true)
7271
@ApiOperation("添加")
7372
@PostMapping("save")
74-
public boolean save(@RequestBody @NotEmpty List<SysLogSaveReqVo> requestList) {
75-
List<SysLog> poList = SysLogConvert.INSTANCE.voToPo(requestList);
73+
public boolean save(@RequestBody @NotEmpty List<PlgLogSaveReqVo> requestList) {
74+
List<PlgLog> poList = PlgLogConvert.INSTANCE.voToPo(requestList);
7675
return logService.saveBatch(poList);
7776
}
7877
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.github.cadecode.uniboot.framework.base.plugin.convert;
2+
3+
import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog;
4+
import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogPageResVo;
5+
import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogSaveReqVo;
6+
import org.mapstruct.Mapper;
7+
import org.mapstruct.factory.Mappers;
8+
9+
import java.util.List;
10+
11+
/**
12+
* 系统日志 bean convert
13+
*
14+
* @author Cade Li
15+
* @since 2023/5/26
16+
*/
17+
@Mapper
18+
public interface PlgLogConvert {
19+
20+
PlgLogConvert INSTANCE = Mappers.getMapper(PlgLogConvert.class);
21+
22+
List<PlgLogPageResVo> poToVo(List<PlgLog> records);
23+
24+
List<PlgLog> voToPo(List<PlgLogSaveReqVo> requestList);
25+
}

framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/LogSaveHandler.java renamed to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.cadecode.uniboot.framework.base.plugin;
1+
package com.github.cadecode.uniboot.framework.base.plugin.handler;
22

33
import cn.hutool.core.exceptions.ExceptionUtil;
44
import cn.hutool.core.util.CharsetUtil;

framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/MybatisFillHandler.java renamed to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MybatisFillHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.cadecode.uniboot.framework.base.plugin;
1+
package com.github.cadecode.uniboot.framework.base.plugin.handler;
22

33
import com.github.cadecode.uniboot.common.plugin.mybatis.handler.AbstractObjectFillHandler;
44
import com.github.cadecode.uniboot.framework.base.util.SecurityUtil;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.github.cadecode.uniboot.framework.base.plugin.mapper;
2+
3+
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4+
import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog;
5+
import org.apache.ibatis.annotations.Mapper;
6+
7+
/**
8+
* 系统日志 DAO
9+
*
10+
* @author Cade Li
11+
* @since 2023/5/26
12+
*/
13+
@Mapper
14+
public interface PlgLogMapper extends BaseMapper<PlgLog> {
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.github.cadecode.uniboot.framework.base.plugin.service;
2+
3+
import com.baomidou.mybatisplus.extension.service.IService;
4+
import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog;
5+
6+
/**
7+
* 系统日志服务
8+
*
9+
* @author Cade Li
10+
* @since 2023/5/26
11+
*/
12+
public interface PlgLogService extends IService<PlgLog> {
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.github.cadecode.uniboot.framework.base.plugin.serviceimpl;
2+
3+
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4+
import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog;
5+
import com.github.cadecode.uniboot.framework.base.plugin.mapper.PlgLogMapper;
6+
import com.github.cadecode.uniboot.framework.base.plugin.service.PlgLogService;
7+
import org.springframework.stereotype.Service;
8+
9+
/**
10+
* 系统日志服务实现
11+
*
12+
* @author Cade Li
13+
* @since 2023/5/26
14+
*/
15+
@Service
16+
public class PlgLogServiceImpl extends ServiceImpl<PlgLogMapper, PlgLog> implements PlgLogService {
17+
}

0 commit comments

Comments
 (0)