dev
fjj 2023-12-27 22:04:27 +08:00
parent efd89a17ab
commit 68d232653b
50 changed files with 196 additions and 1274 deletions

View File

@ -24,7 +24,8 @@
<module>srt-cloud-gateway</module> <module>srt-cloud-gateway</module>
<module>srt-data-development</module> <module>srt-data-development</module>
<module>srt-cloud-data-governance</module> <module>srt-cloud-data-governance</module>
<module>srt-cloud-data-server</module> <module>srt-cloud-data-service</module>
<module>srt-cloud-data-assets</module>
</modules> </modules>
<properties> <properties>

View File

@ -9,7 +9,7 @@
<version>2.0.0</version> <version>2.0.0</version>
</parent> </parent>
<artifactId>srt-cloud-data-server</artifactId> <artifactId>srt-cloud-data-assets</artifactId>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
@ -34,24 +34,15 @@
<version>2.0.0</version> <version>2.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.srt</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>srt-cloud-dbswitch</artifactId> <artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>2.0.0</version>
<exclusions> <exclusions>
<exclusion>
<artifactId>jsqlparser</artifactId>
<groupId>com.github.jsqlparser</groupId>
</exclusion>
<exclusion> <exclusion>
<artifactId>spring-boot-starter-logging</artifactId> <artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
@ -60,14 +51,38 @@
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>easy-captcha</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-springdoc-ui</artifactId> <artifactId>knife4j-springdoc-ui</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
</dependency>
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>cos_api</artifactId>
</dependency>
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
</dependency>
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>esdk-obs-java-bundle</artifactId>
</dependency>
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<!-- <finalName>${project.artifactId}</finalName>--> <!--<finalName>${project.artifactId}</finalName>-->
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
@ -105,7 +120,7 @@
<daemons> <daemons>
<daemon> <daemon>
<id>${project.artifactId}</id> <id>${project.artifactId}</id>
<mainClass>net.srt.DataServiceApplication</mainClass> <mainClass>net.srt.SystemApplication</mainClass>
<platforms> <platforms>
<platform>jsw</platform> <platform>jsw</platform>
</platforms> </platforms>
@ -160,7 +175,7 @@
</daemons> </daemons>
<programs> <programs>
<program> <program>
<mainClass>net.srt.DataServiceApplication</mainClass> <mainClass>net.srt.SystemApplication</mainClass>
<id>${project.artifactId}</id> <id>${project.artifactId}</id>
</program> </program>
</programs> </programs>
@ -202,3 +217,4 @@
</build> </build>
</project> </project>

View File

@ -5,12 +5,17 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @ClassName : ${NAME}
* @Description : ${description}
* @Author : FJJ
* @Date: 2023-12-27 21:47
*/
@EnableFeignClients @EnableFeignClients
@EnableDiscoveryClient @EnableDiscoveryClient
@SpringBootApplication @SpringBootApplication
public class DataServiceApplication { public class AssetsApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DataServiceApplication.class, args); SpringApplication.run(AssetsApplication.class, args);
System.out.println("==============启动成功===================");
} }
} }

View File

@ -0,0 +1,46 @@
server:
port: 8098
spring:
mvc:
servlet:
load-on-startup: 1
application:
name: srt-cloud-data-assets
profiles:
active: dev
cloud:
nacos:
discovery:
server-addr: 101.34.77.101:8848
# 命名空间默认public
namespace: 09dff3e2-9790-4d4f-beb6-9baeb01ae040
service: ${spring.application.name}
group: srt2.0
config:
server-addr: ${spring.cloud.nacos.discovery.server-addr}
namespace: ${spring.cloud.nacos.discovery.namespace}
file-extension: yaml
# 指定配置
extension-configs:
- data-id: datasource.yaml
refresh: true
servlet:
multipart:
max-request-size: 100MB
max-file-size: 1024MB
storage:
enabled: true
config:
# 存储类型local、aliyun
type: local
# 访问域名
domain: http://localhost:8082/sys
# 配置访问前缀
prefix:
local:
# 本地上传路径
path: D://upload
cbx:
isCaptcha: false

View File

@ -25,10 +25,10 @@ public class BusinessInitializer implements ApplicationRunner {
* init task monitor * init task monitor
*/ */
private void initScheduleMonitor() { private void initScheduleMonitor() {
//处理没执行完的采集任务 // //处理没执行完的采集任务
metadataCollectRecordService.dealNotFinished(); // metadataCollectRecordService.dealNotFinished();
//处理没执行完的质量检测任务 // //处理没执行完的质量检测任务
qualityTaskService.dealNotFinished(); // qualityTaskService.dealNotFinished();
} }
} }

View File

@ -1,49 +0,0 @@
package net.srt.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName : DatastandardVo
* @Description :
* @Author : FJJ
* @Date: 2023-12-23 12:05
*/
@Data
@Schema(description = "标准管理查询")
public class DatastandardVo implements Serializable {
private static final long serialVersionUID = 1L;
@TableId("id")
private Long id;
private Integer categoryId;
private String engName;
private String cnName;
private Integer codeNum;
private String dataType;
private Integer dataLength;
private Integer dataPrecision;
private Integer nullable;
private Integer standardCodeId;
private Integer type;
private String note;
private Long projectId;
private Integer status;
private Integer version;
private Integer deleted;
private String creator;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
private String updater;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
private Integer ifStandardRel;
private String group;
}

View File

@ -18,7 +18,7 @@ import java.util.List;
*/ */
@Data @Data
@Schema(description = "数据治理-质量规则配置") @Schema(description = "数据治理-质量规则配置")
public class QualityConfigVO implements Serializable { public class QualityConfigVo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "自增id") @Schema(description = "自增id")

View File

@ -1,119 +0,0 @@
package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import net.srt.dto.ApiConfigDto;
import net.srt.entity.ApiConfigEntity;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.common.utils.Result;
import net.srt.framework.common.utils.TreeNodeVo;
import net.srt.query.ApiConfigQuery;
import net.srt.service.ApiConfigService;
import net.srt.vo.ApiConfig;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping("/api-config")
@AllArgsConstructor
public class ApiConfigController {
private final ApiConfigService apiConfigService;
/**
*
*
* @return
*/
@GetMapping("/api-group")
@Operation(summary = "查询文件分组树")
public Result<List<TreeNodeVo>> listTree() {
return Result.ok(apiConfigService.listTree());
}
/**
* API
* @param query API
* @return
*/
@GetMapping("/page")
@Operation(summary = "分页")
@PreAuthorize("hasAuthority('data-service:api-config:page')")
public Result<PageResult<ApiConfig>> page(@Valid ApiConfigQuery query) {
PageResult<ApiConfig> page = apiConfigService.page(query);
return Result.ok(page);
}
/**
* IP
*
* @return IP
*/
@GetMapping("/getIpPort")
public Result<String> getIpPort() {
return Result.ok(apiConfigService.getIpPort());
}
/**
* IDAPI
*
* @param id APIID
* @return API
*/
@GetMapping("/{id}")
@Operation(summary = "查看")
@PreAuthorize("hasAuthority('data-service:api-config:info')")
public Result<ApiConfigEntity> get(@PathVariable("id") Long id) {
ApiConfigEntity apiConfig = apiConfigService.getByI(id);
return Result.ok(apiConfig);
}
@PutMapping("/{id}")
@Operation(summary = "修改")
@PreAuthorize("hasAuthority('data-service:api-config:update')")
public Result<ApiConfigEntity> update(@PathVariable Long id, @RequestBody @Valid ApiConfigEntity vo) {
apiConfigService.update(id,vo);
return Result.ok();
}
@PutMapping("/{id}/offline")
@Operation(summary = "下线")
@PreAuthorize("hasAuthority('data-service:api-config:update')")
public Result<ApiConfigEntity> xia(@PathVariable Long id) {
apiConfigService.xia(id);
return Result.ok();
}
@PutMapping("/{id}/online")
@Operation(summary = "上线")
@PreAuthorize("hasAuthority('data-service:api-config:update')")
public Result<ApiConfigEntity> shang(@PathVariable Long id) {
apiConfigService.shang(id);
return Result.ok();
}
@PostMapping
@Operation(summary = "新增")
@PreAuthorize("hasAuthority('data-service:api-config:save')")
public Result<String> insert(@RequestBody ApiConfig vo) {
apiConfigService.sav(vo);
return Result.ok();
}
@DeleteMapping
@Operation(summary = "删除")
@PreAuthorize("hasAuthority('data-service:api-config:delete')")
public Result<String> delete(@RequestBody List<Long> idList) {
apiConfigService.removeByI(idList);
return Result.ok();
}
}

View File

@ -1,70 +0,0 @@
package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import net.srt.convert.ApiGroupConvert;
import net.srt.entity.ApiGroupEntity;
import net.srt.framework.common.utils.Result;
import net.srt.framework.common.utils.TreeNodeVo;
import net.srt.service.ApiGroupService;
import net.srt.vo.ApiGroup;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* -api
*
* @author zrx 985134801@qq.com
* @since 1.0.0 2023-01-28
*/
@RestController
@RequestMapping("/api-group")
@AllArgsConstructor
public class ApiGroupController {
private final ApiGroupService apiGroupService;
@GetMapping
@Operation(summary = "查询文件分组树")
public Result<List<TreeNodeVo>> listTree() {
return Result.ok(apiGroupService.listTree());
}
@GetMapping("{id}")
@Operation(summary = "信息")
@PreAuthorize("hasAuthority('data-service:api-group:info')")
public Result<ApiGroup> get(@PathVariable("id") Long id){
ApiGroupEntity entity = apiGroupService.getById(id);
return Result.ok(ApiGroupConvert.INSTANCE.convert(entity));
}
@PostMapping
@Operation(summary = "保存")
@PreAuthorize("hasAuthority('data-service:api-group:save')")
public Result<String> save(@RequestBody ApiGroup vo) {
apiGroupService.save(vo);
return Result.ok();
}
@PutMapping
@Operation(summary = "修改")
@PreAuthorize("hasAuthority('data-service:api-group:update')")
public Result<String> update(@RequestBody @Valid ApiGroup vo) {
apiGroupService.update(vo);
return Result.ok();
}
@DeleteMapping("/{id}")
@Operation(summary = "删除")
@PreAuthorize("hasAuthority('data-service:api-group:delete')")
public Result<String> delete(@PathVariable Long id) {
apiGroupService.delete(id);
return Result.ok();
}
}

View File

@ -1,43 +0,0 @@
package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.common.utils.Result;
import net.srt.query.ApiConfigQuery;
import net.srt.query.ApiLogQuery;
import net.srt.service.ApiLogService;
import net.srt.vo.ApiConfig;
import net.srt.vo.ApiLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
* @ClassName ApiTest
* @Description
* @Author
*/
@RestController
@RequestMapping("/log")
@AllArgsConstructor
public class ApiTest {
@Autowired
ApiLogService apiLogService;
@GetMapping("/page")
@Operation(summary = "日志列表")
@PreAuthorize("hasAuthority('data-service:api-config:page')")
public Result<PageResult<ApiLog>> page(@Valid ApiLogQuery query) {
PageResult<ApiLog> page = apiLogService.pag(query);
return Result.ok(page);
}
}

View File

@ -1,29 +0,0 @@
package net.srt.convert;
import net.srt.dto.ApiConfigDto;
import net.srt.entity.ApiConfigEntity;
import net.srt.vo.ApiConfig;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* -api
*
* @author zrx 985134801@qq.com
* @since 1.0.0 2023-01-28
*/
@Mapper
public interface ApiConfigConvert {
ApiConfigConvert INSTANCE = Mappers.getMapper(ApiConfigConvert.class);
ApiConfigEntity convert(ApiConfig vo);
ApiConfig convert(ApiConfigEntity entity);
ApiConfigDto convertDto(ApiConfigEntity entity);
List<ApiConfig> convertList(List<ApiConfigEntity> list);
}

View File

@ -1,26 +0,0 @@
package net.srt.convert;
import net.srt.entity.ApiGroupEntity;
import net.srt.vo.ApiGroup;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* -api
*
* @author zrx 985134801@qq.com
* @since 1.0.0 2023-01-28
*/
@Mapper
public interface ApiGroupConvert {
ApiGroupConvert INSTANCE = Mappers.getMapper(ApiGroupConvert.class);
ApiGroupEntity convert(ApiGroup vo);
ApiGroup convert(ApiGroupEntity entity);
List<ApiGroup> convertList(List<ApiGroupEntity> list);
}

View File

@ -1,26 +0,0 @@
package net.srt.convert;
import net.srt.entity.ApiLogEntity;
import net.srt.vo.ApiLog;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* @ClassName ApiLogConvert
* @Description
* @Author
*/
@Mapper
public interface ApiLogConvert {
ApiLogConvert INSTANCE = Mappers.getMapper(ApiLogConvert.class);
ApiLogEntity convert(ApiLog vo);
ApiLog convert(ApiLogEntity entity);
List<ApiLog> convertList(List<ApiLogEntity> list);
}

View File

@ -1,49 +0,0 @@
package net.srt.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import net.srt.framework.common.utils.DateUtils;
import java.io.Serializable;
import java.util.Date;
@Data
public class ApiConfigDto implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private Long groupId;
private String path;
private String type;
private String name;
private String note;
private String sqlText;
private String sqlSeparator;
private Integer sqlMaxRow;
private String sqlParam;
private String jsonParam;
private String responseResult;
private String contentType;
private Integer status;
private Date releaseTime;
private Long releaseUserId;
private Integer sqlDbType;
private Long databaseId;
private Integer previlege;
private Integer openTrans;
private Long projectId;
private Integer version;
private Integer deleted;
private Long creator;
private Date createTime;
private Long updater;
private Date updateTime;
private Integer requestedTimes;
private Integer requestedSuccessTimes;
private Integer requestedFailedTimes;
private Long authId;
private String group;
}

View File

@ -1,61 +0,0 @@
package net.srt.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import net.srt.framework.mybatis.entity.BaseEntity;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
@TableName("data_dispatch_catalogue")
public class ApiConfigEntity extends BaseEntity {
/**
* id0
*/
private Long parentId;
/**
*
*/
private String name;
/**
*
*/
private Integer orderNo;
/**
*
*/
private String description;
/**
*
*/
private String path;
private Integer type;
/**
* id
*/
private Long projectId;
private Long id;
// 私有属性,状态
private Integer status;
// 私有属性发布用户ID
private Long releaseUserId;
// 自定义注解,日期格式化,格式为"yyyy-MM-dd HH:mm:ss"
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date releaseTime;
// 私有属性,内容类型
private String contentType;
private Integer previlege;
private Integer openTrans;
}

View File

@ -1,41 +0,0 @@
package net.srt.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import net.srt.framework.mybatis.entity.BaseEntity;
@Data
@TableName(value = "data_dispatch_catalogue",autoResultMap = true)
public class ApiGroupEntity extends BaseEntity {
/**
* id0
*/
private Long parentId;
/**
*
*/
private String name;
/**
*
*/
private Integer orderNo;
/**
*
*/
private String description;
/**
*
*/
private String path;
private Integer type;
/**
* id
*/
private Long projectId;
}

View File

@ -1,31 +0,0 @@
package net.srt.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import net.srt.framework.mybatis.entity.BaseEntity;
import java.util.Date;
/**
* @ClassName ApiLogEntity
* @Description
* @Author
*/
@Data
@TableName(value = "data_service_api_log",autoResultMap = true)
public class ApiLogEntity extends BaseEntity {
// private Integer id;
private String url;
private Integer duration;
private String ip;
private Integer apiId;
private String error;
private Integer projectId;
// private String deleted;
// private Integer creator;
// private String createTime;
// private Integer updater;
private Date updateTime;
private String apiName;
}

View File

@ -1,14 +0,0 @@
package net.srt.mapper;
import net.srt.entity.ApiConfigEntity;
import net.srt.framework.mybatis.dao.BaseDao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface ApiConfigDao extends BaseDao<ApiConfigEntity> {
void xia(@Param("id") Long id);
void shang(@Param("id") Long id);
}

View File

@ -1,9 +0,0 @@
package net.srt.mapper;
import net.srt.entity.ApiGroupEntity;
import net.srt.framework.mybatis.dao.BaseDao;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ApiGroupDao extends BaseDao<ApiGroupEntity> {
}

View File

@ -1,15 +0,0 @@
package net.srt.mapper;
import net.srt.entity.ApiGroupEntity;
import net.srt.entity.ApiLogEntity;
import net.srt.framework.mybatis.dao.BaseDao;
import org.apache.ibatis.annotations.Mapper;
/**
* @ClassName ApiLogDao
* @Description
* @Author
*/
@Mapper
public interface ApiLogDao extends BaseDao<ApiLogEntity> {
}

View File

@ -1,22 +0,0 @@
package net.srt.query;
import lombok.Data;
import net.srt.framework.common.query.Query;
@Data
public class ApiConfigQuery extends Query {
private Long groupId;
private Long resourceId;
private Long appId;
private String name;
private String path;
private String contentType;
private Integer status;
private Integer sqlDbType;
private Long databaseId;
private Integer privates;
private Integer openTrans;
private Integer queryApply;
private Integer ifMarket;
}

View File

@ -1,16 +0,0 @@
package net.srt.query;
import lombok.Data;
import net.srt.framework.common.query.Query;
/**
* @ClassName ApiLogQuery
* @Description
* @Author
*/
@Data
public class ApiLogQuery extends Query {
private String ip;
private String apiName;
}

View File

@ -1,38 +0,0 @@
package net.srt.service;
import net.srt.dto.ApiConfigDto;
import net.srt.entity.ApiConfigEntity;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.common.utils.Result;
import net.srt.framework.common.utils.TreeNodeVo;
import net.srt.framework.mybatis.service.BaseService;
import net.srt.query.ApiConfigQuery;
import net.srt.vo.ApiConfig;
import java.util.List;
public interface ApiConfigService extends BaseService<ApiConfigEntity> {
String getIpPort();
List<TreeNodeVo> listTree();
PageResult<ApiConfig> page(ApiConfigQuery query);
ApiConfigEntity getByI(Long id);
void update(Long id, ApiConfigEntity vo);
void xia(Long id);
void shang(Long id);
void sav(ApiConfig vo);
void removeByI(List<Long> idList);
}

View File

@ -1,18 +0,0 @@
package net.srt.service;
import net.srt.entity.ApiGroupEntity;
import net.srt.framework.common.utils.TreeNodeVo;
import net.srt.framework.mybatis.service.BaseService;
import net.srt.vo.ApiGroup;
import java.util.List;
public interface ApiGroupService extends BaseService<ApiGroupEntity> {
List<TreeNodeVo> listTree();
void save(ApiGroup vo);
void update(ApiGroup vo);
void delete(Long id);
}

View File

@ -1,18 +0,0 @@
package net.srt.service;
import net.srt.entity.ApiLogEntity;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.mybatis.service.BaseService;
import net.srt.query.ApiLogQuery;
import net.srt.vo.ApiLog;
/**
* @ClassName ApiLogService
* @Description
* @Author
*/
public interface ApiLogService extends BaseService<ApiLogEntity> {
PageResult<ApiLog> pag(ApiLogQuery query);
}

View File

@ -1,171 +0,0 @@
package net.srt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import net.srt.convert.ApiConfigConvert;
import net.srt.convert.ApiGroupConvert;
import net.srt.dto.ApiConfigDto;
import net.srt.entity.ApiConfigEntity;
import net.srt.entity.ApiGroupEntity;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.common.utils.BeanUtil;
import net.srt.framework.common.utils.BuildTreeUtils;
import net.srt.framework.common.utils.Result;
import net.srt.framework.common.utils.TreeNodeVo;
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
import net.srt.mapper.ApiConfigDao;
import net.srt.query.ApiConfigQuery;
import net.srt.service.ApiConfigService;
import net.srt.vo.ApiConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import srt.cloud.framework.dbswitch.common.util.StringUtil;
import javax.annotation.Resource;
import java.util.List;
@Service
@AllArgsConstructor
public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfigEntity> implements ApiConfigService {
@Override
public String getIpPort() {
return null;
}
/**
*
* @return List<TreeNodeVo>
*/
@Override
public List<TreeNodeVo> listTree() {
// 创建查询条件
LambdaQueryWrapper<ApiConfigEntity> wrapper = new LambdaQueryWrapper<>();
// 设置查询条件排除组织id
dataScopeWithoutOrgId(wrapper);
// 按照排序字段升序排序
wrapper.orderByAsc(ApiConfigEntity::getOrderNo);
// 从数据库中查询列表数据
List<ApiConfigEntity> dataFileCategoryEntities = baseMapper.selectList(wrapper);
// 将数据转换为树节点vo列表
List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(dataFileCategoryEntities, TreeNodeVo::new, (oldItem, newItem) -> {
// 设置树节点的标签为名称
newItem.setLabel(oldItem.getName());
// 设置树节点的值为id
newItem.setValue(oldItem.getId());
// 设置树节点是否不可用类型为0表示不可用
newItem.setDisabled(oldItem.getType() == 0);
// 如果树节点路径包含斜杠,则设置父路径为路径截取到倒数第一个斜杠的位置
if (newItem.getPath().contains("/")) {
newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/")));
}
});
// 调用工具类构建树结构
return BuildTreeUtils.buildTree(treeNodeVos);
}
/**
* API
*
* @param query
* @return
*/
@Override
public PageResult<ApiConfig> page(ApiConfigQuery query) {
// 调用Mapper层方法查询分页数据
IPage<ApiConfigEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
// 将查询结果转换为ApiConfig对象列表
// 返回分页结果
return new PageResult<>(ApiConfigConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
}
/**
* IDApiConfigEntity
*
* @param id ID
* @return ApiConfigEntity
*/
@Override
public ApiConfigEntity getByI(Long id) {
return id != null ? baseMapper.selectById(id) : null;
}
@Override
public void update(Long id,ApiConfigEntity vo) {
baseMapper.deleteById(id);
baseMapper.insert(vo);
// if (vo.getType() == 0) {
// ApiGroupEntity apiGroupEntity = new ApiGroupEntity();
// apiGroupEntity.setId(vo.getId());
// apiGroupEntity.setVersion(vo.getVersion());
// apiGroupEntity.setDeleted(vo.getDeleted());
// apiGroupEntity.setUpdateTime(vo.getUpdateTime());
// apiGroupEntity.setCreateTime(vo.getCreateTime());
// apiGroupEntity.setUpdater(vo.getUpdater());
// }
}
@Resource
ApiConfigDao apiConfigDto;
@Override
public void xia(Long id) {
apiConfigDto.xia(id);
}
@Override
public void shang(Long id) {
apiConfigDto.shang(id);
}
@Override
public void sav(ApiConfig vo) {
ApiConfigEntity entity = ApiConfigConvert.INSTANCE.convert(vo);
entity.setPath(recursionPath(entity, null));
entity.setProjectId(getProjectId());
baseMapper.insert(entity); // 使用 insertSelective() 方法进行插入操作
}
@Override
public void removeByI(List<Long> idList) {
baseMapper.deleteBatchIds(idList);
}
private String recursionPath(ApiConfigEntity groupEntity, String path) {
if (StringUtil.isBlank(path)) {
path = groupEntity.getName();
}
if (groupEntity.getParentId() != 0) {
ApiConfigEntity parent = getById(groupEntity.getParentId());
path = parent.getName() + "/" + path;
return recursionPath(parent, path);
}
return path;
}
private LambdaQueryWrapper getWrapper(ApiConfigQuery query) {
LambdaQueryWrapper<ApiConfigEntity> wrapper = Wrappers.lambdaQuery();
wrapper.like(StringUtil.isNotBlank(query.getName()), ApiConfigEntity::getName, query.getName());
wrapper.like(StringUtil.isNotBlank(query.getPath()), ApiConfigEntity::getPath, query.getPath());
// wrapper.eq(StringUtil.isNotBlank(query.getContentType()), ApiConfigEntity::getContentType, query.getContentType());
// wrapper.eq(query.getStatus()!= null, ApiConfigEntity::getStatus, query.getStatus());
// wrapper.eq(query.getSqlDbType() != null, ApiConfigEntity::getSqlDbType, query.getSqlDbType());
//
return wrapper;
}
}

View File

@ -1,93 +0,0 @@
package net.srt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.AllArgsConstructor;
import net.srt.convert.ApiGroupConvert;
import net.srt.entity.ApiConfigEntity;
import net.srt.entity.ApiGroupEntity;
import net.srt.framework.common.exception.ServerException;
import net.srt.framework.common.utils.BeanUtil;
import net.srt.framework.common.utils.BuildTreeUtils;
import net.srt.framework.common.utils.TreeNodeVo;
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
import net.srt.mapper.ApiGroupDao;
import net.srt.service.ApiConfigService;
import net.srt.service.ApiGroupService;
import net.srt.vo.ApiGroup;
import org.springframework.stereotype.Service;
import srt.cloud.framework.dbswitch.common.util.StringUtil;
import java.util.List;
@Service
@AllArgsConstructor
public class ApiGroupServiceImpl extends BaseServiceImpl<ApiGroupDao, ApiGroupEntity> implements ApiGroupService{
// private final ApiConfigService apiConfigService;
@Override
public List<TreeNodeVo> listTree() {
List<TreeNodeVo> treeNodeVos = getTreeNodeVos();
return BuildTreeUtils.buildTree(treeNodeVos);
}
private List<TreeNodeVo> getTreeNodeVos() {
LambdaQueryWrapper<ApiGroupEntity> wrapper = new LambdaQueryWrapper<>();
dataScopeWithoutOrgId(wrapper);
wrapper.orderByAsc(ApiGroupEntity::getOrderNo);
List<ApiGroupEntity> apiGroupEntities = baseMapper.selectList(wrapper);
return BeanUtil.copyListProperties(apiGroupEntities, TreeNodeVo::new, (oldItem, newItem) -> {
newItem.setLabel(oldItem.getName());
newItem.setValue(oldItem.getId());
newItem.setDisabled(oldItem.getType() == 1);
if (newItem.getPath().contains("/")) {
newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/")));
}
});
}
@Override
public void save(ApiGroup vo) {
ApiGroupEntity entity = ApiGroupConvert.INSTANCE.convert(vo);
entity.setPath(recursionPath(entity, null));
entity.setProjectId(getProjectId());
baseMapper.insert(entity); // 使用 insertSelective() 方法进行插入操作
}
@Override
public void update(ApiGroup vo) {
ApiGroupEntity entity = ApiGroupConvert.INSTANCE.convert(vo);
entity.setPath(recursionPath(entity, null));
entity.setProjectId(getProjectId());
updateById(entity);
}
private String recursionPath(ApiGroupEntity groupEntity, String path) {
if (StringUtil.isBlank(path)) {
path = groupEntity.getName();
}
if (groupEntity.getParentId() != 0) {
ApiGroupEntity parent = getById(groupEntity.getParentId());
path = parent.getName() + "/" + path;
return recursionPath(parent, path);
}
return path;
}
@Override
public void delete(Long id) {
//查询有没有子节点
LambdaQueryWrapper<ApiGroupEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ApiGroupEntity::getParentId, id).last(" limit 1");
ApiGroupEntity one = baseMapper.selectOne(wrapper);
if (one != null) {
throw new ServerException("存在子节点,不允许删除!");
}
// //查询有没有api与之关联
// LambdaQueryWrapper<ApiConfigEntity> serviceApiConfigWrapper = new LambdaQueryWrapper<>();
// serviceApiConfigWrapper.eq(ApiConfigEntity::getParentId, id).last(" limit 1");
// ApiConfigEntity apiConfigEntity = apiConfigService.getOne(serviceApiConfigWrapper);
// if (apiConfigEntity != null) {
// throw new ServerException("节点下有 api 与之关联,不允许删除!");
// }
// removeById(id);
}
}

View File

@ -1,55 +0,0 @@
package net.srt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import net.srt.convert.ApiLogConvert;
import net.srt.entity.ApiLogEntity;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
import net.srt.mapper.ApiLogDao;
import net.srt.query.ApiLogQuery;
import net.srt.service.ApiLogService;
import net.srt.vo.ApiLog;
import org.springframework.stereotype.Service;
import srt.cloud.framework.dbswitch.common.util.StringUtil;
/**
* @ClassName ApiLogServiceImpl
* @Description
* @Author
*/
@Service
@AllArgsConstructor
public class ApiLogServiceImpl extends BaseServiceImpl<ApiLogDao, ApiLogEntity> implements ApiLogService {
@Override
public PageResult<ApiLog> pag(ApiLogQuery query) {
// 调用Mapper层方法查询分页数据
IPage<ApiLogEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
// 将查询结果转换为ApiConfig对象列表
// 返回分页结果
return new PageResult<>(ApiLogConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
}
private LambdaQueryWrapper getWrapper(ApiLogQuery query) {
LambdaQueryWrapper<ApiLogEntity> wrapper = Wrappers.lambdaQuery();
wrapper.like(StringUtil.isNotBlank(query.getApiName()), ApiLogEntity::getApiName, query.getApiName());
wrapper.like(StringUtil.isNotBlank(query.getIp()), ApiLogEntity::getIp, query.getIp());
// wrapper.eq(StringUtil.isNotBlank(query.getContentType()), ApiConfigEntity::getContentType, query.getContentType());
// wrapper.eq(query.getStatus()!= null, ApiConfigEntity::getStatus, query.getStatus());
// wrapper.eq(query.getSqlDbType() != null, ApiConfigEntity::getSqlDbType, query.getSqlDbType());
return wrapper;
}
}

View File

@ -1,101 +0,0 @@
package net.srt.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* -api
*
* @author zrx 985134801@qq.com
* @since 1.0.0 2023-01-28
*/
@Data
public class ApiConfig implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Integer parentId;
private Integer type;
private String name;
private Integer orderNo;
private String description;
private String path;
private Integer projectId;
private Integer version;
private Integer deleted;
private Integer creator;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
private Integer updater;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
private Integer status;
private String contentType;
private Integer releaseUserId;
private Date releaseTime;
private Integer previlege;
private Integer openTrans;
// @TableId(value = "id", type = IdType.AUTO)
// private Long id;
// private Long groupId;
// private String path;
// private String type;
// private String name;
//// private String note;
// private String sqlText;
// private String sqlSeparator;
// private Integer sqlMaxRow;
// private String sqlParam;
// private String jsonParam;
// private String responseResult;
// private Integer contentType;
// private Integer status
// private Date releaseTime;
// private Long releaseUserId;
// private Integer sqlDbType;
// private Long databaseId;
// private Integer previlege;
// private Integer openTrans;
// private Long projectId;
// private Integer version;
// private Integer deleted;
// private Long creator;
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
// private Date createTime;
// private Long updater;
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
// private Date updateTime;
// private Integer requestedTimes;
// private Integer requestedSuccessTimes;
// private Integer requestedFailedTimes;
// private Long authId;
// private String group;
// private String groupPath;
}

View File

@ -1,25 +0,0 @@
package net.srt.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class ApiGroup implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private Long parentId;
private Integer type;
private String name;
private String description;
private Integer orderNo;
private String path;
private Long projectId;
private Integer version;
private Integer deleted;
private Long creator;
private Date createTime;
private Long updater;
private Date updateTime;
}

View File

@ -1,32 +0,0 @@
package net.srt.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName ApiLog
* @Description
* @Author
*/
@Data
public class ApiLog implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String url;
private Integer duration;
private String ip;
private Integer apiId;
private String error;
private Integer projectId;
private String deleted;
private Integer creator;
private String createTime;
private Integer updater;
private Date updateTime;
}

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.srt.mapper.ApiConfigDao">
<update id="xia" parameterType="java.lang.Long">
update data_dispatch_catalogue set status = 0 where id = #{id}
</update>
<update id="shang" parameterType="java.lang.Long">
update data_dispatch_catalogue set status = 1 where id = #{id}
</update>
</mapper>

View File

@ -11,30 +11,5 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
public class DataServiceApplication { public class DataServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DataServiceApplication.class, args); SpringApplication.run(DataServiceApplication.class, args);
System.out.println("\n" +
"/**\n" +
" * _ooOoo_\n" +
" * o8888888o\n" +
" * 88\" . \"88\n" +
" * (| -_- |)\n" +
" * O\\ = /O\n" +
" * ____/`---'\\____\n" +
" * . ' \\\\| |// `.\n" +
" * / \\\\||| : |||// \\\n" +
" * / _||||| -:- |||||- \\\n" +
" * | | \\\\\\ - /// | |\n" +
" * | \\_| ''\\---/'' | |\n" +
" * \\ .-\\__ `-` ___/-. /\n" +
" * ___`. .' /--.--\\ `. . __\n" +
" * .\"\" '< `.___\\_<|>_/___.' >'\"\".\n" +
" * | | : `- \\`.;`\\ _ /`;.`/ - ` : | |\n" +
" * \\ \\ `-. \\_ __\\ /__ _/ .-` / /\n" +
" * ======`-.____`-.___\\_____/___.-`____.-'======\n" +
" * `=---='\n" +
" *\n" +
" * .............................................\n" +
" * 佛祖保佑 代码 启动 永无BUG\n" +
" */\n" +
"————————代码——启动————————");
} }
} }

View File

@ -9,6 +9,7 @@ import net.srt.framework.common.utils.Result;
import net.srt.query.ApiConfigQuery; import net.srt.query.ApiConfigQuery;
import net.srt.service.ApiConfigService; import net.srt.service.ApiConfigService;
import net.srt.vo.ApiConfigVo; import net.srt.vo.ApiConfigVo;
import net.srt.vo.DataServiceApiAuthVo;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -42,13 +43,33 @@ public class ApiConfigController {
} }
@GetMapping("page-auth") @GetMapping("page-auth")
@Operation(summary = "根据resourceId分页获取")
public Result<PageResult<ApiConfigVo>> pageAuth(@Valid ApiConfigQuery query) { public Result<PageResult<ApiConfigVo>> pageAuth(@Valid ApiConfigQuery query) {
PageResult<ApiConfigVo> page = apiConfigService.page(query); PageResult<ApiConfigVo> page = apiConfigService.page(query);
return Result.ok(page); return Result.ok(page);
} }
//取消授权
// @PutMapping("/auth-info")
// @Operation(summary = "修改授权")
// public Result<String> upAuth(@RequestBody DataServiceApiAuthVo authVO){
// apiConfigService.upAuth(authVO);
// return Result.ok();
// }
@Operation(summary = "回显")
@GetMapping(value = "/auth-info/{authId}")
public Result<DataServiceApiAuthVo> getAuthId(@PathVariable Long authId){
return Result.ok(apiConfigService.getAuthInfo(authId));
}
//重置调用次数
@Operation(summary = "重置调用次数")
@PutMapping("/reset-requested/{authId}")
public Result<String > resetRequested(@PathVariable Long authId){
apiConfigService.resetRequested(authId);
return Result.ok();
}
@GetMapping("{id}") @GetMapping("{id}")
@Operation(summary = "信息") @Operation(summary = "信息")

View File

@ -1,10 +0,0 @@
package net.srt.controller;
/**
* @ClassName : DataServiceApiAuthController
* @Description :
* @Author : FJJ
* @Date: 2023-12-26 15:22
*/
public class DataServiceApiAuthController {
}

View File

@ -34,12 +34,12 @@ public class DataServiceAppController {
PageResult<DataServiceAppVo> pageResult = dataServiceAppService.page(query); PageResult<DataServiceAppVo> pageResult = dataServiceAppService.page(query);
return Result.ok(pageResult); return Result.ok(pageResult);
} }
@GetMapping("{id}") // @GetMapping("{id}")
@Operation(summary = "信息") // @Operation(summary = "信息")
public Result<DataServiceAppVo> get(@PathVariable("id") Long id){ // public Result<DataServiceAppVo> get(@PathVariable("id") Long id){
DataServiceAppEntity dataServiceAppEntity = dataServiceAppService.getById(id); // DataServiceAppEntity dataServiceAppEntity = dataServiceAppService.getById(id);
return Result.ok(DataServiceAppConvert.INSTANCE.convert(dataServiceAppEntity)); // return Result.ok(DataServiceAppConvert.INSTANCE.convert(dataServiceAppEntity));
} // }
@PostMapping @PostMapping
@Operation(summary = "保存") @Operation(summary = "保存")
@ -72,6 +72,7 @@ public class DataServiceAppController {
return Result.ok(); return Result.ok();
} }
@PutMapping("/auth") @PutMapping("/auth")
@Operation(summary = "修改授权") @Operation(summary = "修改授权")
public Result<String> upAuth(@RequestBody DataServiceApiAuthVo authVO){ public Result<String> upAuth(@RequestBody DataServiceApiAuthVo authVO){

View File

@ -17,4 +17,6 @@ public interface ApiConfigDao extends BaseDao<ApiConfigEntity> {
void updateById(@Param("apiId") Long apiId, @Param("id") Long id); void updateById(@Param("apiId") Long apiId, @Param("id") Long id);
List<ApiConfigEntity> getAuthList(Map<String, Object> params); List<ApiConfigEntity> getAuthList(Map<String, Object> params);
void updateAuthId(@Param("authId") Long authId);
} }

View File

@ -3,6 +3,7 @@ package net.srt.dao;
import net.srt.entity.DataServiceApiAuthEntity; import net.srt.entity.DataServiceApiAuthEntity;
import net.srt.framework.mybatis.dao.BaseDao; import net.srt.framework.mybatis.dao.BaseDao;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* @ClassName : DataServiceApiAuthDao * @ClassName : DataServiceApiAuthDao
@ -12,4 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface DataServiceApiAuthDao extends BaseDao<DataServiceApiAuthEntity> { public interface DataServiceApiAuthDao extends BaseDao<DataServiceApiAuthEntity> {
void resetRequested(Long authId);
} }

View File

@ -1,9 +1,6 @@
package net.srt.entity; package net.srt.entity;
import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import net.srt.framework.mybatis.entity.BaseEntity; import net.srt.framework.mybatis.entity.BaseEntity;
@ -18,8 +15,10 @@ import java.util.Date;
*/ */
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Data @Data
@TableName("data_service_api_auth1") @TableName("data_service_api_auth")
public class DataServiceApiAuthEntity extends BaseEntity { public class DataServiceApiAuthEntity extends BaseEntity {
/** /**
* appid * appid
*/ */

View File

@ -13,7 +13,7 @@ import net.srt.framework.mybatis.entity.BaseEntity;
*/ */
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Data @Data
@TableName("data_service_api_log1") @TableName("data_service_api_log")
public class DataServiceApiLogEntity extends BaseEntity { public class DataServiceApiLogEntity extends BaseEntity {
/** /**
* url * url

View File

@ -7,6 +7,7 @@ import net.srt.framework.common.page.PageResult;
import net.srt.framework.mybatis.service.BaseService; import net.srt.framework.mybatis.service.BaseService;
import net.srt.query.ApiConfigQuery; import net.srt.query.ApiConfigQuery;
import net.srt.vo.ApiConfigVo; import net.srt.vo.ApiConfigVo;
import net.srt.vo.DataServiceApiAuthVo;
import srt.cloud.framework.dbswitch.core.model.JdbcSelectResult; import srt.cloud.framework.dbswitch.core.model.JdbcSelectResult;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -37,4 +38,10 @@ public interface ApiConfigService extends BaseService<ApiConfigEntity> {
JdbcSelectResult sqlExecute(SqlDto dto); JdbcSelectResult sqlExecute(SqlDto dto);
void exportDocs(List<Long> ids, HttpServletResponse response); void exportDocs(List<Long> ids, HttpServletResponse response);
void upAuth(DataServiceApiAuthVo authVO);
DataServiceApiAuthVo getAuthInfo(Long authId);
void resetRequested(Long authId);
} }

View File

@ -6,11 +6,14 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import net.srt.api.ServerNames; import net.srt.api.ServerNames;
import net.srt.convert.ApiConfigConvert; import net.srt.convert.ApiConfigConvert;
import net.srt.convert.DataServiceApiAuthConvert;
import net.srt.dao.ApiConfigDao; import net.srt.dao.ApiConfigDao;
import net.srt.dao.ApiGroupDao; import net.srt.dao.ApiGroupDao;
import net.srt.dao.DataServiceApiAuthDao;
import net.srt.dto.SqlDto; import net.srt.dto.SqlDto;
import net.srt.entity.ApiConfigEntity; import net.srt.entity.ApiConfigEntity;
import net.srt.entity.ApiGroupEntity; import net.srt.entity.ApiGroupEntity;
import net.srt.entity.DataServiceApiAuthEntity;
import net.srt.framework.common.constant.Constant; import net.srt.framework.common.constant.Constant;
import net.srt.framework.common.page.PageResult; import net.srt.framework.common.page.PageResult;
import net.srt.framework.mybatis.service.impl.BaseServiceImpl; import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
@ -18,6 +21,7 @@ import net.srt.framework.security.user.SecurityUser;
import net.srt.query.ApiConfigQuery; import net.srt.query.ApiConfigQuery;
import net.srt.service.ApiConfigService; import net.srt.service.ApiConfigService;
import net.srt.vo.ApiConfigVo; import net.srt.vo.ApiConfigVo;
import net.srt.vo.DataServiceApiAuthVo;
import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -42,6 +46,7 @@ public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfi
private final ApiGroupDao apiGroupDao; private final ApiGroupDao apiGroupDao;
private final DiscoveryClient discoveryClient; private final DiscoveryClient discoveryClient;
private final ApiConfigDao apiConfigDao; private final ApiConfigDao apiConfigDao;
private final DataServiceApiAuthDao dataServiceApiAuthDao;
private final Map<String, ApiConfigEntity> mappings = new ConcurrentHashMap<>(); private final Map<String, ApiConfigEntity> mappings = new ConcurrentHashMap<>();
@Override @Override
public String getIpPort() { public String getIpPort() {
@ -168,6 +173,22 @@ public class ApiConfigServiceImpl extends BaseServiceImpl<ApiConfigDao, ApiConfi
} }
} }
@Override
public void upAuth(DataServiceApiAuthVo authVO) {
dataServiceApiAuthDao.updateById(DataServiceApiAuthConvert.INSTANCE.convert(authVO));
}
@Override
public DataServiceApiAuthVo getAuthInfo(Long authId) {
return DataServiceApiAuthConvert.INSTANCE.convert(dataServiceApiAuthDao.selectById(authId));
}
@Override
public void resetRequested(Long authId) {
dataServiceApiAuthDao.resetRequested(authId);
}
@Override @Override
public PageResult<ApiConfigVo> page(ApiConfigQuery query) { public PageResult<ApiConfigVo> page(ApiConfigQuery query) {
// 查询参数 // 查询参数

View File

@ -53,6 +53,7 @@ public class DataServiceAppServiceImpl extends BaseServiceImpl<DataServiceAppDao
@Override @Override
public void update1(DataServiceAppVo vo) { public void update1(DataServiceAppVo vo) {
DataServiceAppEntity app = DataServiceAppConvert.INSTANCE.convert(vo); DataServiceAppEntity app = DataServiceAppConvert.INSTANCE.convert(vo);
@ -69,19 +70,23 @@ public class DataServiceAppServiceImpl extends BaseServiceImpl<DataServiceAppDao
authVO.setProjectId(getProjectId()); authVO.setProjectId(getProjectId());
DataServiceApiAuthEntity entity = DataServiceApiAuthConvert.INSTANCE.convert(authVO); DataServiceApiAuthEntity entity = DataServiceApiAuthConvert.INSTANCE.convert(authVO);
dataServiceApiAuthDao.insert(entity); dataServiceApiAuthDao.insert(entity);
Long id = entity.getId(); Long id = entity.getApiId();
apiConfigDao.updateById(authVO.getApiId(),id); apiConfigDao.updateById(authVO.getApiId(),id);
} }
//修改授权
@Override @Override
public void upAuth(DataServiceApiAuthVo authVO) { public void upAuth(DataServiceApiAuthVo authVO) {
dataServiceApiAuthDao.updateById(DataServiceApiAuthConvert.INSTANCE.convert(authVO)); DataServiceApiAuthEntity entity = DataServiceApiAuthConvert.INSTANCE.convert(authVO);
dataServiceApiAuthDao.updateById(entity);
} }
//取消授权
@Override @Override
public void cancelAuth(Long authId) { public void cancelAuth(Long authId) {
dataServiceAppDao.deleteById(authId); dataServiceApiAuthDao.deleteById(authId);
apiConfigDao.updateAuthId(authId);
} }
@Override @Override

View File

@ -51,5 +51,6 @@ public class ApiConfigVo implements Serializable {
private Long authId; private Long authId;
private String group; private String group;
private String groupPath; private String groupPath;
private Integer previlege;
} }

View File

@ -19,27 +19,27 @@ import java.util.Date;
public class DataServiceApiAuthVo implements Serializable { public class DataServiceApiAuthVo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Schema(description = "主键id") @Schema(description = "id")
private Long id; private Long id;
@Schema(description = "app的id") @Schema(description = "appId")
private Long appId; private Long appId;
@Schema(description = "分组id") @Schema(description = "groupId")
private Long groupId; private Long groupId;
@Schema(description = "api的id") @Schema(description = "apiId")
private Long apiId; private Long apiId;
@Schema(description = "调用次数 不限次数为-1") @Schema(description = "调用的次数:不限次数为-1")
private Integer requestTimes; private Integer requestTimes;
@Schema(description = "已调次数") @Schema(description = "已调次数")
private Integer requestedTimes; private Integer requestedTimes;
private Integer requestedSuccessTimes; private Integer requestedSuccessTimes;
private Integer requestedFailedTimes; private Integer requestedFailedTimes;
@Schema(description = "所属项目id") @Schema(description = "所属项目id")
private Long projectId; private Long projectId;
private Long authId; private Long authId;
@ -47,7 +47,7 @@ public class DataServiceApiAuthVo implements Serializable {
@Schema(description = "版本号") @Schema(description = "版本号")
private Integer version; private Integer version;
@Schema(description = "删除标识 0:正常 1已删除") @Schema(description = "删除标识 0是正常 1是已删除")
private Integer deleted; private Integer deleted;
@Schema(description = "创建者") @Schema(description = "创建者")

View File

@ -5,6 +5,9 @@
<update id="updateById"> <update id="updateById">
update data_service_api_config set auth_id=#{apiId} where id=#{id} update data_service_api_config set auth_id=#{apiId} where id=#{id}
</update> </update>
<update id="updateAuthId">
update data_service_api_config set auth_id=null where auth_id=#{authId}
</update>
<select id="getResourceList" resultType="net.srt.entity.ApiConfigEntity"> <select id="getResourceList" resultType="net.srt.entity.ApiConfigEntity">
<choose> <choose>
<when test="queryApply!=null and queryApply==1"> <when test="queryApply!=null and queryApply==1">
@ -38,7 +41,7 @@
FROM FROM
data_service_api_config dsac data_service_api_config dsac
INNER JOIN data_service_api_group dsag ON dsac.group_id=dsag.id INNER JOIN data_service_api_group dsag ON dsac.group_id=dsag.id
INNER JOIN data_service_api_auth1 dsaa ON dsac.id = dsaa.api_id INNER JOIN data_service_api_auth dsaa ON dsac.id = dsaa.api_id
WHERE WHERE
dsaa.app_id=#{appId} dsaa.app_id=#{appId}
AND dsac.deleted=0 AND dsac.deleted=0
@ -50,11 +53,11 @@
dsaa.id AS auth_id dsaa.id AS auth_id
FROM FROM
data_service_api_config dsac data_service_api_config dsac
LEFT JOIN data_service_api_auth1 dsaa ON dsac.id = dsaa.api_id AND dsaa.app_id=#{appId} LEFT JOIN data_service_api_auth dsaa ON dsac.id = dsaa.api_id AND dsaa.app_id=#{appId}
AND dsaa.deleted=0 AND dsaa.deleted=0
WHERE WHERE
dsac.group_id = #{groupId} dsac.group_id = #{groupId}
AND dsac.previlege=1 AND dsac.privates=1
AND dsac.deleted=0 AND dsac.deleted=0
</otherwise> </otherwise>
</choose> </choose>
@ -67,7 +70,7 @@
<if test="contentType != null and contentType.trim() != ''"> <if test="contentType != null and contentType.trim() != ''">
AND dsac.content_type = #{contentType} AND dsac.content_type = #{contentType}
</if> </if>
<if test="status != null"> <if test="status != ">
AND dsac.status = #{status} AND dsac.status = #{status}
</if> </if>
<if test="sqlDbType != null"> <if test="sqlDbType != null">
@ -76,8 +79,8 @@
<if test="databaseId != null"> <if test="databaseId != null">
AND dsac.database_id = #{databaseId} AND dsac.database_id = #{databaseId}
</if> </if>
<if test="previlege != null"> <if test="privates != null">
AND dsac.previlege = #{previlege} AND dsac.privates = #{privates}
</if> </if>
<if test="openTrans != null"> <if test="openTrans != null">
AND dsac.open_trans = #{openTrans} AND dsac.open_trans = #{openTrans}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.srt.dao.DataServiceApiAuthDao">
<update id="resetRequested">
UPDATE data_service_api_auth SET requested_times=0,requested_success_times=0,requested_failed_times=0 WHERE id =#{id}
</update>
</mapper>