From e30d3a62a87431f476410d47295d9a32add345bd Mon Sep 17 00:00:00 2001
From: JayWenStar <1599603313@qq.com>
Date: Sun, 26 Dec 2021 19:07:47 +0800
Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=9A=84:=20orm=E6=9B=B4=E6=94=B9myba?=
=?UTF-8?q?tis-plus?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config/jdbc-dev.yml | 18 +-
config/sonic-server-task-dev.yml | 2 +
sonic-server-common/pom.xml | 6 +
.../common/exception/BeanToolException.java | 24 +
.../exception/ServerErrorException.java | 22 +
.../common/exception/SonicException.java | 51 +-
.../java/com/sonic/common/tools/BeanTool.java | 141 ++++
.../sonic/common/tools/ReflectionTool.java | 92 +++
sonic-server-controller/pom.xml | 44 +-
.../controller/ControllerApplication.java | 15 +-
.../config/mybatis/ClearForeignKey.java | 64 ++
.../config/mybatis/MyBatisPlusConfig.java | 26 +
.../config/mybatis/MyMetaObjectHandler.java | 36 +
.../controller/AgentsController.java | 177 +++--
.../controller/DevicesController.java | 314 ++++----
.../controller/ElementsController.java | 167 ++--
.../controller/GlobalParamsController.java | 130 +--
.../controller/ModulesController.java | 136 ++--
.../controller/ProjectsController.java | 139 ++--
.../controller/PublicStepsController.java | 181 ++---
.../controller/ResultDetailController.java | 155 ++--
.../controller/ResultsController.java | 239 +++---
.../controller/StepsController.java | 223 +++---
.../controller/TestCasesController.java | 254 +++---
.../controller/TestSuitesController.java | 237 +++---
.../controller/UsersController.java | 148 ++--
.../controller/VersionsController.java | 129 +--
.../controller/dao/AgentsRepository.java | 16 -
.../controller/dao/DevicesRepository.java | 33 -
.../controller/dao/ElementsRepository.java | 20 -
.../dao/GlobalParamsRepository.java | 19 -
.../controller/dao/ModulesRepository.java | 18 -
.../controller/dao/ProjectsRepository.java | 7 -
.../controller/dao/PublicStepsRepository.java | 26 -
.../dao/ResultDetailRepository.java | 37 -
.../controller/dao/ResultsRepository.java | 38 -
.../sonic/controller/dao/StepsRepository.java | 33 -
.../controller/dao/TestCasesRepository.java | 22 -
.../controller/dao/TestSuitesRepository.java | 22 -
.../sonic/controller/dao/UsersRepository.java | 8 -
.../controller/dao/VersionsRepository.java | 20 -
.../sonic/controller/mapper/AgentsMapper.java | 15 +
.../controller/mapper/DevicesMapper.java | 34 +
.../controller/mapper/ElementsMapper.java | 27 +
.../controller/mapper/GlobalParamsMapper.java | 15 +
.../controller/mapper/ModulesMapper.java | 15 +
.../controller/mapper/ProjectsMapper.java | 15 +
.../controller/mapper/PublicStepsMapper.java | 31 +
.../mapper/PublicStepsStepsMapper.java | 15 +
.../controller/mapper/ResultDetailMapper.java | 46 ++
.../controller/mapper/ResultsMapper.java | 41 +
.../mapper/StepsElementsMapper.java | 15 +
.../sonic/controller/mapper/StepsMapper.java | 30 +
.../controller/mapper/TestCasesMapper.java | 23 +
.../mapper/TestSuitesDevicesMapper.java | 15 +
.../controller/mapper/TestSuitesMapper.java | 15 +
.../mapper/TestSuitesTestCasesMapper.java | 15 +
.../sonic/controller/mapper/UsersMapper.java | 15 +
.../controller/mapper/VersionsMapper.java | 15 +
.../com/sonic/controller/models/Agents.java | 120 ---
.../com/sonic/controller/models/Devices.java | 227 ------
.../com/sonic/controller/models/Elements.java | 108 ---
.../sonic/controller/models/GlobalParams.java | 72 --
.../com/sonic/controller/models/Modules.java | 60 --
.../com/sonic/controller/models/Projects.java | 123 ---
.../sonic/controller/models/PublicSteps.java | 85 --
.../sonic/controller/models/ResultDetail.java | 136 ----
.../com/sonic/controller/models/Results.java | 141 ----
.../com/sonic/controller/models/Steps.java | 170 ----
.../sonic/controller/models/TestCases.java | 154 ----
.../sonic/controller/models/TestSuites.java | 110 ---
.../com/sonic/controller/models/Users.java | 72 --
.../com/sonic/controller/models/Versions.java | 74 --
.../controller/models/base/CommentPage.java | 66 ++
.../controller/models/base/TypeConverter.java | 74 ++
.../controller/models/domain/Agents.java | 68 ++
.../controller/models/domain/Devices.java | 105 +++
.../controller/models/domain/Elements.java | 58 ++
.../models/domain/GlobalParams.java | 53 ++
.../controller/models/domain/Modules.java | 48 ++
.../controller/models/domain/Projects.java | 69 ++
.../controller/models/domain/PublicSteps.java | 53 ++
.../models/domain/PublicStepsSteps.java | 45 ++
.../models/domain/ResultDetail.java | 84 ++
.../controller/models/domain/Results.java | 82 ++
.../sonic/controller/models/domain/Steps.java | 75 ++
.../models/domain/StepsElements.java | 45 ++
.../controller/models/domain/TestCases.java | 76 ++
.../controller/models/domain/TestSuites.java | 57 ++
.../models/domain/TestSuitesDevices.java | 43 +
.../models/domain/TestSuitesTestCases.java | 45 ++
.../sonic/controller/models/domain/Users.java | 53 ++
.../controller/models/domain/Versions.java | 55 ++
.../controller/models/dto/AgentsDTO.java | 53 ++
.../controller/models/dto/DevicesDTO.java | 85 ++
.../controller/models/dto/ElementsDTO.java | 54 ++
.../models/dto/GlobalParamsDTO.java | 39 +
.../controller/models/dto/ModulesDTO.java | 35 +
.../controller/models/dto/ProjectsDTO.java | 51 ++
.../controller/models/dto/PublicStepsDTO.java | 43 +
.../models/dto/PublicStepsStepsDTO.java | 33 +
.../models/dto/ResultDetailDTO.java | 52 ++
.../controller/models/dto/ResultsDTO.java | 56 ++
.../sonic/controller/models/dto/StepsDTO.java | 69 ++
.../models/dto/StepsElementsDTO.java | 33 +
.../controller/models/dto/TestCasesDTO.java | 64 ++
.../controller/models/dto/TestSuitesDTO.java | 50 ++
.../models/dto/TestSuitesDevicesDTO.java | 33 +
.../models/dto/TestSuitesTestCasesDTO.java | 34 +
.../sonic/controller/models/dto/UsersDTO.java | 39 +
.../controller/models/dto/VersionsDTO.java | 43 +
.../models/params/DevicesSearchParams.java | 48 ++
.../controller/services/AgentsService.java | 57 +-
.../controller/services/DevicesService.java | 94 +--
.../controller/services/ElementsService.java | 36 +-
.../services/GlobalParamsService.java | 33 +-
.../controller/services/ModulesService.java | 32 +-
.../controller/services/ProjectsService.java | 42 +-
.../services/PublicStepsService.java | 54 +-
.../services/ResultDetailService.java | 57 +-
.../controller/services/ResultsService.java | 76 +-
.../controller/services/StepsService.java | 66 +-
.../controller/services/TestCasesService.java | 58 +-
.../services/TestSuitesService.java | 63 +-
.../controller/services/UsersService.java | 37 +-
.../controller/services/VersionsService.java | 44 +-
.../services/impl/AgentsServiceImpl.java | 244 +++---
.../services/impl/DevicesServiceImpl.java | 544 ++++++-------
.../services/impl/ElementsServiceImpl.java | 198 +++--
.../impl/GlobalParamsServiceImpl.java | 93 +--
.../services/impl/ModulesServiceImpl.java | 82 +-
.../services/impl/ProjectsServiceImpl.java | 151 ++--
.../services/impl/PublicStepsServiceImpl.java | 195 +++--
.../impl/ResultDetailServiceImpl.java | 237 +++---
.../services/impl/ResultsServiceImpl.java | 657 +++++++--------
.../services/impl/StepsServiceImpl.java | 290 ++++---
.../services/impl/TestCasesServiceImpl.java | 330 ++++----
.../services/impl/TestSuitesServiceImpl.java | 751 ++++++++++--------
.../services/impl/UsersServiceImpl.java | 188 ++---
.../services/impl/VersionsServiceImpl.java | 96 ++-
.../services/impl/base/SonicServiceImpl.java | 68 ++
.../sonic/controller/tools/RobotMsgTool.java | 1 -
.../src/main/resources/bootstrap.yml | 9 +
.../main/resources/mapping/AgentsMapper.xml | 5 +
.../main/resources/mapping/DevicesMapper.xml | 85 ++
.../main/resources/mapping/ElementsMapper.xml | 13 +
.../resources/mapping/GlobalParamsMapper.xml | 5 +
.../main/resources/mapping/ModulesMapper.xml | 5 +
.../main/resources/mapping/ProjectsMapper.xml | 5 +
.../resources/mapping/PublicStepsMapper.xml | 13 +
.../mapping/PublicStepsStepsMapper.xml | 5 +
.../resources/mapping/ResultDetailMapper.xml | 5 +
.../main/resources/mapping/ResultsMapper.xml | 5 +
.../resources/mapping/StepsElementsMapper.xml | 5 +
.../main/resources/mapping/StepsMapper.xml | 5 +
.../resources/mapping/TestCasesMapper.xml | 5 +
.../mapping/TestSuitesDevicesMapper.xml | 5 +
.../resources/mapping/TestSuitesMapper.xml | 5 +
.../mapping/TestSuitesTestCasesMapper.xml | 5 +
.../main/resources/mapping/UsersMapper.xml | 5 +
.../main/resources/mapping/VersionsMapper.xml | 5 +
sonic-server-task/pom.xml | 44 +-
.../java/com/sonic/task/TaskApplication.java | 13 +-
.../config/mybatis/MyBatisPlusConfig.java | 26 +
.../sonic/task/controller/JobsController.java | 175 ++--
.../com/sonic/task/dao/JobsRepository.java | 17 -
.../task/feign/ControllerFeignClient.java | 3 -
.../ControllerFeignClientFallBack.java | 3 -
.../com/sonic/task/mapper/JobsMapper.java | 14 +
.../main/java/com/sonic/task/models/Jobs.java | 94 ---
.../sonic/task/models/base/CommentPage.java | 66 ++
.../sonic/task/models/base/TypeConverter.java | 74 ++
.../com/sonic/task/models/domain/Jobs.java | 57 ++
.../com/sonic/task/models/dto/JobsDTO.java | 46 ++
.../com/sonic/task/quartz/QuartzHandler.java | 2 +-
.../java/com/sonic/task/quartz/QuartzJob.java | 5 +-
.../com/sonic/task/service/JobsService.java | 48 +-
.../task/service/impl/JobsServiceImpl.java | 220 ++---
.../service/impl/base/SonicServiceImpl.java | 68 ++
.../src/main/resources/bootstrap.yml | 9 +
sonic-server-task/src/main/resources/data.sql | 2 -
.../src/main/resources/mapping/JobsMapper.xml | 5 +
182 files changed, 7773 insertions(+), 5993 deletions(-)
create mode 100644 sonic-server-common/src/main/java/com/sonic/common/exception/BeanToolException.java
create mode 100644 sonic-server-common/src/main/java/com/sonic/common/exception/ServerErrorException.java
create mode 100644 sonic-server-common/src/main/java/com/sonic/common/tools/BeanTool.java
create mode 100644 sonic-server-common/src/main/java/com/sonic/common/tools/ReflectionTool.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/ClearForeignKey.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/MyBatisPlusConfig.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/MyMetaObjectHandler.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/AgentsRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/DevicesRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/ElementsRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/GlobalParamsRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/ModulesRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/ProjectsRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/PublicStepsRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/ResultDetailRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/ResultsRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/StepsRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/TestCasesRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/TestSuitesRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/UsersRepository.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/dao/VersionsRepository.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/AgentsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/DevicesMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/ElementsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/GlobalParamsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/ModulesMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/ProjectsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/PublicStepsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/PublicStepsStepsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/ResultDetailMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/ResultsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/StepsElementsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/StepsMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/TestCasesMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/TestSuitesDevicesMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/TestSuitesMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/TestSuitesTestCasesMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/UsersMapper.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/mapper/VersionsMapper.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Agents.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Devices.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Elements.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/GlobalParams.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Modules.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Projects.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/PublicSteps.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/ResultDetail.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Results.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Steps.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/TestCases.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/TestSuites.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Users.java
delete mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/Versions.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/base/CommentPage.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/base/TypeConverter.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Agents.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Devices.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Elements.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/GlobalParams.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Modules.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Projects.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/PublicSteps.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/PublicStepsSteps.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/ResultDetail.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Results.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Steps.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/StepsElements.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/TestCases.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/TestSuites.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/TestSuitesDevices.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/TestSuitesTestCases.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Users.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/domain/Versions.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/AgentsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/DevicesDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/ElementsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/GlobalParamsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/ModulesDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/ProjectsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/PublicStepsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/PublicStepsStepsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/ResultDetailDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/ResultsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/StepsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/StepsElementsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/TestCasesDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/TestSuitesDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/TestSuitesDevicesDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/TestSuitesTestCasesDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/UsersDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/dto/VersionsDTO.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/models/params/DevicesSearchParams.java
create mode 100644 sonic-server-controller/src/main/java/com/sonic/controller/services/impl/base/SonicServiceImpl.java
create mode 100644 sonic-server-controller/src/main/resources/mapping/AgentsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/DevicesMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/ElementsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/GlobalParamsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/ModulesMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/ProjectsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/PublicStepsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/PublicStepsStepsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/ResultDetailMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/ResultsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/StepsElementsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/StepsMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/TestCasesMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/TestSuitesDevicesMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/TestSuitesMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/TestSuitesTestCasesMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/UsersMapper.xml
create mode 100644 sonic-server-controller/src/main/resources/mapping/VersionsMapper.xml
create mode 100644 sonic-server-task/src/main/java/com/sonic/task/config/mybatis/MyBatisPlusConfig.java
delete mode 100644 sonic-server-task/src/main/java/com/sonic/task/dao/JobsRepository.java
create mode 100644 sonic-server-task/src/main/java/com/sonic/task/mapper/JobsMapper.java
delete mode 100644 sonic-server-task/src/main/java/com/sonic/task/models/Jobs.java
create mode 100644 sonic-server-task/src/main/java/com/sonic/task/models/base/CommentPage.java
create mode 100644 sonic-server-task/src/main/java/com/sonic/task/models/base/TypeConverter.java
create mode 100644 sonic-server-task/src/main/java/com/sonic/task/models/domain/Jobs.java
create mode 100644 sonic-server-task/src/main/java/com/sonic/task/models/dto/JobsDTO.java
create mode 100644 sonic-server-task/src/main/java/com/sonic/task/service/impl/base/SonicServiceImpl.java
create mode 100644 sonic-server-task/src/main/resources/mapping/JobsMapper.xml
diff --git a/config/jdbc-dev.yml b/config/jdbc-dev.yml
index d26d748c..a1cb81a2 100644
--- a/config/jdbc-dev.yml
+++ b/config/jdbc-dev.yml
@@ -4,8 +4,16 @@ spring:
url: jdbc:mysql://localhost:3306/sonic?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC&autoReconnect=true&serverTimezone=GMT%2b8
username: root
password: Sonic!@#123
- jpa:
- open-in-view: true
- hibernate:
- ddl-auto: update
- show-sql: true
\ No newline at end of file
+# mybatis-plus配置
+mybatis-plus:
+ mapper-locations: classpath:mapping/*.xml, classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml
+ global-config:
+ # 是否显示mybatis-plus图标
+ banner: false
+ configuration:
+ # 关闭二级缓存
+ cache-enabled: false
+ # 关闭一级缓存
+ localCacheScope: STATEMENT
+ # sql日志
+ # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
\ No newline at end of file
diff --git a/config/sonic-server-task-dev.yml b/config/sonic-server-task-dev.yml
index 40714e9f..6d8ad504 100644
--- a/config/sonic-server-task-dev.yml
+++ b/config/sonic-server-task-dev.yml
@@ -4,6 +4,8 @@ server:
spring:
datasource:
initialization-mode: always
+ schema:
+ - classpath:data.sql
quartz:
properties:
org:
diff --git a/sonic-server-common/pom.xml b/sonic-server-common/pom.xml
index 424e4223..92d6bcd1 100644
--- a/sonic-server-common/pom.xml
+++ b/sonic-server-common/pom.xml
@@ -47,6 +47,12 @@
java-jwt
3.10.3
+
+
+ org.projectlombok
+ lombok
+ 1.18.20
+
diff --git a/sonic-server-common/src/main/java/com/sonic/common/exception/BeanToolException.java b/sonic-server-common/src/main/java/com/sonic/common/exception/BeanToolException.java
new file mode 100644
index 00000000..3d51cbed
--- /dev/null
+++ b/sonic-server-common/src/main/java/com/sonic/common/exception/BeanToolException.java
@@ -0,0 +1,24 @@
+package com.sonic.common.exception;
+
+import org.springframework.http.HttpStatus;
+
+/**
+ * BeanUtils exception.
+ *
+ * @author JayWenStar
+ */
+public class BeanToolException extends SonicException {
+
+ public BeanToolException(String message) {
+ super(message);
+ }
+
+ public BeanToolException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ @Override
+ public HttpStatus getStatus() {
+ return HttpStatus.INTERNAL_SERVER_ERROR;
+ }
+}
diff --git a/sonic-server-common/src/main/java/com/sonic/common/exception/ServerErrorException.java b/sonic-server-common/src/main/java/com/sonic/common/exception/ServerErrorException.java
new file mode 100644
index 00000000..45c19f85
--- /dev/null
+++ b/sonic-server-common/src/main/java/com/sonic/common/exception/ServerErrorException.java
@@ -0,0 +1,22 @@
+package com.sonic.common.exception;
+
+import org.springframework.http.HttpStatus;
+
+/**
+ * @author JayWenStar
+ */
+public class ServerErrorException extends SonicException {
+
+ public ServerErrorException(String message) {
+ super(message);
+ }
+
+ public ServerErrorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ @Override
+ public HttpStatus getStatus() {
+ return HttpStatus.INTERNAL_SERVER_ERROR;
+ }
+}
diff --git a/sonic-server-common/src/main/java/com/sonic/common/exception/SonicException.java b/sonic-server-common/src/main/java/com/sonic/common/exception/SonicException.java
index e180c700..2a8a3bea 100644
--- a/sonic-server-common/src/main/java/com/sonic/common/exception/SonicException.java
+++ b/sonic-server-common/src/main/java/com/sonic/common/exception/SonicException.java
@@ -1,12 +1,39 @@
-package com.sonic.common.exception;
-
-/**
- * @author ZhouYiXun
- * @des
- * @date 2021/10/10 11:57
- */
-public class SonicException extends Exception {
- public SonicException(String message) {
- super(message);
- }
-}
+package com.sonic.common.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
+
+/**
+ * @author ZhouYiXun
+ * @des
+ * @date 2021/10/10 11:57
+ */
+public class SonicException extends RuntimeException {
+
+ private Object errorData;
+
+ public SonicException(String message) {
+ super(message);
+ }
+
+ public SonicException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ @NonNull
+ public HttpStatus getStatus() {
+ return HttpStatus.OK;
+ }
+
+ @Nullable
+ public Object getErrorData() {
+ return errorData;
+ }
+
+ @NonNull
+ public SonicException setErrorData(@Nullable Object errorData) {
+ this.errorData = errorData;
+ return this;
+ }
+}
diff --git a/sonic-server-common/src/main/java/com/sonic/common/tools/BeanTool.java b/sonic-server-common/src/main/java/com/sonic/common/tools/BeanTool.java
new file mode 100644
index 00000000..8729768e
--- /dev/null
+++ b/sonic-server-common/src/main/java/com/sonic/common/tools/BeanTool.java
@@ -0,0 +1,141 @@
+package com.sonic.common.tools;
+
+import com.sonic.common.exception.BeanToolException;
+import org.springframework.beans.BeanWrapperImpl;
+import org.springframework.beans.BeansException;
+import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
+import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
+
+import java.beans.PropertyDescriptor;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Bean utilities.
+ *
+ * @author JayWenStar
+ */
+public class BeanTool {
+
+ private BeanTool() {
+ }
+
+ /**
+ * Transforms from the source object. (copy same properties only)
+ *
+ * @param source source data
+ * @param targetClass target class must not be null
+ * @param target class type
+ * @return instance with specified type copying from source data; or null if source data is null
+ * @throws BeanToolException if newing target instance failed or copying failed
+ */
+ @Nullable
+ public static T transformFrom(@Nullable Object source, @NonNull Class targetClass) {
+ Assert.notNull(targetClass, "Target class must not be null");
+
+ if (source == null) {
+ return null;
+ }
+
+ // Init the instance
+ try {
+ // New instance for the target class
+ T targetInstance = targetClass.getDeclaredConstructor().newInstance();
+ // Copy properties
+ org.springframework.beans.BeanUtils.copyProperties(source, targetInstance, getNullPropertyNames(source));
+ // Return the target instance
+ return targetInstance;
+ } catch (Exception e) {
+ throw new BeanToolException("Failed to new " + targetClass.getName() + " instance or copy properties", e);
+ }
+ }
+
+ /**
+ * Transforms from source data collection in batch.
+ *
+ * @param sources source data collection
+ * @param targetClass target class must not be null
+ * @param target class type
+ * @return target collection transforming from source data collection.
+ * @throws BeanToolException if newing target instance failed or copying failed
+ */
+ @NonNull
+ public static List transformFromInBatch(Collection> sources, @NonNull Class targetClass) {
+ if (CollectionUtils.isEmpty(sources)) {
+ return Collections.emptyList();
+ }
+
+ // Transform in batch
+ return sources.stream()
+ .map(source -> transformFrom(source, targetClass))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Update properties (non null).
+ *
+ * @param source source data must not be null
+ * @param target target data must not be null
+ * @throws BeanToolException if copying failed
+ */
+ public static void updateProperties(@NonNull Object source, @NonNull Object target) {
+ Assert.notNull(source, "source object must not be null");
+ Assert.notNull(target, "target object must not be null");
+
+ // Set non null properties from source properties to target properties
+ try {
+ org.springframework.beans.BeanUtils.copyProperties(source, target, getNullPropertyNames(source));
+ } catch (BeansException e) {
+ throw new BeanToolException("Failed to copy properties", e);
+ }
+ }
+
+ /**
+ * Gets null names array of property.
+ *
+ * @param source object data must not be null
+ * @return null name array of property
+ */
+ @NonNull
+ private static String[] getNullPropertyNames(@NonNull Object source) {
+ return getNullPropertyNameSet(source).toArray(new String[0]);
+ }
+
+ /**
+ * Gets null names set of property.
+ *
+ * @param source object data must not be null
+ * @return null name set of property
+ */
+ @NonNull
+ private static Set getNullPropertyNameSet(@NonNull Object source) {
+
+ Assert.notNull(source, "source object must not be null");
+ BeanWrapperImpl beanWrapper = new BeanWrapperImpl(source);
+ PropertyDescriptor[] propertyDescriptors = beanWrapper.getPropertyDescriptors();
+
+ Set emptyNames = new HashSet<>();
+
+ for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
+ String propertyName = propertyDescriptor.getName();
+ Object propertyValue = beanWrapper.getPropertyValue(propertyName);
+
+ // if property value is equal to null, add it to empty name set
+ if (propertyValue == null) {
+ emptyNames.add(propertyName);
+ }
+ }
+
+ return emptyNames;
+ }
+
+ @NonNull
+ public static T toBean(Object source, Class clazz) {
+ Assert.notNull(source, "object must not be null");
+ Assert.notNull(clazz, "clazz must not be null");
+
+ return BeanTool.toBean(source, clazz);
+ }
+}
diff --git a/sonic-server-common/src/main/java/com/sonic/common/tools/ReflectionTool.java b/sonic-server-common/src/main/java/com/sonic/common/tools/ReflectionTool.java
new file mode 100644
index 00000000..f426dfd8
--- /dev/null
+++ b/sonic-server-common/src/main/java/com/sonic/common/tools/ReflectionTool.java
@@ -0,0 +1,92 @@
+package com.sonic.common.tools;
+
+import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
+import org.springframework.util.Assert;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+/**
+ * Reflection utilities.
+ *
+ * @author JayWenStar
+ */
+public class ReflectionTool {
+
+ private ReflectionTool() {
+ }
+
+ /**
+ * Gets parameterized type.
+ *
+ * @param superType super type must not be null (super class or super interface)
+ * @param genericTypes generic type array
+ * @return parameterized type of the interface or null if it is mismatch
+ */
+ @Nullable
+ public static ParameterizedType getParameterizedType(@NonNull Class> superType, Type... genericTypes) {
+ Assert.notNull(superType, "Interface or super type must not be null");
+
+ ParameterizedType currentType = null;
+
+ for (Type genericType : genericTypes) {
+ if (genericType instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) genericType;
+ if (parameterizedType.getRawType().getTypeName().equals(superType.getTypeName())) {
+ currentType = parameterizedType;
+ break;
+ }
+ }
+ }
+
+ return currentType;
+ }
+
+ /**
+ * Gets parameterized type.
+ *
+ * @param interfaceType interface type must not be null
+ * @param implementationClass implementation class of the interface must not be null
+ * @return parameterized type of the interface or null if it is mismatch
+ */
+ @Nullable
+ public static ParameterizedType getParameterizedType(@NonNull Class> interfaceType, Class> implementationClass) {
+ Assert.notNull(interfaceType, "Interface type must not be null");
+ Assert.isTrue(interfaceType.isInterface(), "The give type must be an interface");
+
+ if (implementationClass == null) {
+ // If the super class is Object parent then return null
+ return null;
+ }
+
+ // Get parameterized type
+ ParameterizedType currentType = getParameterizedType(interfaceType, implementationClass.getGenericInterfaces());
+
+ if (currentType != null) {
+ // return the current type
+ return currentType;
+ }
+
+ Class> superclass = implementationClass.getSuperclass();
+
+ return getParameterizedType(interfaceType, superclass);
+ }
+
+ /**
+ * Gets parameterized type by super class.
+ *
+ * @param superClassType super class type must not be null
+ * @param extensionClass extension class
+ * @return parameterized type or null
+ */
+ @Nullable
+ public static ParameterizedType getParameterizedTypeBySuperClass(@NonNull Class> superClassType, Class> extensionClass) {
+
+ if (extensionClass == null) {
+ return null;
+ }
+
+ return getParameterizedType(superClassType, extensionClass.getGenericSuperclass());
+ }
+}
diff --git a/sonic-server-controller/pom.xml b/sonic-server-controller/pom.xml
index 0abe67b9..263a81e7 100644
--- a/sonic-server-controller/pom.xml
+++ b/sonic-server-controller/pom.xml
@@ -35,17 +35,51 @@
org.springframework.boot
spring-boot-starter-undertow
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
mysql
mysql-connector-java
runtime
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.4.3.4
+
+
+
+ com.gitee.sunchenbin.mybatis.actable
+ mybatis-enhance-actable
+ 1.5.0.RELEASE
+
+
+ com.baomidou
+ mybatis-plus-annotation
+
+
+ org.springframework
+ spring-context
+
+
+ org.springframework
+ spring-tx
+
+
+ org.mybatis.scripting
+ mybatis-velocity
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
com.sonic
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/ControllerApplication.java b/sonic-server-controller/src/main/java/com/sonic/controller/ControllerApplication.java
index 46f2e6a9..ab83c884 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/ControllerApplication.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/ControllerApplication.java
@@ -1,18 +1,27 @@
package com.sonic.controller;
+import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
-import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
+import org.springframework.context.annotation.ComponentScan;
/**
* @author ZhouYiXun
* @des 控制中心启动类
* @date 2021/8/15 19:56
*/
-@SpringBootApplication(scanBasePackages = {"com/sonic/controller", "com/sonic/common"})
-@EnableJpaAuditing
+@SpringBootApplication
+@MapperScan(basePackages = {
+ "com.sonic.controller.mapper",
+ "com.gitee.sunchenbin.mybatis.actable.dao.*"
+})
+@ComponentScan(basePackages = {
+ "com.sonic.controller.*",
+ "com.gitee.sunchenbin.mybatis.actable.manager.*",
+ "com.sonic.common.*"
+})
@EnableFeignClients
@EnableEurekaClient
public class ControllerApplication {
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/ClearForeignKey.java b/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/ClearForeignKey.java
new file mode 100644
index 00000000..36a98b51
--- /dev/null
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/ClearForeignKey.java
@@ -0,0 +1,64 @@
+package com.sonic.controller.config.mybatis;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceSchemaCreatedEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 清除历史遗留的外键
+ * @author JayWenStar
+ * @date 2021/12/26 1:39 上午
+ */
+@Component
+@Slf4j
+public class ClearForeignKey implements ApplicationListener {
+
+ @Override
+ public void onApplicationEvent(DataSourceSchemaCreatedEvent event) {
+ DataSource dataSource = (DataSource) event.getSource();
+ String dataBase = "";
+ String findFKSql = "SELECT CONCAT('ALTER TABLE ', TABLE_NAME,' DROP FOREIGN KEY ',CONSTRAINT_NAME) as ddl " +
+ "FROM information_schema.TABLE_CONSTRAINTS c " +
+ "WHERE c.TABLE_SCHEMA='%s' AND c.CONSTRAINT_TYPE='FOREIGN KEY'";
+ List deleteSqlList = new ArrayList<>();
+ try (Connection connection = dataSource.getConnection()) {
+ try (Statement statement = connection.createStatement()) {
+
+ // 获取当前数据库名
+ ResultSet resultSet1 = statement.executeQuery("select DATABASE() db");
+ if (resultSet1.next()) {
+ dataBase = resultSet1.getString("db");
+ }
+
+ // 查询所有外键索引,并拼装成删除sql
+ ResultSet resultSet2 = statement.executeQuery(String.format(findFKSql, dataBase));
+ while (resultSet2.next()) {
+ deleteSqlList.add(resultSet2.getString("ddl"));
+ }
+
+ // 执行删除外键sql
+ for (String deleteSql : deleteSqlList) {
+ statement.executeUpdate(deleteSql);
+ }
+
+ // 删除 test_suites_devices 表的主键
+ try {
+ statement.executeUpdate("Alter table test_suites_devices Drop primary key");
+ } catch (Exception e) {
+ // 无视错误
+ }
+ }
+ } catch (Exception e) {
+ log.error("删除数据库外键失败");
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/MyBatisPlusConfig.java b/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/MyBatisPlusConfig.java
new file mode 100644
index 00000000..9f6e8fae
--- /dev/null
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/MyBatisPlusConfig.java
@@ -0,0 +1,26 @@
+package com.sonic.controller.config.mybatis;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+/**
+ * mybatis-plus 分页插件
+ * 参考:https://baomidou.com/pages/8f40ae/
+ *
+ * @author JayWenStar
+ */
+@Configuration
+@EnableTransactionManagement
+public class MyBatisPlusConfig {
+
+ @Bean
+ public MybatisPlusInterceptor mybatisPlusInterceptor() {
+ MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+ interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+ return interceptor;
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/MyMetaObjectHandler.java b/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/MyMetaObjectHandler.java
new file mode 100644
index 00000000..ca2a3be1
--- /dev/null
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/config/mybatis/MyMetaObjectHandler.java
@@ -0,0 +1,36 @@
+package com.sonic.controller.config.mybatis;
+
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * 自动填充
+ * 参考:https://baomidou.com/pages/4c6bcf/
+ * 后面在统一时间字段的规范
+ *
+ * @author JayWenStar
+ */
+@Slf4j
+@Component
+public class MyMetaObjectHandler implements MetaObjectHandler {
+
+ @Override
+ public void insertFill(MetaObject metaObject) {
+ log.debug("start insert fill ....");
+ this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
+ this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
+ this.strictInsertFill(metaObject, "time", Date.class, new Date());
+ this.strictInsertFill(metaObject, "editTime", Date.class, new Date());
+ }
+
+ @Override
+ public void updateFill(MetaObject metaObject) {
+ log.debug("start update fill ....");
+ this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
+ this.strictUpdateFill(metaObject, "editTime", Date.class, new Date());
+ }
+}
\ No newline at end of file
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/AgentsController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/AgentsController.java
index 93e99566..1452f99b 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/AgentsController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/AgentsController.java
@@ -1,85 +1,92 @@
-package com.sonic.controller.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Agents;
-import com.sonic.controller.services.AgentsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * @author ZhouYiXun
- * @des
- * @date 2021/8/28 21:49
- */
-@Api(tags = "Agent端相关")
-@RestController
-@RequestMapping("/agents")
-public class AgentsController {
- @Autowired
- private AgentsService agentsService;
-
- @WebAspect
- @ApiOperation(value = "查询所有Agent端", notes = "获取所有Agent端以及详细信息")
- @GetMapping("/list")
- public RespModel> findAgents() {
- return new RespModel(RespEnum.SEARCH_OK, agentsService.findAgents());
- }
-
- @WebAspect
- @PutMapping
- public RespModel save(@RequestBody JSONObject jsonObject) {
- agentsService.save(jsonObject);
- return new RespModel(RespEnum.HANDLE_OK);
- }
-
- @WebAspect
- @PutMapping("/updateName")
- public RespModel updateName(@RequestBody JSONObject jsonObject) {
- agentsService.updateName(jsonObject.getInteger("id"), jsonObject.getString("name"));
- return new RespModel(RespEnum.HANDLE_OK);
- }
-
- @WebAspect
- @GetMapping("/offLine")
- public RespModel offLine(@RequestParam(name = "id") int id) {
- agentsService.offLine(id);
- return new RespModel(RespEnum.HANDLE_OK);
- }
-
- @WebAspect
- @GetMapping("/auth")
- public RespModel auth(@RequestParam(name = "key") String key) {
- return new RespModel(RespEnum.SEARCH_OK, agentsService.auth(key));
- }
-
- @WebAspect
- @GetMapping("/findKeyById")
- public RespModel findKeyById(@RequestParam(name = "id") int id) {
- String key = agentsService.findKeyById(id);
- if (key != null) {
- return new RespModel(RespEnum.SEARCH_OK, key);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "查询Agent端信息", notes = "获取对应id的Agent信息")
- @GetMapping
- public RespModel findOne(@RequestParam(name = "id") int id) {
- Agents agents = agentsService.findById(id);
- if (agents != null) {
- return new RespModel(RespEnum.SEARCH_OK, agents);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
-}
+package com.sonic.controller.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.TypeConverter;
+import com.sonic.controller.models.domain.Agents;
+import com.sonic.controller.models.dto.AgentsDTO;
+import com.sonic.controller.services.AgentsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author ZhouYiXun
+ * @des
+ * @date 2021/8/28 21:49
+ */
+@Api(tags = "Agent端相关")
+@RestController
+@RequestMapping("/agents")
+public class AgentsController {
+
+ @Autowired
+ private AgentsService agentsService;
+
+ @WebAspect
+ @ApiOperation(value = "查询所有Agent端", notes = "获取所有Agent端以及详细信息")
+ @GetMapping("/list")
+ public RespModel> findAgents() {
+ return new RespModel<>(
+ RespEnum.SEARCH_OK,
+ agentsService.findAgents().stream().map(TypeConverter::convertTo).collect(Collectors.toList())
+ );
+ }
+
+ @WebAspect
+ @PutMapping
+ public RespModel save(@RequestBody JSONObject jsonObject) {
+ agentsService.saveAgents(jsonObject);
+ return new RespModel<>(RespEnum.HANDLE_OK);
+ }
+
+ @WebAspect
+ @PutMapping("/updateName")
+ public RespModel updateName(@RequestBody JSONObject jsonObject) {
+ agentsService.updateName(jsonObject.getInteger("id"), jsonObject.getString("name"));
+ return new RespModel<>(RespEnum.HANDLE_OK);
+ }
+
+ @WebAspect
+ @GetMapping("/offLine")
+ public RespModel offLine(@RequestParam(name = "id") int id) {
+ agentsService.offLine(id);
+ return new RespModel<>(RespEnum.HANDLE_OK);
+ }
+
+ @WebAspect
+ @GetMapping("/auth")
+ public RespModel auth(@RequestParam(name = "key") String key) {
+ return new RespModel<>(RespEnum.SEARCH_OK, agentsService.auth(key));
+ }
+
+ @WebAspect
+ @GetMapping("/findKeyById")
+ public RespModel findKeyById(@RequestParam(name = "id") int id) {
+ String key = agentsService.findKeyById(id);
+ if (key != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, key);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询Agent端信息", notes = "获取对应id的Agent信息")
+ @GetMapping
+ public RespModel> findOne(@RequestParam(name = "id") int id) {
+ Agents agents = agentsService.findById(id);
+ if (agents != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, agents);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/DevicesController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/DevicesController.java
index 0ac803ff..531e3104 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/DevicesController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/DevicesController.java
@@ -1,155 +1,159 @@
-package com.sonic.controller.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Devices;
-import com.sonic.controller.models.http.DeviceDetailChange;
-import com.sonic.controller.models.http.UpdateDeviceImg;
-import com.sonic.controller.services.DevicesService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-@Api(tags = "设备管理相关")
-@RestController
-@RequestMapping("/devices")
-public class DevicesController {
- @Autowired
- private DevicesService devicesService;
-
- @WebAspect
- @ApiOperation(value = "修改设备安装密码", notes = "修改对应设备id的安装密码")
- @PutMapping("/saveDetail")
- public RespModel saveDetail(@Validated @RequestBody DeviceDetailChange deviceDetailChange) {
- if (devicesService.saveDetail(deviceDetailChange)) {
- return new RespModel(RespEnum.UPDATE_OK);
- } else {
- return new RespModel(3000, "保存异常!");
- }
- }
-
- @PutMapping("/updateDevicesUser")
- public RespModel updateDevicesUser(@RequestBody JSONObject jsonObject) {
- devicesService.updateDevicesUser(jsonObject);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @PutMapping("/refreshDevicesTemper")
- public RespModel refreshDevicesTemper(@RequestBody JSONObject jsonObject) {
- devicesService.refreshDevicesTemper(jsonObject);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "获取温度概况", notes = "获取现有温度概况")
- @GetMapping("/findTemper")
- public RespModel findTemper() {
- return new RespModel(RespEnum.SEARCH_OK, devicesService.findTemper());
- }
-
- @WebAspect
- @ApiOperation(value = "修改设备图片", notes = "修改对应设备id的图片")
- @PutMapping("/updateImg")
- public RespModel updateImg(@Validated @RequestBody UpdateDeviceImg updateDeviceImg) {
- devicesService.updateImg(updateDeviceImg);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查询所有设备", notes = "查找筛选条件下的所有设备,带[]的参数可以重复传")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "androidVersion[]", value = "安卓版本", dataTypeClass = String.class),
- @ApiImplicitParam(name = "iOSVersion[]", value = "iOS版本", dataTypeClass = String.class),
- @ApiImplicitParam(name = "manufacturer[]", value = "制造商", dataTypeClass = String.class),
- @ApiImplicitParam(name = "cpu[]", value = "cpu类型", dataTypeClass = String.class),
- @ApiImplicitParam(name = "size[]", value = "屏幕尺寸", dataTypeClass = String.class),
- @ApiImplicitParam(name = "agentId[]", value = "所在Agent", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "status[]", value = "当前状态", dataTypeClass = String.class),
- @ApiImplicitParam(name = "deviceInfo", value = "设备型号或udId", dataTypeClass = String.class),
- @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
- })
- @GetMapping("/list")
- public RespModel> findAll(@RequestParam(name = "androidVersion[]", required = false) List androidVersion,
- @RequestParam(name = "iOSVersion[]", required = false) List iOSVersion,
- @RequestParam(name = "manufacturer[]", required = false) List manufacturer,
- @RequestParam(name = "cpu[]", required = false) List cpu,
- @RequestParam(name = "size[]", required = false) List size,
- @RequestParam(name = "agentId[]", required = false) List agentId,
- @RequestParam(name = "status[]", required = false) List status,
- @RequestParam(name = "deviceInfo", required = false) String deviceInfo,
- @RequestParam(name = "page") int page,
- @RequestParam(name = "pageSize") int pageSize) {
- Pageable pageable = PageRequest.of(page - 1, pageSize);
- return new RespModel(RespEnum.SEARCH_OK,
- devicesService.findAll(iOSVersion, androidVersion, manufacturer, cpu, size,
- agentId, status, deviceInfo, pageable));
- }
-
- @WebAspect
- @ApiOperation(value = "查询所有设备", notes = "不分页的设备列表")
- @ApiImplicitParam(name = "platform", value = "平台", dataTypeClass = Integer.class)
- @GetMapping("/listAll")
- public RespModel> listAll(@RequestParam(name = "platform") int platform) {
- return new RespModel(RespEnum.SEARCH_OK,
- devicesService.findAll(platform));
- }
-
- @WebAspect
- @ApiOperation(value = "批量查询设备", notes = "查找id列表的设备信息,可以传多个ids[]")
- @ApiImplicitParam(name = "ids[]", value = "id列表", dataTypeClass = Integer.class)
- @GetMapping("/findByIdIn")
- public RespModel> findByIdIn(@RequestParam(name = "ids[]") List ids) {
- return new RespModel(RespEnum.SEARCH_OK,
- devicesService.findByIdIn(ids));
- }
-
- @WebAspect
- @ApiOperation(value = "获取查询条件", notes = "获取现有筛选条件(所有设备有的条件)")
- @GetMapping("/getFilterOption")
- public RespModel getFilterOption() {
- return new RespModel(RespEnum.SEARCH_OK, devicesService.getFilterOption());
- }
-
-// @WebAspect
-// @ApiOperation(value = "查询单个设备信息", notes = "获取单个设备的详细信息")
-// @ApiImplicitParam(name = "udId", value = "设备序列号", dataTypeClass = String.class)
-// @GetMapping
-// public RespModel findByUdId(@RequestParam(name = "udId") String udId) {
-// Devices devices = devicesService.findByUdId(udId);
-// if (devices != null) {
-// return new RespModel(RespEnum.SEARCH_OK, devices);
-// } else {
-// return new RespModel(3000, "设备不存在!");
-// }
-// }
-
- @WebAspect
- @PutMapping("/deviceStatus")
- public RespModel deviceStatus(@RequestBody JSONObject jsonObject) {
- devicesService.deviceStatus(jsonObject);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- Devices devices = devicesService.findById(id);
- if (devices != null) {
- return new RespModel(RespEnum.SEARCH_OK, devices);
- } else {
- return new RespModel(3000, "设备不存在!");
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.CommentPage;
+import com.sonic.controller.models.domain.Devices;
+import com.sonic.controller.models.http.DeviceDetailChange;
+import com.sonic.controller.models.http.UpdateDeviceImg;
+import com.sonic.controller.services.DevicesService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Api(tags = "设备管理相关")
+@RestController
+@RequestMapping("/devices")
+public class DevicesController {
+
+ @Autowired
+ private DevicesService devicesService;
+
+ @WebAspect
+ @ApiOperation(value = "修改设备安装密码", notes = "修改对应设备id的安装密码")
+ @PutMapping("/saveDetail")
+ public RespModel saveDetail(@Validated @RequestBody DeviceDetailChange deviceDetailChange) {
+ if (devicesService.saveDetail(deviceDetailChange)) {
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ } else {
+ return new RespModel<>(3000, "保存异常!");
+ }
+ }
+
+ @PutMapping("/updateDevicesUser")
+ public RespModel updateDevicesUser(@RequestBody JSONObject jsonObject) {
+ devicesService.updateDevicesUser(jsonObject);
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @PutMapping("/refreshDevicesTemper")
+ public RespModel refreshDevicesTemper(@RequestBody JSONObject jsonObject) {
+ devicesService.refreshDevicesTemper(jsonObject);
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "修改设备图片", notes = "修改对应设备id的图片")
+ @PutMapping("/updateImg")
+ public RespModel updateImg(@Validated @RequestBody UpdateDeviceImg updateDeviceImg) {
+ devicesService.updateImg(updateDeviceImg);
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询所有设备", notes = "查找筛选条件下的所有设备,带[]的参数可以重复传")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "androidVersion[]", value = "安卓版本", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "iOSVersion[]", value = "iOS版本", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "manufacturer[]", value = "制造商", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "cpu[]", value = "cpu类型", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "size[]", value = "屏幕尺寸", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "agentId[]", value = "所在Agent", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "status[]", value = "当前状态", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "deviceInfo", value = "设备型号或udId", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
+ })
+ @GetMapping("/list")
+ public RespModel> findAll(@RequestParam(name = "androidVersion[]", required = false) List androidVersion,
+ @RequestParam(name = "iOSVersion[]", required = false) List iOSVersion,
+ @RequestParam(name = "manufacturer[]", required = false) List manufacturer,
+ @RequestParam(name = "cpu[]", required = false) List cpu,
+ @RequestParam(name = "size[]", required = false) List size,
+ @RequestParam(name = "agentId[]", required = false) List agentId,
+ @RequestParam(name = "status[]", required = false) List status,
+ @RequestParam(name = "deviceInfo", required = false) String deviceInfo,
+ @RequestParam(name = "page") int page,
+ @RequestParam(name = "pageSize") int pageSize) {
+ Page pageable = new Page<>(page, pageSize);
+ return new RespModel<>(
+ RespEnum.SEARCH_OK,
+ CommentPage.convertFrom(
+ devicesService.findAll(iOSVersion, androidVersion, manufacturer, cpu, size,
+ agentId, status, deviceInfo, pageable)
+ )
+ );
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询所有设备", notes = "不分页的设备列表")
+ @ApiImplicitParam(name = "platform", value = "平台", dataTypeClass = Integer.class)
+ @GetMapping("/listAll")
+ public RespModel> listAll(@RequestParam(name = "platform") int platform) {
+ return new RespModel<>(RespEnum.SEARCH_OK,
+ devicesService.findAll(platform));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "批量查询设备", notes = "查找id列表的设备信息,可以传多个ids[]")
+ @ApiImplicitParam(name = "ids[]", value = "id列表", dataTypeClass = Integer.class)
+ @GetMapping("/findByIdIn")
+ public RespModel> findByIdIn(@RequestParam(name = "ids[]") List ids) {
+ return new RespModel<>(RespEnum.SEARCH_OK,
+ devicesService.findByIdIn(ids));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "获取查询条件", notes = "获取现有筛选条件(所有设备有的条件)")
+ @GetMapping("/getFilterOption")
+ public RespModel getFilterOption() {
+ return new RespModel<>(RespEnum.SEARCH_OK, devicesService.getFilterOption());
+ }
+
+// @WebAspect
+// @ApiOperation(value = "查询单个设备信息", notes = "获取单个设备的详细信息")
+// @ApiImplicitParam(name = "udId", value = "设备序列号", dataTypeClass = String.class)
+// @GetMapping
+// public RespModel findByUdId(@RequestParam(name = "udId") String udId) {
+// Devices devices = devicesService.findByUdId(udId);
+// if (devices != null) {
+// return new RespModel(RespEnum.SEARCH_OK, devices);
+// } else {
+// return new RespModel(3000, "设备不存在!");
+// }
+// }
+
+ @WebAspect
+ @PutMapping("/deviceStatus")
+ public RespModel deviceStatus(@RequestBody JSONObject jsonObject) {
+ devicesService.deviceStatus(jsonObject);
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @GetMapping
+ public RespModel findById(@RequestParam(name = "id") int id) {
+ Devices devices = devicesService.findById(id);
+ if (devices != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, devices);
+ } else {
+ return new RespModel<>(3000, "设备不存在!");
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "获取温度概况", notes = "获取现有温度概况")
+ @GetMapping("/findTemper")
+ public RespModel findTemper() {
+ return new RespModel<>(RespEnum.SEARCH_OK, devicesService.findTemper());
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ElementsController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ElementsController.java
index d585d6a9..41d8f118 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ElementsController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ElementsController.java
@@ -1,81 +1,86 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Elements;
-import com.sonic.controller.services.ElementsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-@Api(tags = "控件元素管理相关")
-@RestController
-@RequestMapping("/elements")
-public class ElementsController {
- @Autowired
- private ElementsService elementsService;
-
- @WebAspect
- @ApiOperation(value = "查找控件元素列表1", notes = "查找对应项目id的控件元素列表")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "eleTypes[]", value = "类型(多个)", dataTypeClass = String.class),
- @ApiImplicitParam(name = "name", value = "控件名称", dataTypeClass = String.class),
- @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = String.class),
- @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
- })
- @GetMapping("/list")
- public RespModel> findAll(@RequestParam(name = "projectId") int projectId,
- @RequestParam(name = "type", required = false) String type,
- @RequestParam(name = "eleTypes[]", required = false) List eleTypes,
- @RequestParam(name = "name", required = false) String name,
- @RequestParam(name = "page") int page,
- @RequestParam(name = "pageSize") int pageSize) {
- Pageable pageable = PageRequest.of(page - 1, pageSize);
- return new RespModel(RespEnum.SEARCH_OK, elementsService.findAll(projectId, type, eleTypes, name, pageable));
- }
-
- @WebAspect
- @ApiOperation(value = "查找控件元素详情", notes = "查找对应id的对应控件元素详细信息")
- @ApiImplicitParam(name = "id", value = "控件元素id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- Elements elements = elementsService.findById(id);
- if (elements != null) {
- return new RespModel(RespEnum.SEARCH_OK, elements);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "删除控件元素", notes = "删除对应id的控件元素,当控件元素存在于用例或id不存在时,删除失败")
- @ApiImplicitParam(name = "id", value = "元素id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- return elementsService.delete(id);
- }
-
- @WebAspect
- @ApiOperation(value = "更新控件元素", notes = "新增或更新控件元素信息,id为0时新增,否则为更新对应id的信息")
- @PutMapping
- public RespModel save(@Validated @RequestBody Elements elements) {
- if (elementsService.save(elements)) {
- return new RespModel(RespEnum.UPDATE_OK);
- } else {
- return new RespModel(-1, "操作失败!请检查控件元素值是否过长!");
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.CommentPage;
+import com.sonic.controller.models.domain.Elements;
+import com.sonic.controller.models.dto.ElementsDTO;
+import com.sonic.controller.services.ElementsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Api(tags = "控件元素管理相关")
+@RestController
+@RequestMapping("/elements")
+public class ElementsController {
+
+ @Autowired
+ private ElementsService elementsService;
+
+ @WebAspect
+ @ApiOperation(value = "查找控件元素列表1", notes = "查找对应项目id的控件元素列表")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "eleTypes[]", value = "类型(多个)", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "name", value = "控件名称", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
+ })
+ @GetMapping("/list")
+ public RespModel> findAll(@RequestParam(name = "projectId") int projectId,
+ @RequestParam(name = "type", required = false) String type,
+ @RequestParam(name = "eleTypes[]", required = false) List eleTypes,
+ @RequestParam(name = "name", required = false) String name,
+ @RequestParam(name = "page") int page,
+ @RequestParam(name = "pageSize") int pageSize) {
+ Page pageable = new Page<>(page, pageSize);
+ return new RespModel<>(
+ RespEnum.SEARCH_OK,
+ CommentPage.convertFrom(
+ elementsService.findAll(projectId, type, eleTypes, name, pageable)
+ )
+ );
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查找控件元素详情", notes = "查找对应id的对应控件元素详细信息")
+ @ApiImplicitParam(name = "id", value = "控件元素id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel findById(@RequestParam(name = "id") int id) {
+ Elements elements = elementsService.findById(id);
+ if (elements != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, elements);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除控件元素", notes = "删除对应id的控件元素,当控件元素存在于用例或id不存在时,删除失败")
+ @ApiImplicitParam(name = "id", value = "元素id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ return elementsService.delete(id);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "更新控件元素", notes = "新增或更新控件元素信息,id为0时新增,否则为更新对应id的信息")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody ElementsDTO elementsDTO) {
+ if (elementsService.save(elementsDTO.convertTo())) {
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ } else {
+ return new RespModel<>(-1, "操作失败!请检查控件元素值是否过长!");
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/GlobalParamsController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/GlobalParamsController.java
index 69c9a601..704cc5c4 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/GlobalParamsController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/GlobalParamsController.java
@@ -1,64 +1,66 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.GlobalParams;
-import com.sonic.controller.services.GlobalParamsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-@Api(tags = "公共参数相关")
-@RestController
-@RequestMapping("/globalParams")
-public class GlobalParamsController {
- @Autowired
- private GlobalParamsService globalParamsService;
-
- @WebAspect
- @ApiOperation(value = "更新公共参数", notes = "新增或更新对应的公共参数")
- @PutMapping
- public RespModel save(@Validated @RequestBody GlobalParams globalParams) {
- globalParamsService.save(globalParams);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查找公共参数", notes = "查找对应项目id的公共参数列表")
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
- @GetMapping("/list")
- public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) {
- return new RespModel(RespEnum.SEARCH_OK, globalParamsService.findAll(projectId));
- }
-
- @WebAspect
- @ApiOperation(value = "删除公共参数", notes = "删除对应id的公共参数")
- @ApiImplicitParam(name = "id", value = "id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- if (globalParamsService.delete(id)) {
- return new RespModel(RespEnum.DELETE_OK);
- } else {
- return new RespModel(RespEnum.DELETE_ERROR);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "查看公共参数信息", notes = "查看对应id的公共参数")
- @ApiImplicitParam(name = "id", value = "id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- GlobalParams globalParams = globalParamsService.findById(id);
- if (globalParams != null) {
- return new RespModel(RespEnum.SEARCH_OK, globalParams);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.domain.GlobalParams;
+import com.sonic.controller.models.dto.GlobalParamsDTO;
+import com.sonic.controller.services.GlobalParamsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Api(tags = "公共参数相关")
+@RestController
+@RequestMapping("/globalParams")
+public class GlobalParamsController {
+
+ @Autowired
+ private GlobalParamsService globalParamsService;
+
+ @WebAspect
+ @ApiOperation(value = "更新公共参数", notes = "新增或更新对应的公共参数")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody GlobalParamsDTO globalParamsDTO) {
+ globalParamsService.save(globalParamsDTO.convertTo());
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查找公共参数", notes = "查找对应项目id的公共参数列表")
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
+ @GetMapping("/list")
+ public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) {
+ return new RespModel<>(RespEnum.SEARCH_OK, globalParamsService.findAll(projectId));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除公共参数", notes = "删除对应id的公共参数")
+ @ApiImplicitParam(name = "id", value = "id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ if (globalParamsService.delete(id)) {
+ return new RespModel<>(RespEnum.DELETE_OK);
+ } else {
+ return new RespModel<>(RespEnum.DELETE_ERROR);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查看公共参数信息", notes = "查看对应id的公共参数")
+ @ApiImplicitParam(name = "id", value = "id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel findById(@RequestParam(name = "id") int id) {
+ GlobalParams globalParams = globalParamsService.findById(id);
+ if (globalParams != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, globalParams);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ModulesController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ModulesController.java
index bbc073f4..8142fefa 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ModulesController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ModulesController.java
@@ -1,64 +1,72 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Modules;
-import com.sonic.controller.services.ModulesService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-@Api(tags = "模块管理相关")
-@RestController
-@RequestMapping("/modules")
-public class ModulesController {
- @Autowired
- private ModulesService modulesService;
-
- @WebAspect
- @ApiOperation(value = "更新模块信息", notes = "新增或更新对应的模块信息")
- @PutMapping
- public RespModel save(@Validated @RequestBody Modules modules) {
- modulesService.save(modules);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查找模块列表", notes = "查找对应项目id的模块列表")
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
- @GetMapping("/list")
- public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) {
- return new RespModel(RespEnum.SEARCH_OK, modulesService.findByProjectId(projectId));
- }
-
- @WebAspect
- @ApiOperation(value = "删除模块", notes = "删除对应id的模块")
- @ApiImplicitParam(name = "id", value = "模块id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- if (modulesService.delete(id)) {
- return new RespModel(RespEnum.DELETE_OK);
- } else {
- return new RespModel(RespEnum.DELETE_ERROR);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "查看模块信息", notes = "查看对应id的模块信息")
- @ApiImplicitParam(name = "id", value = "模块id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- Modules modules = modulesService.findById(id);
- if (modules != null) {
- return new RespModel(RespEnum.SEARCH_OK, modules);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.TypeConverter;
+import com.sonic.controller.models.domain.Modules;
+import com.sonic.controller.models.dto.ModulesDTO;
+import com.sonic.controller.services.ModulesService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Api(tags = "模块管理相关")
+@RestController
+@RequestMapping("/modules")
+public class ModulesController {
+
+ @Autowired
+ private ModulesService modulesService;
+
+ @WebAspect
+ @ApiOperation(value = "更新模块信息", notes = "新增或更新对应的模块信息")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody ModulesDTO modules) {
+ modulesService.save(modules.convertTo());
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查找模块列表", notes = "查找对应项目id的模块列表")
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
+ @GetMapping("/list")
+ public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) {
+ return new RespModel<>(
+ RespEnum.SEARCH_OK,
+ modulesService.findByProjectId(projectId)
+ .stream().map(TypeConverter::convertTo).collect(Collectors.toList())
+ );
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除模块", notes = "删除对应id的模块")
+ @ApiImplicitParam(name = "id", value = "模块id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ if (modulesService.delete(id)) {
+ return new RespModel<>(RespEnum.DELETE_OK);
+ } else {
+ return new RespModel<>(RespEnum.DELETE_ERROR);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查看模块信息", notes = "查看对应id的模块信息")
+ @ApiImplicitParam(name = "id", value = "模块id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel findById(@RequestParam(name = "id") int id) {
+ Modules modules = modulesService.findById(id);
+ if (modules != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, modules.convertTo());
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ProjectsController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ProjectsController.java
index 91a812bb..f735d72f 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ProjectsController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ProjectsController.java
@@ -1,66 +1,73 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.exception.SonicException;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Projects;
-import com.sonic.controller.services.ProjectsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * @author ZhouYiXun
- * @des
- * @date 2021/9/9 22:46
- */
-@Api(tags = "项目管理相关")
-@RestController
-@RequestMapping("/projects")
-public class ProjectsController {
- @Autowired
- private ProjectsService projectsService;
-
- @WebAspect
- @ApiOperation(value = "更新项目信息", notes = "新增或更新项目信息")
- @PutMapping
- public RespModel save(@Validated @RequestBody Projects projects) {
- projectsService.save(projects);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查找所有项目", notes = "查找所有项目列表")
- @GetMapping("/list")
- public RespModel> findAll() {
- return new RespModel(RespEnum.SEARCH_OK, projectsService.findAll());
- }
-
- @WebAspect
- @ApiOperation(value = "查询项目信息", notes = "查找对应id下的详细信息")
- @ApiImplicitParam(name = "id", value = "项目id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- Projects projects = projectsService.findById(id);
- if (projects != null) {
- return new RespModel(RespEnum.SEARCH_OK, projects);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "删除", notes = "删除对应id下的详细信息")
- @ApiImplicitParam(name = "id", value = "项目id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) throws SonicException {
- projectsService.delete(id);
- return new RespModel(RespEnum.DELETE_OK);
- }
-}
+package com.sonic.controller.controller;
+
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.exception.SonicException;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.TypeConverter;
+import com.sonic.controller.models.domain.Projects;
+import com.sonic.controller.models.dto.ProjectsDTO;
+import com.sonic.controller.services.ProjectsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author ZhouYiXun
+ * @des
+ * @date 2021/9/9 22:46
+ */
+@Api(tags = "项目管理相关")
+@RestController
+@RequestMapping("/projects")
+public class ProjectsController {
+
+ @Autowired
+ private ProjectsService projectsService;
+
+ @WebAspect
+ @ApiOperation(value = "更新项目信息", notes = "新增或更新项目信息")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody ProjectsDTO projects) {
+ projectsService.save(projects.convertTo());
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查找所有项目", notes = "查找所有项目列表")
+ @GetMapping("/list")
+ public RespModel> findAll() {
+ return new RespModel<>(
+ RespEnum.SEARCH_OK,
+ projectsService.findAll().stream().map(TypeConverter::convertTo).collect(Collectors.toList())
+ );
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询项目信息", notes = "查找对应id下的详细信息")
+ @ApiImplicitParam(name = "id", value = "项目id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel> findById(@RequestParam(name = "id") int id) {
+ Projects projects = projectsService.findById(id);
+ if (projects != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, projects.convertTo());
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除", notes = "删除对应id下的详细信息")
+ @ApiImplicitParam(name = "id", value = "项目id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) throws SonicException {
+ projectsService.delete(id);
+ return new RespModel<>(RespEnum.DELETE_OK);
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/PublicStepsController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/PublicStepsController.java
index 0031a1ed..ee9a61ab 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/PublicStepsController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/PublicStepsController.java
@@ -1,89 +1,92 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.PublicSteps;
-import com.sonic.controller.services.PublicStepsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-import java.util.Map;
-
-@Api(tags = "公共步骤相关")
-@RestController
-@RequestMapping("/publicSteps")
-public class PublicStepsController {
- @Autowired
- private PublicStepsService publicStepsService;
-
- @WebAspect
- @ApiOperation(value = "查询公共步骤列表1", notes = "查找对应项目id下的公共步骤列表(分页)")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
- })
- @GetMapping("/list")
- public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId,
- @RequestParam(name = "page") int page,
- @RequestParam(name = "pageSize") int pageSize) {
- Pageable pageable = PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC, "id"));
- return new RespModel(RespEnum.SEARCH_OK, publicStepsService.findByProjectId(projectId, pageable));
- }
-
- @WebAspect
- @ApiOperation(value = "查询公共步骤列表2", notes = "查找对应项目id下的公共步骤列表(不分页,只查询id和name)")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "platform", value = "平台", dataTypeClass = Integer.class),
- })
- @GetMapping("/findNameByProjectId")
- public RespModel>> findByProjectId(@RequestParam(name = "projectId") int projectId,
- @RequestParam(name = "platform") int platform) {
- return new RespModel(RespEnum.SEARCH_OK, publicStepsService.findByProjectIdAndPlatform(projectId, platform));
- }
-
- @WebAspect
- @ApiOperation(value = "更新公共步骤信息", notes = "新增或更新公共步骤信息")
- @PutMapping
- public RespModel save(@Validated @RequestBody PublicSteps publicSteps) {
- publicStepsService.save(publicSteps);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "删除公共步骤", notes = "删除对应公共步骤id,包含的操作步骤不会被删除")
- @ApiImplicitParam(name = "id", value = "公共步骤id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- if (publicStepsService.delete(id)) {
- return new RespModel(RespEnum.DELETE_OK);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "查找公共步骤信息", notes = "查询对应公共步骤的详细信息")
- @ApiImplicitParam(name = "id", value = "公共步骤id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- PublicSteps publicSteps = publicStepsService.findById(id);
- if (publicSteps != null) {
- return new RespModel(RespEnum.SEARCH_OK, publicSteps);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.CommentPage;
+import com.sonic.controller.models.domain.PublicSteps;
+import com.sonic.controller.models.dto.PublicStepsDTO;
+import com.sonic.controller.services.PublicStepsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+@Api(tags = "公共步骤相关")
+@RestController
+@RequestMapping("/publicSteps")
+public class PublicStepsController {
+
+ @Autowired
+ private PublicStepsService publicStepsService;
+
+ @WebAspect
+ @ApiOperation(value = "查询公共步骤列表1", notes = "查找对应项目id下的公共步骤列表(分页)")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
+ })
+ @GetMapping("/list")
+ public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId,
+ @RequestParam(name = "page") int page,
+ @RequestParam(name = "pageSize") int pageSize) {
+ Page pageable = new Page<>(page, pageSize);
+ return new RespModel<>(
+ RespEnum.SEARCH_OK,
+ publicStepsService.findByProjectId(projectId, pageable)
+ );
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询公共步骤列表2", notes = "查找对应项目id下的公共步骤列表(不分页,只查询id和name)")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "platform", value = "平台", dataTypeClass = Integer.class),
+ })
+ @GetMapping("/findNameByProjectId")
+ public RespModel>> findByProjectId(@RequestParam(name = "projectId") int projectId,
+ @RequestParam(name = "platform") int platform) {
+ return new RespModel<>(RespEnum.SEARCH_OK, publicStepsService.findByProjectIdAndPlatform(projectId, platform));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "更新公共步骤信息", notes = "新增或更新公共步骤信息")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody PublicStepsDTO publicStepsDTO) {
+ publicStepsService.savePublicSteps(publicStepsDTO);
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除公共步骤", notes = "删除对应公共步骤id,包含的操作步骤不会被删除")
+ @ApiImplicitParam(name = "id", value = "公共步骤id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ if (publicStepsService.delete(id)) {
+ return new RespModel<>(RespEnum.DELETE_OK);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查找公共步骤信息", notes = "查询对应公共步骤的详细信息")
+ @ApiImplicitParam(name = "id", value = "公共步骤id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel> findById(@RequestParam(name = "id") int id) {
+ PublicStepsDTO publicStepsDTO = publicStepsService.findById(id);
+ if (publicStepsDTO != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, publicStepsDTO);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ResultDetailController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ResultDetailController.java
index b7e6e283..f6d0528d 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ResultDetailController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ResultDetailController.java
@@ -1,77 +1,78 @@
-package com.sonic.controller.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.ResultDetail;
-import com.sonic.controller.services.ResultDetailService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * @author ZhouYiXun
- * @des
- * @date 2021/8/29 16:59
- */
-@Api(tags = "测试结果详情相关")
-@RestController
-@RequestMapping("/resultDetail")
-public class ResultDetailController {
- @Autowired
- private ResultDetailService resultDetailService;
-
- @WebAspect
- @PostMapping
- public RespModel save(@RequestBody JSONObject jsonObject) {
- resultDetailService.saveByTransport(jsonObject);
- return new RespModel(RespEnum.HANDLE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查找测试结果详情", notes = "查找对应测试结果详情")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "caseId", value = "测试用例id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "resultId", value = "测试结果id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "deviceId", value = "设备id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = String.class),
- @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class)
- })
- @GetMapping("/list")
- public RespModel> findAll(@RequestParam(name = "caseId") int caseId,
- @RequestParam(name = "resultId") int resultId,
- @RequestParam(name = "deviceId") int deviceId,
- @RequestParam(name = "type") String type,
- @RequestParam(name = "page") int page) {
- Pageable pageable = PageRequest.of(page - 1, 20);
- return new RespModel(RespEnum.SEARCH_OK,
- resultDetailService.findAll(resultId, caseId, type, deviceId, pageable));
- }
-
- @WebAspect
- @ApiOperation(value = "查找测试结果详情2", notes = "查找对应测试结果详情")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "caseId", value = "测试用例id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "resultId", value = "测试结果id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "deviceId", value = "设备id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = String.class),
- })
- @GetMapping("/listAll")
- public RespModel> findAll(@RequestParam(name = "caseId") int caseId,
- @RequestParam(name = "resultId") int resultId,
- @RequestParam(name = "deviceId") int deviceId,
- @RequestParam(name = "type") String type) {
- return new RespModel(RespEnum.SEARCH_OK,
- resultDetailService.findAll(resultId, caseId, type, deviceId));
- }
-}
+package com.sonic.controller.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.CommentPage;
+import com.sonic.controller.models.domain.ResultDetail;
+import com.sonic.controller.services.ResultDetailService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author ZhouYiXun
+ * @des
+ * @date 2021/8/29 16:59
+ */
+@Api(tags = "测试结果详情相关")
+@RestController
+@RequestMapping("/resultDetail")
+public class ResultDetailController {
+
+ @Autowired
+ private ResultDetailService resultDetailService;
+
+ @WebAspect
+ @PostMapping
+ public RespModel save(@RequestBody JSONObject jsonObject) {
+ resultDetailService.saveByTransport(jsonObject);
+ return new RespModel<>(RespEnum.HANDLE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查找测试结果详情", notes = "查找对应测试结果详情")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "caseId", value = "测试用例id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "resultId", value = "测试结果id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "deviceId", value = "设备id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class)
+ })
+ @GetMapping("/list")
+ public RespModel> findAll(@RequestParam(name = "caseId") int caseId,
+ @RequestParam(name = "resultId") int resultId,
+ @RequestParam(name = "deviceId") int deviceId,
+ @RequestParam(name = "type") String type,
+ @RequestParam(name = "page") int page) {
+ Page pageable = new Page<>(page, 20);
+ return new RespModel<>(RespEnum.SEARCH_OK,
+ CommentPage.convertFrom(
+ resultDetailService.findAll(resultId, caseId, type, deviceId, pageable))
+ );
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查找测试结果详情2", notes = "查找对应测试结果详情")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "caseId", value = "测试用例id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "resultId", value = "测试结果id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "deviceId", value = "设备id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = String.class),
+ })
+ @GetMapping("/listAll")
+ public RespModel> findAll(@RequestParam(name = "caseId") int caseId,
+ @RequestParam(name = "resultId") int resultId,
+ @RequestParam(name = "deviceId") int deviceId,
+ @RequestParam(name = "type") String type) {
+ return new RespModel<>(RespEnum.SEARCH_OK,
+ resultDetailService.findAll(resultId, caseId, type, deviceId));
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ResultsController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ResultsController.java
index c9ce7f06..0c18c37b 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/ResultsController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/ResultsController.java
@@ -1,119 +1,120 @@
-package com.sonic.controller.controller;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Results;
-import com.sonic.controller.services.ResultsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.web.bind.annotation.*;
-
-@Api(tags = "测试结果相关")
-@RestController
-@RequestMapping("/results")
-public class ResultsController {
- @Autowired
- private ResultsService resultsService;
-
- @WebAspect
- @ApiOperation(value = "查询测试结果列表", notes = "查找对应项目id下的测试结果列表")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
- })
- @GetMapping("/list")
- public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId,
- @RequestParam(name = "page") int page,
- @RequestParam(name = "pageSize") int pageSize) {
- Pageable pageable = PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC, "id"));
- return new RespModel(RespEnum.SEARCH_OK, resultsService.findByProjectId(projectId, pageable));
- }
-
- @WebAspect
- @ApiOperation(value = "删除测试结果", notes = "删除对应的测试结果id以及测试结果详情")
- @ApiImplicitParam(name = "id", value = "测试结果id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- if (resultsService.delete(id)) {
- return new RespModel(RespEnum.DELETE_OK);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "查询测试结果信息", notes = "查询对应id的测试结果信息")
- @ApiImplicitParam(name = "id", value = "测试结果id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- return new RespModel(RespEnum.SEARCH_OK, resultsService.findById(id));
- }
-
- @WebAspect
- @GetMapping("/clean")
- public RespModel clean(@RequestParam(name = "day") int day) {
- resultsService.clean(day);
- return new RespModel(0, "开始清理测试结果!");
- }
-
- @WebAspect
- @GetMapping("/subResultCount")
- public RespModel subResultCount(@RequestParam(name = "id") int id) {
- resultsService.subResultCount(id);
- return new RespModel(RespEnum.HANDLE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查询测试结果用例状态", notes = "查询对应id的测试结果用例状态")
- @ApiImplicitParam(name = "id", value = "测试结果id", dataTypeClass = Integer.class)
- @GetMapping("/findCaseStatus")
- public RespModel findCaseStatus(@RequestParam(name = "id") int id) {
- JSONArray result = resultsService.findCaseStatus(id);
- if (result == null) {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- } else {
- return new RespModel(RespEnum.SEARCH_OK, result);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "查询报表", notes = "查找前端首页报表信息")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "startTime", value = "起始时间", dataTypeClass = String.class),
- @ApiImplicitParam(name = "endTime", value = "结束时间", dataTypeClass = String.class)
- })
- @GetMapping("/chart")
- public RespModel chart(@RequestParam(name = "projectId") int projectId,
- @RequestParam(name = "startTime") String startTime,
- @RequestParam(name = "endTime") String endTime) {
- return new RespModel(RespEnum.SEARCH_OK, resultsService.chart(startTime, endTime, projectId));
- }
-
- @WebAspect
- @ApiOperation(value = "发送日报", notes = "发送所有项目日报")
- @GetMapping("/sendDayReport")
- public RespModel sendDayReport() {
- resultsService.sendDayReport();
- return new RespModel(RespEnum.HANDLE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "发送周报", notes = "发送所有项目周报")
- @GetMapping("/sendWeekReport")
- public RespModel sendWeekReport() {
- resultsService.sendWeekReport();
- return new RespModel(RespEnum.HANDLE_OK);
- }
-}
+package com.sonic.controller.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.CommentPage;
+import com.sonic.controller.models.domain.Results;
+import com.sonic.controller.services.ResultsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+@Api(tags = "测试结果相关")
+@RestController
+@RequestMapping("/results")
+public class ResultsController {
+ @Autowired
+ private ResultsService resultsService;
+
+ @WebAspect
+ @ApiOperation(value = "查询测试结果列表", notes = "查找对应项目id下的测试结果列表")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
+ })
+ @GetMapping("/list")
+ public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId,
+ @RequestParam(name = "page") int page,
+ @RequestParam(name = "pageSize") int pageSize) {
+ Page pageable = new Page<>(page, pageSize);
+ return new RespModel<>(
+ RespEnum.SEARCH_OK,
+ CommentPage.convertFrom(resultsService.findByProjectId(projectId, pageable))
+ );
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除测试结果", notes = "删除对应的测试结果id以及测试结果详情")
+ @ApiImplicitParam(name = "id", value = "测试结果id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ if (resultsService.delete(id)) {
+ return new RespModel<>(RespEnum.DELETE_OK);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询测试结果信息", notes = "查询对应id的测试结果信息")
+ @ApiImplicitParam(name = "id", value = "测试结果id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel findById(@RequestParam(name = "id") int id) {
+ return new RespModel<>(RespEnum.SEARCH_OK, resultsService.findById(id));
+ }
+
+ @WebAspect
+ @GetMapping("/clean")
+ public RespModel clean(@RequestParam(name = "day") int day) {
+ resultsService.clean(day);
+ return new RespModel<>(0, "开始清理测试结果!");
+ }
+
+ @WebAspect
+ @GetMapping("/subResultCount")
+ public RespModel subResultCount(@RequestParam(name = "id") int id) {
+ resultsService.subResultCount(id);
+ return new RespModel<>(RespEnum.HANDLE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询测试结果用例状态", notes = "查询对应id的测试结果用例状态")
+ @ApiImplicitParam(name = "id", value = "测试结果id", dataTypeClass = Integer.class)
+ @GetMapping("/findCaseStatus")
+ public RespModel findCaseStatus(@RequestParam(name = "id") int id) {
+ JSONArray result = resultsService.findCaseStatus(id);
+ if (result == null) {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ } else {
+ return new RespModel<>(RespEnum.SEARCH_OK, result);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询报表", notes = "查找前端首页报表信息")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "startTime", value = "起始时间", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "endTime", value = "结束时间", dataTypeClass = String.class)
+ })
+ @GetMapping("/chart")
+ public RespModel chart(@RequestParam(name = "projectId") int projectId,
+ @RequestParam(name = "startTime") String startTime,
+ @RequestParam(name = "endTime") String endTime) {
+ return new RespModel<>(RespEnum.SEARCH_OK, resultsService.chart(startTime, endTime, projectId));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "发送日报", notes = "发送所有项目日报")
+ @GetMapping("/sendDayReport")
+ public RespModel sendDayReport() {
+ resultsService.sendDayReport();
+ return new RespModel<>(RespEnum.HANDLE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "发送周报", notes = "发送所有项目周报")
+ @GetMapping("/sendWeekReport")
+ public RespModel sendWeekReport() {
+ resultsService.sendWeekReport();
+ return new RespModel<>(RespEnum.HANDLE_OK);
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/StepsController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/StepsController.java
index 4a25ae09..fc1910a0 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/StepsController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/StepsController.java
@@ -1,112 +1,111 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Steps;
-import com.sonic.controller.models.http.StepSort;
-import com.sonic.controller.services.StepsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * @author ZhouYiXun
- * @des
- * @date 2021/9/19 11:45
- */
-@Api(tags = "操作步骤相关")
-@RestController
-@RequestMapping("/steps")
-public class StepsController {
- @Autowired
- private StepsService stepsService;
-
- @WebAspect
- @ApiOperation(value = "查找步骤列表", notes = "查找对应用例id下的步骤列表(分页)")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "platform", value = "平台", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
- })
- @GetMapping("/list")
- public RespModel> findAll(@RequestParam(name = "projectId") int projectId,
- @RequestParam(name = "platform") int platform,
- @RequestParam(name = "page") int page,
- @RequestParam(name = "pageSize") int pageSize) {
- Pageable pageable = PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC, "id"));
- return new RespModel(RespEnum.SEARCH_OK, stepsService.findByProjectIdAndPlatform(projectId, platform, pageable));
- }
-
- @WebAspect
- @ApiOperation(value = "查找步骤列表", notes = "查找对应用例id下的步骤列表")
- @ApiImplicitParam(name = "caseId", value = "测试用例id", dataTypeClass = Integer.class)
- @GetMapping("/listAll")
- public RespModel> findByCaseIdOrderBySort(@RequestParam(name = "caseId") int caseId) {
- return new RespModel(RespEnum.SEARCH_OK, stepsService.findByCaseIdOrderBySort(caseId));
- }
-
- @WebAspect
- @ApiOperation(value = "移出测试用例", notes = "将步骤从测试用例移出")
- @ApiImplicitParam(name = "id", value = "步骤id", dataTypeClass = Integer.class)
- @GetMapping("/resetCaseId")
- public RespModel resetCaseId(@RequestParam(name = "id") int id) {
- if (stepsService.resetCaseId(id)) {
- return new RespModel(2000, "移出测试用例成功!");
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "删除操作步骤", notes = "将步骤删除,并且从所有公共步骤里移除")
- @ApiImplicitParam(name = "id", value = "步骤id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- if (stepsService.delete(id)) {
- return new RespModel(RespEnum.DELETE_OK);
- } else {
- return new RespModel(RespEnum.DELETE_ERROR);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "更新操作步骤", notes = "新增或更新操作步骤")
- @PutMapping
- public RespModel save(@Validated @RequestBody Steps steps) {
- stepsService.save(steps);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "拖拽排序步骤", notes = "用于前端页面拖拽排序步骤")
- @PutMapping("/stepSort")
- public RespModel stepSort(@Validated @RequestBody StepSort stepSort) {
- stepsService.sortSteps(stepSort);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查询步骤详情", notes = "查询对应步骤id的详情信息")
- @ApiImplicitParam(name = "id", value = "步骤id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- Steps steps = stepsService.findById(id);
- if (steps != null) {
- return new RespModel(RespEnum.SEARCH_OK, steps);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.base.CommentPage;
+import com.sonic.controller.models.domain.Steps;
+import com.sonic.controller.models.dto.StepsDTO;
+import com.sonic.controller.models.http.StepSort;
+import com.sonic.controller.services.StepsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author ZhouYiXun
+ * @des
+ * @date 2021/9/19 11:45
+ */
+@Api(tags = "操作步骤相关")
+@RestController
+@RequestMapping("/steps")
+public class StepsController {
+ @Autowired
+ private StepsService stepsService;
+
+ @WebAspect
+ @ApiOperation(value = "查找步骤列表", notes = "查找对应用例id下的步骤列表(分页)")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "platform", value = "平台", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
+ })
+ @GetMapping("/list")
+ public RespModel> findAll(@RequestParam(name = "projectId") int projectId,
+ @RequestParam(name = "platform") int platform,
+ @RequestParam(name = "page") int page,
+ @RequestParam(name = "pageSize") int pageSize) {
+ Page pageable = new Page<>(page, pageSize);
+ return new RespModel<>(RespEnum.SEARCH_OK, stepsService.findByProjectIdAndPlatform(projectId, platform, pageable));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查找步骤列表", notes = "查找对应用例id下的步骤列表")
+ @ApiImplicitParam(name = "caseId", value = "测试用例id", dataTypeClass = Integer.class)
+ @GetMapping("/listAll")
+ public RespModel> findByCaseIdOrderBySort(@RequestParam(name = "caseId") int caseId) {
+ return new RespModel<>(RespEnum.SEARCH_OK, stepsService.findByCaseIdOrderBySort(caseId));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "移出测试用例", notes = "将步骤从测试用例移出")
+ @ApiImplicitParam(name = "id", value = "步骤id", dataTypeClass = Integer.class)
+ @GetMapping("/resetCaseId")
+ public RespModel resetCaseId(@RequestParam(name = "id") int id) {
+ if (stepsService.resetCaseId(id)) {
+ return new RespModel<>(2000, "移出测试用例成功!");
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除操作步骤", notes = "将步骤删除,并且从所有公共步骤里移除")
+ @ApiImplicitParam(name = "id", value = "步骤id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ if (stepsService.delete(id)) {
+ return new RespModel<>(RespEnum.DELETE_OK);
+ } else {
+ return new RespModel<>(RespEnum.DELETE_ERROR);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "更新操作步骤", notes = "新增或更新操作步骤")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody StepsDTO stepsDTO) {
+ stepsService.saveStep(stepsDTO);
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "拖拽排序步骤", notes = "用于前端页面拖拽排序步骤")
+ @PutMapping("/stepSort")
+ public RespModel stepSort(@Validated @RequestBody StepSort stepSort) {
+ stepsService.sortSteps(stepSort);
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询步骤详情", notes = "查询对应步骤id的详情信息")
+ @ApiImplicitParam(name = "id", value = "步骤id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel> findById(@RequestParam(name = "id") int id) {
+ StepsDTO steps = stepsService.findById(id);
+ if (steps != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, steps);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/TestCasesController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/TestCasesController.java
index 482536c3..fa89327b 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/TestCasesController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/TestCasesController.java
@@ -1,127 +1,127 @@
-package com.sonic.controller.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.common.tools.JWTTokenTool;
-import com.sonic.controller.models.TestCases;
-import com.sonic.controller.models.Users;
-import com.sonic.controller.services.TestCasesService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-
-@Api(tags = "测试用例相关")
-@RestController
-@RequestMapping("/testCases")
-public class TestCasesController {
- @Autowired
- private TestCasesService testCasesService;
- @Autowired
- private JWTTokenTool jwtTokenTool;
-
- @WebAspect
- @ApiOperation(value = "查询测试用例列表", notes = "查找对应项目id下的测试用例列表")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "platform", value = "平台类型", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "name", value = "用例名称", dataTypeClass = String.class),
- @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
- })
- @GetMapping("/list")
- public RespModel> findAll(@RequestParam(name = "projectId") int projectId,
- @RequestParam(name = "platform") int platform,
- @RequestParam(name = "name") String name,
- @RequestParam(name = "page") int page,
- @RequestParam(name = "pageSize") int pageSize) {
- Pageable pageable = PageRequest.of(page - 1, pageSize, Sort.by(Sort.Direction.DESC, "editTime"));
- return new RespModel(RespEnum.SEARCH_OK,
- testCasesService.findAll(projectId, platform, name, pageable));
- }
-
- @WebAspect
- @ApiOperation(value = "查询测试用例列表", notes = "不分页的测试用例列表")
- @ApiImplicitParams(value = {
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
- @ApiImplicitParam(name = "platform", value = "平台类型", dataTypeClass = Integer.class),
- })
- @GetMapping("/listAll")
- public RespModel> findAll(@RequestParam(name = "projectId") int projectId,
- @RequestParam(name = "platform") int platform) {
- return new RespModel(RespEnum.SEARCH_OK,
- testCasesService.findAll(projectId, platform));
- }
-
- @WebAspect
- @ApiOperation(value = "删除测试用例", notes = "删除对应用例id,用例下的操作步骤的caseId重置为0")
- @ApiImplicitParam(name = "id", value = "用例id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- if (testCasesService.delete(id)) {
- return new RespModel(RespEnum.DELETE_OK);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "更新测试用例信息", notes = "新增或更改测试用例信息")
- @PutMapping
- public RespModel save(@Validated @RequestBody TestCases testCases, HttpServletRequest request) {
- if (request.getHeader("SonicToken") != null) {
- String token = request.getHeader("SonicToken");
- String userName = jwtTokenTool.getUserName(token);
- if (userName != null) {
- testCases.setDesigner(userName);
- }
- }
- testCasesService.save(testCases);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查询测试用例详情", notes = "查找对应用例id的用例详情")
- @ApiImplicitParam(name = "id", value = "用例id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- TestCases testCases = testCasesService.findById(id);
- if (testCases != null) {
- return new RespModel(RespEnum.SEARCH_OK, testCases);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @GetMapping("/findSteps")
- public RespModel findSteps(@RequestParam(name = "id") int id) {
- JSONObject jsonObject = testCasesService.findSteps(id);
- if (jsonObject != null) {
- return new RespModel(RespEnum.SEARCH_OK, jsonObject);
- } else {
- return new RespModel(-1, "查询出错!");
- }
- }
-
- @WebAspect
- @ApiOperation(value = "批量查询用例", notes = "查找id列表的用例信息,可以传多个ids[]")
- @ApiImplicitParam(name = "ids[]", value = "id列表", dataTypeClass = Integer.class)
- @GetMapping("/findByIdIn")
- public RespModel> findByIdIn(@RequestParam(name = "ids[]") List ids) {
- return new RespModel(RespEnum.SEARCH_OK,
- testCasesService.findByIdIn(ids));
- }
-}
+package com.sonic.controller.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.common.tools.JWTTokenTool;
+import com.sonic.controller.models.base.CommentPage;
+import com.sonic.controller.models.domain.TestCases;
+import com.sonic.controller.models.dto.TestCasesDTO;
+import com.sonic.controller.services.TestCasesService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@Api(tags = "测试用例相关")
+@RestController
+@RequestMapping("/testCases")
+public class TestCasesController {
+ @Autowired
+ private TestCasesService testCasesService;
+ @Autowired
+ private JWTTokenTool jwtTokenTool;
+
+ @WebAspect
+ @ApiOperation(value = "查询测试用例列表", notes = "查找对应项目id下的测试用例列表")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "platform", value = "平台类型", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "name", value = "用例名称", dataTypeClass = String.class),
+ @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "pageSize", value = "页数据大小", dataTypeClass = Integer.class)
+ })
+ @GetMapping("/list")
+ public RespModel> findAll(@RequestParam(name = "projectId") int projectId,
+ @RequestParam(name = "platform") int platform,
+ @RequestParam(name = "name") String name,
+ @RequestParam(name = "page") int page,
+ @RequestParam(name = "pageSize") int pageSize) {
+ Page pageable = new Page<>(page, pageSize);
+ return new RespModel<>(
+ RespEnum.SEARCH_OK,
+ CommentPage.convertFrom(testCasesService.findAll(projectId, platform, name, pageable))
+ );
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询测试用例列表", notes = "不分页的测试用例列表")
+ @ApiImplicitParams(value = {
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class),
+ @ApiImplicitParam(name = "platform", value = "平台类型", dataTypeClass = Integer.class),
+ })
+ @GetMapping("/listAll")
+ public RespModel> findAll(@RequestParam(name = "projectId") int projectId,
+ @RequestParam(name = "platform") int platform) {
+ return new RespModel<>(RespEnum.SEARCH_OK,
+ testCasesService.findAll(projectId, platform));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除测试用例", notes = "删除对应用例id,用例下的操作步骤的caseId重置为0")
+ @ApiImplicitParam(name = "id", value = "用例id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ if (testCasesService.delete(id)) {
+ return new RespModel<>(RespEnum.DELETE_OK);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "更新测试用例信息", notes = "新增或更改测试用例信息")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody TestCasesDTO testCasesDTO, HttpServletRequest request) {
+ if (request.getHeader("SonicToken") != null) {
+ String token = request.getHeader("SonicToken");
+ String userName = jwtTokenTool.getUserName(token);
+ if (userName != null) {
+ testCasesDTO.setDesigner(userName);
+ }
+ }
+ testCasesService.save(testCasesDTO.convertTo());
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询测试用例详情", notes = "查找对应用例id的用例详情")
+ @ApiImplicitParam(name = "id", value = "用例id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel findById(@RequestParam(name = "id") int id) {
+ TestCases testCases = testCasesService.findById(id);
+ if (testCases != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, testCases);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @GetMapping("/findSteps")
+ public RespModel findSteps(@RequestParam(name = "id") int id) {
+ JSONObject jsonObject = testCasesService.findSteps(id);
+ if (jsonObject != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, jsonObject);
+ } else {
+ return new RespModel<>(-1, "查询出错!");
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "批量查询用例", notes = "查找id列表的用例信息,可以传多个ids[]")
+ @ApiImplicitParam(name = "ids[]", value = "id列表", dataTypeClass = Integer.class)
+ @GetMapping("/findByIdIn")
+ public RespModel> findByIdIn(@RequestParam(name = "ids[]") List ids) {
+ return new RespModel<>(RespEnum.SEARCH_OK,
+ testCasesService.findByIdIn(ids));
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/TestSuitesController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/TestSuitesController.java
index eebb6dc0..8e3fef3a 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/TestSuitesController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/TestSuitesController.java
@@ -1,119 +1,118 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.common.tools.JWTTokenTool;
-import com.sonic.controller.models.TestSuites;
-import com.sonic.controller.models.Users;
-import com.sonic.controller.services.TestSuitesService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-
-@Api(tags = "测试套件相关")
-@RestController
-@RequestMapping("/testSuites")
-public class TestSuitesController {
- @Autowired
- private TestSuitesService testSuitesService;
- @Autowired
- private JWTTokenTool jwtTokenTool;
-
- @WebAspect
- @ApiOperation(value = "运行测试套件", notes = "运行指定项目的指定测试套件")
- @ApiImplicitParam(name = "id", value = "测试套件id", dataTypeClass = Integer.class)
- @GetMapping("/runSuite")
- public RespModel runSuite(@RequestParam(name = "id") int id
- , HttpServletRequest request) {
- String strike = "SYSTEM";
- if (request.getHeader("SonicToken") != null) {
- String token = request.getHeader("SonicToken");
- String userName = jwtTokenTool.getUserName(token);
- if (userName != null) {
- strike = userName;
- }
- }
- return testSuitesService.runSuite(id, strike);
- }
-
- @WebAspect
- @ApiOperation(value = "停止测试套件运行", notes = "停止测试套件运行")
- @ApiImplicitParam(name = "resultId", value = "测试结果Id", dataTypeClass = Integer.class)
- @GetMapping("/forceStopSuite")
- public RespModel forceStopSuite(@RequestParam(name = "resultId") int resultId
- , HttpServletRequest request) {
- String strike = "SYSTEM";
- if (request.getHeader("SonicToken") != null) {
- String token = request.getHeader("SonicToken");
- String userName = jwtTokenTool.getUserName(token);
- if (userName != null) {
- strike = userName;
- }
- }
- return testSuitesService.forceStopSuite(resultId, strike);
- }
-
-
- @WebAspect
- @ApiOperation(value = "删除测试套件", notes = "删除指定id的测试套件")
- @ApiImplicitParam(name = "id", value = "测试套件id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- if (testSuitesService.delete(id)) {
- return new RespModel(RespEnum.DELETE_OK);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "更新测试套件", notes = "更新或新增测试套件")
- @PutMapping
- public RespModel save(@Validated @RequestBody TestSuites testSuites) {
- testSuitesService.save(testSuites);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查询测试套件列表", notes = "用于查询对应项目id下的测试套件列表")
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
- @GetMapping("/list")
- public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId
- , @RequestParam(name = "name") String name
- , @RequestParam(name = "page") int page
- , @RequestParam(name = "pageSize") int pageSize) {
- Pageable pageable = PageRequest.of(page - 1, pageSize);
- return new RespModel(RespEnum.SEARCH_OK, testSuitesService.findByProjectId(projectId, name, pageable));
- }
-
- @WebAspect
- @ApiOperation(value = "查询测试套件列表", notes = "用于查询对应项目id下的测试套件列表(不分页)")
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
- @GetMapping("/listAll")
- public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) {
- return new RespModel(RespEnum.SEARCH_OK, testSuitesService.findByProjectId(projectId));
- }
-
- @WebAspect
- @ApiOperation(value = "测试套件详情", notes = "查看测试套件的配置信息详情")
- @ApiImplicitParam(name = "id", value = "测试套件id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- TestSuites testSuites = testSuitesService.findById(id);
- if (testSuites != null) {
- return new RespModel(RespEnum.SEARCH_OK, testSuites);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.common.tools.JWTTokenTool;
+import com.sonic.controller.models.base.CommentPage;
+import com.sonic.controller.models.domain.TestSuites;
+import com.sonic.controller.models.dto.TestSuitesDTO;
+import com.sonic.controller.services.TestSuitesService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+
+@Api(tags = "测试套件相关")
+@RestController
+@RequestMapping("/testSuites")
+public class TestSuitesController {
+ @Autowired
+ private TestSuitesService testSuitesService;
+ @Autowired
+ private JWTTokenTool jwtTokenTool;
+
+ @WebAspect
+ @ApiOperation(value = "运行测试套件", notes = "运行指定项目的指定测试套件")
+ @ApiImplicitParam(name = "id", value = "测试套件id", dataTypeClass = Integer.class)
+ @GetMapping("/runSuite")
+ public RespModel runSuite(@RequestParam(name = "id") int id
+ , HttpServletRequest request) {
+ String strike = "SYSTEM";
+ if (request.getHeader("SonicToken") != null) {
+ String token = request.getHeader("SonicToken");
+ String userName = jwtTokenTool.getUserName(token);
+ if (userName != null) {
+ strike = userName;
+ }
+ }
+ return testSuitesService.runSuite(id, strike);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "停止测试套件运行", notes = "停止测试套件运行")
+ @ApiImplicitParam(name = "resultId", value = "测试结果Id", dataTypeClass = Integer.class)
+ @GetMapping("/forceStopSuite")
+ public RespModel forceStopSuite(@RequestParam(name = "resultId") int resultId
+ , HttpServletRequest request) {
+ String strike = "SYSTEM";
+ if (request.getHeader("SonicToken") != null) {
+ String token = request.getHeader("SonicToken");
+ String userName = jwtTokenTool.getUserName(token);
+ if (userName != null) {
+ strike = userName;
+ }
+ }
+ return testSuitesService.forceStopSuite(resultId, strike);
+ }
+
+
+ @WebAspect
+ @ApiOperation(value = "删除测试套件", notes = "删除指定id的测试套件")
+ @ApiImplicitParam(name = "id", value = "测试套件id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ if (testSuitesService.delete(id)) {
+ return new RespModel<>(RespEnum.DELETE_OK);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "更新测试套件", notes = "更新或新增测试套件")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody TestSuitesDTO testSuitesDTO) {
+ testSuitesService.saveTestSuites(testSuitesDTO);
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询测试套件列表", notes = "用于查询对应项目id下的测试套件列表")
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
+ @GetMapping("/list")
+ public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId
+ , @RequestParam(name = "name") String name
+ , @RequestParam(name = "page") int page
+ , @RequestParam(name = "pageSize") int pageSize) {
+ Page pageable = new Page<>(page, pageSize);
+ return new RespModel<>(RespEnum.SEARCH_OK, testSuitesService.findByProjectId(projectId, name, pageable));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询测试套件列表", notes = "用于查询对应项目id下的测试套件列表(不分页)")
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
+ @GetMapping("/listAll")
+ public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) {
+ return new RespModel<>(RespEnum.SEARCH_OK, testSuitesService.findByProjectId(projectId));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "测试套件详情", notes = "查看测试套件的配置信息详情")
+ @ApiImplicitParam(name = "id", value = "测试套件id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel> findById(@RequestParam(name = "id") int id) {
+ TestSuitesDTO testSuitesDTO = testSuitesService.findById(id);
+ if (testSuitesDTO != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, testSuitesDTO);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/UsersController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/UsersController.java
index c259bf43..2282618a 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/UsersController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/UsersController.java
@@ -1,74 +1,74 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.exception.SonicException;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Users;
-import com.sonic.controller.models.http.ChangePwd;
-import com.sonic.controller.models.http.UserInfo;
-import com.sonic.controller.services.UsersService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * @author ZhouYiXun
- * @des
- * @date 2021/10/13 19:05
- */
-@Api(tags = "用户体系相关")
-@RestController
-@RequestMapping("/users")
-public class UsersController {
- @Autowired
- private UsersService usersService;
-
- @WebAspect
- @ApiOperation(value = "登录", notes = "用户登录")
- @PostMapping("/login")
- public RespModel login(@Validated @RequestBody UserInfo userInfo) {
- String token = usersService.login(userInfo);
- if (token != null) {
- return new RespModel(2000, "登录成功!", token);
- } else {
- return new RespModel(2001, "登录失败!");
- }
- }
-
- @WebAspect
- @ApiOperation(value = "注册", notes = "注册用户")
- @PostMapping("/register")
- public RespModel register(@Validated @RequestBody Users users) throws SonicException {
- usersService.register(users);
- return new RespModel(2000, "注册成功!");
- }
-
- @WebAspect
- @ApiOperation(value = "获取用户信息", notes = "获取token的用户信息")
- @GetMapping
- public RespModel getUserInfo(HttpServletRequest request) {
- if (request.getHeader("SonicToken") != null) {
- String token = request.getHeader("SonicToken");
- return new RespModel(RespEnum.SEARCH_OK, usersService.getUserInfo(token));
- } else {
- return new RespModel(RespEnum.UNAUTHORIZED);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "修改密码", notes = "修改token的用户密码")
- @PutMapping
- public RespModel changePwd(HttpServletRequest request, @Validated @RequestBody ChangePwd changePwd) {
- if (request.getHeader("SonicToken") != null) {
- String token = request.getHeader("SonicToken");
- return usersService.resetPwd(token, changePwd);
- } else {
- return new RespModel(RespEnum.UNAUTHORIZED);
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.exception.SonicException;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.dto.UsersDTO;
+import com.sonic.controller.models.http.ChangePwd;
+import com.sonic.controller.models.http.UserInfo;
+import com.sonic.controller.services.UsersService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author ZhouYiXun
+ * @des
+ * @date 2021/10/13 19:05
+ */
+@Api(tags = "用户体系相关")
+@RestController
+@RequestMapping("/users")
+public class UsersController {
+ @Autowired
+ private UsersService usersService;
+
+ @WebAspect
+ @ApiOperation(value = "登录", notes = "用户登录")
+ @PostMapping("/login")
+ public RespModel login(@Validated @RequestBody UserInfo userInfo) {
+ String token = usersService.login(userInfo);
+ if (token != null) {
+ return new RespModel<>(2000, "登录成功!", token);
+ } else {
+ return new RespModel<>(2001, "登录失败!");
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "注册", notes = "注册用户")
+ @PostMapping("/register")
+ public RespModel register(@Validated @RequestBody UsersDTO users) throws SonicException {
+ usersService.register(users.convertTo());
+ return new RespModel<>(2000, "注册成功!");
+ }
+
+ @WebAspect
+ @ApiOperation(value = "获取用户信息", notes = "获取token的用户信息")
+ @GetMapping
+ public RespModel> getUserInfo(HttpServletRequest request) {
+ if (request.getHeader("SonicToken") != null) {
+ String token = request.getHeader("SonicToken");
+ return new RespModel<>(RespEnum.SEARCH_OK, usersService.getUserInfo(token).convertTo());
+ } else {
+ return new RespModel<>(RespEnum.UNAUTHORIZED);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "修改密码", notes = "修改token的用户密码")
+ @PutMapping
+ public RespModel changePwd(HttpServletRequest request, @Validated @RequestBody ChangePwd changePwd) {
+ if (request.getHeader("SonicToken") != null) {
+ String token = request.getHeader("SonicToken");
+ return usersService.resetPwd(token, changePwd);
+ } else {
+ return new RespModel<>(RespEnum.UNAUTHORIZED);
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/controller/VersionsController.java b/sonic-server-controller/src/main/java/com/sonic/controller/controller/VersionsController.java
index 56358174..16493df2 100644
--- a/sonic-server-controller/src/main/java/com/sonic/controller/controller/VersionsController.java
+++ b/sonic-server-controller/src/main/java/com/sonic/controller/controller/VersionsController.java
@@ -1,64 +1,65 @@
-package com.sonic.controller.controller;
-
-import com.sonic.common.config.WebAspect;
-import com.sonic.common.http.RespEnum;
-import com.sonic.common.http.RespModel;
-import com.sonic.controller.models.Versions;
-import com.sonic.controller.services.VersionsService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-@Api(tags = "版本迭代相关")
-@RestController
-@RequestMapping("/versions")
-public class VersionsController {
- @Autowired
- private VersionsService versionsService;
-
- @WebAspect
- @ApiOperation(value = "更新版本迭代", notes = "新增或更改版本迭代信息")
- @PutMapping
- public RespModel save(@Validated @RequestBody Versions versions) {
- versionsService.save(versions);
- return new RespModel(RespEnum.UPDATE_OK);
- }
-
- @WebAspect
- @ApiOperation(value = "查询版本迭代列表", notes = "用于查询对应项目id下的版本迭代列表")
- @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
- @GetMapping("/list")
- public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) {
- return new RespModel(RespEnum.SEARCH_OK, versionsService.findByProjectId(projectId));
- }
-
- @WebAspect
- @ApiOperation(value = "删除版本迭代", notes = "删除指定id的版本迭代")
- @ApiImplicitParam(name = "id", value = "版本迭代id", dataTypeClass = Integer.class)
- @DeleteMapping
- public RespModel delete(@RequestParam(name = "id") int id) {
- if (versionsService.delete(id)) {
- return new RespModel(RespEnum.DELETE_OK);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-
- @WebAspect
- @ApiOperation(value = "查询版本迭代信息", notes = "查询指定id的版本迭代的详细信息")
- @ApiImplicitParam(name = "id", value = "版本迭代id", dataTypeClass = Integer.class)
- @GetMapping
- public RespModel findById(@RequestParam(name = "id") int id) {
- Versions versions = versionsService.findById(id);
- if (versions != null) {
- return new RespModel(RespEnum.SEARCH_OK, versions);
- } else {
- return new RespModel(RespEnum.ID_NOT_FOUND);
- }
- }
-}
+package com.sonic.controller.controller;
+
+import com.sonic.common.config.WebAspect;
+import com.sonic.common.http.RespEnum;
+import com.sonic.common.http.RespModel;
+import com.sonic.controller.models.domain.Versions;
+import com.sonic.controller.models.dto.VersionsDTO;
+import com.sonic.controller.services.VersionsService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@Api(tags = "版本迭代相关")
+@RestController
+@RequestMapping("/versions")
+public class VersionsController {
+ @Autowired
+ private VersionsService versionsService;
+
+ @WebAspect
+ @ApiOperation(value = "更新版本迭代", notes = "新增或更改版本迭代信息")
+ @PutMapping
+ public RespModel save(@Validated @RequestBody VersionsDTO versionsDTO) {
+ versionsService.save(versionsDTO.convertTo());
+ return new RespModel<>(RespEnum.UPDATE_OK);
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询版本迭代列表", notes = "用于查询对应项目id下的版本迭代列表")
+ @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class)
+ @GetMapping("/list")
+ public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) {
+ return new RespModel<>(RespEnum.SEARCH_OK, versionsService.findByProjectId(projectId));
+ }
+
+ @WebAspect
+ @ApiOperation(value = "删除版本迭代", notes = "删除指定id的版本迭代")
+ @ApiImplicitParam(name = "id", value = "版本迭代id", dataTypeClass = Integer.class)
+ @DeleteMapping
+ public RespModel delete(@RequestParam(name = "id") int id) {
+ if (versionsService.delete(id)) {
+ return new RespModel<>(RespEnum.DELETE_OK);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+
+ @WebAspect
+ @ApiOperation(value = "查询版本迭代信息", notes = "查询指定id的版本迭代的详细信息")
+ @ApiImplicitParam(name = "id", value = "版本迭代id", dataTypeClass = Integer.class)
+ @GetMapping
+ public RespModel findById(@RequestParam(name = "id") int id) {
+ Versions versions = versionsService.findById(id);
+ if (versions != null) {
+ return new RespModel<>(RespEnum.SEARCH_OK, versions);
+ } else {
+ return new RespModel<>(RespEnum.ID_NOT_FOUND);
+ }
+ }
+}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/dao/AgentsRepository.java b/sonic-server-controller/src/main/java/com/sonic/controller/dao/AgentsRepository.java
deleted file mode 100644
index b63e085c..00000000
--- a/sonic-server-controller/src/main/java/com/sonic/controller/dao/AgentsRepository.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.sonic.controller.dao;
-
-import com.sonic.controller.models.Agents;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
-
-import java.util.List;
-
-/**
- * @author ZhouYiXun
- * @des Agent数据库操作
- * @date 2021/8/16 20:29
- */
-public interface AgentsRepository extends JpaRepository {
- Agents findBySecretKey(String key);
-}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/dao/DevicesRepository.java b/sonic-server-controller/src/main/java/com/sonic/controller/dao/DevicesRepository.java
deleted file mode 100644
index 92e7d560..00000000
--- a/sonic-server-controller/src/main/java/com/sonic/controller/dao/DevicesRepository.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.sonic.controller.dao;
-
-import com.sonic.controller.models.Devices;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.data.jpa.repository.Query;
-
-import java.util.List;
-
-/**
- * @author ZhouYiXun
- * @des Devices数据库操作
- * @date 2021/8/16 20:29
- */
-public interface DevicesRepository extends JpaRepository, JpaSpecificationExecutor {
- Devices findByAgentIdAndUdId(int agentId, String udId);
-
- List findByAgentId(int agentId);
-
- List findByIdIn(List ids);
-
- List findByPlatformOrderByIdDesc(int platform);
-
- @Query(value = "select avg(temperature) as avg from devices " +
- "where temperature <> 0 and status in (?1)", nativeQuery = true)
- Integer findTemper(List ids);
-
- @Query(value = "select cpu from devices group by cpu", nativeQuery = true)
- List findCpuList();
-
- @Query(value = "select size from devices group by size", nativeQuery = true)
- List findSizeList();
-}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/dao/ElementsRepository.java b/sonic-server-controller/src/main/java/com/sonic/controller/dao/ElementsRepository.java
deleted file mode 100644
index c4efa4fe..00000000
--- a/sonic-server-controller/src/main/java/com/sonic/controller/dao/ElementsRepository.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.sonic.controller.dao;
-
-import com.sonic.controller.models.Elements;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-/**
- * @author ZhouYiXun
- * @des Elements数据库操作
- * @date 2021/8/16 20:29
- */
-public interface ElementsRepository extends JpaRepository, JpaSpecificationExecutor {
- @Transactional
- void deleteByProjectId(int projectId);
-}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/dao/GlobalParamsRepository.java b/sonic-server-controller/src/main/java/com/sonic/controller/dao/GlobalParamsRepository.java
deleted file mode 100644
index 9d7b5313..00000000
--- a/sonic-server-controller/src/main/java/com/sonic/controller/dao/GlobalParamsRepository.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.sonic.controller.dao;
-
-import com.sonic.controller.models.GlobalParams;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-/**
- * @author ZhouYiXun
- * @des GlobalParams数据库操作
- * @date 2021/8/20 20:29
- */
-public interface GlobalParamsRepository extends JpaRepository {
- List findByProjectId(int projectId);
-
- @Transactional
- void deleteByProjectId(int projectId);
-}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/dao/ModulesRepository.java b/sonic-server-controller/src/main/java/com/sonic/controller/dao/ModulesRepository.java
deleted file mode 100644
index 30d50934..00000000
--- a/sonic-server-controller/src/main/java/com/sonic/controller/dao/ModulesRepository.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.sonic.controller.dao;
-
-import com.sonic.controller.models.Modules;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-/**
- * @author ZhouYiXun
- * @des Modules数据库操作
- * @date 2021/8/16 20:29
- */
-public interface ModulesRepository extends JpaRepository {
- List findByProjectId(int projectId);
-
- @Transactional
- void deleteByProjectId(int projectId);
-}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/dao/ProjectsRepository.java b/sonic-server-controller/src/main/java/com/sonic/controller/dao/ProjectsRepository.java
deleted file mode 100644
index ebbd039c..00000000
--- a/sonic-server-controller/src/main/java/com/sonic/controller/dao/ProjectsRepository.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.sonic.controller.dao;
-
-import com.sonic.controller.models.Projects;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-public interface ProjectsRepository extends JpaRepository {
-}
diff --git a/sonic-server-controller/src/main/java/com/sonic/controller/dao/PublicStepsRepository.java b/sonic-server-controller/src/main/java/com/sonic/controller/dao/PublicStepsRepository.java
deleted file mode 100644
index b9755982..00000000
--- a/sonic-server-controller/src/main/java/com/sonic/controller/dao/PublicStepsRepository.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.sonic.controller.dao;
-
-import com.sonic.controller.models.PublicSteps;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author ZhouYiXun
- * @des PublicSteps数据库操作
- * @date 2021/8/16 20:29
- */
-public interface PublicStepsRepository extends JpaRepository {
- Page findByProjectId(int projectId, Pageable pageable);
-
- @Query(value = "select id,name from public_steps where project_id=?1 and platform=?2 order by id desc", nativeQuery = true)
- List