Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	srt-cloud-data-governance/src/main/java/net/srt/controller/MetadataController.java
#	srt-cloud-data-governance/src/main/java/net/srt/service/MetadataService.java
#	srt-cloud-data-governance/src/main/java/net/srt/service/impl/MetadataServiceimpl.java
dev
chenbingxuan 2023-12-25 22:40:46 +08:00
commit 400524d5ae
80 changed files with 2587 additions and 76 deletions

View File

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

View File

@ -9,10 +9,7 @@ import net.srt.framework.common.utils.Result;
import net.srt.query.DatastandrdQuery;
import net.srt.service.DatastandardService;
import net.srt.vo.DatastandardVo;
import net.srt.vo.MetamodelPropertyVO;
import net.srt.vo.StandardManagementVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

View File

@ -0,0 +1,45 @@
package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.srt.convert.MetadataCollectRecordConvert;
import net.srt.entity.MetadataCollectRecordEntity;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.common.utils.Result;
import net.srt.query.MetadataCollectRecordQuery;
import net.srt.service.MetadataCollectRecordService;
import net.srt.vo.MetadataCollectRecordVO;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping("metadata-collect-record")
@Tag(name = "数据治理-元数据采集任务记录")
@AllArgsConstructor
public class MetadataCollectRecordController {
private final MetadataCollectRecordService metadataCollectRecordService;
@GetMapping("page")
@Operation(summary = "分页")
public Result<PageResult<MetadataCollectRecordVO>> page(@Valid MetadataCollectRecordQuery query){
PageResult<MetadataCollectRecordVO> page = metadataCollectRecordService.page(query);
return Result.ok(page);
}
@GetMapping("{id}")
@Operation(summary = "信息")
public Result<MetadataCollectRecordVO> get(@PathVariable Long id){
MetadataCollectRecordEntity entity = metadataCollectRecordService.getById(id);
return Result.ok(MetadataCollectRecordConvert.INSTANCE.convert(entity));
}
@DeleteMapping
@Operation(summary = "删除")
public Result<String> delete(@RequestBody List<Long> idList) {
metadataCollectRecordService.delete(idList);
return Result.ok();
}
}

View File

@ -0,0 +1,51 @@
package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.srt.convert.MetadataPropertyConvert;
import net.srt.entity.MetadataPropertyEntity;
import net.srt.framework.common.utils.Result;
import net.srt.service.MetadataPropertyService;
import net.srt.vo.MetadataPropertyVo;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping("metadata-property")
@Tag(name = "数据治理-元数据属性值")
@AllArgsConstructor
public class MetadataPropertyController {
private final MetadataPropertyService metadataPropertyService;
@GetMapping("{id}")
@Operation(summary = "信息")
public Result<MetadataPropertyVo> get(@PathVariable("id") Long id) {
MetadataPropertyEntity entity = metadataPropertyService.getById(id);
return Result.ok(MetadataPropertyConvert.INSTANCE.convert(entity));
}
@PostMapping
@Operation(summary = "保存")
public Result<String> save(@RequestBody MetadataPropertyVo vo){
metadataPropertyService.save(vo);
return Result.ok();
}
@PutMapping
@Operation(summary = "修改")
public Result<String> update(@RequestBody @Valid MetadataPropertyVo vo){
metadataPropertyService.update(vo);
return Result.ok();
}
@DeleteMapping
@Operation(summary = "删除")
public Result<String> delete(@RequestBody List<Long> idList){
metadataPropertyService.delete(idList);
return Result.ok();
}
}

View File

@ -0,0 +1,47 @@
package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.srt.convert.MetadataStandardRelConvert;
import net.srt.entity.MetadataStandardRelEntity;
import net.srt.framework.common.utils.Result;
import net.srt.service.MetadataStandardRelService;
import net.srt.vo.MetadataStandardRelVO;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("standard-rel")
@Tag(name = "数据治理-元数据标准关联表")
@AllArgsConstructor
public class MetadataStandarRelController {
private final MetadataStandardRelService metadataStandardRelService;
@GetMapping("/{metadataId}/{metadata-rel}")
@Operation(summary = "根据metadataId获取标准字段")
public Result<MetadataStandardRelVO> getMetadataRel(@PathVariable("metadataId") Long metadataId){
MetadataStandardRelVO standardRelVO = metadataStandardRelService.getMetadataRel(metadataId);
return Result.ok(standardRelVO);
}
@GetMapping("{id}")
@Operation(summary = "信息")
public Result<MetadataStandardRelVO> get(@PathVariable("id") Long id) {
MetadataStandardRelEntity entity = metadataStandardRelService.getById(id);
return Result.ok(MetadataStandardRelConvert.INSTANCE.convert(entity));
}
@PostMapping
@Operation(summary = "保存")
public Result<String> save(@RequestBody MetadataStandardRelVO vo){
metadataStandardRelService.save(vo);
return Result.ok();
}
@DeleteMapping("/{metadataId}/{standardId}")
@Operation(summary = "删除")
public Result<String> delete(@PathVariable Long metadataId,@PathVariable Long standardId){
metadataStandardRelService.delete(metadataId,standardId);
return Result.ok();
}
}

View File

@ -2,7 +2,6 @@ package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import lombok.AllArgsConstructor;
import net.srt.convert.MetamodelConvert;
import net.srt.entity.MetamodelEntity;

View File

@ -1,6 +1,5 @@
package net.srt.controller;
import cn.hutool.db.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;

View File

@ -1,6 +1,5 @@
package net.srt.controller;
import cn.hutool.db.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;

View File

@ -2,7 +2,6 @@ package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import lombok.AllArgsConstructor;
import net.srt.convert.QualityTaskConvert;
import net.srt.entity.QualityTaskEntity;

View File

@ -2,9 +2,6 @@ package net.srt.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.srt.entity.DatastandardEntity;
import net.srt.entity.StandardEntity;
import net.srt.framework.common.utils.BeanUtil;
import net.srt.framework.common.utils.Result;
import net.srt.framework.common.utils.TreeNodeVo;
import net.srt.service.StandardService;
@ -12,8 +9,6 @@ import net.srt.vo.StandardManagementVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
/**

View File

@ -2,7 +2,6 @@ package net.srt.convert;
import net.srt.entity.DatastandardEntity;
import net.srt.vo.DatastandardVo;
import net.srt.vo.StandardManagementVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

View File

@ -0,0 +1,23 @@
package net.srt.convert;
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataCollectRecordDto;
import net.srt.entity.MetadataCollectRecordEntity;
import net.srt.vo.MetadataCollectRecordVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface MetadataCollectRecordConvert {
MetadataCollectRecordConvert INSTANCE = Mappers.getMapper(MetadataCollectRecordConvert.class);
MetadataCollectRecordEntity convert(MetadataCollectRecordVO vo);
MetadataCollectRecordEntity convert(DataGovernanceMetadataCollectRecordDto dto);
MetadataCollectRecordVO convert(MetadataCollectRecordEntity entity);
List<MetadataCollectRecordVO> convertList(List<MetadataCollectRecordEntity> list);
}

View File

@ -1,22 +1,27 @@
package net.srt.convert;
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataDto;
import net.srt.entity.MetadataEntity;
import net.srt.vo.MetadataVo;
import net.srt.vo.MetadataVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* @BelongsProject: srt_cloud
* @BelongsPackage: net.srt.convert
* @Author: jpz
* @CreateTime: 2023/12/24 15:42
*/
import java.util.List;
@Mapper
public interface MetadataConvert {
MetadataConvert INSTANCE = Mappers.getMapper(MetadataConvert.class);
MetadataVo convert(MetadataEntity entity);
MetadataEntity convert(MetadataVO vo);
MetadataEntity convert(DataGovernanceMetadataDto dto);
MetadataVO convert(MetadataEntity entity);
DataGovernanceMetadataDto convertDto(MetadataEntity entity);
List<MetadataVO> convertList(List<MetadataEntity> list);
List<DataGovernanceMetadataDto> convertDtoList(List<MetadataEntity> list);
MetadataEntity convert(MetadataVo vo);
}

View File

@ -0,0 +1,25 @@
package net.srt.convert;
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataPropertyDto;
import net.srt.entity.MetadataPropertyEntity;
import net.srt.vo.MetadataPropertyVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface MetadataPropertyConvert {
MetadataPropertyConvert INSTANCE = Mappers.getMapper(MetadataPropertyConvert.class);
MetadataPropertyEntity convert(MetadataPropertyVo vo);
MetadataPropertyEntity convert(DataGovernanceMetadataPropertyDto dto);
MetadataPropertyVo convert(MetadataPropertyEntity entity);
DataGovernanceMetadataPropertyDto convertDto(MetadataPropertyEntity entity);
List<MetadataPropertyVo> convertList(List<MetadataPropertyEntity> list);
}

View File

@ -0,0 +1,20 @@
package net.srt.convert;
import net.srt.entity.MetadataStandardRelEntity;
import net.srt.vo.MetadataStandardRelVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface MetadataStandardRelConvert {
MetadataStandardRelConvert INSTANCE = Mappers.getMapper(MetadataStandardRelConvert.class);
MetadataStandardRelEntity convert(MetadataStandardRelVO vo);
MetadataStandardRelVO convert(MetadataStandardRelEntity entity);
List<MetadataStandardRelVO> convertList(List<MetadataStandardRelEntity> list);
}

View File

@ -4,7 +4,6 @@ import net.srt.entity.MetamodelEntity;
import net.srt.vo.MetamodelVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;
import java.util.List;
@Mapper

View File

@ -1,8 +1,6 @@
package net.srt.convert;
import net.srt.entity.QualityQueryEntity;
import net.srt.entity.QualityTaskColumnEntity;
import net.srt.vo.QualityRuleVo;
import net.srt.vo.QualityTaskColumnVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

View File

@ -1,13 +1,10 @@
package net.srt.convert;
import net.srt.controller.QualityTaskController;
import net.srt.entity.QualityTaskEntity;
import net.srt.vo.QualityTaskVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;
import javax.swing.*;
import java.util.List;
/**

View File

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

View File

@ -8,13 +8,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @BelongsProject: srt_cloud
* @BelongsPackage: net.srt.dao
* @Author: jpz
* @CreateTime: 2023/12/24 15:49
*/
@Mapper
public interface MetadataPropertyDao extends BaseDao<MetadataPropertyEntity> {
List<MetamodelPropertyVO> listPropertyById(@Param("id") Long id, Long metamodelId);
List<MetamodelPropertyVO> listPropertyById(@Param("id") Long id, @Param("metamodelId") Long metamodelId);
}

View File

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

View File

@ -1,8 +1,6 @@
package net.srt.dao;
import net.srt.entity.QualityTaskColumnEntity;
import net.srt.entity.QualityTaskEntity;
import net.srt.entity.QualityTaskTableEntity;
import net.srt.framework.mybatis.dao.BaseDao;
import org.apache.ibatis.annotations.Mapper;

View File

@ -1,6 +1,5 @@
package net.srt.dao;
import net.srt.entity.QualityTaskEntity;
import net.srt.entity.QualityTaskTableEntity;
import net.srt.framework.mybatis.dao.BaseDao;
import org.apache.ibatis.annotations.Mapper;

View File

@ -1,6 +1,5 @@
package net.srt.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;

View File

@ -0,0 +1,51 @@
package net.srt.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.srt.framework.mybatis.entity.BaseEntity;
import java.util.Date;
@EqualsAndHashCode(callSuper = false)
@Data
@TableName("data_governance_metadata_collect_record")
public class MetadataCollectRecordEntity extends BaseEntity {
/**
* id
*/
private Long metadataCollectId;
/**
* 1- 0- 2-
*/
private Integer status;
/**
*
*/
private String realTimeLog;
/**
*
*/
private String errorLog;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
/**
* id
*/
private Long projectId;
}

View File

@ -5,16 +5,11 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import net.srt.framework.mybatis.entity.BaseEntity;
/**
* @BelongsProject: srt_cloud
* @BelongsPackage: net.srt.entity
* @Author: jpz
* @CreateTime: 2023/12/24 15:50
*/
@EqualsAndHashCode(callSuper = false)
@Data
@TableName("data_governance_metadata_property")
public class MetadataPropertyEntity extends BaseEntity {
/**
* id
*/
@ -35,4 +30,6 @@ public class MetadataPropertyEntity extends BaseEntity {
*/
private Long projectId;
}

View File

@ -0,0 +1,76 @@
package net.srt.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.srt.framework.mybatis.entity.BaseEntity;
@EqualsAndHashCode(callSuper = false)
@Data
@TableName("data_governance_standard")
public class MetadataStandardEntity extends BaseEntity {
/**
* id
*/
private Long categoryId;
/**
*
*/
private String engName;
/**
*
*/
private String cnName;
/**
*
*/
private Integer codeNum;
/**
*
*/
private String dataType;
/**
*
*/
private Integer dataLength;
/**
*
*/
private Integer dataPrecision;
/**
* 0- 1-
*/
private Integer nullable;
/**
* id
*/
private Integer standardCodeId;
/**
* 1- 2-
*/
private Integer type;
/**
*
*/
private String note;
/**
* id
*/
private Long projectId;
private Integer status;
}

View File

@ -0,0 +1,29 @@
package net.srt.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.srt.framework.mybatis.entity.BaseEntity;
@EqualsAndHashCode(callSuper = false)
@Data
@TableName("data_governance_metadata_standard_rel")
public class MetadataStandardRelEntity extends BaseEntity {
/**
* id
*/
private Long metadataId;
/**
* id
*/
private Long standardId;
/**
*
*/
private Integer deleted;
}

View File

@ -0,0 +1,34 @@
package net.srt.init;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.srt.service.MetadataCollectRecordService;
import net.srt.service.QualityTaskService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
public class BusinessInitializer implements ApplicationRunner {
private final MetadataCollectRecordService metadataCollectRecordService;
private final QualityTaskService qualityTaskService;
@Override
public void run(ApplicationArguments args) {
initScheduleMonitor();
}
/**
* init task monitor
*/
private void initScheduleMonitor() {
//处理没执行完的采集任务
metadataCollectRecordService.dealNotFinished();
//处理没执行完的质量检测任务
qualityTaskService.dealNotFinished();
}
}

View File

@ -0,0 +1,27 @@
package net.srt.query;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.srt.framework.common.query.Query;
import net.srt.framework.common.utils.DateUtils;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(description = "数据治理-源数据采集任务记录查询")
public class MetadataCollectRecordQuery extends Query {
private Long metadataCollectId;
@Schema(description = "开始时间")
@DateTimeFormat(pattern = DateUtils.DATE_TIME_PATTERN)
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date startTime;
@Schema(description = "结束时间")
@DateTimeFormat(pattern = DateUtils.DATE_TIME_PATTERN)
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date endTime;
private Integer status;
}

View File

@ -0,0 +1,16 @@
package net.srt.service;
import net.srt.entity.MetadataCollectQuery;
import net.srt.entity.MetadataCollectRecordEntity;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.mybatis.service.BaseService;
import net.srt.query.MetadataCollectRecordQuery;
import net.srt.vo.MetadataCollectRecordVO;
import java.util.List;
public interface MetadataCollectRecordService extends BaseService<MetadataCollectRecordEntity> {
PageResult<MetadataCollectRecordVO> page(MetadataCollectRecordQuery query);
void delete(List<Long> idList);
}

View File

@ -0,0 +1,15 @@
package net.srt.service;
import net.srt.entity.MetadataPropertyEntity;
import net.srt.framework.mybatis.service.BaseService;
import net.srt.vo.MetadataPropertyVo;
import java.util.List;
public interface MetadataPropertyService extends BaseService<MetadataPropertyEntity> {
void save(MetadataPropertyVo vo);
void update(MetadataPropertyVo vo);
void delete(List<Long> idList);
}

View File

@ -0,0 +1,13 @@
package net.srt.service;
import net.srt.entity.MetadataStandardRelEntity;
import net.srt.framework.mybatis.service.BaseService;
import net.srt.vo.MetadataStandardRelVO;
public interface MetadataStandardRelService extends BaseService<MetadataStandardRelEntity> {
void delete(Long metadataId, Long standardId);
MetadataStandardRelVO getMetadataRel(Long metadataId);
void save(MetadataStandardRelVO vo);
}

View File

@ -0,0 +1,45 @@
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.MetadataCollectRecordConvert;
import net.srt.dao.MetadataCollectRecordDao;
import net.srt.entity.MetadataCollectRecordEntity;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
import net.srt.query.MetadataCollectRecordQuery;
import net.srt.service.MetadataCollectRecordService;
import net.srt.vo.MetadataCollectRecordVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@AllArgsConstructor
public class MetadataCollectRecordServiceImpl extends BaseServiceImpl<MetadataCollectRecordDao, MetadataCollectRecordEntity> implements MetadataCollectRecordService {
@Override
public PageResult<MetadataCollectRecordVO> page(MetadataCollectRecordQuery query) {
IPage<MetadataCollectRecordEntity> page = baseMapper.selectPage(getPage(query),getWrapper(query));
return new PageResult<>(MetadataCollectRecordConvert.INSTANCE.convertList(page.getRecords()),page.getTotal());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(List<Long> idList) {
removeByIds(idList);
}
private LambdaQueryWrapper<MetadataCollectRecordEntity> getWrapper(MetadataCollectRecordQuery query) {
LambdaQueryWrapper<MetadataCollectRecordEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(query.getMetadataCollectId() != null,MetadataCollectRecordEntity::getMetadataCollectId,query.getMetadataCollectId())
.eq(query.getStatus() != null, MetadataCollectRecordEntity::getStatus,query.getStatus())
.gt(query.getStartTime()!=null,MetadataCollectRecordEntity::getStartTime,query.getStartTime())
.lt(query.getEndTime()!=null,MetadataCollectRecordEntity::getEndTime,query.getEndTime())
.orderByDesc(MetadataCollectRecordEntity::getId);
return wrapper;
}
}

View File

@ -10,8 +10,10 @@ import net.srt.api.module.data.governance.constant.MetadataCollectType;
import net.srt.api.module.quartz.QuartzDataGovernanceMetadataCollectApi;
import net.srt.convert.MetadataCollectConvert;
import net.srt.dao.MetadataCollectDao;
import net.srt.dao.MetadataCollectRecordDao;
import net.srt.entity.MetadataCollectEntity;
import net.srt.entity.MetadataCollectQuery;
import net.srt.entity.MetadataCollectRecordEntity;
import net.srt.framework.common.exception.ServerException;
import net.srt.framework.common.page.PageResult;
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
@ -29,6 +31,7 @@ import java.util.List;
public class MetadataCollectServiceImpl extends BaseServiceImpl<MetadataCollectDao, MetadataCollectEntity> implements MetadataCollectService {
private final QuartzDataGovernanceMetadataCollectApi metadataCollectApi;
private final MetadataCollectRecordDao collectRecordDao;
@Override
public PageResult<MetadataCollectVO> page(MetadataCollectQuery query) {
@ -78,10 +81,12 @@ public class MetadataCollectServiceImpl extends BaseServiceImpl<MetadataCollectD
@Override
public void delete(List<Long> idList) {
removeByIds(idList);
// for (Long id : idList) {
// LambdaQueryWrapper<MetadataCollectEntity> wrapper = Wrappers.lambdaQuery();
//
// }
for (Long id : idList) {
LambdaQueryWrapper<MetadataCollectRecordEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(MetadataCollectRecordEntity::getMetadataCollectId,id);
collectRecordDao.delete(wrapper);
}
}
private void checkParam(MetadataCollectVO vo){

View File

@ -0,0 +1,35 @@
package net.srt.service.impl;
import lombok.AllArgsConstructor;
import net.srt.convert.MetadataPropertyConvert;
import net.srt.dao.MetadataPropertyDao;
import net.srt.entity.MetadataPropertyEntity;
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
import net.srt.service.MetadataPropertyService;
import net.srt.vo.MetadataPropertyVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@AllArgsConstructor
public class MetadataPropertyServiceImpl extends BaseServiceImpl<MetadataPropertyDao, MetadataPropertyEntity> implements MetadataPropertyService {
@Override
public void save(MetadataPropertyVo vo) {
MetadataPropertyEntity entity = MetadataPropertyConvert.INSTANCE.convert(vo);
baseMapper.insert(entity);
}
@Override
public void update(MetadataPropertyVo vo) {
MetadataPropertyEntity entity = MetadataPropertyConvert.INSTANCE.convert(vo);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(List<Long> idList) {
removeByIds(idList);
}
}

View File

@ -1,12 +1,234 @@
package net.srt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.v3.oas.annotations.servers.Server;
import lombok.AllArgsConstructor;
import net.srt.api.module.data.governance.constant.BuiltInMetamodel;
import net.srt.convert.MetadataConvert;
import net.srt.dao.MetadataDao;
import net.srt.dao.MetadataPropertyDao;
import net.srt.entity.MetadataEntity;
import net.srt.entity.MetadataPropertyEntity;
import net.srt.framework.common.cache.bean.Neo4jInfo;
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.framework.security.cache.TokenStoreCache;
import net.srt.service.MetadataService;
@Server
import net.srt.vo.MetadataVO;
import net.srt.vo.MetamodelPropertyVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import srt.cloud.framework.dbswitch.common.util.StringUtil;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Service
@AllArgsConstructor
public class MetadataServiceImpl extends BaseServiceImpl<MetadataDao, MetadataEntity> implements MetadataService {
private final MetadataDao metadataDao;
private final MetadataPropertyDao metadataPropertyDao;
private final TokenStoreCache tokenStoreCache;
@Override
public List<TreeNodeVo> listByParentId(Long parentId) {
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MetadataEntity::getParentId,parentId)
.orderByAsc(MetadataEntity::getOrderNo);
dataScopeWithOrgId(wrapper);
List<MetadataEntity> metadataEntities = baseMapper.selectList(wrapper);
return BeanUtil.copyListProperties(metadataEntities,TreeNodeVo::new, (oldItem, newItem) ->{
newItem.setLabel(oldItem.getName());
newItem.setValue(oldItem.getId());
newItem.setLeaf(BuiltInMetamodel.COLUMN.getId().equals(oldItem.getMetamodelId()));
if(newItem.getPath().contains("/")){
newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
}
});
}
@Override
public List<TreeNodeVo> listFloder() {
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MetadataEntity::getIfLeaf,1)
.orderByAsc(MetadataEntity::getOrderNo)
.orderByAsc(MetadataEntity::getId);
dataScopeWithOrgId(wrapper);
List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(metadatas, TreeNodeVo::new, (oldItem, newItem) -> {
newItem.setLabel(oldItem.getName());
newItem.setValue(oldItem.getId());
if (newItem.getPath().contains("/")) {
newItem.setParentPath(newItem.getPath().substring(0, newItem.getPath().lastIndexOf("/")));
}
});
return BuildTreeUtils.buildTree(treeNodeVos);
}
@Override
public List<TreeNodeVo> listDb() {
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.in(MetadataEntity::getMetamodelId,BuiltInMetamodel.SCHEMA.getId(),BuiltInMetamodel.TABLE.getId())
.or()
.isNull(MetadataEntity::getMetamodelId)
.orderByAsc(MetadataEntity::getOrderNo);
dataScopeWithOrgId(wrapper);
List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(metadatas,TreeNodeVo::new, (oldItem, newItem) -> {
newItem.setLabel(oldItem.getName());
newItem.setValue(oldItem.getId());
newItem.setDisabled(!BuiltInMetamodel.TABLE.getId().equals(oldItem.getMetamodelId()));
if(newItem.getPath().contains("/")) {
newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
}
});
return BuildTreeUtils.buildTree(treeNodeVos);
}
@Override
public List<TreeNodeVo> listByKeyword(String keyword) {
if(StringUtil.isBlank(keyword)){
return listByParentId(0L);
}
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.like(MetadataEntity::getName,keyword)
.or()
.like(MetadataEntity::getCode,keyword)
.orderByAsc(MetadataEntity::getOrderNo)
.orderByAsc(MetadataEntity::getId);
dataScopeWithOrgId(wrapper);
List<MetadataEntity> metadatas = baseMapper.selectList(wrapper);
List<MetadataEntity> resultList = new ArrayList<>();
//递归获取父级
for (MetadataEntity metadata : metadatas) {
recursionAddParent(metadata,resultList);
}
List<MetadataEntity> result = resultList.stream().sorted(Comparator.comparing(MetadataEntity::getOrderNo)).collect(Collectors.toList());
List<TreeNodeVo> treeNodeVos = BeanUtil.copyListProperties(result ,TreeNodeVo::new, (oldItem, newItem) -> {
newItem.setLabel(oldItem.getName());
newItem.setValue(oldItem.getId());
newItem.setLeaf(BuiltInMetamodel.COLUMN.getId().equals(oldItem.getMetamodelId()));
if(newItem.getPath().contains("/")) {
newItem.setParentPath(newItem.getPath().substring(0,newItem.getPath().lastIndexOf("/")));
}
});
return BuildTreeUtils.buildTree(treeNodeVos);
}
@Override
public MetadataVO get(Long id) {
MetadataEntity metadataEntity = getById(id);
MetadataVO metadataVO = MetadataConvert.INSTANCE.convert(metadataEntity);
metadataVO.setProperties(metadataPropertyDao.listPropertyById(id,metadataEntity.getMetamodelId()));
return metadataVO;
}
@Override
public void save(MetadataVO vo) {
MetadataEntity entity = MetadataConvert.INSTANCE.convert(vo);
entity.setProjectId(getProjectId());
entity.setPath(recursionPath(entity,null));
buildField(entity);
MetadataEntity parentMetadata = baseMapper.selectById(vo.getParentId());
if(parentMetadata != null) {
entity.setDbType(parentMetadata.getDbType());
entity.setDatasourceId(parentMetadata.getDatasourceId());
entity.setCollectTaskId(parentMetadata.getCollectTaskId());
}
baseMapper.insert(entity);
buildProperties(entity,vo.getProperties());
}
@Override
public void update(MetadataVO vo) {
MetadataEntity entity = MetadataConvert.INSTANCE.convert(vo);
entity.setProjectId(getProjectId());
entity.setPath(recursionPath(entity,null));
buildField(entity);
updateById(entity);
buildProperties(entity,vo.getProperties());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MetadataEntity::getParentId,id).last("limit 1");
if(baseMapper.selectOne(wrapper)!=null){
throw new ServerException("存在子节点,不可删除!");
}
removeById(id);
LambdaQueryWrapper<MetadataPropertyEntity> propertyWrapper = new LambdaQueryWrapper<>();
propertyWrapper.eq(MetadataPropertyEntity::getMetadataId,id);
metadataPropertyDao.delete(propertyWrapper);
}
@Override
public void upNeo4jInfo(Neo4jInfo neo4jInfo) {
tokenStoreCache.saveNeo4jInfo(getProjectId(),neo4jInfo);
}
@Override
public Neo4jInfo getNeo4jInfo() {
return tokenStoreCache.getNeo4jInfo(getProjectId());
}
private void recursionAddParent(MetadataEntity metadataEntity, List<MetadataEntity> resultList){
if(resultList.stream().noneMatch(item -> metadataEntity.getId().equals(item.getId()))) {
resultList.add(metadataEntity);
}
if(metadataEntity.getParentId()!=0){
MetadataEntity parent = getById(metadataEntity.getParentId());
recursionAddParent(parent,resultList);
}
}
private void buildField(MetadataEntity entity){
if(entity.getMetamodelId()!=null){
entity.setIcon(metadataDao.selectById(entity.getMetamodelId()).getIcon());
}
if(entity.getIfLeaf() == 1 && entity.getMetamodelId() == null) {
entity.setIcon("/src/assets/folder.png");
}
}
private String recursionPath(MetadataEntity metadataEntity, String path) {
if(StringUtil.isBlank(path)){
path = metadataEntity.getName();
}
if(metadataEntity.getParentId()!=0){
MetadataEntity parent = getById(metadataEntity.getParentId());
path = parent.getName() + "/" +path;
return recursionPath(parent,path);
}
return path;
}
private void buildProperties(MetadataEntity entity, List<MetamodelPropertyVO> properties){
if(!CollectionUtils.isEmpty(properties)){
LambdaQueryWrapper<MetadataPropertyEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MetadataPropertyEntity::getMetadataId,entity.getId());
for (MetamodelPropertyVO property : properties) {
MetadataPropertyEntity metadataPropertyEntity = new MetadataPropertyEntity();
metadataPropertyEntity.setMetamodelPropertyId(property.getId());
metadataPropertyEntity.setMetadataId(entity.getId());
metadataPropertyEntity.setProperty(property.getValue());
metadataPropertyEntity.setProjectId(entity.getProjectId());
if(property.getMetadataPropertyId()!=null){
metadataPropertyEntity.setId(property.getMetadataPropertyId());
metadataPropertyDao.updateById(metadataPropertyEntity);
}else {
metadataPropertyDao.insert(metadataPropertyEntity);
}
}
}
}
}

View File

@ -0,0 +1,57 @@
package net.srt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import net.srt.convert.MetadataStandardRelConvert;
import net.srt.dao.MetadataStandardRelDao;
import net.srt.dao.StandardDao;
import net.srt.entity.MetadataStandardRelEntity;
import net.srt.entity.StandardEntity;
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
import net.srt.service.MetadataStandardRelService;
import net.srt.vo.MetadataStandardRelVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@AllArgsConstructor
public class MetadataStandardRelServiceImpl extends BaseServiceImpl<MetadataStandardRelDao, MetadataStandardRelEntity> implements MetadataStandardRelService {
private final StandardDao standardDao;
@Override
public MetadataStandardRelVO getMetadataRel(Long metadataId) {
LambdaQueryWrapper<MetadataStandardRelEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(MetadataStandardRelEntity::getMetadataId,metadataId).last("limit 1");
MetadataStandardRelEntity relEntity = baseMapper.selectOne(wrapper);
if(relEntity!=null){
StandardEntity standardEntity = standardDao.selectById(relEntity.getStandardId());
MetadataStandardRelVO convert = MetadataStandardRelConvert.INSTANCE.convert(relEntity);
convert.setStandardCategoryId(standardEntity.getParentId());
return convert;
}
return null;
}
@Override
public void save(MetadataStandardRelVO vo) {
MetadataStandardRelEntity entity = MetadataStandardRelConvert.INSTANCE.convert(vo);
LambdaQueryWrapper<MetadataStandardRelEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(MetadataStandardRelEntity::getMetadataId,vo.getMetadataId()).eq(MetadataStandardRelEntity::getStandardId,vo.getStandardId()).last("limit 1");
MetadataStandardRelEntity relEntity = baseMapper.selectOne(wrapper);
if(relEntity!=null) {
entity.setId(relEntity.getId());
baseMapper.updateById(entity);
}else {
baseMapper.insert(entity);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long metadataId, Long standardId) {
LambdaQueryWrapper<MetadataStandardRelEntity> wrapper = Wrappers.lambdaQuery();
wrapper.eq(MetadataStandardRelEntity::getMetadataId,metadataId).eq(MetadataStandardRelEntity::getStandardId,standardId);
baseMapper.delete(wrapper);
}
}

View File

@ -0,0 +1,49 @@
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

@ -0,0 +1,49 @@
package net.srt.vo;
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
@Schema(description = "数据治理-元数据标准关联表")
public class MetadataCollectRecordRelVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "主键id")
private Long id;
@Schema(description = "元数据id")
private Long metadataId;
@Schema(description = "标准字段id")
private Long standardId;
@Schema(description = "版本号")
private Integer version;
@Schema(description = "删除标识 0正常 1已删除")
private Integer deleted;
@Schema(description = "创建者")
private Long creator;
@Schema(description = "创建时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date createTime;
@Schema(description = "更新者")
private Long updater;
@Schema(description = "更新时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date updateTime;
private Long standardCategoryId;
}

View File

@ -0,0 +1,64 @@
package net.srt.vo;
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
@Schema(description = "数据治理-元数据采集任务记录")
public class MetadataCollectRecordVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "主键id")
private Long id;
@Schema(description = "采集任务id")
private Long metadataCollectId;
@Schema(description = "1-成功 0-失败 2-运行中")
private Integer status;
@Schema(description = "实时日志")
private String realTimeLog;
@Schema(description = "错误日志")
private String errorLog;
@Schema(description = "开始时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date startTime;
@Schema(description = "结束时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date endTime;
@Schema(description = "项目租户id")
private Long projectId;
@Schema(description = "版本号")
private Integer version;
@Schema(description = "删除标识 0正常 1已删除")
private Integer deleted;
@Schema(description = "创建者")
private Long creator;
@Schema(description = "创建时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date createTime;
@Schema(description = "更新者")
private Long updater;
@Schema(description = "更新时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date updateTime;
}

View File

@ -0,0 +1,48 @@
package net.srt.vo;
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
@Schema(description = "数据治理-元数据标准关联表")
public class MetadataStandardRelVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "主键id")
private Long id;
@Schema(description = "元数据id")
private Long metadataId;
@Schema(description = "标准字段id")
private Long standardId;
@Schema(description = "版本号")
private Integer version;
@Schema(description = "删除标识 0正常 1已删除")
private Integer deleted;
@Schema(description = "创建者")
private Long creator;
@Schema(description = "创建时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date createTime;
@Schema(description = "更新者")
private Long updater;
@Schema(description = "更新时间")
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
private Date updateTime;
private Long standardCategoryId;
}

View File

@ -17,7 +17,7 @@ import java.util.List;
*/
@Data
@Schema(description = "数据治理-元数据")
public class MetadataVo implements Serializable {
public class MetadataVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "主键id")

View File

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

View File

@ -1,12 +1,30 @@
<?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">
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.srt.dao.MetadataPropertyDao">
<select id="listPropertyById" resultType="net.srt.vo.MetamodelPropertyVO">
SELECT mo.id,mo.metamodel_id,mo.id AS metamodel_property_id,mo.name,mo.code,mo.data_type,mo.data_length,mo.input_type,mo.nullable,mo.builtin,md.id as metadata_property_id,md.property as `value` FROM data_governance_metamodel_property mo
LEFT JOIN data_governance_metadata_property md ON mo.id=md.metamodel_property_id AND md.metadata_id=#{id}
WHERE mo.metamodel_id=#{metamodelId} AND mo.deleted=0 AND md.deleted=0 order by mo.order_no
SELECT
mo.id,
mo.metamodel_id,
mo.id AS metamodel_property_id,
mo.NAME,
mo.CODE,
mo.data_type,
mo.data_length,
mo.input_type,
mo.nullable,
mo.builtin,
md.id AS metadata_property_id,
md.property AS `value`
FROM
data_governance_metamodel_property mo
LEFT JOIN data_governance_metadata_property md ON mo.id = md.metamodel_property_id
AND md.metadata_id = #{id}
WHERE
mo.metamodel_id = #{metamodelId} AND mo.deleted=0 AND md.deleted=0 order by mo.order_no
</select>
</mapper>

View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.srt</groupId>
<artifactId>srt-cloud</artifactId>
<version>2.0.0</version>
</parent>
<artifactId>srt-cloud-data-server</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.srt</groupId>
<artifactId>srt-cloud-api</artifactId>
<version>2.0.0</version>
</dependency>
<!--使用log42j-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>net.srt</groupId>
<artifactId>srt-cloud-mybatis</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>net.srt</groupId>
<artifactId>srt-cloud-dbswitch</artifactId>
<version>2.0.0</version>
<exclusions>
<exclusion>
<artifactId>jsqlparser</artifactId>
<groupId>com.github.jsqlparser</groupId>
</exclusion>
<exclusion>
<artifactId>spring-boot-starter-logging</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-springdoc-ui</artifactId>
</dependency>
</dependencies>
<build>
<!-- <finalName>${project.artifactId}</finalName>-->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>2.1.0</version>
<!-- 如果不配置 generate-daemons则打包命令为 mvn clean package appassembler:assemble -->
<!-- 如果配置了 generate-daemons打包命令可以是 mvn clean package 也可以是 mvn clean package appassembler:assemble -->
<executions>
<execution>
<id>generate-jsw-scripts</id>
<phase>package</phase>
<goals>
<goal>generate-daemons</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- flat与lib共同决定将项目用的的所有jar包复制到lib目录下 -->
<repositoryLayout>flat</repositoryLayout>
<!--从哪里copy配置文件-->
<configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
<includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
<!--是否copy配置文件-->
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<!--配置文件存放在conf目录路径-->
<configurationDirectory>conf</configurationDirectory>
<!-- 打包的jar以及maven依赖的jar放到这个目录里面 -->
<repositoryName>lib</repositoryName>
<!-- 可执行脚本的目录 -->
<binFolder>bin</binFolder>
<encoding>UTF-8</encoding>
<logsDirectory>logs</logsDirectory>
<daemons>
<daemon>
<id>${project.artifactId}</id>
<mainClass>net.srt.DataServiceApplication</mainClass>
<platforms>
<platform>jsw</platform>
</platforms>
<generatorConfigurations>
<generatorConfiguration>
<generator>jsw</generator>
<includes>
<include>linux-x86-32</include>
<include>linux-x86-64</include>
<include>windows-x86-32</include>
<include>windows-x86-64</include>
</includes>
<configuration>
<property>
<name>configuration.directory.in.classpath.first</name>
<value>conf</value>
</property>
<property>
<name>wrapper.ping.timeout</name>
<value>120</value>
</property>
<property>
<name>set.default.REPO_DIR</name>
<value>lib</value>
</property>
<property>
<name>wrapper.logfile</name>
<value>logs/wrapper.log</value>
</property>
</configuration>
</generatorConfiguration>
</generatorConfigurations>
<jvmSettings>
<!-- jvm参数 -->
<!--<systemProperties>
<systemProperty>com.sun.management.jmxremote</systemProperty>
<systemProperty>com.sun.management.jmxremote.port=1984</systemProperty>
<systemProperty>com.sun.management.jmxremote.authenticate=false</systemProperty>
<systemProperty>com.sun.management.jmxremote.ssl=false</systemProperty>
</systemProperties>-->
<extraArguments>
<extraArgument>-server</extraArgument>
<extraArgument>-Dfile.encoding=utf-8</extraArgument>
<extraArgument>-Xms128m</extraArgument>
<extraArgument>-Xmx1024m</extraArgument>
<extraArgument>-XX:+PrintGCDetails</extraArgument><!--输出GC的详细日志-->
<extraArgument>-XX:+PrintGCDateStamps</extraArgument><!--输出GC的时间戳-->
<extraArgument>-Xloggc:logs/gc.log</extraArgument><!--日志文件的输出路径-->
</extraArguments>
</jvmSettings>
</daemon>
</daemons>
<programs>
<program>
<mainClass>net.srt.DataServiceApplication</mainClass>
<id>${project.artifactId}</id>
</program>
</programs>
</configuration>
</plugin>
<!--打包 日常调试打包可以把该组件注释掉不然install的速度比较慢-->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${project.parent.basedir}/assembly/assembly-win.xml</descriptor>
<descriptor>${project.parent.basedir}/assembly/assembly-linux.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!--<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,16 @@
package net.srt;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public class DataServiceApplication {
public static void main(String[] args) {
SpringApplication.run(DataServiceApplication.class, args);
System.out.println("==============启动成功===================");
}
}

View File

@ -0,0 +1,119 @@
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

@ -0,0 +1,70 @@
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

@ -0,0 +1,43 @@
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

@ -0,0 +1,29 @@
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

@ -0,0 +1,26 @@
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

@ -0,0 +1,26 @@
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

@ -0,0 +1,49 @@
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

@ -0,0 +1,61 @@
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

@ -0,0 +1,41 @@
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

@ -0,0 +1,31 @@
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

@ -0,0 +1,14 @@
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

@ -0,0 +1,9 @@
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

@ -0,0 +1,15 @@
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

@ -0,0 +1,22 @@
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

@ -0,0 +1,16 @@
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

@ -0,0 +1,38 @@
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

@ -0,0 +1,18 @@
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

@ -0,0 +1,18 @@
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

@ -0,0 +1,171 @@
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

@ -0,0 +1,93 @@
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

@ -0,0 +1,55 @@
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

@ -0,0 +1,101 @@
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

@ -0,0 +1,25 @@
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

@ -0,0 +1,32 @@
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

@ -0,0 +1,7 @@
auth:
ignore_urls:
- /auth/captcha
- /auth/login
- /auth/send/code
- /auth/mobile
- /upload/**

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--status用于设置log4j2框架内部的日志信息输出设置成OFF将禁止log4j2内部日志输出毕竟这个日志对我们没有什么作用如果设置成trace你会看到log4j2内部各种详细输出monitorInterval是监控间隔例如下面的设置是指log4j2每隔600秒自动监控该配置文件是否有变化如果有变化则根据文件内容新的配置生成日志-->
<configuration status="OFF" monitorInterval="600">
<Properties>
<property name="LOG_PATH">./logs/</property>
<property name="LOG_FILE">srt-cloud-system</property>
</Properties>
<!--定义添加器-->
<appenders>
<!--Console是输出控制台的标签target可以控制往控制台输出日志的颜色例如SYSTEM_OUT就是蓝色的SYSTEM_ERR就是红色的-->
<Console name="Console" target="SYSTEM_OUT">
<!--控制台只输出level及以上级别的信息onMatch为true代表符合level标准的才输出onMismatch为true代表不符合level标准的就不输出-->
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="ACCEPT"/>
<!--这个是输出日志的格式如果对里面的参数不理解可以去看我的这篇文章网址是“https://blog.csdn.net/qq_42449963/article/details/104617356”-->
<!--<PatternLayout pattern=" %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>-->
<PatternLayout
pattern=" %d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%6p} %style{%5pid}{bright,magenta} --- [%15.15t] %style{%c{20}}{bright,cyan}: %m%n"/>
</Console>
<!--这种存储文件的方式更加合理可以设置多长时间把文件归档一次也可以设置多大文件归档一次如果都把所有的日志存在一个文件里面文件会受不了的解释一下参数信息fileName后面如果后面不跟/例如dev/logs/app.log那就会把日志文件放在project工程下面不是所属的项目下面如果后面跟/,例如/dev/logs/app.log那就会把日志文件直接放在项目所在盘符的根目录下例如项目在E盘存放那就会把日志文件直接放在E盘的根目录下如果后面直接加盘符那就会存在特定的位置例如F:/dev/logs/app.log,那就会直接放在F盘中特定的位置上面都是经过测验的fileName后面的app.log文件相当于是一个缓存文件我们会把日志信息先放在app.log中当达到我们设置的要求之后会把app.log中的日志信息转移到filePattern指定的日志文件中转移的内容就会从app.log日志文件中清除没有转移的内容还存放在app.log中等到下一次符合要求的时候在进行一次转移-->
<!--$${date:yyyy-MM}用在文件上面输出的是目录的名字例如2020-03%d{MM-dd-yyyy}输入的就是月日年例如03-02-2020%i按照轮询输出毕竟一天可能有符合要求的多个日志文件生成所以需要在后面加一个类似于后缀的东西当天的第一个日志文件可能是-1.log.gz第二个文件就是-2.log.gz-->
<RollingFile name="RollingFile" fileName="${LOG_PATH}/${LOG_FILE}.log"
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${LOG_FILE}-%d{yyyy-MM-dd}-%i.log">
<!--%thread:线程名;%-5level:级别从左显示5个字符宽度;%msg:在代码中需要输出的日志消息;%class{36}:估计显示的是完整类名-->
<PatternLayout pattern=" %d{yyyy-MM-dd HH:mm:ss z} %-5level %class{36} %L %M - %msg%xEx%n"/>
<!--<SizeBasedTriggeringPolicy size="300MB"/>-->
<Policies>
<!--TimeBasedTriggeringPolicy基于时间的触发策略integer属性和上面<RollingFile>标签中的filePattern的值有关,例如filePattern=”xxx%d{yyyy-MM-dd}xx” interval=”1” 表示将1天一个日志文件filePattern=”xxx%d{yyyy-MM-dd-HH}xxx” interval=”1”表示一个小时一个日志文件,也就是说interval的单位取决于filePattern中的最小时间单位modulate是boolean以0点钟为边界进行偏移计算应该就是假设你中午启动项目晚上0点也是一天了而不是经过24小时才算一天-->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
<!--当app.log文件大小到达100MB的时候就归档一次日志文件也就是把app.log中的那前面100MB文件取出来放到上面<RollingFile >中的filePattern后面的路径中-->
<SizeBasedTriggeringPolicy size="100MB"/>
</Policies>
</RollingFile>
</appenders>
<loggers>
<logger name="net.srt.system.dao" level="DEBUG" additivity="false">
<appender-ref ref="Console"/>
</logger>
<!--level="info"代表只能打印出info及其以上的信息Console是上面Console标签的名字往这一写就可以往控制台上输出内容了RollingFile是上面RollingFile标签的名字往这一写就会往设定的文件中输出内容了当程序运行的时候就会被创建日志输出文件不过里面没有任何日志内容是否往里面输入日志是通过下面的appender-ref标签控制的-->
<root level="info">
<appender-ref ref="Console"/>
<!--一般不使用这个,只是让你知道有这个输出日志文件的方式而已-->
<!--<appender-ref ref="File"/>-->
<appender-ref ref="RollingFile"/>
</root>
</loggers>
</configuration>

View File

@ -0,0 +1,14 @@
<?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

@ -198,13 +198,20 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M,
/**
* MyBatis-Plus
*/
// protected void dataScopeWithoutOrgId(LambdaQueryWrapper<T> queryWrapper) {
// DataScope dataScope = getDataScope(null, null, null, null, false, true);
// if (dataScope != null) {
// queryWrapper.apply(dataScope.getSqlFilter());
// }
// }
protected void dataScopeWithoutOrgId(LambdaQueryWrapper<T> queryWrapper) {
DataScope dataScope = getDataScope(null, null, null, null, false, true);
DataScope dataScope = this.getDataScope((String)null, (String)null, (String)null, (String)null, false, true);
if (dataScope != null) {
queryWrapper.apply(dataScope.getSqlFilter());
}
queryWrapper.apply(dataScope.getSqlFilter(), new Object[0]);
}
}
/**
* MyBatis-Plus
*/

View File

@ -101,11 +101,11 @@
<!-- mvn install:install-file -Dfile=lib/datax-core-0.0.1-SNAPSHOT.jar -DgroupId=com.alibaba.datax -DartifactId=mysqlreader -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar
-->
<dependency>
<groupId>com.alibaba.datax</groupId>
<artifactId>mysqlreader</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.datax</groupId>-->
<!-- <artifactId>mysqlreader</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- mvn install:install-file -Dfile=lib/datax-core-0.0.1-SNAPSHOT.jar -DgroupId=com.alibaba.datax -DartifactId=mysqlwriter -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar
-->
@ -117,11 +117,11 @@
<!-- mvn install:install-file -Dfile=lib/datax-core-0.0.1-SNAPSHOT.jar -DgroupId=com.alibaba.datax -DartifactId=oraclereader -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar
-->
<dependency>
<groupId>com.alibaba.datax</groupId>
<artifactId>oraclereader</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba.datax</groupId>-->
<!-- <artifactId>oraclereader</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- </dependency>-->
<!--httpclient-->
<dependency>