From 7c3e09edfc64ad7451a78ade52c407870a9fa90d Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期三, 18 九月 2024 16:35:37 +0800
Subject: [PATCH] http api

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java   |   33 +++-------
 iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql                                                                         |    6 +-
 iailab-module-system/iailab-module-system-biz/db/增量SQL/202409.sql                                                                     |    6 ++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java                 |   49 +++++++++++++++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java   |   11 +++
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java |   18 ++++-
 6 files changed, 88 insertions(+), 35 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql b/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql
index 8a36401..89bbaa5 100644
--- a/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql
+++ b/iailab-module-data/iailab-module-data-biz/db/mysql/tenant.sql
@@ -200,13 +200,13 @@
                              `code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '编码',
                              `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '名称',
                              `url` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'URL',
-                             `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '方法',
+                             `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '请求方法',
                              `param` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '参数',
                              `descp` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
                              `status` int NULL DEFAULT NULL COMMENT '状态',
-                             `creator` VARCHAR(255)   COMMENT '创建人' ,
+                             `creator` VARCHAR(64)   COMMENT '创建人' ,
                              `create_time` DATETIME   COMMENT '创建时间' ,
-                             `updater` VARCHAR(255)   COMMENT '修改人' ,
+                             `updater` VARCHAR(64)   COMMENT '修改人' ,
                              `update_time` DATETIME   COMMENT '修改时间' ,
                              PRIMARY KEY (`ID`) USING BTREE,
                              UNIQUE KEY `uk_code` (`code`) USING BTREE
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java
index 222a362..1d8dac9 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpApiController.java
@@ -7,6 +7,7 @@
 import com.iailab.module.data.channel.http.service.HttpApiService;
 import com.iailab.module.data.channel.http.vo.HttpApiPageReqVO;
 import com.iailab.module.data.channel.http.vo.HttpApiRespVO;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -28,58 +29,44 @@
     @Resource
     private HttpApiService httpApiService;
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("page")
     public CommonResult<PageResult<HttpApiRespVO>> page(@Valid HttpApiPageReqVO reqVO) {
         PageResult<HttpApiEntity> page = httpApiService.queryPage(reqVO);
         return success(BeanUtils.toBean(page, HttpApiRespVO.class));
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("list")
     public CommonResult<List<HttpApiEntity>> list() {
         List<HttpApiEntity> list = httpApiService.list();
         return success(list);
     }
 
-    /**
-     * 根据id查询详情
-     *
-     * @param id
-     */
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("/info/{id}")
     public CommonResult<HttpApiEntity> info(@PathVariable("id") String id){
         HttpApiEntity info= httpApiService.info(id);
         return success(info);
     }
-    /**
-     * 添加API
-     *
-     * @param httpApiEntity
-     */
-    @PostMapping("/add")
-    public CommonResult<Boolean> add(@RequestBody HttpApiEntity httpApiEntity){
+
+    @PreAuthorize("@ss.hasPermission('data:channel-http:create')")
+    @PostMapping("/create")
+    public CommonResult<Boolean> create(@RequestBody HttpApiEntity httpApiEntity){
         String id = UUID.randomUUID().toString();
         httpApiEntity.setId(id);
         httpApiService.add(httpApiEntity);
         return success(true);
     }
 
-    /**
-     * 修改API
-     *
-     * @param httpApiEntity
-     */
+    @PreAuthorize("@ss.hasPermission('data:channel-http:update')")
     @PutMapping("/update")
     public CommonResult<Boolean> update(@RequestBody HttpApiEntity httpApiEntity) {
         httpApiService.update(httpApiEntity);
         return success(true);
     }
 
-    /**
-     * 删除API
-     *
-     * @param id
-     *
-     */
+    @PreAuthorize("@ss.hasPermission('data:channel-http:delete')")
     @DeleteMapping("/delete")
     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
         httpApiService.delete(id);
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java
index 66a8a54..94e7768 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTagController.java
@@ -7,6 +7,7 @@
 import com.iailab.module.data.channel.http.service.HttpTagService;
 import com.iailab.module.data.channel.http.vo.HttpTagPageReqVO;
 import com.iailab.module.data.channel.http.vo.HttpTagRespVO;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -23,31 +24,35 @@
  * @createTime 2024年08月27日
  */
 @RestController
-@RequestMapping("/data/http/tag")
+@RequestMapping("/data/channel/http/tag")
 public class HttpTagController {
 
     @Resource
     private HttpTagService tagService;
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("page")
     public CommonResult<PageResult<HttpTagRespVO>> page(@Valid HttpTagPageReqVO reqVO) {
         PageResult<HttpTagEntity> page = tagService.queryPage(reqVO);
         return success(BeanUtils.toBean(page, HttpTagRespVO.class));
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("list")
     public CommonResult<List<HttpTagEntity>> list(){
         List<HttpTagEntity> list = tagService.list();
         return new CommonResult<List<HttpTagEntity>>().setData(list);
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("/info/{id}")
     public CommonResult<HttpTagEntity> info(@PathVariable("id") String id){
         HttpTagEntity info= tagService.info(id);
         return success(info);
     }
 
-    @PostMapping("/add")
+    @PreAuthorize("@ss.hasPermission('data:channel-http:create')")
+    @PostMapping("/create")
     public CommonResult<Boolean> add(@RequestBody HttpTagEntity httpTagEntity){
         String id = UUID.randomUUID().toString();
         httpTagEntity.setId(id);
@@ -55,12 +60,14 @@
         return success(true);
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:update')")
     @PutMapping("/update")
     public CommonResult<Boolean> update(@RequestBody HttpTagEntity httpTagEntity) {
         tagService.update(httpTagEntity);
         return success(true);
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:delete')")
     @DeleteMapping("/delete")
     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
         tagService.delete(id);
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java
index 31bd57c..7895f66 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/controller/admin/HttpTokenController.java
@@ -7,6 +7,7 @@
 import com.iailab.module.data.channel.http.service.HttpTokenService;
 import com.iailab.module.data.channel.http.vo.HttpTokenPageReqVO;
 import com.iailab.module.data.channel.http.vo.HttpTokenRespVO;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -22,52 +23,59 @@
  * @createTime 2024年08月27日
  */
 @RestController
-@RequestMapping("/data/http/token")
+@RequestMapping("/data/channel/http/token")
 public class HttpTokenController {
 
     @Resource
     private HttpTokenService httpTokenService;
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("page")
     public CommonResult<PageResult<HttpTokenRespVO>> page(@Valid HttpTokenPageReqVO reqVO) {
         PageResult<HttpTokenEntity> page = httpTokenService.queryPage(reqVO);
         return success(BeanUtils.toBean(page, HttpTokenRespVO.class));
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("list")
     public CommonResult<List<HttpTokenEntity>> list(){
         List<HttpTokenEntity> list = httpTokenService.list();
         return new CommonResult<List<HttpTokenEntity>>().setData(list);
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
     @GetMapping("/info/{id}")
     public CommonResult<HttpTokenEntity> info(@PathVariable("id") String id){
         HttpTokenEntity info= httpTokenService.info(id);
         return success(info);
     }
 
-    @PostMapping("/add")
-    public CommonResult<Boolean> add(@RequestBody HttpTokenEntity HttpTokenEntity){
+    @PreAuthorize("@ss.hasPermission('data:channel-http:create')")
+    @PostMapping("/create")
+    public CommonResult<Boolean> create(@RequestBody HttpTokenEntity HttpTokenEntity){
         String id = UUID.randomUUID().toString();
         HttpTokenEntity.setId(id);
         httpTokenService.add(HttpTokenEntity);
         return success(true);
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:update')")
     @PutMapping("/update")
     public CommonResult<Boolean> update(@RequestBody HttpTokenEntity HttpTokenEntity) {
         httpTokenService.update(HttpTokenEntity);
         return success(true);
     }
 
+    @PreAuthorize("@ss.hasPermission('data:channel-http:delete')")
     @DeleteMapping("/delete")
     public CommonResult<Boolean> delete(@RequestParam("id") String id) {
         httpTokenService.delete(id);
         return success(true);
     }
 
-    @GetMapping("/api-id/{apiId}")
-    public CommonResult<HttpTokenEntity> apiId(@PathVariable("apiId") String apiId) {
+    @PreAuthorize("@ss.hasPermission('data:channel-http:query')")
+    @GetMapping("/api-id")
+    public CommonResult<HttpTokenEntity> apiId(@RequestParam("apiId") String apiId) {
         HttpTokenEntity info = httpTokenService.getByApiId(apiId);
         return success(info);
     }
diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java
index de52968..d31bcc3 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/http/entity/HttpApiEntity.java
@@ -20,14 +20,59 @@
     @Schema(description = "主键")
     @TableId(value = "id", type = IdType.INPUT)
     private String id;
-    private String name;
+
+    /**
+     * 编码
+     */
     private String code;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * URL
+     */
     private String url;
+
+    /**
+     * 请求方法
+     */
     private String method;
-    private String collectType;
+
+    /**
+     * 参数
+     */
     private String param;
+
+    /**
+     * 描述
+     */
     private String descp;
+
+    /**
+     * 状态
+     */
     private Integer status;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 创建时间
+     */
     private Date createTime;
+
+    /**
+     * 修改人
+     */
+    private String updater;
+
+    /**
+     * 修改时间
+     */
     private Date updateTime;
 }
diff --git "a/iailab-module-system/iailab-module-system-biz/db/\345\242\236\351\207\217SQL/202409.sql" "b/iailab-module-system/iailab-module-system-biz/db/\345\242\236\351\207\217SQL/202409.sql"
new file mode 100644
index 0000000..334ffc0
--- /dev/null
+++ "b/iailab-module-system/iailab-module-system-biz/db/\345\242\236\351\207\217SQL/202409.sql"
@@ -0,0 +1,6 @@
+alter table system_menu add column `app_id` int DEFAULT NULL;
+alter table system_menu add column `tenant_id` int DEFAULT NULL;
+
+alter table system_app add column `type` int DEFAULT NULL;
+alter table system_app add column `tenant_id` int DEFAULT NULL;
+alter table system_app add column `group_id` int DEFAULT NULL;
\ No newline at end of file

--
Gitblit v1.9.3