Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

只传递了个别字段值的更新操作,记录日志会存在问题 #154

Open
wyy159 opened this issue Jun 11, 2024 · 2 comments
Open

Comments

@wyy159
Copy link

wyy159 commented Jun 11, 2024

框架自带的DIFF函数没有做null判断,个人感觉可以加一下字段值为Null就不比较

@otter2025
Copy link

我们也遇到相同问题,例如,我只修改了用户"nickname"字段,但是必须要把所有的其他没有修改的字段也让前端传过来,才能正确比对字段的修改记录,否则就会出现以下日志内容:
更新管理员:删除了【备注】:【测试】;删除了【管理员状态】:【0】;删除了【登录用户名】:【test】
上面的内容明显不是想要的;
希望大佬能够增加个判断,如果传入的对象为null,则忽略对比;或者增加的配置,让开发者自己选择是否忽略

@flik1337
Copy link

flik1337 commented Nov 19, 2024

有个不优雅的解决方案:
@LogRecord(
success = "客户存单{_DIFF{#customerChargeDto}}",
type = LogRecordType.CUSTOMER, subType = LogRecordType.CUSTOMER_SUB.CHARGE,
bizNo = "{{#customerChargeDto.customerId}}"
)
public CommonResult chargeCustomer(Principal principal, @RequestBody CustomerChargeDto customerChargeDto) {
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, new CustomerChargeDto());
return false;
}
将初始化的入参对象作为OLD_OBJECT,这样就会对比前端传入的入参对象和初始化的入参对象

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants