feat(pigx-codegen): 优化数据源密码更新逻辑

- 密码为空时自动从数据库查询并解密原始密码用于连接校验
- 简化密码加密逻辑,移除冗余的条件判断
This commit is contained in:
PIGCLOUD committed 2026-03-08 15:06:08 +08:00
1 parent 650d791222
commit 1b27c695d8
1 file changed
+7 -3
@@ -83,6 +83,12 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl<GenDatasourceConfM
*/
@Override
public Boolean updateDsByEnc(GenDatasourceConf conf) {
// 密码为空时,从数据库查询原始密码并解密,用于连接校验
if (StrUtil.isBlank(conf.getPassword())) {
GenDatasourceConf dbConf = this.baseMapper.selectById(conf.getId());
conf.setPassword(stringEncryptor.decrypt(dbConf.getPassword()));
}
if (!checkDataSource(conf)) {
return Boolean.FALSE;
}
@@ -94,9 +100,7 @@ public class GenDatasourceConfServiceImpl extends ServiceImpl<GenDatasourceConfM
addDynamicDataSource(conf);
// 更新数据库配置
if (StrUtil.isNotBlank(conf.getPassword())) {
conf.setPassword(stringEncryptor.encrypt(conf.getPassword()));
}
conf.setPassword(stringEncryptor.encrypt(conf.getPassword()));
this.baseMapper.updateById(conf);
return Boolean.TRUE;
}