From a3516019c445eb6c643c202af114d7a93bb77704 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Mon, 26 Jun 2023 20:53:58 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=907.6.0=E3=80=91=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=B4=E6=97=B6devops=E7=9A=84=E6=8E=A7=E5=88=B6=E5=99=A8?= =?UTF-8?q?=E5=92=8C=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demo/controller/DemoController.java | 54 ------------ .../demo/controller/DevOpsController.java | 82 +++++++++++++++++++ src/main/resources/application-dev.yml | 5 ++ src/main/resources/application-local.yml | 5 ++ 4 files changed, 92 insertions(+), 54 deletions(-) delete mode 100644 src/main/java/cn/stylefeng/guns/modular/demo/controller/DemoController.java create mode 100644 src/main/java/cn/stylefeng/guns/modular/demo/controller/DevOpsController.java diff --git a/src/main/java/cn/stylefeng/guns/modular/demo/controller/DemoController.java b/src/main/java/cn/stylefeng/guns/modular/demo/controller/DemoController.java deleted file mode 100644 index 7b7afdb8..00000000 --- a/src/main/java/cn/stylefeng/guns/modular/demo/controller/DemoController.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.stylefeng.guns.modular.demo.controller; - -import cn.hutool.core.lang.Dict; -import cn.stylefeng.guns.modular.demo.service.DemoService; -import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData; -import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData; -import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource; -import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource; -import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; - -/** - * 示例控制器 - * - * @author fengshuonan - * @since 2021/1/24 10:57 - */ -@RestController -@ApiResource(name = "示例") -public class DemoController { - - @Resource - private DemoService demoService; - - /** - * 示例方法 - * - * @author fengshuonan - * @since 2021/1/24 10:59 - */ - @GetResource(name = "示例方法", path = "/json/success") - public ResponseData renderSuccess() { - demoService.demoService(); - return new SuccessResponseData<>(); - } - - /** - * 示例加密方法 - *

- * requiredEncryption = true - *

- * - * @author fengshuonan - * @since 2021/1/24 10:59 - */ - @PostResource(name = "示例加密方法", path = "/encode", requiredPermission = false, requiredLogin = false, requiredEncryption = true) - public ResponseData encode(@RequestBody Dict dict) { - return new SuccessResponseData<>(dict); - } - -} diff --git a/src/main/java/cn/stylefeng/guns/modular/demo/controller/DevOpsController.java b/src/main/java/cn/stylefeng/guns/modular/demo/controller/DevOpsController.java new file mode 100644 index 00000000..52c74a88 --- /dev/null +++ b/src/main/java/cn/stylefeng/guns/modular/demo/controller/DevOpsController.java @@ -0,0 +1,82 @@ +package cn.stylefeng.guns.modular.demo.controller; + +import cn.hutool.core.bean.BeanUtil; +import cn.stylefeng.roses.kernel.auth.api.AuthServiceApi; +import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginRequest; +import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginResponse; +import cn.stylefeng.roses.kernel.rule.enums.StatusEnum; +import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum; +import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData; +import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData; +import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource; +import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource; +import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource; +import cn.stylefeng.roses.kernel.sys.modular.user.entity.SysUser; +import cn.stylefeng.roses.kernel.sys.modular.user.pojo.request.SysUserRequest; +import cn.stylefeng.roses.kernel.sys.modular.user.service.SysUserService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 示例控制器 + * + * @author fengshuonan + * @since 2021/1/24 10:57 + */ +@RestController +@ApiResource(name = "示例") +public class DevOpsController { + + @Resource + private AuthServiceApi authServiceApi; + + @Resource + private SysUserService sysUserService; + + /** + * 用户登陆 + * + * @author fengshuonan + * @since 2021/3/17 17:23 + */ + @PostResource(name = "登陆", path = "/login", requiredLogin = false) + public ResponseData login(@RequestBody @Validated LoginRequest loginRequest) { + LoginResponse loginResponse = authServiceApi.login(loginRequest); + return new SuccessResponseData<>(loginResponse.getToken()); + } + + /** + * 临时兼容旧的devops平台 + * + * @author fengshuonan + * @since 2023/6/26 20:42 + */ + @GetResource(name = "运维平台接口检测", path = "/sysUser/devopsApiCheck", requiredLogin = false, requiredPermission = false) + public ResponseData devopsApiCheck() { + return new SuccessResponseData<>(999); + } + + /** + * 获取所有用户ID和名称列表 + * + * @author majianguo + * @since 2022/1/17 14:24 + **/ + @GetResource(name = "获取所有用户ID和名称列表", path = "/sysUser/getAllUserIdList") + public ResponseData> getAllUserIdList() { + LambdaQueryWrapper userLambdaQueryWrapper = new LambdaQueryWrapper<>(); + userLambdaQueryWrapper.select(SysUser::getUserId, SysUser::getAccount); + userLambdaQueryWrapper.eq(SysUser::getStatusFlag, StatusEnum.ENABLE.getCode()); + userLambdaQueryWrapper.ne(SysUser::getDelFlag, YesOrNotEnum.Y.getCode()); + List list = this.sysUserService.list(userLambdaQueryWrapper); + List collect = list.stream().map(item -> BeanUtil.toBean(item, SysUserRequest.class)).collect(Collectors.toList()); + return new SuccessResponseData<>(collect); + } + +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 2d157cd6..f3d0ae83 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -9,3 +9,8 @@ spring: # 连接池大小根据实际情况调整 max-active: 100 max-pool-prepared-statement-per-connection-size: 100 + +devops: + serverHost: http://192.168.31.58:12909 + project-unique-code: Y4JdNfsfS2tjAQouFm1t035IAnsjSKG3 + project-interaction-secret-key: QBAttyH2ZkolwtkDcn0Y5b8HLGHEtOHC \ No newline at end of file diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 28f8ebf4..700531f1 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -9,3 +9,8 @@ spring: # 连接池大小根据实际情况调整 max-active: 100 max-pool-prepared-statement-per-connection-size: 100 + +devops: + serverHost: http://192.168.31.58:12909 + project-unique-code: Y4JdNfsfS2tjAQouFm1t035IAnsjSKG3 + project-interaction-secret-key: QBAttyH2ZkolwtkDcn0Y5b8HLGHEtOHC \ No newline at end of file