refactor(系统设置): 个人中心本地执行去掉校验接口
This commit is contained in:
parent
95586e1efa
commit
ee9928ebca
|
@ -31,12 +31,6 @@ public class UserLocalConfigController {
|
|||
return userLocalConfigService.add(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/validate/{id}")
|
||||
@Operation(summary = "系统设置-个人中心-我的设置-本地执行-验证是否通过")
|
||||
public boolean validate(@PathVariable String id) {
|
||||
return userLocalConfigService.validate(id);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "系统设置-个人中心-我的设置-本地执行-获取本地执行")
|
||||
public List<UserLocalConfig> get() {
|
||||
|
|
|
@ -21,8 +21,6 @@ import jakarta.annotation.Resource;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -73,24 +71,6 @@ public class UserLocalConfigService {
|
|||
|
||||
}
|
||||
|
||||
public boolean validate(String id) {
|
||||
UserLocalConfig userLocalConfig = checkResourceById(id);
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
URI url = new URI(userLocalConfig.getUserUrl());
|
||||
connection = (HttpURLConnection) url.toURL().openConnection();
|
||||
connection.setConnectTimeout(3000);
|
||||
return connection.getResponseCode() == HttpURLConnection.HTTP_OK;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<UserLocalConfig> get(String userId) {
|
||||
UserLocalConfigExample userLocalConfigExample = new UserLocalConfigExample();
|
||||
userLocalConfigExample.createCriteria().andCreateUserEqualTo(userId);
|
||||
|
@ -99,12 +79,8 @@ public class UserLocalConfigService {
|
|||
|
||||
public void enable(String id) {
|
||||
UserLocalConfig userLocalConfig = checkResourceById(id);
|
||||
if (validate(id)) {
|
||||
userLocalConfig.setEnable(true);
|
||||
userLocalConfigMapper.updateByPrimaryKeySelective(userLocalConfig);
|
||||
} else {
|
||||
throw new MSException(Translator.get("current_user_local_config_not_validate"));
|
||||
}
|
||||
}
|
||||
|
||||
public void disable(String id) {
|
||||
|
|
|
@ -79,21 +79,6 @@ public class UserLocalConfigControllerTests extends BaseTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testValidate() throws Exception {
|
||||
UserLocalConfigExample userLocalConfigExample = new UserLocalConfigExample();
|
||||
userLocalConfigExample.createCriteria().andCreateUserEqualTo("admin").andTypeEqualTo("API");
|
||||
UserLocalConfig userLocalConfig = userLocalConfigMapper.selectByExample(userLocalConfigExample).get(0);
|
||||
requestGet(String.format(VALIDATE, userLocalConfig.getId()));
|
||||
userLocalConfigExample.clear();
|
||||
userLocalConfigExample.createCriteria().andCreateUserEqualTo("admin").andTypeEqualTo("UI");
|
||||
userLocalConfig = userLocalConfigMapper.selectByExample(userLocalConfigExample).get(0);
|
||||
requestGet(String.format(VALIDATE, userLocalConfig.getId()));
|
||||
//不存在的
|
||||
requestGet(String.format(VALIDATE, UUID.randomUUID().toString()), status().is5xxServerError());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testUpdate() throws Exception {
|
||||
|
@ -134,10 +119,6 @@ public class UserLocalConfigControllerTests extends BaseTest {
|
|||
checkLog(userLocalConfig.getId(), OperationLogType.UPDATE);
|
||||
//不存在的
|
||||
requestGet(String.format(ENABLE, UUID.randomUUID().toString()), status().is5xxServerError());
|
||||
userLocalConfigExample.clear();
|
||||
userLocalConfigExample.createCriteria().andCreateUserEqualTo("admin").andTypeEqualTo("UI");
|
||||
userLocalConfig = userLocalConfigMapper.selectByExample(userLocalConfigExample).get(0);
|
||||
requestGet(String.format(ENABLE, userLocalConfig.getId())).andExpect(status().is5xxServerError());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue