refactor(个人中心): 三方账号保存接口优化

This commit is contained in:
song-cc-rock 2024-01-29 10:13:43 +08:00 committed by 刘瑞斌
parent e8233fe336
commit 6b3a686c71
2 changed files with 9 additions and 0 deletions

View File

@ -68,6 +68,9 @@ public class UserPlatformAccountService {
userExtend.setId(userId);
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
userExtendMapper.insertSelective(userExtend);
} else if (userExtend.getPlatformInfo() == null){
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
userExtendMapper.updateByPrimaryKeySelective(userExtend);
} else {
// noinspection unchecked
Map<String, Object> originalUserPlatformInfo = JSON.parseMap(new String(userExtend.getPlatformInfo()));

View File

@ -5,6 +5,7 @@ import io.metersphere.system.base.BasePluginTestService;
import io.metersphere.system.base.BaseTest;
import io.metersphere.system.controller.handler.ResultHolder;
import io.metersphere.system.domain.Plugin;
import io.metersphere.system.domain.UserExtend;
import io.metersphere.system.domain.UserExtendExample;
import io.metersphere.system.mapper.UserExtendMapper;
import jakarta.annotation.Resource;
@ -95,6 +96,11 @@ public class UserPlatformAccountControllerTests extends BaseTest {
Assertions.assertNull(accountMap);
// @@请求成功 保存两次
this.requestPostWithOk(SAVE_POST, buildUserPlatformConfig());
UserExtend record = new UserExtend();
record.setId("admin");
record.setPlatformInfo(null);
userExtendMapper.updateByPrimaryKeyWithBLOBs(record);
this.requestPostWithOk(SAVE_POST, buildUserPlatformConfig());
this.requestPostWithOk(SAVE_POST, buildUserPlatformConfig());
}