diff --git a/dc3-center/dc3-center-auth/pom.xml b/dc3-center/dc3-center-auth/pom.xml index b34e700ac..52c6e7f74 100644 --- a/dc3-center/dc3-center-auth/pom.xml +++ b/dc3-center/dc3-center-auth/pom.xml @@ -31,12 +31,6 @@ - - - io.github.pnoker diff --git a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/AuthApplication.java b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/AuthApplication.java index f76750e7b..9513d183d 100644 --- a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/AuthApplication.java +++ b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/AuthApplication.java @@ -28,8 +28,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; * @since 2022.1.0 */ @SpringBootApplication -// 开发环境无需注册中心 -// @EnableDiscoveryClient @EnableTransactionManagement @MapperScan("io.github.pnoker.center.auth.mapper") public class AuthApplication { diff --git a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/DictionaryController.java b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/DictionaryController.java index 197e2913a..f7d20e866 100644 --- a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/DictionaryController.java +++ b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/DictionaryController.java @@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; import java.util.List; @@ -55,14 +56,14 @@ public class DictionaryController implements BaseController { * @return 字典列表 */ @GetMapping("/tenant") - public R> tenantDictionary() { + public Mono>> tenantDictionary() { try { List entityBOList = dictionaryService.tenantDictionary(); List entityVOList = dictionaryForAuthBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVOList); + return Mono.just(R.ok(entityVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -72,14 +73,14 @@ public class DictionaryController implements BaseController { * @return 字典列表 */ @GetMapping("/limited_ip") - public R> limitedIpDictionary() { + public Mono>> limitedIpDictionary() { try { List entityBOList = dictionaryService.limitedIpDictionary(getTenantId()); List entityVOList = dictionaryForAuthBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVOList); + return Mono.just(R.ok(entityVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/LimitedIpController.java b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/LimitedIpController.java index cc028708d..b087c9ccb 100644 --- a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/LimitedIpController.java +++ b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/LimitedIpController.java @@ -32,6 +32,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -61,15 +62,15 @@ public class LimitedIpController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody LimitedIpVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody LimitedIpVO entityVO) { try { LimitedIpBO entityBO = limitedIpBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); limitedIpService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -80,13 +81,13 @@ public class LimitedIpController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { limitedIpService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -101,14 +102,14 @@ public class LimitedIpController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody LimitedIpVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody LimitedIpVO entityVO) { try { LimitedIpBO entityBO = limitedIpBuilder.buildBOByVO(entityVO); limitedIpService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -119,14 +120,14 @@ public class LimitedIpController implements BaseController { * @return LimitedIpVO {@link LimitedIpVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { LimitedIpBO entityBO = limitedIpService.selectById(id); LimitedIpVO entityVO = limitedIpBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -137,14 +138,14 @@ public class LimitedIpController implements BaseController { * @return {@link LimitedIpBO} */ @GetMapping("/ip/{ip}") - public R selectByIp(@NotNull @PathVariable(value = "ip") String ip) { + public Mono> selectByIp(@NotNull @PathVariable(value = "ip") String ip) { try { LimitedIpBO entityBO = limitedIpService.selectByIp(ip); LimitedIpVO entityVO = limitedIpBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -155,7 +156,7 @@ public class LimitedIpController implements BaseController { * @return 带分页的 {@link LimitedIpBO} */ @PostMapping("/list") - public R> list(@RequestBody(required = false) LimitedIpQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) LimitedIpQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new LimitedIpQuery(); @@ -163,10 +164,10 @@ public class LimitedIpController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = limitedIpService.selectByPage(entityQuery); Page entityPageVO = limitedIpBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -177,12 +178,12 @@ public class LimitedIpController implements BaseController { * @return 当前IP是否在限制IP中 */ @GetMapping("/check/{ip}") - public R checkValid(@NotNull @PathVariable(value = "ip") String ip) { + public Mono> checkValid(@NotNull @PathVariable(value = "ip") String ip) { try { - return Boolean.TRUE.equals(limitedIpService.checkValid(ip)) ? R.ok() : R.fail(); + return Boolean.TRUE.equals(limitedIpService.checkValid(ip)) ? Mono.just(R.ok()) : Mono.just(R.fail()); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/TenantController.java b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/TenantController.java index 2eeaac23c..945bc964a 100644 --- a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/TenantController.java +++ b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/TenantController.java @@ -32,6 +32,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -61,14 +62,14 @@ public class TenantController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody TenantVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody TenantVO entityVO) { try { TenantBO entityBO = tenantBuilder.buildBOByVO(entityVO); tenantService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -79,13 +80,13 @@ public class TenantController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { tenantService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -100,14 +101,14 @@ public class TenantController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody TenantVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody TenantVO entityVO) { try { TenantBO entityBO = tenantBuilder.buildBOByVO(entityVO); tenantService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -118,14 +119,14 @@ public class TenantController implements BaseController { * @return TenantVO {@link TenantVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { TenantBO entityBO = tenantService.selectById(id); TenantVO entityVO = tenantBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -136,17 +137,17 @@ public class TenantController implements BaseController { * @return {@link TenantBO} */ @GetMapping("/code/{code}") - public R selectByCode(@NotNull @PathVariable(value = "code") String code) { + public Mono> selectByCode(@NotNull @PathVariable(value = "code") String code) { try { TenantBO select = tenantService.selectByCode(code); if (!Objects.isNull(select)) { - return R.ok(select); + return Mono.just(R.ok(select)); } } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } - return R.fail(ResponseEnum.NO_RESOURCE.getText()); + return Mono.just(R.fail(ResponseEnum.NO_RESOURCE.getText())); } /** @@ -156,17 +157,17 @@ public class TenantController implements BaseController { * @return 带分页的 {@link TenantBO} */ @PostMapping("/list") - public R> list(@RequestBody(required = false) TenantQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) TenantQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new TenantQuery(); } Page entityPageBO = tenantService.selectByPage(entityQuery); Page entityPageVO = tenantBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/TokenController.java b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/TokenController.java index 46c36dce8..25d6de50d 100644 --- a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/TokenController.java +++ b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/TokenController.java @@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -56,9 +57,9 @@ public class TokenController implements BaseController { * @return 盐值 */ @PostMapping("/salt") - public R generateSalt(@Validated @RequestBody TokenQuery entityVO) { + public Mono> generateSalt(@Validated @RequestBody TokenQuery entityVO) { String salt = tokenService.generateSalt(entityVO.getName(), entityVO.getTenant()); - return !Objects.isNull(salt) ? R.ok(salt, "The salt will expire in 5 minutes") : R.fail(); + return !Objects.isNull(salt) ? Mono.just(R.ok(salt, "The salt will expire in 5 minutes")) : Mono.just(R.fail()); } /** @@ -68,9 +69,9 @@ public class TokenController implements BaseController { * @return Token 令牌 */ @PostMapping("/generate") - public R generateToken(@Validated @RequestBody TokenQuery entityVO) { + public Mono> generateToken(@Validated @RequestBody TokenQuery entityVO) { String token = tokenService.generateToken(entityVO.getName(), entityVO.getSalt(), entityVO.getPassword(), entityVO.getTenant()); - return !Objects.isNull(token) ? R.ok(token, "The token will expire in 12 hours.") : R.fail(); + return !Objects.isNull(token) ? Mono.just(R.ok(token, "The token will expire in 12 hours.")) : Mono.just(R.fail()); } /** @@ -80,7 +81,7 @@ public class TokenController implements BaseController { * @return 是否有效, 并返回过期时间 */ @PostMapping("/check") - public R checkValid(@Validated @RequestBody TokenQuery entityVO) { + public Mono> checkValid(@Validated @RequestBody TokenQuery entityVO) { TokenValid tokenValid = tokenService.checkValid(entityVO.getName(), entityVO.getSalt(), entityVO.getToken(), entityVO.getTenant()); boolean valid = tokenValid.isValid(); @@ -93,7 +94,7 @@ public class TokenController implements BaseController { message = "The token has expired in " + expireTime; } - return R.ok(valid, message); + return Mono.just(R.ok(valid, message)); } /** @@ -103,7 +104,7 @@ public class TokenController implements BaseController { * @return 是否注销成功 */ @PostMapping("/cancel") - public R cancelToken(@Validated @RequestBody TokenQuery entityVO) { - return Boolean.TRUE.equals(tokenService.cancelToken(entityVO.getName(), entityVO.getTenant())) ? R.ok() : R.fail(); + public Mono> cancelToken(@Validated @RequestBody TokenQuery entityVO) { + return Boolean.TRUE.equals(tokenService.cancelToken(entityVO.getName(), entityVO.getTenant())) ? Mono.just(R.ok()) : Mono.just(R.fail()); } } diff --git a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/UserLoginController.java b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/UserLoginController.java index 9396753b9..4b31eddf5 100644 --- a/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/UserLoginController.java +++ b/dc3-center/dc3-center-auth/src/main/java/io/github/pnoker/center/auth/controller/UserLoginController.java @@ -33,6 +33,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -64,14 +65,14 @@ public class UserLoginController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody UserLoginVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody UserLoginVO entityVO) { try { UserLoginBO entityBO = userLoginBuilder.buildBOByVO(entityVO); userLoginService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -82,13 +83,13 @@ public class UserLoginController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { userLoginService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -103,14 +104,14 @@ public class UserLoginController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody UserLoginVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody UserLoginVO entityVO) { try { UserLoginBO entityBO = userLoginBuilder.buildBOByVO(entityVO); userLoginService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -121,13 +122,13 @@ public class UserLoginController implements BaseController { * @return 是否重置 */ @PostMapping("/reset/{id}") - public R restPassword(@NotNull @PathVariable(value = "id") Long id) { + public Mono> restPassword(@NotNull @PathVariable(value = "id") Long id) { try { userPasswordService.restPassword(id); - return R.ok(); + return Mono.just(R.ok()); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -138,14 +139,14 @@ public class UserLoginController implements BaseController { * @return UserLoginVO {@link UserLoginVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { UserLoginBO entityBO = userLoginService.selectById(id); UserLoginVO entityVO = userLoginBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -156,14 +157,14 @@ public class UserLoginController implements BaseController { * @return {@link UserLoginBO} */ @GetMapping("/name/{name}") - public R selectByName(@NotNull @PathVariable(value = "name") String name) { + public Mono> selectByName(@NotNull @PathVariable(value = "name") String name) { try { UserLoginBO entityBO = userLoginService.selectByLoginName(name, false); UserLoginVO entityVO = userLoginBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -174,16 +175,16 @@ public class UserLoginController implements BaseController { * @return 带分页的 {@link UserLoginBO} */ @PostMapping("/list") - public R> list(@RequestBody(required = false) UserLoginQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) UserLoginQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new UserLoginQuery(); } Page entityPageBO = userLoginService.selectByPage(entityQuery); Page entityPageVO = userLoginBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -194,11 +195,11 @@ public class UserLoginController implements BaseController { * @return 是否有效 */ @GetMapping("/check/{name}") - public R checkLoginNameValid(@NotNull @PathVariable(value = "name") String name) { + public Mono> checkLoginNameValid(@NotNull @PathVariable(value = "name") String name) { try { - return Boolean.TRUE.equals(userLoginService.checkLoginNameValid(name)) ? R.ok() : R.fail(); + return Boolean.TRUE.equals(userLoginService.checkLoginNameValid(name)) ? Mono.just(R.ok()) : Mono.just(R.fail()); } catch (Exception e) { - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-auth/src/main/resources/application-dev.yml b/dc3-center/dc3-center-auth/src/main/resources/application-dev.yml index 0cc146da2..3db2bb528 100644 --- a/dc3-center/dc3-center-auth/src/main/resources/application-dev.yml +++ b/dc3-center/dc3-center-auth/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 spring: env: dev group: ${user.name} diff --git a/dc3-center/dc3-center-auth/src/main/resources/application-pre.yml b/dc3-center/dc3-center-auth/src/main/resources/application-pre.yml index 49c89e28a..29011f086 100644 --- a/dc3-center/dc3-center-auth/src/main/resources/application-pre.yml +++ b/dc3-center/dc3-center-auth/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_auth}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-auth/src/main/resources/application-pro.yml b/dc3-center/dc3-center-auth/src/main/resources/application-pro.yml index f1559530c..45ed99a59 100644 --- a/dc3-center/dc3-center-auth/src/main/resources/application-pro.yml +++ b/dc3-center/dc3-center-auth/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_auth}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-auth/src/main/resources/application-test.yml b/dc3-center/dc3-center-auth/src/main/resources/application-test.yml index 3867a82d8..2cb122a95 100644 --- a/dc3-center/dc3-center-auth/src/main/resources/application-test.yml +++ b/dc3-center/dc3-center-auth/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_auth}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/DataApplication.java b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/DataApplication.java index 1b0dc263c..9cea01cc9 100644 --- a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/DataApplication.java +++ b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/DataApplication.java @@ -28,8 +28,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; * @since 2022.1.0 */ @SpringBootApplication -// 开发环境无需注册中心 -// @EnableDiscoveryClient @EnableTransactionManagement @MapperScan({"io.github.pnoker.center.data.mapper", "io.github.pnoker.common.tdengine.mapper", "io.github.pnoker.common.prometheus.dashboard.rabbitmq.mapper"}) public class DataApplication { diff --git a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DeviceEventController.java b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DeviceEventController.java index 64c5fc3b4..f7c7134ff 100644 --- a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DeviceEventController.java +++ b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DeviceEventController.java @@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -55,20 +56,20 @@ public class DeviceEventController implements BaseController { * @return Page Of DeviceEvent */ @PostMapping("/device") - public R> deviceEvent(@RequestBody(required = false) DeviceEventQuery deviceEventQuery) { + public Mono>> deviceEvent(@RequestBody(required = false) DeviceEventQuery deviceEventQuery) { try { if (Objects.isNull(deviceEventQuery)) { deviceEventQuery = new DeviceEventQuery(); } Page page = eventService.deviceEvent(deviceEventQuery); if (!Objects.isNull(page)) { - return R.ok(page); + return Mono.just(R.ok(page)); } } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } - return R.fail(); + return Mono.just(R.fail()); } } \ No newline at end of file diff --git a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DeviceStatusController.java b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DeviceStatusController.java index 64da546fe..d542d992d 100644 --- a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DeviceStatusController.java +++ b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DeviceStatusController.java @@ -27,6 +27,7 @@ import io.github.pnoker.common.entity.R; import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.Map; @@ -57,14 +58,14 @@ public class DeviceStatusController implements BaseController { * @return Map String:String */ @PostMapping("/device") - public R> deviceStatus(@RequestBody(required = false) DeviceQuery deviceQuery) { + public Mono>> deviceStatus(@RequestBody(required = false) DeviceQuery deviceQuery) { try { deviceQuery.setTenantId(getTenantId()); Map statuses = deviceStatusService.device(deviceQuery); - return R.ok(statuses); + return Mono.just(R.ok(statuses)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -76,15 +77,15 @@ public class DeviceStatusController implements BaseController { * @return Map String:String */ @GetMapping("/device/driver_id/{driverId}") - public R> deviceStatusByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono>> deviceStatusByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { DeviceQuery deviceQuery = new DeviceQuery(); deviceQuery.setDriverId(driverId); Map statuses = deviceStatusService.device(deviceQuery); - return R.ok(statuses); + return Mono.just(R.ok(statuses)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -96,13 +97,13 @@ public class DeviceStatusController implements BaseController { * @return Map String:String */ @GetMapping("/device/profile_id/{profileId}") - public R> deviceStatusByProfileId(@NotNull @PathVariable(value = "profileId") Long profileId) { + public Mono>> deviceStatusByProfileId(@NotNull @PathVariable(value = "profileId") Long profileId) { try { Map statuses = deviceStatusService.deviceByProfileId(profileId); - return R.ok(statuses); + return Mono.just(R.ok(statuses)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -113,14 +114,14 @@ public class DeviceStatusController implements BaseController { * @return */ @GetMapping("/deviceOnline/{deviceId}") - public R selectOnlineByDriverId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { + public Mono> selectOnlineByDriverId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { try { DeviceRunBO duration = deviceStatusService.selectOnlineByDeviceId(deviceId); DeviceRunVO result = deviceDurationBuilder.buildVOByBOList(duration); - return R.ok(result); + return Mono.just(R.ok(result)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -131,14 +132,14 @@ public class DeviceStatusController implements BaseController { * @return */ @GetMapping("/deviceOffline/{deviceId}") - public R selectOfflineByDriverId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { + public Mono> selectOfflineByDriverId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { try { DeviceRunBO duration = deviceStatusService.selectOfflineByDeviceId(deviceId); DeviceRunVO result = deviceDurationBuilder.buildVOByBOList(duration); - return R.ok(result); + return Mono.just(R.ok(result)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DriverEventController.java b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DriverEventController.java index 97631a02f..c2a3a0862 100644 --- a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DriverEventController.java +++ b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DriverEventController.java @@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -55,20 +56,20 @@ public class DriverEventController implements BaseController { * @return Page Of DriverEvent */ @PostMapping("/driver") - public R> driverEvent(@RequestBody(required = false) DriverEventQuery driverEventQuery) { + public Mono>> driverEvent(@RequestBody(required = false) DriverEventQuery driverEventQuery) { try { if (Objects.isNull(driverEventQuery)) { driverEventQuery = new DriverEventQuery(); } Page page = eventService.driverEvent(driverEventQuery); if (!Objects.isNull(page)) { - return R.ok(page); + return Mono.just(R.ok(page)); } } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } - return R.fail(); + return Mono.just(R.fail()); } } \ No newline at end of file diff --git a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DriverStatusController.java b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DriverStatusController.java index 343a8983b..4a4adb7a2 100644 --- a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DriverStatusController.java +++ b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/DriverStatusController.java @@ -27,6 +27,7 @@ import io.github.pnoker.common.entity.R; import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.Map; @@ -57,14 +58,14 @@ public class DriverStatusController implements BaseController { * @return Map String:String */ @PostMapping("/driver") - public R> driverStatus(@RequestBody(required = false) DriverQuery driverQuery) { + public Mono>> driverStatus(@RequestBody(required = false) DriverQuery driverQuery) { try { driverQuery.setTenantId(getTenantId()); Map statuses = driverStatusService.driver(driverQuery); - return R.ok(statuses); + return Mono.just(R.ok(statuses)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -75,14 +76,14 @@ public class DriverStatusController implements BaseController { * @return */ @GetMapping("/driverOnline/{driverId}") - public R selectOnlineByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono> selectOnlineByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { DriverRunBO duration = driverStatusService.selectOnlineByDriverId(driverId); DriverRunVO result = driverDurationBuilder.buildVOByBOList(duration); - return R.ok(result); + return Mono.just(R.ok(result)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -93,14 +94,14 @@ public class DriverStatusController implements BaseController { * @return */ @GetMapping("/driverOffline/{driverId}") - public R selectOfflineByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono> selectOfflineByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { DriverRunBO duration = driverStatusService.selectOfflineByDriverId(driverId); DriverRunVO result = driverDurationBuilder.buildVOByBOList(duration); - return R.ok(result); + return Mono.just(R.ok(result)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -111,13 +112,13 @@ public class DriverStatusController implements BaseController { * @return */ @GetMapping("/getDeviceOnlineByDriverId/{driverId}") - public R getDeviceOnlineByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono> getDeviceOnlineByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { String result = driverStatusService.getDeviceOnlineByDriverId(driverId); - return R.ok(result); + return Mono.just(R.ok(result)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -128,13 +129,13 @@ public class DriverStatusController implements BaseController { * @return */ @GetMapping("/getDeviceOfflineByDriverId/{driverId}") - public R getDeviceOfflineByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono> getDeviceOfflineByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { String result = driverStatusService.getDeviceOfflineByDriverId(driverId); - return R.ok(result); + return Mono.just(R.ok(result)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/PointValueCommandController.java b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/PointValueCommandController.java index 155a9962b..fe7a235e6 100644 --- a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/PointValueCommandController.java +++ b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/PointValueCommandController.java @@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; /** * PointValue Controller @@ -53,14 +54,14 @@ public class PointValueCommandController implements BaseController { * @return PointValue */ @PostMapping("/read") - public R read(@Validated @RequestBody PointValueReadVO entityVO) { + public Mono> read(@Validated @RequestBody PointValueReadVO entityVO) { try { pointValueCommandService.read(entityVO); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } - return R.ok(); + return Mono.just(R.ok()); } /** @@ -70,14 +71,14 @@ public class PointValueCommandController implements BaseController { * @return PointValue */ @PostMapping("/write") - public R write(@Validated @RequestBody PointValueWriteVO entityVO) { + public Mono> write(@Validated @RequestBody PointValueWriteVO entityVO) { try { pointValueCommandService.write(entityVO); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } - return R.ok(); + return Mono.just(R.ok()); } } \ No newline at end of file diff --git a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/PointValueController.java b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/PointValueController.java index 1bb421ee4..b9445b39d 100644 --- a/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/PointValueController.java +++ b/dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/controller/PointValueController.java @@ -28,6 +28,7 @@ import io.github.pnoker.common.entity.query.PointValueQuery; import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.List; import java.util.Objects; @@ -58,7 +59,7 @@ public class PointValueController implements BaseController { * @return 带分页的 {@link PointValueBO} */ @PostMapping("/latest") - public R> latest(@RequestBody PointValueQuery pointValueQuery) { + public Mono>> latest(@RequestBody PointValueQuery pointValueQuery) { try { if (Objects.isNull(pointValueQuery)) { pointValueQuery = new PointValueQuery(); @@ -66,10 +67,10 @@ public class PointValueController implements BaseController { pointValueQuery.setTenantId(getTenantId()); Page entityPageBO = pointValueService.latest(pointValueQuery); Page entityPageVO = pointValueBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -80,17 +81,17 @@ public class PointValueController implements BaseController { * @return 带分页的 {@link PointValueBO} */ @PostMapping("/list") - public R> list(@RequestBody(required = false) PointValueQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) PointValueQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new PointValueQuery(); } Page entityPageBO = pointValueService.page(entityQuery); Page entityPageVO = pointValueBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -102,16 +103,16 @@ public class PointValueController implements BaseController { * @return 带分页的 {@link PointValueBO} */ @GetMapping("/history/device_id/{deviceId}/point_id/{pointId}") - public R> history( + public Mono>> history( @NotNull @PathVariable(name = "deviceId") Long deviceId, @NotNull @PathVariable(name = "pointId") Long pointId, @RequestParam(name = "count", required = false, defaultValue = "100") Integer count) { try { List history = pointValueService.history(deviceId, pointId, count); - return R.ok(history); + return Mono.just(R.ok(history)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-data/src/main/resources/application-dev.yml b/dc3-center/dc3-center-data/src/main/resources/application-dev.yml index 5332520c7..e734b221f 100644 --- a/dc3-center/dc3-center-data/src/main/resources/application-dev.yml +++ b/dc3-center/dc3-center-data/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 spring: env: dev group: ${user.name} diff --git a/dc3-center/dc3-center-data/src/main/resources/application-pre.yml b/dc3-center/dc3-center-data/src/main/resources/application-pre.yml index 97549bc60..e0b68ca42 100644 --- a/dc3-center/dc3-center-data/src/main/resources/application-pre.yml +++ b/dc3-center/dc3-center-data/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_data}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-data/src/main/resources/application-pro.yml b/dc3-center/dc3-center-data/src/main/resources/application-pro.yml index 7cbc18e0b..26b4f8abc 100644 --- a/dc3-center/dc3-center-data/src/main/resources/application-pro.yml +++ b/dc3-center/dc3-center-data/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_data}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-data/src/main/resources/application-test.yml b/dc3-center/dc3-center-data/src/main/resources/application-test.yml index f3d5757f6..f2f22e9ec 100644 --- a/dc3-center/dc3-center-data/src/main/resources/application-test.yml +++ b/dc3-center/dc3-center-data/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_data}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-ekuiper/src/main/resources/application-dev.yml b/dc3-center/dc3-center-ekuiper/src/main/resources/application-dev.yml index 6edb17556..0152cf3a6 100644 --- a/dc3-center/dc3-center-ekuiper/src/main/resources/application-dev.yml +++ b/dc3-center/dc3-center-ekuiper/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 spring: env: dev group: ${user.name} diff --git a/dc3-center/dc3-center-ekuiper/src/main/resources/application-pre.yml b/dc3-center/dc3-center-ekuiper/src/main/resources/application-pre.yml index e9db90c57..08a439ce1 100644 --- a/dc3-center/dc3-center-ekuiper/src/main/resources/application-pre.yml +++ b/dc3-center/dc3-center-ekuiper/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_data}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-ekuiper/src/main/resources/application-pro.yml b/dc3-center/dc3-center-ekuiper/src/main/resources/application-pro.yml index 6f59c9474..54d1ccdeb 100644 --- a/dc3-center/dc3-center-ekuiper/src/main/resources/application-pro.yml +++ b/dc3-center/dc3-center-ekuiper/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_data}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-ekuiper/src/main/resources/application-test.yml b/dc3-center/dc3-center-ekuiper/src/main/resources/application-test.yml index 8279f9a0a..8d0dbe431 100644 --- a/dc3-center/dc3-center-ekuiper/src/main/resources/application-test.yml +++ b/dc3-center/dc3-center-ekuiper/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_data}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/ManagerApplication.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/ManagerApplication.java index 1ca2e175c..f42967bf2 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/ManagerApplication.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/ManagerApplication.java @@ -28,8 +28,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; * @since 2022.1.0 */ @SpringBootApplication -// 开发环境无需注册中心 -// @EnableDiscoveryClient @EnableTransactionManagement @MapperScan("io.github.pnoker.center.manager.mapper") public class ManagerApplication { diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DeviceController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DeviceController.java index 370259bbe..b02f9e73a 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DeviceController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DeviceController.java @@ -35,6 +35,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import reactor.core.publisher.Mono; import java.nio.file.Path; import java.util.List; @@ -68,15 +69,15 @@ public class DeviceController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody DeviceVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody DeviceVO entityVO) { try { DeviceBO entityBO = deviceBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); deviceService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -87,13 +88,13 @@ public class DeviceController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { deviceService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -104,14 +105,14 @@ public class DeviceController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody DeviceVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody DeviceVO entityVO) { try { DeviceBO entityBO = deviceBuilder.buildBOByVO(entityVO); deviceService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -122,14 +123,14 @@ public class DeviceController implements BaseController { * @return DeviceVO {@link DeviceVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { DeviceBO entityBO = deviceService.selectById(id); DeviceVO entityVO = deviceBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -140,14 +141,14 @@ public class DeviceController implements BaseController { * @return Map(ID, DeviceVO) */ @PostMapping("/ids") - public R> selectByIds(@RequestBody List deviceIds) { + public Mono>> selectByIds(@RequestBody List deviceIds) { try { List entityBOList = deviceService.selectByIds(deviceIds); Map deviceMap = entityBOList.stream().collect(Collectors.toMap(DeviceBO::getId, entityBO -> deviceBuilder.buildVOByBO(entityBO))); - return R.ok(deviceMap); + return Mono.just(R.ok(deviceMap)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -158,7 +159,7 @@ public class DeviceController implements BaseController { * @return R Of DeviceVO Page */ @PostMapping("/list") - public R> list(@RequestBody(required = false) DeviceQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) DeviceQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DeviceQuery(); @@ -166,10 +167,10 @@ public class DeviceController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = deviceService.selectByPage(entityQuery); Page entityPageVO = deviceBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -180,15 +181,15 @@ public class DeviceController implements BaseController { * @return R of String */ @PostMapping("/import") - public R importDevice(@Validated(Update.class) DeviceVO entityVO, @RequestParam("file") MultipartFile multipartFile) { + public Mono> importDevice(@Validated(Update.class) DeviceVO entityVO, @RequestParam("file") MultipartFile multipartFile) { try { DeviceBO entityBO = deviceBuilder.buildBOByVO(entityVO); deviceService.importDevice(entityBO, multipartFile); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } - return R.ok(); + return Mono.just(R.ok()); } /** @@ -215,13 +216,13 @@ public class DeviceController implements BaseController { * @return */ @GetMapping("/getDeviceByDriverId/{driverId}") - public R getDeviceByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono> getDeviceByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { List deviceBOList = deviceService.selectByDriverId(driverId); - return R.ok(String.valueOf(deviceBOList.size())); + return Mono.just(R.ok(String.valueOf(deviceBOList.size()))); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DictionaryController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DictionaryController.java index 842039427..2310cca4c 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DictionaryController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DictionaryController.java @@ -32,6 +32,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -61,7 +62,7 @@ public class DictionaryController implements BaseController { * @return R Of DictionaryVO Page */ @PostMapping("/driver") - public R> driverDictionary(@RequestBody(required = false) DictionaryQuery entityQuery) { + public Mono>> driverDictionary(@RequestBody(required = false) DictionaryQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DictionaryQuery(); @@ -69,10 +70,10 @@ public class DictionaryController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = dictionaryService.driverDictionary(entityQuery); Page entityPageVO = dictionaryForManagerBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -83,7 +84,7 @@ public class DictionaryController implements BaseController { * @return R Of DictionaryVO Page */ @PostMapping("/profile") - public R> profileDictionary(@RequestBody(required = false) DictionaryQuery entityQuery) { + public Mono>> profileDictionary(@RequestBody(required = false) DictionaryQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DictionaryQuery(); @@ -91,10 +92,10 @@ public class DictionaryController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = dictionaryService.profileDictionary(entityQuery); Page entityPageVO = dictionaryForManagerBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -105,7 +106,7 @@ public class DictionaryController implements BaseController { * @return R Of DictionaryVO Page */ @PostMapping("/profile_point") - public R> pointDictionaryForProfile(@Validated(Parent.class) @RequestBody(required = false) DictionaryQuery entityQuery) { + public Mono>> pointDictionaryForProfile(@Validated(Parent.class) @RequestBody(required = false) DictionaryQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DictionaryQuery(); @@ -113,10 +114,10 @@ public class DictionaryController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = dictionaryService.pointDictionaryForProfile(entityQuery); Page entityPageVO = dictionaryForManagerBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -127,7 +128,7 @@ public class DictionaryController implements BaseController { * @return R Of DictionaryVO Page */ @PostMapping("/device_point") - public R> pointDictionaryForDevice(@Validated(Parent.class) @RequestBody(required = false) DictionaryQuery entityQuery) { + public Mono>> pointDictionaryForDevice(@Validated(Parent.class) @RequestBody(required = false) DictionaryQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DictionaryQuery(); @@ -135,10 +136,10 @@ public class DictionaryController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = dictionaryService.pointDictionaryForDevice(entityQuery); Page entityPageVO = dictionaryForManagerBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -149,7 +150,7 @@ public class DictionaryController implements BaseController { * @return R Of DictionaryVO Page */ @PostMapping("/device") - public R> deviceDictionary(@RequestBody(required = false) DictionaryQuery entityQuery) { + public Mono>> deviceDictionary(@RequestBody(required = false) DictionaryQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DictionaryQuery(); @@ -157,10 +158,10 @@ public class DictionaryController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = dictionaryService.deviceDictionary(entityQuery); Page entityPageVO = dictionaryForManagerBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -171,7 +172,7 @@ public class DictionaryController implements BaseController { * @return R Of DictionaryVO Page */ @PostMapping("/driver_device") - public R> deviceDictionaryForDriver(@Validated(Parent.class) @RequestBody(required = false) DictionaryQuery entityQuery) { + public Mono>> deviceDictionaryForDriver(@Validated(Parent.class) @RequestBody(required = false) DictionaryQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DictionaryQuery(); @@ -179,9 +180,9 @@ public class DictionaryController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = dictionaryService.deviceDictionaryForDriver(entityQuery); Page entityPageVO = dictionaryForManagerBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverAttributeConfigController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverAttributeConfigController.java index f548f1d10..c6f6912f7 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverAttributeConfigController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverAttributeConfigController.java @@ -32,6 +32,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.List; import java.util.Objects; @@ -62,15 +63,15 @@ public class DriverAttributeConfigController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody DriverAttributeConfigVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody DriverAttributeConfigVO entityVO) { try { DriverAttributeConfigBO entityBO = driverAttributeConfigBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); driverAttributeConfigService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -81,13 +82,13 @@ public class DriverAttributeConfigController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { driverAttributeConfigService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -98,14 +99,14 @@ public class DriverAttributeConfigController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody DriverAttributeConfigVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody DriverAttributeConfigVO entityVO) { try { DriverAttributeConfigBO entityBO = driverAttributeConfigBuilder.buildBOByVO(entityVO); driverAttributeConfigService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -116,14 +117,14 @@ public class DriverAttributeConfigController implements BaseController { * @return DriverAttributeConfigVO {@link DriverAttributeConfigVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { DriverAttributeConfigBO entityBO = driverAttributeConfigService.selectById(id); DriverAttributeConfigVO entityVO = driverAttributeConfigBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -135,15 +136,15 @@ public class DriverAttributeConfigController implements BaseController { * @return DriverConfig */ @GetMapping("/device_id/{deviceId}/attribute_id/{attributeId}") - public R selectByDeviceIdAndAttributeId(@NotNull @PathVariable(value = "deviceId") Long deviceId, - @NotNull @PathVariable(value = "attributeId") Long attributeId) { + public Mono> selectByDeviceIdAndAttributeId(@NotNull @PathVariable(value = "deviceId") Long deviceId, + @NotNull @PathVariable(value = "attributeId") Long attributeId) { try { DriverAttributeConfigBO entityBO = driverAttributeConfigService.selectByAttributeIdAndDeviceId(deviceId, attributeId); DriverAttributeConfigVO entityVO = driverAttributeConfigBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -154,14 +155,14 @@ public class DriverAttributeConfigController implements BaseController { * @return DriverConfig 集合 */ @GetMapping("/device_id/{deviceId}") - public R> selectByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { + public Mono>> selectByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { try { List entityBOList = driverAttributeConfigService.selectByDeviceId(deviceId); List entityVOList = driverAttributeConfigBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVOList); + return Mono.just(R.ok(entityVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -172,7 +173,7 @@ public class DriverAttributeConfigController implements BaseController { * @return Page Of DriverConfig */ @PostMapping("/list") - public R> list(@RequestBody(required = false) DriverAttributeConfigQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) DriverAttributeConfigQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DriverAttributeConfigQuery(); @@ -180,10 +181,10 @@ public class DriverAttributeConfigController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = driverAttributeConfigService.selectByPage(entityQuery); Page entityPageVO = driverAttributeConfigBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverAttributeController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverAttributeController.java index 8d69b214c..e846d524d 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverAttributeController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverAttributeController.java @@ -33,8 +33,9 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -64,15 +65,15 @@ public class DriverAttributeController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody DriverAttributeVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody DriverAttributeVO entityVO) { try { DriverAttributeBO entityBO = driverAttributeBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); driverAttributeService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -83,13 +84,13 @@ public class DriverAttributeController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { driverAttributeService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -100,14 +101,14 @@ public class DriverAttributeController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody DriverAttributeVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody DriverAttributeVO entityVO) { try { DriverAttributeBO entityBO = driverAttributeBuilder.buildBOByVO(entityVO); driverAttributeService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -118,14 +119,14 @@ public class DriverAttributeController implements BaseController { * @return DriverAttributeVO {@link DriverAttributeVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { DriverAttributeBO entityBO = driverAttributeService.selectById(id); DriverAttributeVO entityVO = driverAttributeBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -136,16 +137,16 @@ public class DriverAttributeController implements BaseController { * @return DriverAttribute */ @GetMapping("/driver_id/{id}") - public R> selectByDriverId(@NotNull @PathVariable(value = "id") Long id) { + public Mono>> selectByDriverId(@NotNull @PathVariable(value = "id") Long id) { try { List entityBOList = driverAttributeService.selectByDriverId(id); List entityVO = driverAttributeBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (NotFoundException ne) { - return R.ok(new ArrayList<>()); + return Mono.just(R.ok(Collections.emptyList())); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -156,7 +157,7 @@ public class DriverAttributeController implements BaseController { * @return Page Of DriverAttribute */ @PostMapping("/list") - public R> list(@RequestBody(required = false) DriverAttributeQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) DriverAttributeQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DriverAttributeQuery(); @@ -164,10 +165,10 @@ public class DriverAttributeController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = driverAttributeService.selectByPage(entityQuery); Page entityPageVO = driverAttributeBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverController.java index deb762dc3..d4d584abf 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/DriverController.java @@ -32,6 +32,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.List; import java.util.Map; @@ -65,15 +66,15 @@ public class DriverController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody DriverVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody DriverVO entityVO) { try { DriverBO entityBO = driverBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); driverService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -84,13 +85,13 @@ public class DriverController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { driverService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -101,14 +102,14 @@ public class DriverController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody DriverVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody DriverVO entityVO) { try { DriverBO entityBO = driverBuilder.buildBOByVO(entityVO); driverService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -119,14 +120,14 @@ public class DriverController implements BaseController { * @return DriverVO {@link DriverVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { DriverBO entityBO = driverService.selectById(id); DriverVO entityVO = driverBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -137,14 +138,14 @@ public class DriverController implements BaseController { * @return Map(ID, DriverVO) */ @PostMapping("/ids") - public R> selectByIds(@RequestBody Set driverIds) { + public Mono>> selectByIds(@RequestBody Set driverIds) { try { List entityBOList = driverService.selectByIds(driverIds); Map driverMap = entityBOList.stream().collect(Collectors.toMap(DriverBO::getId, entityBO -> driverBuilder.buildVOByBO(entityBO))); - return R.ok(driverMap); + return Mono.just(R.ok(driverMap)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -155,14 +156,14 @@ public class DriverController implements BaseController { * @return Driver */ @GetMapping("/service/{serviceName}") - public R selectByServiceName(@NotNull @PathVariable(value = "serviceName") String serviceName) { + public Mono> selectByServiceName(@NotNull @PathVariable(value = "serviceName") String serviceName) { try { DriverBO entityBO = driverService.selectByServiceName(serviceName, getTenantId()); DriverVO entityVO = driverBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -173,7 +174,7 @@ public class DriverController implements BaseController { * @return Page Of Driver */ @PostMapping("/list") - public R> list(@RequestBody(required = false) DriverQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) DriverQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new DriverQuery(); @@ -181,10 +182,10 @@ public class DriverController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = driverService.selectByPage(entityQuery); Page entityPageVO = driverBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/GroupController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/GroupController.java index 9291bbd6e..81639dd28 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/GroupController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/GroupController.java @@ -32,6 +32,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -61,15 +62,15 @@ public class GroupController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody GroupVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody GroupVO entityVO) { try { GroupBO entityBO = groupForManagerBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); groupService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -80,13 +81,13 @@ public class GroupController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { groupService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -97,14 +98,14 @@ public class GroupController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody GroupVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody GroupVO entityVO) { try { GroupBO entityBO = groupForManagerBuilder.buildBOByVO(entityVO); groupService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -115,14 +116,14 @@ public class GroupController implements BaseController { * @return GroupVO {@link GroupVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { GroupBO entityBO = groupService.selectById(id); GroupVO entityVO = groupForManagerBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -133,7 +134,7 @@ public class GroupController implements BaseController { * @return R Of GroupVO Page */ @PostMapping("/list") - public R> list(@RequestBody(required = false) GroupQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) GroupQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new GroupQuery(); @@ -141,10 +142,10 @@ public class GroupController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = groupService.selectByPage(entityQuery); Page entityPageVO = groupForManagerBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/LabelController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/LabelController.java index 718548f6f..d605a2654 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/LabelController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/LabelController.java @@ -32,6 +32,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.Objects; @@ -61,15 +62,15 @@ public class LabelController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody LabelVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody LabelVO entityVO) { try { LabelBO entityBO = labelForManagerBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); labelService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -80,13 +81,13 @@ public class LabelController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { labelService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -97,14 +98,14 @@ public class LabelController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody LabelVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody LabelVO entityVO) { try { LabelBO entityBO = labelForManagerBuilder.buildBOByVO(entityVO); labelService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -115,14 +116,14 @@ public class LabelController implements BaseController { * @return LabelVO {@link LabelVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { LabelBO entityBO = labelService.selectById(id); LabelVO entityVO = labelForManagerBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -133,7 +134,7 @@ public class LabelController implements BaseController { * @return R Of LabelVO Page */ @PostMapping("/list") - public R> list(@RequestBody(required = false) LabelQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) LabelQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new LabelQuery(); @@ -141,10 +142,10 @@ public class LabelController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = labelService.selectByPage(entityQuery); Page entityPageVO = labelForManagerBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointAttributeConfigController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointAttributeConfigController.java index bba84e16b..baffcdd91 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointAttributeConfigController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointAttributeConfigController.java @@ -32,6 +32,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.List; import java.util.Objects; @@ -62,15 +63,15 @@ public class PointAttributeConfigController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody PointAttributeConfigVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody PointAttributeConfigVO entityVO) { try { PointAttributeConfigBO entityBO = pointAttributeConfigBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); pointAttributeConfigService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -81,13 +82,13 @@ public class PointAttributeConfigController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { pointAttributeConfigService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -98,14 +99,14 @@ public class PointAttributeConfigController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody PointAttributeConfigVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody PointAttributeConfigVO entityVO) { try { PointAttributeConfigBO entityBO = pointAttributeConfigBuilder.buildBOByVO(entityVO); pointAttributeConfigService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -116,14 +117,14 @@ public class PointAttributeConfigController implements BaseController { * @return PointAttributeConfigVO {@link PointAttributeConfigVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { PointAttributeConfigBO entityBO = pointAttributeConfigService.selectById(id); PointAttributeConfigVO entityVO = pointAttributeConfigBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -136,16 +137,16 @@ public class PointAttributeConfigController implements BaseController { * @return PointConfig */ @GetMapping("/attribute_id/{attributeId}/device_id/{deviceId}/point_id/{pointId}") - public R selectByAttributeIdAndDeviceIdAndPointId(@NotNull @PathVariable(value = "attributeId") Long attributeId, - @NotNull @PathVariable(value = "deviceId") Long deviceId, - @NotNull @PathVariable(value = "pointId") Long pointId) { + public Mono> selectByAttributeIdAndDeviceIdAndPointId(@NotNull @PathVariable(value = "attributeId") Long attributeId, + @NotNull @PathVariable(value = "deviceId") Long deviceId, + @NotNull @PathVariable(value = "pointId") Long pointId) { try { PointAttributeConfigBO entityBO = pointAttributeConfigService.selectByAttributeIdAndDeviceIdAndPointId(attributeId, deviceId, pointId); PointAttributeConfigVO entityVO = pointAttributeConfigBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -157,15 +158,15 @@ public class PointAttributeConfigController implements BaseController { * @return PointConfig */ @GetMapping("/device_id/{deviceId}/point_id/{pointId}") - public R> selectByDeviceIdAndPointId(@NotNull @PathVariable(value = "deviceId") Long deviceId, - @NotNull @PathVariable(value = "pointId") Long pointId) { + public Mono>> selectByDeviceIdAndPointId(@NotNull @PathVariable(value = "deviceId") Long deviceId, + @NotNull @PathVariable(value = "pointId") Long pointId) { try { List entityBOList = pointAttributeConfigService.selectByDeviceIdAndPointId(deviceId, pointId); List entityVOList = pointAttributeConfigBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVOList); + return Mono.just(R.ok(entityVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -176,13 +177,13 @@ public class PointAttributeConfigController implements BaseController { * @return PointConfig */ @GetMapping("/device_id/{deviceId}") - public R> selectByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { + public Mono>> selectByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { try { List entityBOList = pointAttributeConfigService.selectByDeviceId(deviceId); List entityVOList = pointAttributeConfigBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVOList); + return Mono.just(R.ok(entityVOList)); } catch (Exception e) { - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -193,7 +194,7 @@ public class PointAttributeConfigController implements BaseController { * @return Page Of PointConfig */ @PostMapping("/list") - public R> list(@RequestBody(required = false) PointAttributeConfigQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) PointAttributeConfigQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new PointAttributeConfigQuery(); @@ -201,9 +202,9 @@ public class PointAttributeConfigController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = pointAttributeConfigService.selectByPage(entityQuery); Page entityPageVO = pointAttributeConfigBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointAttributeController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointAttributeController.java index 106f3cf4c..5024806be 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointAttributeController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointAttributeController.java @@ -33,8 +33,9 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -64,15 +65,15 @@ public class PointAttributeController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody PointAttributeVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody PointAttributeVO entityVO) { try { PointAttributeBO entityBO = pointAttributeBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); pointAttributeService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -83,13 +84,13 @@ public class PointAttributeController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { pointAttributeService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -100,14 +101,14 @@ public class PointAttributeController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody PointAttributeVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody PointAttributeVO entityVO) { try { PointAttributeBO entityBO = pointAttributeBuilder.buildBOByVO(entityVO); pointAttributeService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -118,14 +119,14 @@ public class PointAttributeController implements BaseController { * @return PointAttributeVO {@link PointAttributeVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { PointAttributeBO entityBO = pointAttributeService.selectById(id); PointAttributeVO entityVO = pointAttributeBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -136,16 +137,16 @@ public class PointAttributeController implements BaseController { * @return 位号属性Array */ @GetMapping("/driver_id/{id}") - public R> selectByDriverId(@NotNull @PathVariable(value = "id") Long id) { + public Mono>> selectByDriverId(@NotNull @PathVariable(value = "id") Long id) { try { List entityBOList = pointAttributeService.selectByDriverId(id); List entityVO = pointAttributeBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (NotFoundException ne) { - return R.ok(new ArrayList<>()); + return Mono.just(R.ok(Collections.emptyList())); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -156,7 +157,7 @@ public class PointAttributeController implements BaseController { * @return Page Of PointAttribute */ @PostMapping("/list") - public R> list(@RequestBody(required = false) PointAttributeQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) PointAttributeQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new PointAttributeQuery(); @@ -164,10 +165,10 @@ public class PointAttributeController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = pointAttributeService.selectByPage(entityQuery); Page entityPageVO = pointAttributeBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointController.java index 02e074982..ce206b464 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/PointController.java @@ -34,6 +34,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.List; import java.util.Map; @@ -69,15 +70,15 @@ public class PointController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody PointVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody PointVO entityVO) { try { PointBO entityBO = pointBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); pointService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -88,13 +89,13 @@ public class PointController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { pointService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -105,14 +106,14 @@ public class PointController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody PointVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody PointVO entityVO) { try { PointBO entityBO = pointBuilder.buildBOByVO(entityVO); pointService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -123,14 +124,14 @@ public class PointController implements BaseController { * @return PointVO {@link PointVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { PointBO entityBO = pointService.selectById(id); PointVO entityVO = pointBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -141,14 +142,14 @@ public class PointController implements BaseController { * @return Map(ID, PointVO) */ @PostMapping("/ids") - public R> selectByIds(@RequestBody Set pointIds) { + public Mono>> selectByIds(@RequestBody Set pointIds) { try { List entityBOList = pointService.selectByIds(pointIds); Map deviceMap = entityBOList.stream().collect(Collectors.toMap(PointBO::getId, entityBO -> pointBuilder.buildVOByBO(entityBO))); - return R.ok(deviceMap); + return Mono.just(R.ok(deviceMap)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -159,14 +160,14 @@ public class PointController implements BaseController { * @return Point 集合 */ @GetMapping("/profile_id/{profileId}") - public R> selectByProfileId(@NotNull @PathVariable(value = "profileId") Long profileId) { + public Mono>> selectByProfileId(@NotNull @PathVariable(value = "profileId") Long profileId) { try { List entityBOList = pointService.selectByProfileId(profileId); List entityVOList = pointBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVOList); + return Mono.just(R.ok(entityVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -177,14 +178,14 @@ public class PointController implements BaseController { * @return Point Array */ @GetMapping("/device_id/{deviceId}") - public R> selectByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { + public Mono>> selectByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { try { List entityBOList = pointService.selectByDeviceId(deviceId); List entityVOList = pointBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVOList); + return Mono.just(R.ok(entityVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -195,7 +196,7 @@ public class PointController implements BaseController { * @return Page Of Point */ @PostMapping("/list") - public R> list(@RequestBody(required = false) PointQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) PointQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new PointQuery(); @@ -203,10 +204,10 @@ public class PointController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = pointService.selectByPage(entityQuery); Page entityPageVO = pointBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -217,18 +218,18 @@ public class PointController implements BaseController { * @return Map String:String */ @PostMapping("/unit") - public R> unit(@RequestBody Set pointIds) { + public Mono>> unit(@RequestBody Set pointIds) { try { Map units = pointService.unit(pointIds); if (!Objects.isNull(units)) { Map unitCodeMap = units.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - return R.ok(unitCodeMap); + return Mono.just(R.ok(unitCodeMap)); } } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } - return R.fail(); + return Mono.just(R.fail()); } @@ -240,14 +241,14 @@ public class PointController implements BaseController { * @return {@link R}<{@link Set}<{@link Long}>> */ @GetMapping("/selectPointStatisticsWithDevice/{pointId}") - public R selectPointStatisticsWithDevice(@NotNull @PathVariable(value = "pointId") Long pointId) { + public Mono> selectPointStatisticsWithDevice(@NotNull @PathVariable(value = "pointId") Long pointId) { try { DeviceByPointBO deviceByPointBO = pointService.selectPointStatisticsWithDevice(pointId); DeviceByPointVO deviceByPointVO = deviceBuilder.buildVOPointByBO(deviceByPointBO); - return R.ok(deviceByPointVO); + return Mono.just(R.ok(deviceByPointVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -261,14 +262,14 @@ public class PointController implements BaseController { * @return {@link R}<{@link Map}<{@link Long}, {@link String}>> */ @PostMapping("/selectPointStatisticsByDeviceId/{pointId}") - public R> selectPointStatisticsByDeviceId(@NotNull @PathVariable(value = "pointId") Long pointId, @NotNull @RequestBody Set deviceIds) { + public Mono>> selectPointStatisticsByDeviceId(@NotNull @PathVariable(value = "pointId") Long pointId, @NotNull @RequestBody Set deviceIds) { try { List list = pointService.selectPointStatisticsByDeviceId(pointId, deviceIds); List pointDataVolumeRunVO = pointBuilder.buildVOPointDataByBO(list); - return R.ok(pointDataVolumeRunVO); + return Mono.just(R.ok(pointDataVolumeRunVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -280,13 +281,13 @@ public class PointController implements BaseController { * @return {@link R}<{@link Map}<{@link Long}, {@link String}>> */ @GetMapping("/selectPointStatisticsByPointId/{pointId}") - public R selectPointStatisticsByPointId(@NotNull @PathVariable(value = "pointId") Long pointId) { + public Mono> selectPointStatisticsByPointId(@NotNull @PathVariable(value = "pointId") Long pointId) { try { PointDataVolumeRunDO pointDataVolumeRunDO = pointService.selectPointStatisticsByPointId(pointId); - return R.ok(Objects.isNull(pointDataVolumeRunDO.getTotal()) ? 0 : pointDataVolumeRunDO.getTotal()); + return Mono.just(R.ok(Objects.isNull(pointDataVolumeRunDO.getTotal()) ? 0 : pointDataVolumeRunDO.getTotal())); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -297,13 +298,13 @@ public class PointController implements BaseController { * @return */ @GetMapping("/selectPointByDeviceId/{deviceId}") - public R selectPointByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { + public Mono> selectPointByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { try { Long count = pointService.selectPointByDeviceId(deviceId); - return R.ok(count); + return Mono.just(R.ok(count)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -314,14 +315,14 @@ public class PointController implements BaseController { * @return */ @GetMapping("/selectPointConfigByDeviceId/{deviceId}") - public R selectPointConfigByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { + public Mono> selectPointConfigByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { try { PointConfigByDeviceBO pointConfigByDeviceBO = pointService.selectPointConfigByDeviceId(deviceId); PointConfigByDeviceVO pointConfigByDeviceVO = pointBuilder.buildVODeviceByBO(pointConfigByDeviceBO); - return R.ok(pointConfigByDeviceVO); + return Mono.just(R.ok(pointConfigByDeviceVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -334,14 +335,14 @@ public class PointController implements BaseController { * @return */ @PostMapping("/selectDeviceStatisticsByPointId/{deviceId}") - public R> selectDeviceStatisticsByPointId(@NotNull @PathVariable(value = "deviceId") Long deviceId, @NotNull @RequestBody Set pointIds) { + public Mono>> selectDeviceStatisticsByPointId(@NotNull @PathVariable(value = "deviceId") Long deviceId, @NotNull @RequestBody Set pointIds) { try { List list = pointService.selectDeviceStatisticsByPointId(deviceId, pointIds); List deviceDataVolumeRunVOList = pointBuilder.buildVODeviceDataByBO(list); - return R.ok(deviceDataVolumeRunVOList); + return Mono.just(R.ok(deviceDataVolumeRunVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -352,13 +353,13 @@ public class PointController implements BaseController { * @return */ @GetMapping("/selectPointDataByDriverId/{driverId}") - public R selectPointDataByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono> selectPointDataByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { PointDataVolumeRunDO pointDataVolumeRunDO = pointService.selectPointDataByDriverId(driverId); - return R.ok(Objects.isNull(pointDataVolumeRunDO.getTotal()) ? 0 : pointDataVolumeRunDO.getTotal()); + return Mono.just(R.ok(Objects.isNull(pointDataVolumeRunDO.getTotal()) ? 0 : pointDataVolumeRunDO.getTotal())); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -369,25 +370,25 @@ public class PointController implements BaseController { * @return */ @GetMapping("/selectPointByDriverId/{driverId}") - public R selectPointByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono> selectPointByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { Long result = pointService.selectPointByDriverId(driverId); - return R.ok(result); + return Mono.just(R.ok(result)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @GetMapping("/selectPointDataStatisticsByDriverId/{driverId}") - public R selectPointDataStatisticsByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { + public Mono> selectPointDataStatisticsByDriverId(@NotNull @PathVariable(value = "driverId") Long driverId) { try { PointDataStatisticsByDriverIdBO pointDataStatisticsByDriverIdBOList = pointService.selectPointDataStatisticsByDriverId(driverId); PointDataStatisticsByDriverIdVO pointDataStatisticsByDriverIdVOList = pointBuilder.buildVOPointDataDriverByBO(pointDataStatisticsByDriverIdBOList); - return R.ok(pointDataStatisticsByDriverIdVOList); + return Mono.just(R.ok(pointDataStatisticsByDriverIdVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/ProfileController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/ProfileController.java index 718223e42..6edd96b21 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/ProfileController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/ProfileController.java @@ -32,6 +32,7 @@ import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import reactor.core.publisher.Mono; import java.util.List; import java.util.Map; @@ -65,15 +66,15 @@ public class ProfileController implements BaseController { * @return R of String */ @PostMapping("/add") - public R add(@Validated(Add.class) @RequestBody ProfileVO entityVO) { + public Mono> add(@Validated(Add.class) @RequestBody ProfileVO entityVO) { try { ProfileBO entityBO = profileBuilder.buildBOByVO(entityVO); entityBO.setTenantId(getTenantId()); profileService.save(entityBO); - return R.ok(ResponseEnum.ADD_SUCCESS); + return Mono.just(R.ok(ResponseEnum.ADD_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -84,13 +85,13 @@ public class ProfileController implements BaseController { * @return R of String */ @PostMapping("/delete/{id}") - public R delete(@NotNull @PathVariable(value = "id") Long id) { + public Mono> delete(@NotNull @PathVariable(value = "id") Long id) { try { profileService.remove(id); - return R.ok(ResponseEnum.DELETE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.DELETE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -101,14 +102,14 @@ public class ProfileController implements BaseController { * @return R of String */ @PostMapping("/update") - public R update(@Validated(Update.class) @RequestBody ProfileVO entityVO) { + public Mono> update(@Validated(Update.class) @RequestBody ProfileVO entityVO) { try { ProfileBO entityBO = profileBuilder.buildBOByVO(entityVO); profileService.update(entityBO); - return R.ok(ResponseEnum.UPDATE_SUCCESS); + return Mono.just(R.ok(ResponseEnum.UPDATE_SUCCESS)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -119,14 +120,14 @@ public class ProfileController implements BaseController { * @return ProfileVO {@link ProfileVO} */ @GetMapping("/id/{id}") - public R selectById(@NotNull @PathVariable(value = "id") Long id) { + public Mono> selectById(@NotNull @PathVariable(value = "id") Long id) { try { ProfileBO entityBO = profileService.selectById(id); ProfileVO entityVO = profileBuilder.buildVOByBO(entityBO); - return R.ok(entityVO); + return Mono.just(R.ok(entityVO)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -137,14 +138,14 @@ public class ProfileController implements BaseController { * @return Map(ID, ProfileVO) */ @PostMapping("/ids") - public R> selectByIds(@RequestBody Set profileIds) { + public Mono>> selectByIds(@RequestBody Set profileIds) { try { List entityBOList = profileService.selectByIds(profileIds); Map deviceMap = entityBOList.stream().collect(Collectors.toMap(ProfileBO::getId, entityBO -> profileBuilder.buildVOByBO(entityBO))); - return R.ok(deviceMap); + return Mono.just(R.ok(deviceMap)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -155,14 +156,14 @@ public class ProfileController implements BaseController { * @return Profile 集合 */ @GetMapping("/device_id/{deviceId}") - public R> selectByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { + public Mono>> selectByDeviceId(@NotNull @PathVariable(value = "deviceId") Long deviceId) { try { List entityBOList = profileService.selectByDeviceId(deviceId); List entityVOList = profileBuilder.buildVOListByBOList(entityBOList); - return R.ok(entityVOList); + return Mono.just(R.ok(entityVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } @@ -173,7 +174,7 @@ public class ProfileController implements BaseController { * @return Page Of Profile */ @PostMapping("/list") - public R> list(@RequestBody(required = false) ProfileQuery entityQuery) { + public Mono>> list(@RequestBody(required = false) ProfileQuery entityQuery) { try { if (Objects.isNull(entityQuery)) { entityQuery = new ProfileQuery(); @@ -181,9 +182,9 @@ public class ProfileController implements BaseController { entityQuery.setTenantId(getTenantId()); Page entityPageBO = profileService.selectByPage(entityQuery); Page entityPageVO = profileBuilder.buildVOPageByBOPage(entityPageBO); - return R.ok(entityPageVO); + return Mono.just(R.ok(entityPageVO)); } catch (Exception e) { - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } diff --git a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/TopicController.java b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/TopicController.java index 6d4edb07b..ad8476f32 100644 --- a/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/TopicController.java +++ b/dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/controller/TopicController.java @@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; import java.util.List; @@ -45,13 +46,13 @@ public class TopicController implements BaseController { } @PostMapping("/list") - public R>> query(@RequestBody(required = false) TopicQuery topicQuery) { + public Mono>>> query(@RequestBody(required = false) TopicQuery topicQuery) { try { Page> topicVOList = topicService.query(topicQuery); - return R.ok(topicVOList); + return Mono.just(R.ok(topicVOList)); } catch (Exception e) { log.error(e.getMessage(), e); - return R.fail(e.getMessage()); + return Mono.just(R.fail(e.getMessage())); } } } diff --git a/dc3-center/dc3-center-manager/src/main/resources/application-dev.yml b/dc3-center/dc3-center-manager/src/main/resources/application-dev.yml index 2b11a8da3..14ec70d74 100644 --- a/dc3-center/dc3-center-manager/src/main/resources/application-dev.yml +++ b/dc3-center/dc3-center-manager/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 spring: env: dev group: ${user.name} diff --git a/dc3-center/dc3-center-manager/src/main/resources/application-pre.yml b/dc3-center/dc3-center-manager/src/main/resources/application-pre.yml index 5bc470f4c..74737660a 100644 --- a/dc3-center/dc3-center-manager/src/main/resources/application-pre.yml +++ b/dc3-center/dc3-center-manager/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_manager}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-manager/src/main/resources/application-pro.yml b/dc3-center/dc3-center-manager/src/main/resources/application-pro.yml index 0c96494ea..7e55920b8 100644 --- a/dc3-center/dc3-center-manager/src/main/resources/application-pro.yml +++ b/dc3-center/dc3-center-manager/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_manager}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-center/dc3-center-manager/src/main/resources/application-test.yml b/dc3-center/dc3-center-manager/src/main/resources/application-test.yml index f6f709863..a3655d648 100644 --- a/dc3-center/dc3-center-manager/src/main/resources/application-test.yml +++ b/dc3-center/dc3-center-manager/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 spring: datasource: url: jdbc:mysql://${MYSQL_HOST:dc3-mysql}:${MYSQL_PORT:3306}/${MYSQL_DB:dc3_manager}?allowPublicKeyRetrieval=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai diff --git a/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-dev.yml index 6fde3e48e..33b92a161 100644 --- a/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-pre.yml index 31549e278..d726bd0ff 100644 --- a/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-pro.yml index 4dbfafd00..0b3d5dded 100644 --- a/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-test.yml index cc9d13edc..c90105ef0 100644 --- a/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-dtu-yeecom/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-dev.yml index 0f4432c02..1fa21fcb0 100644 --- a/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-pre.yml index eba890978..51d480955 100644 --- a/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-pro.yml index eb4465aad..f7d6bad8b 100644 --- a/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-test.yml index 97755af5d..cd6643c39 100644 --- a/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-edge-gateway/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-dev.yml index 6fde3e48e..33b92a161 100644 --- a/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-pre.yml index 31549e278..d726bd0ff 100644 --- a/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-pro.yml index 4dbfafd00..0b3d5dded 100644 --- a/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-test.yml index 002e1a285..77858fb7e 100644 --- a/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-listening-virtual/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-lwm2m/pom.xml b/dc3-driver/dc3-driver-lwm2m/pom.xml index b59df2f04..5a5676b33 100644 --- a/dc3-driver/dc3-driver-lwm2m/pom.xml +++ b/dc3-driver/dc3-driver-lwm2m/pom.xml @@ -35,11 +35,6 @@ leshan-server-cf 2.0.0-M10 - - - - - \ No newline at end of file diff --git a/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-dev.yml index 6fde3e48e..33b92a161 100644 --- a/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-pre.yml index 31549e278..d726bd0ff 100644 --- a/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-pro.yml index 4dbfafd00..0b3d5dded 100644 --- a/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-test.yml index cc9d13edc..c90105ef0 100644 --- a/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-lwm2m/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-dev.yml index 6fde3e48e..33b92a161 100644 --- a/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-pre.yml index 31549e278..d726bd0ff 100644 --- a/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-pro.yml index 4dbfafd00..0b3d5dded 100644 --- a/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-test.yml index 002e1a285..77858fb7e 100644 --- a/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-modbus-tcp/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-mqtt/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-mqtt/src/main/resources/application-dev.yml index 0f4432c02..1fa21fcb0 100644 --- a/dc3-driver/dc3-driver-mqtt/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-mqtt/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-mqtt/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-mqtt/src/main/resources/application-pre.yml index eba890978..51d480955 100644 --- a/dc3-driver/dc3-driver-mqtt/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-mqtt/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-mqtt/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-mqtt/src/main/resources/application-pro.yml index eb4465aad..f7d6bad8b 100644 --- a/dc3-driver/dc3-driver-mqtt/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-mqtt/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-mqtt/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-mqtt/src/main/resources/application-test.yml index 97755af5d..cd6643c39 100644 --- a/dc3-driver/dc3-driver-mqtt/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-mqtt/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-opc-da/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-opc-da/src/main/resources/application-dev.yml index c6bca8b41..5b86c762f 100644 --- a/dc3-driver/dc3-driver-opc-da/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-opc-da/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-opc-da/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-opc-da/src/main/resources/application-pre.yml index 31549e278..d726bd0ff 100644 --- a/dc3-driver/dc3-driver-opc-da/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-opc-da/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-opc-da/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-opc-da/src/main/resources/application-pro.yml index 4dbfafd00..0b3d5dded 100644 --- a/dc3-driver/dc3-driver-opc-da/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-opc-da/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-opc-da/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-opc-da/src/main/resources/application-test.yml index cc9d13edc..c90105ef0 100644 --- a/dc3-driver/dc3-driver-opc-da/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-opc-da/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-dev.yml index 6fde3e48e..33b92a161 100644 --- a/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-pre.yml index 31549e278..d726bd0ff 100644 --- a/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-pro.yml index 4dbfafd00..0b3d5dded 100644 --- a/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-test.yml index cc9d13edc..c90105ef0 100644 --- a/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-opc-ua/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-plcs7/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-plcs7/src/main/resources/application-dev.yml index 6fde3e48e..33b92a161 100644 --- a/dc3-driver/dc3-driver-plcs7/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-plcs7/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-plcs7/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-plcs7/src/main/resources/application-pre.yml index 31549e278..d726bd0ff 100644 --- a/dc3-driver/dc3-driver-plcs7/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-plcs7/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-plcs7/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-plcs7/src/main/resources/application-pro.yml index 4dbfafd00..0b3d5dded 100644 --- a/dc3-driver/dc3-driver-plcs7/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-plcs7/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-plcs7/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-plcs7/src/main/resources/application-test.yml index cc9d13edc..c90105ef0 100644 --- a/dc3-driver/dc3-driver-plcs7/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-plcs7/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-virtual/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-virtual/src/main/resources/application-dev.yml index 2d7e09982..ace8a8db9 100644 --- a/dc3-driver/dc3-driver-virtual/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-virtual/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-virtual/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-virtual/src/main/resources/application-pre.yml index ccfca9073..7181dece8 100644 --- a/dc3-driver/dc3-driver-virtual/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-virtual/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-virtual/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-virtual/src/main/resources/application-pro.yml index 84171f017..3746f9e93 100644 --- a/dc3-driver/dc3-driver-virtual/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-virtual/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-virtual/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-virtual/src/main/resources/application-test.yml index e0c704363..d79151885 100644 --- a/dc3-driver/dc3-driver-virtual/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-virtual/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-dev.yml b/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-dev.yml index 86a60ed70..9a2e8f8e4 100644 --- a/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-dev.yml +++ b/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-pre.yml b/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-pre.yml index 31549e278..d726bd0ff 100644 --- a/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-pre.yml +++ b/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-pro.yml b/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-pro.yml index 4dbfafd00..0b3d5dded 100644 --- a/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-pro.yml +++ b/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-test.yml b/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-test.yml index cc9d13edc..c90105ef0 100644 --- a/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-test.yml +++ b/dc3-driver/dc3-driver-weather-amap/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 driver: schedule: # 定时读数据 diff --git a/dc3-gateway/src/main/java/io/github/pnoker/gateway/GatewayApplication.java b/dc3-gateway/src/main/java/io/github/pnoker/gateway/GatewayApplication.java index cb4374a24..71858089f 100644 --- a/dc3-gateway/src/main/java/io/github/pnoker/gateway/GatewayApplication.java +++ b/dc3-gateway/src/main/java/io/github/pnoker/gateway/GatewayApplication.java @@ -27,8 +27,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; * @since 2022.1.0 */ @SpringBootApplication -// 开发环境无需注册中心 -// @EnableDiscoveryClient @EnableTransactionManagement public class GatewayApplication { diff --git a/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/ExceptionConfig.java b/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/ExceptionConfig.java deleted file mode 100644 index 2725dd511..000000000 --- a/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/ExceptionConfig.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2016-present the IoT DC3 original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.github.pnoker.gateway.config; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.github.pnoker.common.entity.R; -import jakarta.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler; -import org.springframework.core.annotation.Order; -import org.springframework.core.io.buffer.DataBufferFactory; -import org.springframework.http.MediaType; -import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; -import org.springframework.web.server.ResponseStatusException; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.server.handler.ResponseStatusExceptionHandler; -import reactor.core.publisher.Mono; - -/** - * 网关异常通用处理器, 只作用在webflux 环境下 , 优先级低于 {@link ResponseStatusExceptionHandler} 执行 - * - * @author pnoker - * @since 2022.1.0 - */ -@Slf4j -@Order(-1) -@Component -public class ExceptionConfig implements ErrorWebExceptionHandler { - - @Resource - private ObjectMapper objectMapper; - - @NonNull - @Override - public Mono handle(ServerWebExchange exchange, @NonNull Throwable throwable) { - ServerHttpResponse response = exchange.getResponse(); - - if (response.isCommitted()) { - return Mono.error(throwable); - } - - response.getHeaders().setContentType(MediaType.APPLICATION_JSON); - if (throwable instanceof ResponseStatusException) { - response.setStatusCode(((ResponseStatusException) throwable).getStatusCode()); - } - - return response.writeWith(Mono.fromSupplier(() -> { - DataBufferFactory bufferFactory = response.bufferFactory(); - try { - return bufferFactory.wrap(objectMapper.writeValueAsBytes(R.fail(throwable.getMessage()))); - } catch (Exception e) { - log.error(e.getMessage(), e); - return bufferFactory.wrap(new byte[0]); - } - })); - } - -} \ No newline at end of file diff --git a/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/GatewayConfig.java b/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/GatewayConfig.java index d2ddc8fa9..a76f44bdb 100644 --- a/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/GatewayConfig.java +++ b/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/GatewayConfig.java @@ -17,21 +17,22 @@ package io.github.pnoker.gateway.config; import io.github.pnoker.gateway.fallback.GatewayFallback; -import io.github.pnoker.gateway.filter.LimitedIpGlobalFilter; -import io.github.pnoker.gateway.filter.factory.AuthenticGatewayFilterFactory; import lombok.extern.slf4j.Slf4j; -import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; +import org.springframework.cloud.gateway.filter.ratelimit.RedisRateLimiter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.server.RequestPredicates; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; +import reactor.core.publisher.Mono; + +import java.util.Objects; /** - * 网关配置 + * 自定义Route配置 * * @author pnoker * @since 2022.1.0 @@ -39,31 +40,40 @@ import org.springframework.web.reactive.function.server.ServerResponse; @Slf4j @Configuration public class GatewayConfig { + private final GatewayFallback gatewayFallback; public GatewayConfig(GatewayFallback gatewayFallback) { this.gatewayFallback = gatewayFallback; } + /** + * 根据 HostAddress 进行限流 + * + * @return KeyResolver + */ @Bean - @LoadBalanced - public WebClient.Builder loadBalancedWebClientBuilder() { - return WebClient.builder(); + public KeyResolver hostKeyResolver() { + return exchange -> Mono.just(Objects.requireNonNull(exchange.getRequest().getRemoteAddress()).getHostString()); } + /** + * Redis 令牌桶 限流 + * + * @return RedisRateLimiter + */ @Bean - public LimitedIpGlobalFilter limitedIpGlobalFilter() { - return new LimitedIpGlobalFilter(); - } - - @Bean - public AuthenticGatewayFilterFactory authenticGatewayFilterFactory() { - return new AuthenticGatewayFilterFactory(); + RedisRateLimiter redisRateLimiter() { + return new RedisRateLimiter(100, 2000); } + /** + * fallback 配置 + * + * @return RouterFunction + */ @Bean public RouterFunction routerFunction() { return RouterFunctions.route(RequestPredicates.path("/fallback").and(RequestPredicates.accept(MediaType.APPLICATION_JSON)), gatewayFallback); } - -} \ No newline at end of file +} diff --git a/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/RouteConfig.java b/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/RouteConfig.java deleted file mode 100644 index 93eb98bc3..000000000 --- a/dc3-gateway/src/main/java/io/github/pnoker/gateway/config/RouteConfig.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2016-present the IoT DC3 original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.github.pnoker.gateway.config; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; -import org.springframework.cloud.gateway.filter.ratelimit.RedisRateLimiter; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import reactor.core.publisher.Mono; - -import java.util.Objects; - -/** - * 自定义Route配置 - * - * @author pnoker - * @since 2022.1.0 - */ -@Slf4j -@Configuration -public class RouteConfig { - - /** - * 根据 HostAddress 进行限流 - * - * @return KeyResolver - */ - @Bean - public KeyResolver hostKeyResolver() { - return exchange -> Mono.just(Objects.requireNonNull(exchange.getRequest().getRemoteAddress()).getHostString()); - } - - /** - * Redis 令牌桶 限流 - * - * @return RedisRateLimiter - */ - @Bean - RedisRateLimiter redisRateLimiter() { - return new RedisRateLimiter(100, 2000); - } -} diff --git a/dc3-gateway/src/main/java/io/github/pnoker/gateway/fallback/GatewayFallback.java b/dc3-gateway/src/main/java/io/github/pnoker/gateway/fallback/GatewayFallback.java index 825a4d492..f2e6ad01a 100644 --- a/dc3-gateway/src/main/java/io/github/pnoker/gateway/fallback/GatewayFallback.java +++ b/dc3-gateway/src/main/java/io/github/pnoker/gateway/fallback/GatewayFallback.java @@ -18,6 +18,7 @@ package io.github.pnoker.gateway.fallback; import io.github.pnoker.common.entity.R; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; import org.springframework.cloud.gateway.support.ServerWebExchangeUtils; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -41,6 +42,7 @@ import java.util.Optional; @Component public class GatewayFallback implements HandlerFunction { + @NotNull @Override public Mono handle(ServerRequest serverRequest) { log.info(serverRequest.toString()); diff --git a/dc3-gateway/src/main/java/io/github/pnoker/gateway/filter/LimitedIpGlobalFilter.java b/dc3-gateway/src/main/java/io/github/pnoker/gateway/filter/LimitedIpGlobalFilter.java index e362d5207..a1cdde2dd 100644 --- a/dc3-gateway/src/main/java/io/github/pnoker/gateway/filter/LimitedIpGlobalFilter.java +++ b/dc3-gateway/src/main/java/io/github/pnoker/gateway/filter/LimitedIpGlobalFilter.java @@ -23,6 +23,7 @@ import net.devh.boot.grpc.client.inject.GrpcClient; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.core.Ordered; +import org.springframework.stereotype.Component; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; @@ -33,6 +34,7 @@ import reactor.core.publisher.Mono; * @since 2022.1.0 */ @Slf4j +@Component public class LimitedIpGlobalFilter implements GlobalFilter, Ordered { @GrpcClient(AuthConstant.SERVICE_NAME) diff --git a/dc3-gateway/src/main/java/io/github/pnoker/gateway/filter/factory/AuthenticGatewayFilterFactory.java b/dc3-gateway/src/main/java/io/github/pnoker/gateway/filter/factory/AuthenticGatewayFilterFactory.java index 84fd9e0a9..600f7a0bd 100644 --- a/dc3-gateway/src/main/java/io/github/pnoker/gateway/filter/factory/AuthenticGatewayFilterFactory.java +++ b/dc3-gateway/src/main/java/io/github/pnoker/gateway/filter/factory/AuthenticGatewayFilterFactory.java @@ -17,7 +17,6 @@ package io.github.pnoker.gateway.filter.factory; import io.github.pnoker.gateway.filter.AuthenticGatewayFilter; -import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; @@ -34,8 +33,11 @@ import org.springframework.stereotype.Component; @Component public class AuthenticGatewayFilterFactory extends AbstractGatewayFilterFactory { - @Resource - private AuthenticGatewayFilter authenticGatewayFilter; + private final AuthenticGatewayFilter authenticGatewayFilter; + + public AuthenticGatewayFilterFactory(AuthenticGatewayFilter authenticGatewayFilter) { + this.authenticGatewayFilter = authenticGatewayFilter; + } @Override public GatewayFilter apply(Object config) { diff --git a/dc3-gateway/src/main/resources/application-dev.yml b/dc3-gateway/src/main/resources/application-dev.yml index 81e577af3..6223de01c 100644 --- a/dc3-gateway/src/main/resources/application-dev.yml +++ b/dc3-gateway/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Development environment, customizable configuration +# 开发环境配置, 会覆盖 application-*.yml 中配置的内容 spring: env: dev group: ${user.name} diff --git a/dc3-gateway/src/main/resources/application-pre.yml b/dc3-gateway/src/main/resources/application-pre.yml index 0d9434886..ddc3b2859 100644 --- a/dc3-gateway/src/main/resources/application-pre.yml +++ b/dc3-gateway/src/main/resources/application-pre.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Pre-release environment, customizable configuration +# 预发布环境配置, 会覆盖 application-*.yml 中配置的内容 spring: data: redis: diff --git a/dc3-gateway/src/main/resources/application-pro.yml b/dc3-gateway/src/main/resources/application-pro.yml index 0ebdf8d71..2ec5f7072 100644 --- a/dc3-gateway/src/main/resources/application-pro.yml +++ b/dc3-gateway/src/main/resources/application-pro.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Product environment, customizable configuration +# 生产环境配置, 会覆盖 application-*.yml 中配置的内容 spring: data: redis: diff --git a/dc3-gateway/src/main/resources/application-test.yml b/dc3-gateway/src/main/resources/application-test.yml index 1d71c50c7..cc973b911 100644 --- a/dc3-gateway/src/main/resources/application-test.yml +++ b/dc3-gateway/src/main/resources/application-test.yml @@ -14,7 +14,7 @@ # limitations under the License. # -# Test environment, customizable configuration +# 测试环境配置, 会覆盖 application-*.yml 中配置的内容 spring: data: redis: