Commit b0af874214a59232bd79bd25d31edf1bf8219e64
1 parent
3182e5d7
fix: 订单操作日志/审批日志
Showing
9 changed files
with
299 additions
and
20 deletions
src/main/java/com/order/erp/controller/OrderAuditLogController.java
@@ -36,11 +36,11 @@ public class OrderAuditLogController { | @@ -36,11 +36,11 @@ public class OrderAuditLogController { | ||
36 | * @param orderAuditLogQueryVO 查询条件 | 36 | * @param orderAuditLogQueryVO 查询条件 |
37 | * @return 查询结果 | 37 | * @return 查询结果 |
38 | */ | 38 | */ |
39 | - @PostMapping("/list") | 39 | + @PostMapping("/list_by_page") |
40 | @ApiOperation("分页查询") | 40 | @ApiOperation("分页查询") |
41 | @AnonymousAccess | 41 | @AnonymousAccess |
42 | public ServerResult list(@RequestBody @Validated OrderAuditLogQueryVO orderAuditLogQueryVO) { | 42 | public ServerResult list(@RequestBody @Validated OrderAuditLogQueryVO orderAuditLogQueryVO) { |
43 | - return orderAuditLogService.list(orderAuditLogQueryVO); | 43 | + return orderAuditLogService.listByPage(orderAuditLogQueryVO); |
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |
src/main/java/com/order/erp/controller/OrderOptLogController.java
1 | package com.order.erp.controller; | 1 | package com.order.erp.controller; |
2 | 2 | ||
3 | +import com.order.erp.common.annotation.AnonymousAccess; | ||
4 | +import com.order.erp.common.constant.ServerResult; | ||
5 | +import com.order.erp.domain.vo.order.OrderOptLogQueryVO; | ||
6 | +import com.order.erp.service.order.OrderOptLogService; | ||
3 | import io.swagger.annotations.Api; | 7 | import io.swagger.annotations.Api; |
8 | +import io.swagger.annotations.ApiOperation; | ||
9 | +import org.springframework.validation.annotation.Validated; | ||
10 | +import org.springframework.web.bind.annotation.PostMapping; | ||
11 | +import org.springframework.web.bind.annotation.RequestBody; | ||
4 | import org.springframework.web.bind.annotation.RequestMapping; | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
5 | import org.springframework.web.bind.annotation.RestController; | 13 | import org.springframework.web.bind.annotation.RestController; |
6 | 14 | ||
15 | +import javax.annotation.Resource; | ||
16 | + | ||
7 | /** | 17 | /** |
8 | * 用户订单操作日志表(OrderOptLog)表控制层 | 18 | * 用户订单操作日志表(OrderOptLog)表控制层 |
9 | * | 19 | * |
10 | * @author makejava | 20 | * @author makejava |
11 | * @since 2023-09-08 15:26:46 | 21 | * @since 2023-09-08 15:26:46 |
12 | */ | 22 | */ |
13 | -@Api(tags = "(忽略)") | 23 | +@Api(tags = "订单操作日志") |
14 | @RestController | 24 | @RestController |
15 | -@RequestMapping("/gwms/xxx") | 25 | +@RequestMapping("/order/erp/opt/log") |
16 | public class OrderOptLogController { | 26 | public class OrderOptLogController { |
17 | 27 | ||
28 | + @Resource | ||
29 | + private OrderOptLogService orderOptLogService; | ||
30 | + | ||
31 | + /** | ||
32 | + * 分页查询 | ||
33 | + * | ||
34 | + * @param queryVO 查询条件 | ||
35 | + * @return 查询结果 | ||
36 | + */ | ||
37 | + @PostMapping("/list_by_page") | ||
38 | + @ApiOperation("分页查询") | ||
39 | + @AnonymousAccess | ||
40 | + public ServerResult listByPage(@RequestBody @Validated OrderOptLogQueryVO queryVO) { | ||
41 | + return orderOptLogService.listByPage(queryVO); | ||
42 | + } | ||
43 | + | ||
18 | } | 44 | } |
19 | 45 |
src/main/java/com/order/erp/domain/vo/order/OrderAuditLogResultVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.order; | ||
2 | + | ||
3 | +import lombok.*; | ||
4 | +import lombok.experimental.SuperBuilder; | ||
5 | + | ||
6 | +import java.io.Serializable; | ||
7 | + | ||
8 | +/** | ||
9 | + * 订单操作信息表实体类 | ||
10 | + * | ||
11 | + * @author makejava | ||
12 | + * @since 2023-09-08 15:26:43 | ||
13 | + */ | ||
14 | +@Data | ||
15 | +@AllArgsConstructor | ||
16 | +@ToString | ||
17 | +@NoArgsConstructor | ||
18 | +@EqualsAndHashCode(callSuper = false) | ||
19 | +@SuperBuilder | ||
20 | +public class OrderAuditLogResultVO implements Serializable { | ||
21 | + private Long id; | ||
22 | + | ||
23 | + /** | ||
24 | + * 订单id | ||
25 | + */ | ||
26 | + private Long orderId; | ||
27 | + /** | ||
28 | + * 申请id | ||
29 | + */ | ||
30 | + private Long applyId; | ||
31 | + | ||
32 | + /** | ||
33 | + * 申请备注信息 | ||
34 | + */ | ||
35 | + private String applyRemark; | ||
36 | + | ||
37 | + /** | ||
38 | + * 操作类型 | ||
39 | + */ | ||
40 | + private String optType; | ||
41 | + | ||
42 | + /** | ||
43 | + * 申请用户id | ||
44 | + */ | ||
45 | + private Long applyUserId; | ||
46 | + | ||
47 | + /** | ||
48 | + * 申请用户名称 | ||
49 | + */ | ||
50 | + private String applyUserName; | ||
51 | + | ||
52 | + /** | ||
53 | + * 审核人 | ||
54 | + */ | ||
55 | + private String auditUserName; | ||
56 | + | ||
57 | + /** | ||
58 | + * 操作字段 json字符串 | ||
59 | + */ | ||
60 | + private String fields; | ||
61 | + | ||
62 | +} |
src/main/java/com/order/erp/domain/vo/order/OrderOptLogQueryVO.java
@@ -30,18 +30,6 @@ public class OrderOptLogQueryVO extends BasePageVO implements Serializable { | @@ -30,18 +30,6 @@ public class OrderOptLogQueryVO extends BasePageVO implements Serializable { | ||
30 | * 订单id | 30 | * 订单id |
31 | */ | 31 | */ |
32 | private Long orderId; | 32 | private Long orderId; |
33 | - /** | ||
34 | - * 用户id | ||
35 | - */ | ||
36 | - private Long userId; | ||
37 | - /** | ||
38 | - * 操作类型 | ||
39 | - */ | ||
40 | - private String optType; | ||
41 | - /** | ||
42 | - * 操作字段 json字符串 | ||
43 | - */ | ||
44 | - private String fields; | ||
45 | 33 | ||
46 | 34 | ||
47 | } | 35 | } |
src/main/java/com/order/erp/domain/vo/order/OrderOptLogResultVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.order; | ||
2 | + | ||
3 | +import lombok.*; | ||
4 | +import lombok.experimental.SuperBuilder; | ||
5 | + | ||
6 | +import java.io.Serializable; | ||
7 | + | ||
8 | +/** | ||
9 | + * 订单操作信息表实体类 | ||
10 | + * | ||
11 | + * @author makejava | ||
12 | + * @since 2023-09-08 15:26:43 | ||
13 | + */ | ||
14 | +@Data | ||
15 | +@AllArgsConstructor | ||
16 | +@ToString | ||
17 | +@NoArgsConstructor | ||
18 | +@EqualsAndHashCode(callSuper = false) | ||
19 | +@SuperBuilder | ||
20 | +public class OrderOptLogResultVO implements Serializable { | ||
21 | + private Long id; | ||
22 | + /** | ||
23 | + * 订单id | ||
24 | + */ | ||
25 | + private Long orderId; | ||
26 | + /** | ||
27 | + * 用户id | ||
28 | + */ | ||
29 | + private Long userId; | ||
30 | + | ||
31 | + /** | ||
32 | + * 用户名称 | ||
33 | + */ | ||
34 | + private String userName; | ||
35 | + /** | ||
36 | + * 操作类型 | ||
37 | + */ | ||
38 | + private String optType; | ||
39 | + /** | ||
40 | + * 操作字段 json字符串 | ||
41 | + */ | ||
42 | + private String fields; | ||
43 | + | ||
44 | +} |
src/main/java/com/order/erp/service/order/OrderAuditLogService.java
@@ -32,6 +32,14 @@ public interface OrderAuditLogService extends IService<OrderAuditLogDO> { | @@ -32,6 +32,14 @@ public interface OrderAuditLogService extends IService<OrderAuditLogDO> { | ||
32 | */ | 32 | */ |
33 | ServerResult list(OrderAuditLogQueryVO orderAuditLogQueryVO); | 33 | ServerResult list(OrderAuditLogQueryVO orderAuditLogQueryVO); |
34 | 34 | ||
35 | + | ||
36 | + /** | ||
37 | + * | ||
38 | + * @param queryVO | ||
39 | + * @return | ||
40 | + */ | ||
41 | + ServerResult listByPage(OrderAuditLogQueryVO queryVO); | ||
42 | + | ||
35 | /** | 43 | /** |
36 | * 新增数据 | 44 | * 新增数据 |
37 | * | 45 | * |
src/main/java/com/order/erp/service/order/OrderOptLogService.java
@@ -33,6 +33,13 @@ public interface OrderOptLogService extends IService<OrderOptLogDO> { | @@ -33,6 +33,13 @@ public interface OrderOptLogService extends IService<OrderOptLogDO> { | ||
33 | ServerResult list(OrderOptLogQueryVO orderOptLogQueryVO); | 33 | ServerResult list(OrderOptLogQueryVO orderOptLogQueryVO); |
34 | 34 | ||
35 | /** | 35 | /** |
36 | + * | ||
37 | + * @param orderOptLogQueryVO | ||
38 | + * @return | ||
39 | + */ | ||
40 | + ServerResult listByPage(OrderOptLogQueryVO orderOptLogQueryVO); | ||
41 | + | ||
42 | + /** | ||
36 | * 新增数据 | 43 | * 新增数据 |
37 | * | 44 | * |
38 | * @param orderOptLogVO 数据VO | 45 | * @param orderOptLogVO 数据VO |
src/main/java/com/order/erp/service/order/impl/OrderAuditLogServiceImpl.java
@@ -2,20 +2,33 @@ package com.order.erp.service.order.impl; | @@ -2,20 +2,33 @@ package com.order.erp.service.order.impl; | ||
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.collection.CollUtil; | 4 | import cn.hutool.core.collection.CollUtil; |
5 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
5 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 6 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
7 | +import com.baomidou.mybatisplus.core.metadata.IPage; | ||
8 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | ||
9 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 10 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
7 | import com.order.erp.common.constant.Constant; | 11 | import com.order.erp.common.constant.Constant; |
8 | import com.order.erp.common.constant.ServerResult; | 12 | import com.order.erp.common.constant.ServerResult; |
13 | +import com.order.erp.domain.dto.BaseDO; | ||
14 | +import com.order.erp.domain.dto.admin.AdminUserDO; | ||
9 | import com.order.erp.domain.dto.order.OrderAuditLogDO; | 15 | import com.order.erp.domain.dto.order.OrderAuditLogDO; |
16 | +import com.order.erp.domain.dto.order.OrderFieldLockApplyDO; | ||
10 | import com.order.erp.domain.vo.order.OrderAuditLogQueryVO; | 17 | import com.order.erp.domain.vo.order.OrderAuditLogQueryVO; |
18 | +import com.order.erp.domain.vo.order.OrderAuditLogResultVO; | ||
11 | import com.order.erp.domain.vo.order.OrderAuditLogVO; | 19 | import com.order.erp.domain.vo.order.OrderAuditLogVO; |
12 | import com.order.erp.mapper.order.OrderAuditLogMapper; | 20 | import com.order.erp.mapper.order.OrderAuditLogMapper; |
21 | +import com.order.erp.service.admin.AdminUserService; | ||
13 | import com.order.erp.service.order.OrderAuditLogService; | 22 | import com.order.erp.service.order.OrderAuditLogService; |
23 | +import com.order.erp.service.order.OrderFieldLockApplyService; | ||
14 | import lombok.extern.slf4j.Slf4j; | 24 | import lombok.extern.slf4j.Slf4j; |
25 | +import org.springframework.beans.BeanUtils; | ||
15 | import org.springframework.stereotype.Service; | 26 | import org.springframework.stereotype.Service; |
16 | 27 | ||
17 | -import java.util.List; | ||
18 | -import java.util.Objects; | 28 | +import javax.annotation.Resource; |
29 | +import java.util.*; | ||
30 | +import java.util.function.Function; | ||
31 | +import java.util.stream.Collectors; | ||
19 | 32 | ||
20 | /** | 33 | /** |
21 | * 用户订单审批日志表(OrderAuditLog)表服务实现类 | 34 | * 用户订单审批日志表(OrderAuditLog)表服务实现类 |
@@ -28,6 +41,12 @@ import java.util.Objects; | @@ -28,6 +41,12 @@ import java.util.Objects; | ||
28 | public class OrderAuditLogServiceImpl extends ServiceImpl<OrderAuditLogMapper, OrderAuditLogDO> implements OrderAuditLogService { | 41 | public class OrderAuditLogServiceImpl extends ServiceImpl<OrderAuditLogMapper, OrderAuditLogDO> implements OrderAuditLogService { |
29 | 42 | ||
30 | 43 | ||
44 | + @Resource | ||
45 | + private AdminUserService userService; | ||
46 | + | ||
47 | + @Resource | ||
48 | + private OrderFieldLockApplyService applyService; | ||
49 | + | ||
31 | /** | 50 | /** |
32 | * 通过ID查询单条数据 | 51 | * 通过ID查询单条数据 |
33 | * <p> | 52 | * <p> |
@@ -59,6 +78,70 @@ public class OrderAuditLogServiceImpl extends ServiceImpl<OrderAuditLogMapper, O | @@ -59,6 +78,70 @@ public class OrderAuditLogServiceImpl extends ServiceImpl<OrderAuditLogMapper, O | ||
59 | return ServerResult.success(); | 78 | return ServerResult.success(); |
60 | } | 79 | } |
61 | 80 | ||
81 | + @Override | ||
82 | + public ServerResult listByPage(OrderAuditLogQueryVO queryVO) { | ||
83 | + LambdaQueryWrapper<OrderAuditLogDO> queryWrapper = buildQueryByParam(queryVO); | ||
84 | + Page page = new Page<>(queryVO.getPageNo(), queryVO.getPageSize()); | ||
85 | + IPage<OrderAuditLogDO> iPage = page(page, queryWrapper); | ||
86 | + | ||
87 | + Page<OrderAuditLogResultVO> webVOPage = new Page<>(); | ||
88 | + List<OrderAuditLogDO> auditLogDOS = iPage.getRecords(); | ||
89 | + if (CollectionUtils.isNotEmpty(auditLogDOS)) { | ||
90 | + Set<Long> applyIds = auditLogDOS.stream().map(OrderAuditLogDO::getApplyId).collect(Collectors.toSet()); | ||
91 | + Map<Long, AdminUserDO> userDOMap = new HashMap<>(); | ||
92 | + Map<Long, OrderFieldLockApplyDO> applyDOMap = new HashMap<>(); | ||
93 | + Set<Long> userIds = new HashSet<>(); | ||
94 | + if (CollectionUtils.isNotEmpty(applyIds)) { | ||
95 | + List<OrderFieldLockApplyDO> applyDOS = applyService.listByIds(applyIds); | ||
96 | + if (CollectionUtils.isNotEmpty(applyDOS)) { | ||
97 | + userIds.addAll(applyDOS.stream().map(OrderFieldLockApplyDO::getApplyUserId).collect(Collectors.toSet())); | ||
98 | + userIds.addAll(applyDOS.stream().map(OrderFieldLockApplyDO::getAuditUserId).collect(Collectors.toSet())); | ||
99 | + applyDOMap = applyDOS.stream().collect(Collectors.toMap(OrderFieldLockApplyDO::getId, Function.identity())); | ||
100 | + } | ||
101 | + } | ||
102 | + if (CollectionUtils.isNotEmpty(userIds)) { | ||
103 | + List<AdminUserDO> userDOS = userService.listByIds(userIds); | ||
104 | + if (CollectionUtils.isNotEmpty(userDOS)) { | ||
105 | + userDOMap = userDOS.stream().collect(Collectors.toMap(AdminUserDO::getId, Function.identity())); | ||
106 | + } | ||
107 | + } | ||
108 | + Map<Long, AdminUserDO> finalUserDOMap = userDOMap; | ||
109 | + Map<Long, OrderFieldLockApplyDO> finalApplyDOMap = applyDOMap; | ||
110 | + List<OrderAuditLogResultVO> resultVOList = auditLogDOS.stream().map(x -> { | ||
111 | + OrderAuditLogResultVO resultVO = new OrderAuditLogResultVO(); | ||
112 | + BeanUtils.copyProperties(x, resultVO); | ||
113 | + if (finalApplyDOMap.containsKey(x.getApplyId())) { | ||
114 | + OrderFieldLockApplyDO applyDO = finalApplyDOMap.get(x.getApplyId()); | ||
115 | + if (finalUserDOMap.containsKey(applyDO.getApplyUserId())) { | ||
116 | + resultVO.setApplyUserName(finalUserDOMap.get(applyDO.getApplyUserId()).getUserName()); | ||
117 | + } | ||
118 | + if (finalUserDOMap.containsKey(applyDO.getAuditUserId())) { | ||
119 | + resultVO.setAuditUserName(finalUserDOMap.get(applyDO.getAuditUserId()).getUserName()); | ||
120 | + } | ||
121 | + resultVO.setApplyRemark(applyDO.getRemark()); | ||
122 | + resultVO.setFields(applyDO.getFields()); | ||
123 | + } | ||
124 | + return resultVO; | ||
125 | + }).collect(Collectors.toList()); | ||
126 | + | ||
127 | + webVOPage.setRecords(resultVOList); | ||
128 | + } | ||
129 | + BeanUtils.copyProperties(page, webVOPage, "records"); | ||
130 | + return ServerResult.success(webVOPage); | ||
131 | + } | ||
132 | + | ||
133 | + /** | ||
134 | + * @param queryVO | ||
135 | + * @return | ||
136 | + */ | ||
137 | + private LambdaQueryWrapper<OrderAuditLogDO> buildQueryByParam(OrderAuditLogQueryVO queryVO) { | ||
138 | + return new LambdaQueryWrapper<OrderAuditLogDO>() | ||
139 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | ||
140 | + .eq(Objects.nonNull(queryVO.getOrderId()), OrderAuditLogDO::getOrderId, queryVO.getOrderId()) | ||
141 | + .orderByDesc(OrderAuditLogDO::getId) | ||
142 | + ; | ||
143 | + } | ||
144 | + | ||
62 | /** | 145 | /** |
63 | * 新增数据 | 146 | * 新增数据 |
64 | * | 147 | * |
@@ -123,6 +206,7 @@ public class OrderAuditLogServiceImpl extends ServiceImpl<OrderAuditLogMapper, O | @@ -123,6 +206,7 @@ public class OrderAuditLogServiceImpl extends ServiceImpl<OrderAuditLogMapper, O | ||
123 | 206 | ||
124 | /** | 207 | /** |
125 | * 逻辑删除,通过订单id删除 用户订单审批日志表(OrderAuditLog)实体类 | 208 | * 逻辑删除,通过订单id删除 用户订单审批日志表(OrderAuditLog)实体类 |
209 | + * | ||
126 | * @param orderId | 210 | * @param orderId |
127 | * @return | 211 | * @return |
128 | */ | 212 | */ |
src/main/java/com/order/erp/service/order/impl/OrderOptLogServiceImpl.java
@@ -2,20 +2,31 @@ package com.order.erp.service.order.impl; | @@ -2,20 +2,31 @@ package com.order.erp.service.order.impl; | ||
2 | 2 | ||
3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
4 | import cn.hutool.core.collection.CollUtil; | 4 | import cn.hutool.core.collection.CollUtil; |
5 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
5 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 6 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
7 | +import com.baomidou.mybatisplus.core.metadata.IPage; | ||
8 | +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | ||
9 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
6 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 10 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
7 | import com.order.erp.common.constant.Constant; | 11 | import com.order.erp.common.constant.Constant; |
8 | import com.order.erp.common.constant.ServerResult; | 12 | import com.order.erp.common.constant.ServerResult; |
13 | +import com.order.erp.domain.dto.BaseDO; | ||
14 | +import com.order.erp.domain.dto.admin.AdminUserDO; | ||
9 | import com.order.erp.domain.dto.order.OrderOptLogDO; | 15 | import com.order.erp.domain.dto.order.OrderOptLogDO; |
10 | import com.order.erp.domain.vo.order.OrderOptLogQueryVO; | 16 | import com.order.erp.domain.vo.order.OrderOptLogQueryVO; |
17 | +import com.order.erp.domain.vo.order.OrderOptLogResultVO; | ||
11 | import com.order.erp.domain.vo.order.OrderOptLogVO; | 18 | import com.order.erp.domain.vo.order.OrderOptLogVO; |
12 | import com.order.erp.mapper.order.OrderOptLogMapper; | 19 | import com.order.erp.mapper.order.OrderOptLogMapper; |
20 | +import com.order.erp.service.admin.AdminUserService; | ||
13 | import com.order.erp.service.order.OrderOptLogService; | 21 | import com.order.erp.service.order.OrderOptLogService; |
14 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
23 | +import org.springframework.beans.BeanUtils; | ||
15 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
16 | 25 | ||
17 | -import java.util.List; | ||
18 | -import java.util.Objects; | 26 | +import javax.annotation.Resource; |
27 | +import java.util.*; | ||
28 | +import java.util.function.Function; | ||
29 | +import java.util.stream.Collectors; | ||
19 | 30 | ||
20 | /** | 31 | /** |
21 | * 用户订单操作日志表(OrderOptLog)表服务实现类 | 32 | * 用户订单操作日志表(OrderOptLog)表服务实现类 |
@@ -28,6 +39,9 @@ import java.util.Objects; | @@ -28,6 +39,9 @@ import java.util.Objects; | ||
28 | public class OrderOptLogServiceImpl extends ServiceImpl<OrderOptLogMapper, OrderOptLogDO> implements OrderOptLogService { | 39 | public class OrderOptLogServiceImpl extends ServiceImpl<OrderOptLogMapper, OrderOptLogDO> implements OrderOptLogService { |
29 | 40 | ||
30 | 41 | ||
42 | + @Resource | ||
43 | + private AdminUserService userService; | ||
44 | + | ||
31 | /** | 45 | /** |
32 | * 通过ID查询单条数据 | 46 | * 通过ID查询单条数据 |
33 | * <p> | 47 | * <p> |
@@ -59,6 +73,51 @@ public class OrderOptLogServiceImpl extends ServiceImpl<OrderOptLogMapper, Order | @@ -59,6 +73,51 @@ public class OrderOptLogServiceImpl extends ServiceImpl<OrderOptLogMapper, Order | ||
59 | return ServerResult.success(); | 73 | return ServerResult.success(); |
60 | } | 74 | } |
61 | 75 | ||
76 | + @Override | ||
77 | + public ServerResult listByPage(OrderOptLogQueryVO queryVO) { | ||
78 | + LambdaQueryWrapper<OrderOptLogDO> queryWrapper = buildQueryByParam(queryVO); | ||
79 | + Page page = new Page<>(queryVO.getPageNo(), queryVO.getPageSize()); | ||
80 | + IPage<OrderOptLogDO> iPage = page(page, queryWrapper); | ||
81 | + | ||
82 | + Page<OrderOptLogResultVO> webVOPage = new Page<>(); | ||
83 | + List<OrderOptLogDO> orderOptLogDOS = iPage.getRecords(); | ||
84 | + if (CollectionUtils.isNotEmpty(orderOptLogDOS)) { | ||
85 | + Set<Long> userIds = orderOptLogDOS.stream().map(OrderOptLogDO::getUserId).collect(Collectors.toSet()); | ||
86 | + Map<Long, AdminUserDO> userDOMap = new HashMap<>(); | ||
87 | + if (CollectionUtils.isNotEmpty(userIds)) { | ||
88 | + List<AdminUserDO> userDOS = userService.listByIds(userIds); | ||
89 | + if (CollectionUtils.isNotEmpty(userDOS)) { | ||
90 | + userDOMap = userDOS.stream().collect(Collectors.toMap(AdminUserDO::getId, Function.identity())); | ||
91 | + } | ||
92 | + } | ||
93 | + Map<Long, AdminUserDO> finalUserDOMap = userDOMap; | ||
94 | + List<OrderOptLogResultVO> resultVOList = orderOptLogDOS.stream().map(x -> { | ||
95 | + OrderOptLogResultVO resultVO = new OrderOptLogResultVO(); | ||
96 | + BeanUtils.copyProperties(x, resultVO); | ||
97 | + if (finalUserDOMap.containsKey(x.getUserId())) { | ||
98 | + resultVO.setUserName(finalUserDOMap.get(x.getUserId()).getUserName()); | ||
99 | + } | ||
100 | + return resultVO; | ||
101 | + }).collect(Collectors.toList()); | ||
102 | + | ||
103 | + webVOPage.setRecords(resultVOList); | ||
104 | + } | ||
105 | + BeanUtils.copyProperties(page, webVOPage, "records"); | ||
106 | + return ServerResult.success(webVOPage); | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
110 | + * @param queryVO | ||
111 | + * @return | ||
112 | + */ | ||
113 | + private LambdaQueryWrapper<OrderOptLogDO> buildQueryByParam(OrderOptLogQueryVO queryVO) { | ||
114 | + return new LambdaQueryWrapper<OrderOptLogDO>() | ||
115 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | ||
116 | + .eq(Objects.nonNull(queryVO.getOrderId()), OrderOptLogDO::getOrderId, queryVO.getOrderId()) | ||
117 | + .orderByDesc(OrderOptLogDO::getId) | ||
118 | + ; | ||
119 | + } | ||
120 | + | ||
62 | /** | 121 | /** |
63 | * 新增数据 | 122 | * 新增数据 |
64 | * | 123 | * |
@@ -123,6 +182,7 @@ public class OrderOptLogServiceImpl extends ServiceImpl<OrderOptLogMapper, Order | @@ -123,6 +182,7 @@ public class OrderOptLogServiceImpl extends ServiceImpl<OrderOptLogMapper, Order | ||
123 | 182 | ||
124 | /** | 183 | /** |
125 | * 通过订单id逻辑删除 | 184 | * 通过订单id逻辑删除 |
185 | + * | ||
126 | * @param orderId | 186 | * @param orderId |
127 | * @return | 187 | * @return |
128 | */ | 188 | */ |