diff --git a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java index 659d1d046..3e1c9ddda 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java @@ -478,8 +478,10 @@ public class SimulationV1Controller { return groupSimulationService.getAllPaTimedPlayInfo(group, stationCode); } + /* ----------------------- 仿真新接口 ----------------------- */ + /** - * 新仿真创建接口(新) + * 仿真创建接口(新) */ @PostMapping("/new/{mapId}") public String createSimulation(@PathVariable long mapId, @RequestBody @Validated SimulationWorkParamVO paramVO, diff --git a/src/main/java/club/joylink/rtss/controller/user/ThirdAccountConfigController.java b/src/main/java/club/joylink/rtss/controller/user/ThirdAccountConfigController.java index 4bc6ea20b..ca740f023 100644 --- a/src/main/java/club/joylink/rtss/controller/user/ThirdAccountConfigController.java +++ b/src/main/java/club/joylink/rtss/controller/user/ThirdAccountConfigController.java @@ -1,12 +1,16 @@ package club.joylink.rtss.controller.user; import club.joylink.rtss.services.thridAccount.ThirdAccountConfigService; -import club.joylink.rtss.vo.AccountVO; +import club.joylink.rtss.vo.client.PageQueryVO; +import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.thirdAccount.ThirdAccountConfigVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +/** + * 第三方配置接口 + */ @RestController @RequestMapping("/api/thirdAccountConfig") public class ThirdAccountConfigController { @@ -14,9 +18,27 @@ public class ThirdAccountConfigController { @Autowired private ThirdAccountConfigService thirdAccountConfigService; + /** + * 分页查询所有配置 + */ + @GetMapping("/paged") + public PageVO pagedQuery(PageQueryVO queryVO) { + return this.thirdAccountConfigService.pagedQuery(queryVO); + } + + /** + * 新增或更新 + */ @PostMapping("") - public void saveOrUpdate(@RequestBody @Validated ThirdAccountConfigVO configVO, @RequestAttribute AccountVO user) { + public void saveOrUpdate(@RequestBody @Validated ThirdAccountConfigVO configVO) { this.thirdAccountConfigService.saveOrUpdateConfig(configVO); } + /** + * 删除 + */ + @DeleteMapping("/{id}") + public void delete(@PathVariable long id) { + this.thirdAccountConfigService.delete(id); + } } diff --git a/src/main/java/club/joylink/rtss/services/ReleaseService.java b/src/main/java/club/joylink/rtss/services/ReleaseService.java index 747856f03..42d8c9505 100644 --- a/src/main/java/club/joylink/rtss/services/ReleaseService.java +++ b/src/main/java/club/joylink/rtss/services/ReleaseService.java @@ -448,6 +448,7 @@ public class ReleaseService implements IReleaseService { rtsMapSystem.setUpdateTime(now); rtsMapSystemDAO.updateByPrimaryKeyWithBLOBs(rtsMapSystem); } else { + rtsMapSystem.setMapId(mapId); rtsMapSystem.setCreateTime(now); rtsMapSystem.setCreatorId(user.getId()); rtsMapSystemDAO.insert(rtsMapSystem); diff --git a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigService.java b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigService.java index 5d82e7d5a..068d1c6eb 100644 --- a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigService.java +++ b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigService.java @@ -1,5 +1,7 @@ package club.joylink.rtss.services.thridAccount; +import club.joylink.rtss.vo.client.PageQueryVO; +import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.thirdAccount.ThirdAccountConfigVO; import club.joylink.rtss.vo.thirdAccount.ThirdInterfaceConfig; @@ -8,4 +10,8 @@ public interface ThirdAccountConfigService { void saveOrUpdateConfig(ThirdAccountConfigVO configVO); ThirdInterfaceConfig getInterfaceConfigByAccountId(String account); + + PageVO pagedQuery(PageQueryVO queryVO); + + void delete(long id); } diff --git a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImpl.java b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImpl.java index 376bdb726..5cacf10f7 100644 --- a/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImpl.java @@ -5,8 +5,12 @@ import club.joylink.rtss.entity.SysThirdAccountConfig; import club.joylink.rtss.entity.SysThirdAccountConfigExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.cache.ICacheService; +import club.joylink.rtss.vo.client.PageQueryVO; +import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.thirdAccount.ThirdAccountConfigVO; import club.joylink.rtss.vo.thirdAccount.ThirdInterfaceConfig; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -51,6 +55,19 @@ public class ThirdAccountConfigServiceImpl implements ThirdAccountConfigService return config; } + @Override + public PageVO pagedQuery(PageQueryVO queryVO) { + Page page = PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); + List list = sysThirdAccountConfigDAO.selectByExampleWithBLOBs(null); + List voList = ThirdAccountConfigVO.convert(list); + return PageVO.convert(page, voList); + } + + @Override + public void delete(long id) { + sysThirdAccountConfigDAO.deleteByPrimaryKey(id); + } + private String buildInterfaceConfigCacheKey(String account) { return String.format(String.format("%s%s", InterfaceConfigCacheKeyPre, account)); } diff --git a/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdAccountConfigVO.java b/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdAccountConfigVO.java index b9be7dc3b..cd5320307 100644 --- a/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdAccountConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdAccountConfigVO.java @@ -6,10 +6,14 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.springframework.util.CollectionUtils; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; @Getter @Setter @@ -39,6 +43,22 @@ public class ThirdAccountConfigVO { @NotNull(message = "接口配置不能为空") private ThirdInterfaceConfig interfaceConfig; + public ThirdAccountConfigVO(SysThirdAccountConfig config) { + this.id = config.getId(); + this.account = config.getAccount(); + this.createTime = config.getCreateTime(); + this.updateTime = config.getUpdateTime(); + this.interfaceConfig = readInterfaceConfig(config.getInterfaceConfig()); + } + + public static List convert(List configList) { + if (!CollectionUtils.isEmpty(configList)) { + return configList.stream().map(ThirdAccountConfigVO::new).collect(Collectors.toList()); + } else { + return new ArrayList<>(); + } + } + public static ThirdInterfaceConfig readInterfaceConfig(String interfaceConfig) { return JsonUtils.read(interfaceConfig, ThirdInterfaceConfig.class); } diff --git a/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdInterfaceConfig.java b/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdInterfaceConfig.java index 719fa6374..2604c9cfb 100644 --- a/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdInterfaceConfig.java +++ b/src/main/java/club/joylink/rtss/vo/thirdAccount/ThirdInterfaceConfig.java @@ -1,8 +1,12 @@ package club.joylink.rtss.vo.thirdAccount; import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; @Getter +@Setter +@NoArgsConstructor public class ThirdInterfaceConfig { /** * 用户仿真使用记录同步第三方url diff --git a/src/test/java/club/joylink/rtss/services/MapServiceTest.java b/src/test/java/club/joylink/rtss/services/MapServiceTest.java index c520fa6c3..f549f91e9 100644 --- a/src/test/java/club/joylink/rtss/services/MapServiceTest.java +++ b/src/test/java/club/joylink/rtss/services/MapServiceTest.java @@ -31,6 +31,7 @@ public class MapServiceTest { @Test void copyMapData() { + long mapId = 59L; String mapName = "单元测试地图" + new Random().nextInt(100); MapCopyOption mapCopyOption = new MapCopyOption(); @@ -40,7 +41,7 @@ public class MapServiceTest { mapCopyOption.setCopyDataConfig(releaseConfigVO); AccountVO accountVO = new AccountVO(); accountVO.setId(10086L); - mapService.copyMapData(59L, mapCopyOption, accountVO); + mapService.copyMapData(mapId, mapCopyOption, accountVO); //验证 List onlineMapInfos = mapService.queryOnlineMapInfos(); diff --git a/src/test/java/club/joylink/rtss/services/QRCodeManagerTest.java b/src/test/java/club/joylink/rtss/services/QRCodeManagerTest.java deleted file mode 100644 index 8ca8cc5a3..000000000 --- a/src/test/java/club/joylink/rtss/services/QRCodeManagerTest.java +++ /dev/null @@ -1,153 +0,0 @@ -package club.joylink.rtss.services; - -import club.joylink.rtss.configuration.configProp.OtherConfig; -import club.joylink.rtss.constants.Project; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -@SpringBootTest(classes = {QRCodeManagerTest.class}) -class QRCodeManagerTest { - @Autowired - private QRCodeManager qrCodeManager; - - @Autowired - private OtherConfig otherConfig; - - @Test - void getLoginCode() { - String[] envArr = new String[]{"dev", "test", "prd"}; - for (String env : envArr) { - otherConfig.setEnv(env); - for (Project project : Project.values()) { - String result = qrCodeManager.getLoginCode(null, project.name(), null); - switch (env) { - case "dev": - assertEquals("", result); - break; - case "test": { - String[] split = result.split("__"); - assertEquals(Project.TEST.name(), split[split.length - 1]); - break; - } - case "prd": - String[] split = result.split("__"); - assertEquals(project.name(), split[split.length - 1]); - break; - default: - throw new IllegalStateException("Unexpected value: " + env); - } - } - } - } - - @Test - void getDistributeCode() { - String[] envArr = new String[]{"dev", "test", "prd"}; - for (String env : envArr) { - otherConfig.setEnv(env); - for (Project project : Project.values()) { - String result = qrCodeManager.getDistributeCode(1, project.name()); - switch (env) { - case "dev": - assertEquals("", result); - break; - case "test": { - String[] split = result.split("\\?"); - assertEquals(split[1], "state=1__TEST"); - break; - } - case "prd": - String[] split = result.split("\\?"); - assertEquals(split[1], "state=1__" + project.name()); - break; - default: - throw new IllegalStateException("Unexpected value: " + env); - } - } - } - } - - @Test - void getSimulationCode() { - String[] envArr = new String[]{"dev", "test", "prd"}; - for (String env : envArr) { - otherConfig.setEnv(env); - for (Project project : Project.values()) { - String result = qrCodeManager.getSimulationCode("42-10086", project.name()); - switch (env) { - case "dev": - assertEquals("", result); - break; - case "test": { - String[] split = result.split("\\?"); - assertEquals(split[1], "state=42-10086__TEST"); - break; - } - case "prd": - String[] split = result.split("\\?"); - assertEquals(split[1], "state=42-10086__" + project.name()); - break; - default: - throw new IllegalStateException("Unexpected value: " + env); - } - } - } - } - - @Test - void getWeChatBindUrl() { - String[] envArr = new String[]{"dev", "test", "prd"}; - for (String env : envArr) { - otherConfig.setEnv(env); - for (Project project : Project.values()) { - String result = qrCodeManager.getWeChatBindUrl(1, project.name()); - switch (env) { - case "dev": - assertEquals("", result); - break; - case "test": { - String[] split = result.split("\\?"); - assertEquals(split[1], "state=1__TEST"); - break; - } - case "prd": - String[] split = result.split("\\?"); - assertEquals(split[1], "state=1__" + project.name()); - break; - default: - throw new IllegalStateException("Unexpected value: " + env); - } - } - } - } - - @Test - void getOrgBindCode() { - String[] envArr = new String[]{"dev", "test", "prd"}; - for (String env : envArr) { - otherConfig.setEnv(env); - for (Project project : Project.values()) { - String result = qrCodeManager.getOrgBindCode(1, project.name()); - switch (env) { - case "dev": - assertEquals("", result); - break; - case "test": { - String[] split = result.split("\\?"); - assertEquals(split[1], "state=1__TEST"); - break; - } - case "prd": - String[] split = result.split("\\?"); - assertEquals(split[1], "state=1__" + project.name()); - break; - default: - throw new IllegalStateException("Unexpected value: " + env); - } - } - } - } -} diff --git a/src/test/java/club/joylink/rtss/services/project/ServerServiceImplTest.java b/src/test/java/club/joylink/rtss/services/project/ServerServiceImplTest.java deleted file mode 100644 index be51b7fae..000000000 --- a/src/test/java/club/joylink/rtss/services/project/ServerServiceImplTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package club.joylink.rtss.services.project; - -import club.joylink.rtss.constants.Project; -import club.joylink.rtss.vo.project.ProjectServerVO; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.transaction.annotation.Transactional; - -import static org.junit.jupiter.api.Assertions.*; - -@SpringBootTest -class ServerServiceImplTest { - @Autowired - private ServerService serverService; - - @Transactional - @Test - void getByProject() { - //正常取值 - for (Project project : Project.values()) { - serverService.getByProject(project.name()); - } - //参数异常 - try { - serverService.getByProject(null); - } catch (Exception e) { - assertTrue(e instanceof NullPointerException); - } - //校验取值结果 - ProjectServerVO xtyProjectVO = serverService.getByProject("XTY"); - assertEquals(xtyProjectVO.getDomainName(), "test.joylink.club/jlcloud"); - assertEquals(xtyProjectVO.getResourcesDomainName(), "joylink.club/oss/joylink"); - ProjectServerVO drtsProjectVO = serverService.getByProject("DRTS"); - assertNull(drtsProjectVO); - } -} \ No newline at end of file diff --git a/src/test/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImplTest.java b/src/test/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImplTest.java new file mode 100644 index 000000000..db90be748 --- /dev/null +++ b/src/test/java/club/joylink/rtss/services/thridAccount/ThirdAccountConfigServiceImplTest.java @@ -0,0 +1,56 @@ +package club.joylink.rtss.services.thridAccount; + +import club.joylink.rtss.vo.client.PageQueryVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.thirdAccount.ThirdAccountConfigVO; +import club.joylink.rtss.vo.thirdAccount.ThirdInterfaceConfig; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.Rollback; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; + +import static org.junit.jupiter.api.Assertions.fail; + +@SpringBootTest +@Transactional +@Rollback +class ThirdAccountConfigServiceImplTest { + @Autowired + private ThirdAccountConfigServiceImpl thirdAccountConfigService; + + @Test + void saveOrUpdateConfig() { + String account = "unit test"; + + ThirdAccountConfigVO thirdAccountConfigVO = new ThirdAccountConfigVO(); + thirdAccountConfigVO.setAccount(account); + thirdAccountConfigVO.setCreateTime(LocalDateTime.now()); + ThirdInterfaceConfig thirdInterfaceConfig = new ThirdInterfaceConfig(); + thirdInterfaceConfig.setUserSimulationRecordSyncUrl("unit test -1"); + thirdInterfaceConfig.setUserExamRecordSyncUrl("unit test -2"); + thirdAccountConfigVO.setInterfaceConfig(thirdInterfaceConfig); + thirdAccountConfigService.saveOrUpdateConfig(thirdAccountConfigVO); + //检验 + try { + thirdAccountConfigService.getInterfaceConfigByAccountId(account); + } catch (Exception e) { + fail("创建账号配置后查询报错"); + } + } + + @Test + void getInterfaceConfigByAccountId() { + } + + @Test + void pagedQuery() { + PageVO pageVO = thirdAccountConfigService.pagedQuery(new PageQueryVO()); + } + + @Test + void delete() { + } +}