Commit 3c74b22933cd84bcf2c62293d76a823af29a100b
1 parent
c74881c8
系统操作日志:集成 mzt-biz-log 4
Showing
12 changed files
with
224 additions
and
17 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java
| ... | ... | @@ -20,8 +20,7 @@ public interface LogRecordConstants { |
| 20 | 20 | |
| 21 | 21 | //======================= 客户转移操作日志 ======================= |
| 22 | 22 | |
| 23 | - String TRANSFER_CUSTOMER_LOG_SUCCESS = "把客户【{{#crmCustomer == null ? '' : #crmCustomer.name}}】负责人从" + | |
| 24 | - "【{getAdminUserById{#crmCustomer == null ? '' : #crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; | |
| 23 | + String TRANSFER_CUSTOMER_LOG_SUCCESS = "把客户【{{#crmCustomer.name}}】的负责人从【{getAdminUserById{#crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; | |
| 25 | 24 | String TRANSFER_CUSTOMER_LOG_FAIL = ""; |
| 26 | 25 | |
| 27 | 26 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/pom.xml
| ... | ... | @@ -60,6 +60,10 @@ |
| 60 | 60 | <groupId>cn.iocoder.boot</groupId> |
| 61 | 61 | <artifactId>yudao-spring-boot-starter-excel</artifactId> |
| 62 | 62 | </dependency> |
| 63 | + <dependency> | |
| 64 | + <groupId>cn.iocoder.boot</groupId> | |
| 65 | + <artifactId>yudao-spring-boot-starter-biz-dict</artifactId> | |
| 66 | + </dependency> | |
| 63 | 67 | |
| 64 | 68 | <!-- Test 测试相关 --> |
| 65 | 69 | <dependency> | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http
| ... | ... | @@ -9,4 +9,8 @@ tenant-id: {{adminTenentId}} |
| 9 | 9 | "newOwnerUserId": 127 |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | +### 自定义日志记录结果 | |
| 13 | +### 操作日志 ===> OperateLogV2CreateReqBO(traceId=, userId=1, userType=2, module=CRM-客户, name=客户转移, bizId=10, content=把客户【张三】的负责人从【芋道源码(15612345678)】变更为了【tttt】, requestMethod=PUT, requestUrl=/admin-api/crm/customer/transfer, userIp=127.0.0.1, userAgent=Apache-HttpClient/4.5.14 (Java/17.0.9)) | |
| 12 | 14 | |
| 15 | +### diff 日志 | |
| 16 | +### | 操作日志 ===> OperateLogV2CreateReqBO(traceId=, userId=1, userType=2, module=CRM-客户, name=更新客户, bizId=11, content=更新了客户【所属行业】从【H 住宿和餐饮业】修改为【D 电力、热力、燃气及水生产和供应业】;【客户等级】从【C (非优先客户)】修改为【A (重点客户)】;【客户来源】从【线上咨询】修改为【预约上门】, requestMethod=PUT, requestUrl=/admin-api/crm/customer/update, userIp=0:0:0:0:0:0:0:1, userAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36) | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| ... | ... | @@ -59,7 +59,7 @@ public class CrmCustomerController { |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | @PutMapping("/update") |
| 62 | - @Operation(summary = "更新客户") | |
| 62 | + //@Operation(summary = "更新客户") | |
| 63 | 63 | @PreAuthorize("@ss.hasPermission('crm:customer:update')") |
| 64 | 64 | public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) { |
| 65 | 65 | customerService.updateCustomer(updateReqVO); |
| ... | ... | @@ -123,6 +123,7 @@ public class CrmCustomerController { |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | @PutMapping("/transfer") |
| 126 | + //@Operation(summary = "客户转移") | |
| 126 | 127 | @PreAuthorize("@ss.hasPermission('crm:customer:update')") |
| 127 | 128 | public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) { |
| 128 | 129 | customerService.transferCustomer(reqVO, getLoginUserId()); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java
| ... | ... | @@ -3,17 +3,20 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.validation.Mobile; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.validation.Telephone; |
| 6 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 6 | 7 | import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; |
| 8 | +import com.mzt.logapi.starter.annotation.DiffLogField; | |
| 7 | 9 | import io.swagger.v3.oas.annotations.media.Schema; |
| 8 | -import lombok.Data; | |
| 9 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 10 | - | |
| 11 | 10 | import jakarta.validation.constraints.Email; |
| 12 | 11 | import jakarta.validation.constraints.NotEmpty; |
| 13 | 12 | import jakarta.validation.constraints.Size; |
| 13 | +import lombok.Data; | |
| 14 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 15 | + | |
| 14 | 16 | import java.time.LocalDateTime; |
| 15 | 17 | |
| 16 | 18 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 19 | +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; | |
| 17 | 20 | |
| 18 | 21 | /** |
| 19 | 22 | * 客户 Base VO,提供给添加、修改、详细的子 VO 使用 |
| ... | ... | @@ -23,57 +26,73 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 23 | 26 | public class CrmCustomerBaseVO { |
| 24 | 27 | |
| 25 | 28 | @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") |
| 29 | + @DiffLogField(name = "客户名称") | |
| 26 | 30 | @NotEmpty(message = "客户名称不能为空") |
| 27 | 31 | private String name; |
| 28 | 32 | |
| 29 | 33 | @Schema(description = "所属行业", example = "1") |
| 34 | + @DiffLogField(name = "所属行业", function = "getIndustryById") | |
| 35 | + @DictFormat(CRM_CUSTOMER_INDUSTRY) | |
| 30 | 36 | private Integer industryId; |
| 31 | 37 | |
| 32 | 38 | @Schema(description = "客户等级", example = "2") |
| 39 | + @DiffLogField(name = "客户等级", function = "getLevel") | |
| 33 | 40 | @InEnum(CrmCustomerLevelEnum.class) |
| 34 | 41 | private Integer level; |
| 35 | 42 | |
| 36 | 43 | @Schema(description = "客户来源", example = "3") |
| 44 | + @DiffLogField(name = "客户来源", function = "getSource") | |
| 37 | 45 | private Integer source; |
| 38 | 46 | |
| 39 | 47 | @Schema(description = "手机", example = "18000000000") |
| 48 | + @DiffLogField(name = "手机") | |
| 40 | 49 | @Mobile |
| 41 | 50 | private String mobile; |
| 42 | 51 | |
| 43 | 52 | @Schema(description = "电话", example = "18000000000") |
| 53 | + @DiffLogField(name = "电话") | |
| 44 | 54 | @Telephone |
| 45 | 55 | private String telephone; |
| 46 | 56 | |
| 47 | 57 | @Schema(description = "网址", example = "https://www.baidu.com") |
| 58 | + @DiffLogField(name = "网址") | |
| 48 | 59 | private String website; |
| 49 | 60 | |
| 50 | 61 | @Schema(description = "QQ", example = "123456789") |
| 62 | + @DiffLogField(name = "QQ") | |
| 51 | 63 | @Size(max = 20, message = "QQ长度不能超过 20 个字符") |
| 52 | 64 | private String qq; |
| 53 | 65 | |
| 54 | - @Schema(description = "wechat", example = "123456789") | |
| 66 | + @Schema(description = "微信", example = "123456789") | |
| 67 | + @DiffLogField(name = "微信") | |
| 55 | 68 | @Size(max = 255, message = "微信长度不能超过 255 个字符") |
| 56 | 69 | private String wechat; |
| 57 | 70 | |
| 58 | - @Schema(description = "email", example = "123456789@qq.com") | |
| 71 | + @Schema(description = "邮箱", example = "123456789@qq.com") | |
| 72 | + @DiffLogField(name = "邮箱") | |
| 59 | 73 | @Email(message = "邮箱格式不正确") |
| 60 | 74 | @Size(max = 255, message = "邮箱长度不能超过 255 个字符") |
| 61 | 75 | private String email; |
| 62 | 76 | |
| 63 | 77 | @Schema(description = "客户描述", example = "任意文字") |
| 78 | + @DiffLogField(name = "客户描述") | |
| 64 | 79 | @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") |
| 65 | 80 | private String description; |
| 66 | 81 | |
| 67 | 82 | @Schema(description = "备注", example = "随便") |
| 83 | + @DiffLogField(name = "备注") | |
| 68 | 84 | private String remark; |
| 69 | 85 | |
| 70 | 86 | @Schema(description = "地区编号", example = "20158") |
| 87 | + @DiffLogField(name = "地区编号", function = "getAreaById") | |
| 71 | 88 | private Integer areaId; |
| 72 | 89 | |
| 73 | 90 | @Schema(description = "详细地址", example = "北京市海淀区") |
| 91 | + @DiffLogField(name = "详细地址") | |
| 74 | 92 | private String detailAddress; |
| 75 | 93 | |
| 76 | 94 | @Schema(description = "下次联系时间") |
| 95 | + @DiffLogField(name = "下次联系时间") | |
| 77 | 96 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 78 | 97 | private LocalDateTime contactNextTime; |
| 79 | 98 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/bizlog/function/CrmIndustryParseFunction.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.framework.bizlog.function; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 4 | +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; | |
| 5 | +import com.mzt.logapi.service.IParseFunction; | |
| 6 | +import lombok.extern.slf4j.Slf4j; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 自定义函数-通过行业编号获取行业信息 | |
| 13 | + * | |
| 14 | + * @author HUIHUI | |
| 15 | + */ | |
| 16 | +@Slf4j | |
| 17 | +@Component | |
| 18 | +public class CrmIndustryParseFunction implements IParseFunction { | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public boolean executeBefore() { | |
| 22 | + return true; // 先转换值后对比 | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public String functionName() { | |
| 27 | + return "getIndustryById"; | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public String apply(Object value) { | |
| 32 | + if (value == null) { | |
| 33 | + return ""; | |
| 34 | + } | |
| 35 | + if (StrUtil.isEmpty(value.toString())) { | |
| 36 | + return ""; | |
| 37 | + } | |
| 38 | + | |
| 39 | + // 获取行业信息 | |
| 40 | + try { | |
| 41 | + return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_INDUSTRY, value.toString()); | |
| 42 | + } catch (Exception ignored) { | |
| 43 | + } | |
| 44 | + return ""; | |
| 45 | + } | |
| 46 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/bizlog/function/CrmLevelParseFunction.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.framework.bizlog.function; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 4 | +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; | |
| 5 | +import com.mzt.logapi.service.IParseFunction; | |
| 6 | +import lombok.extern.slf4j.Slf4j; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 自定义函数-通过客户等级编号获取客户等级信息 | |
| 13 | + * | |
| 14 | + * @author HUIHUI | |
| 15 | + */ | |
| 16 | +@Slf4j | |
| 17 | +@Component | |
| 18 | +public class CrmLevelParseFunction implements IParseFunction { | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public boolean executeBefore() { | |
| 22 | + return true; // 先转换值后对比 | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public String functionName() { | |
| 27 | + return "getLevel"; | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public String apply(Object value) { | |
| 32 | + if (value == null) { | |
| 33 | + return ""; | |
| 34 | + } | |
| 35 | + if (StrUtil.isEmpty(value.toString())) { | |
| 36 | + return ""; | |
| 37 | + } | |
| 38 | + | |
| 39 | + // 获取客户等级信息 | |
| 40 | + try { | |
| 41 | + return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_LEVEL, value.toString()); | |
| 42 | + } catch (Exception ignored) { | |
| 43 | + } | |
| 44 | + return ""; | |
| 45 | + } | |
| 46 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/bizlog/function/CrmSourceParseFunction.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.framework.bizlog.function; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 4 | +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; | |
| 5 | +import com.mzt.logapi.service.IParseFunction; | |
| 6 | +import lombok.extern.slf4j.Slf4j; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 自定义函数-通过客户来源编号获取客户来源信息 | |
| 13 | + * | |
| 14 | + * @author HUIHUI | |
| 15 | + */ | |
| 16 | +@Slf4j | |
| 17 | +@Component | |
| 18 | +public class CrmSourceParseFunction implements IParseFunction { | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public boolean executeBefore() { | |
| 22 | + return true; // 先转换值后对比 | |
| 23 | + } | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public String functionName() { | |
| 27 | + return "getSource"; | |
| 28 | + } | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public String apply(Object value) { | |
| 32 | + if (value == null) { | |
| 33 | + return ""; | |
| 34 | + } | |
| 35 | + if (StrUtil.isEmpty(value.toString())) { | |
| 36 | + return ""; | |
| 37 | + } | |
| 38 | + | |
| 39 | + // 获取客户来源信息 | |
| 40 | + try { | |
| 41 | + return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_SOURCE, value.toString()); | |
| 42 | + } catch (Exception ignored) { | |
| 43 | + } | |
| 44 | + return ""; | |
| 45 | + } | |
| 46 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/bizlog/package-info.java
0 → 100644
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; |
| 6 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; |
| 7 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; |
| ... | ... | @@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 16 | 17 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 17 | 18 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 18 | 19 | import com.mzt.logapi.context.LogRecordContext; |
| 20 | +import com.mzt.logapi.service.impl.DiffParseFunction; | |
| 19 | 21 | import com.mzt.logapi.starter.annotation.LogRecord; |
| 20 | 22 | import jakarta.annotation.Resource; |
| 21 | 23 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -63,11 +65,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 63 | 65 | |
| 64 | 66 | @Override |
| 65 | 67 | @Transactional(rollbackFor = Exception.class) |
| 68 | + @LogRecord(success = "更新了客户{_DIFF{#updateReqVO}}", type = CRM_CUSTOMER, subType = "更新客户", bizNo = "{{#updateReqVO.id}}") | |
| 66 | 69 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) |
| 67 | 70 | public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { |
| 68 | 71 | // 校验存在 |
| 69 | - validateCustomerExists(updateReqVO.getId()); | |
| 72 | + CrmCustomerDO oldCustomerDO = validateCustomerExists(updateReqVO.getId()); | |
| 70 | 73 | |
| 74 | + // __DIFF 函数传递了一个参数,传递的参数是修改之后的对象,这种方式需要在方法内部向 LogRecordContext 中 put 一个变量,代表是之前的对象,这个对象可以是null | |
| 75 | + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomerDO, CrmCustomerUpdateReqVO.class)); | |
| 71 | 76 | // 更新 |
| 72 | 77 | CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); |
| 73 | 78 | customerMapper.updateById(updateObj); |
| ... | ... | @@ -86,10 +91,12 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 86 | 91 | crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), id); |
| 87 | 92 | } |
| 88 | 93 | |
| 89 | - private void validateCustomerExists(Long id) { | |
| 90 | - if (customerMapper.selectById(id) == null) { | |
| 94 | + private CrmCustomerDO validateCustomerExists(Long id) { | |
| 95 | + CrmCustomerDO customerDO = customerMapper.selectById(id); | |
| 96 | + if (customerDO == null) { | |
| 91 | 97 | throw exception(CUSTOMER_NOT_EXISTS); |
| 92 | 98 | } |
| 99 | + return customerDO; | |
| 93 | 100 | } |
| 94 | 101 | |
| 95 | 102 | @Override |
| ... | ... | @@ -135,7 +142,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 135 | 142 | public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { |
| 136 | 143 | // 1. 校验客户是否存在 |
| 137 | 144 | validateCustomer(reqVO.getId()); |
| 138 | - // 添加 crmCustomer 到日志上下文 | |
| 145 | + // 添加 crmCustomer 到日志上下文 TODO 日志记录放在 service 里是因为已经过了权限校验查询时不用走两次校验 | |
| 139 | 146 | LogRecordContext.putVariable("crmCustomer", customerMapper.selectById(reqVO.getId())); |
| 140 | 147 | // 2.1 数据权限转移 |
| 141 | 148 | crmPermissionService.transferPermission( | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/bizlog/function/AdminUserParseFunction.java
| ... | ... | @@ -22,11 +22,6 @@ public class AdminUserParseFunction implements IParseFunction { |
| 22 | 22 | private AdminUserApi adminUserApi; |
| 23 | 23 | |
| 24 | 24 | @Override |
| 25 | - public boolean executeBefore() { | |
| 26 | - return true; | |
| 27 | - } | |
| 28 | - | |
| 29 | - @Override | |
| 30 | 25 | public String functionName() { |
| 31 | 26 | return "getAdminUserById"; |
| 32 | 27 | } | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/bizlog/function/AreaParseFunction.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.framework.bizlog.function; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 4 | +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; | |
| 5 | +import com.mzt.logapi.service.IParseFunction; | |
| 6 | +import lombok.extern.slf4j.Slf4j; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 自定义函数-通过区域编号获取区域信息 | |
| 11 | + * | |
| 12 | + * @author HUIHUI | |
| 13 | + */ | |
| 14 | +@Slf4j | |
| 15 | +@Component | |
| 16 | +public class AreaParseFunction implements IParseFunction { | |
| 17 | + | |
| 18 | + @Override | |
| 19 | + public boolean executeBefore() { | |
| 20 | + return true; // 先转换值后对比 | |
| 21 | + } | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public String functionName() { | |
| 25 | + return "getAreaById"; | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public String apply(Object value) { | |
| 30 | + if (value == null) { | |
| 31 | + return ""; | |
| 32 | + } | |
| 33 | + if (StrUtil.isEmpty(value.toString())) { | |
| 34 | + return ""; | |
| 35 | + } | |
| 36 | + | |
| 37 | + return AreaUtils.format(Integer.parseInt(value.toString())); | |
| 38 | + } | |
| 39 | +} | ... | ... |