fix(system): 修复支付密码更新逻辑及防止空更新异常
- 支付密码使用加密后存储,避免明文入库 - 仅当支付密码非空时才更新密码字段,避免清空原有密码 - 增加更新字段检测,防止无字段更新时报错 - 确保返回当前用户信息时包含支付密码字段状态
This commit is contained in:
@@ -447,6 +447,12 @@ public class MainController extends BaseController {
|
||||
update.setAddress(user.getAddress());
|
||||
update.setIntroduction(user.getIntroduction());
|
||||
|
||||
// 支付密码变更(个人中心设置/修改支付密码时透传明文):加密后落库,不允许明文入库
|
||||
// 注意:仅当本次提交携带非空 payPassword 才更新,避免清空已有密码
|
||||
if (StrUtil.isNotBlank(user.getPayPassword())) {
|
||||
update.setPayPassword(userService.encodePassword(user.getPayPassword()));
|
||||
}
|
||||
|
||||
// MyBatis-Plus: 如果没有任何可更新字段,会生成 `UPDATE ... WHERE ...`(没有 SET)导致 SQL 报错
|
||||
// 这里检测一下“确实有字段需要更新”,否则直接返回当前用户信息。
|
||||
if (ObjectUtil.isAllEmpty(
|
||||
@@ -460,7 +466,8 @@ public class MainController extends BaseController {
|
||||
update.getCity(),
|
||||
update.getRegion(),
|
||||
update.getAddress(),
|
||||
update.getIntroduction()
|
||||
update.getIntroduction(),
|
||||
update.getPayPassword()
|
||||
)) {
|
||||
return success("没有需要更新的字段", userService.getByIdRel(update.getUserId()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user