数据质量规则配置目录树
parent
486346b618
commit
2e08010677
|
@ -0,0 +1,65 @@
|
|||
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.QualityConfigCategoryConvert;
|
||||
import net.srt.entity.QualityConfigCategoryEntity;
|
||||
import net.srt.framework.common.utils.Result;
|
||||
import net.srt.framework.common.utils.TreeNodeVo;
|
||||
import net.srt.service.QualityConfigCategoryService;
|
||||
import net.srt.vo.QualityConfigCategoryVo;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.controller
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/23 13:31
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/quality-config-category")
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "数据治理-规则配置")
|
||||
public class QualityConfigCategoryController {
|
||||
private final QualityConfigCategoryService qualityConfigCategoryService;
|
||||
|
||||
@GetMapping("/list-tree")
|
||||
@Operation(summary = "获取规则配置数")
|
||||
public Result<List<TreeNodeVo>> listTree(){
|
||||
List<TreeNodeVo> list=qualityConfigCategoryService.listTree();
|
||||
return Result.ok(list);
|
||||
}
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
public Result<QualityConfigCategoryVo> get(@PathVariable("id") Long id){
|
||||
QualityConfigCategoryEntity entity=qualityConfigCategoryService.getById(id);
|
||||
return Result.ok(QualityConfigCategoryConvert.INSTANCE.convert(entity));
|
||||
}
|
||||
|
||||
@GetMapping()
|
||||
@Operation(summary = "修改")
|
||||
public Result<String> update(@RequestBody @Valid QualityConfigCategoryVo vo){
|
||||
qualityConfigCategoryService.update(vo);
|
||||
return Result.ok();
|
||||
}
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
public Result<String> save(@RequestBody QualityConfigCategoryVo vo){
|
||||
qualityConfigCategoryService.save(vo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@Operation(summary = "删除")
|
||||
public Result<String> delete(@PathVariable Long id){
|
||||
qualityConfigCategoryService.delete(id);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package net.srt.convert;
|
||||
|
||||
import net.srt.entity.QualityConfigCategoryEntity;
|
||||
import net.srt.vo.QualityConfigCategoryVo;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.convert
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/24 10:27
|
||||
*/
|
||||
@Mapper
|
||||
public interface QualityConfigCategoryConvert {
|
||||
QualityConfigCategoryConvert INSTANCE = Mappers.getMapper(QualityConfigCategoryConvert.class);
|
||||
|
||||
QualityConfigCategoryEntity convert(QualityConfigCategoryVo vo);
|
||||
QualityConfigCategoryVo convert(QualityConfigCategoryEntity entity);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package net.srt.dao;
|
||||
|
||||
import net.srt.entity.QualityConfigCategoryEntity;
|
||||
import net.srt.framework.mybatis.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.dao
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/24 9:47
|
||||
*/
|
||||
@Mapper
|
||||
public interface QualityConfigCategoryDao extends BaseDao<QualityConfigCategoryEntity> {
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package net.srt.dao;
|
||||
|
||||
import net.srt.entity.QualityConfigEntity;
|
||||
import net.srt.framework.mybatis.dao.BaseDao;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.dao
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/24 11:36
|
||||
*/
|
||||
@Mapper
|
||||
public interface QualityConfigDao extends BaseDao<QualityConfigEntity> {
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package net.srt.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
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 9:20
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Data
|
||||
@TableName("data_governance_quality_config_category")
|
||||
public class QualityConfigCategoryEntity extends BaseEntity {
|
||||
/**
|
||||
* 0-普通目录 1-规则配置目录
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 父级id(顶级为0)
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 目录名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 目录路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
private Integer orderNo;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String note;
|
||||
|
||||
/**
|
||||
* 项目(租户)id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package net.srt.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import net.srt.api.module.data.governance.dto.quality.QualityConfigParam;
|
||||
import net.srt.framework.mybatis.entity.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.entity
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/24 11:32
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Data
|
||||
@TableName(value = "data_governance_quality_config",autoResultMap = true)
|
||||
public class QualityConfigEntity extends BaseEntity {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
private Long categoryId;
|
||||
|
||||
/**
|
||||
* 规则id
|
||||
*/
|
||||
private Integer ruleId;
|
||||
|
||||
/**
|
||||
* 个性化参数json
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private QualityConfigParam param;
|
||||
|
||||
/**
|
||||
* 元数据字段列表
|
||||
*/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Integer> metadataIds;
|
||||
|
||||
/**
|
||||
* 状态,1-启用,0-关闭
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 任务类型,1-一次性任务,2-周期任务
|
||||
*/
|
||||
private Integer taskType;
|
||||
|
||||
/**
|
||||
* cron表达式
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String cron;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String note;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package net.srt.service;
|
||||
|
||||
import net.srt.entity.QualityConfigCategoryEntity;
|
||||
import net.srt.framework.common.utils.TreeNodeVo;
|
||||
import net.srt.framework.mybatis.service.BaseService;
|
||||
import net.srt.vo.QualityConfigCategoryVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.service
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/24 9:19
|
||||
*/
|
||||
|
||||
public interface QualityConfigCategoryService extends BaseService<QualityConfigCategoryEntity> {
|
||||
List<TreeNodeVo> listTree();
|
||||
|
||||
void update(QualityConfigCategoryVo vo);
|
||||
|
||||
void save(QualityConfigCategoryVo vo);
|
||||
|
||||
void delete(Long id);
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package net.srt.service.impl;
|
||||
|
||||
import com.alibaba.spring.util.BeanUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import net.srt.convert.QualityConfigCategoryConvert;
|
||||
import net.srt.dao.QualityConfigCategoryDao;
|
||||
import net.srt.dao.QualityConfigDao;
|
||||
import net.srt.entity.QualityConfigCategoryEntity;
|
||||
import net.srt.entity.QualityConfigEntity;
|
||||
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.service.QualityConfigCategoryService;
|
||||
import net.srt.vo.QualityConfigCategoryVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||
import srt.cloud.framework.dbswitch.pgwriter.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.service.impl
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/24 9:46
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class QualityConfigCategoryServiceimpl extends BaseServiceImpl<QualityConfigCategoryDao, QualityConfigCategoryEntity> implements QualityConfigCategoryService {
|
||||
private final QualityConfigDao qualityConfigDao;
|
||||
@Override
|
||||
public List<TreeNodeVo> listTree() {
|
||||
LambdaQueryWrapper<QualityConfigCategoryEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(QualityConfigCategoryEntity::getProjectId, getProjectId()).orderByAsc(QualityConfigCategoryEntity::getOrderNo);
|
||||
List<QualityConfigCategoryEntity> list = baseMapper.selectList(wrapper);
|
||||
List<TreeNodeVo> tree = BeanUtil.copyListProperties(list,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(tree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(QualityConfigCategoryVo vo) {
|
||||
QualityConfigCategoryEntity entity= QualityConfigCategoryConvert.INSTANCE.convert(vo);
|
||||
entity.setProjectId(getProjectId());
|
||||
entity.setPath(recursionPath(entity,null));
|
||||
updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(QualityConfigCategoryVo vo) {
|
||||
QualityConfigCategoryEntity entity= QualityConfigCategoryConvert.INSTANCE.convert(vo);
|
||||
entity.setProjectId(getProjectId());
|
||||
entity.setPath(recursionPath(entity,null));
|
||||
baseMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long id) {
|
||||
LambdaQueryWrapper<QualityConfigCategoryEntity> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(QualityConfigCategoryEntity::getParentId,id).last("'limit 1");
|
||||
QualityConfigCategoryEntity oneChild=baseMapper.selectOne(wrapper);
|
||||
if (oneChild!=null){
|
||||
throw new ServerException("存在子项,不可删除");
|
||||
}
|
||||
LambdaQueryWrapper<QualityConfigEntity> wrapper1 = Wrappers.lambdaQuery();
|
||||
wrapper1.eq(QualityConfigEntity::getCategoryId,id).last("limit 1");
|
||||
QualityConfigEntity qualityConfigEntity=qualityConfigDao.selectOne(wrapper1);
|
||||
if (qualityConfigEntity!=null){
|
||||
throw new ServerException("目录下存在规则配置,不可删除!");
|
||||
}
|
||||
removeById(id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private String recursionPath(QualityConfigCategoryEntity entity, String path) {
|
||||
if (StringUtil.isBlank(path)){
|
||||
path=entity.getName();
|
||||
}
|
||||
if (entity.getParentId()!=0){
|
||||
QualityConfigCategoryEntity parent=getById(entity.getParentId());
|
||||
path=parent.getName()+"/"+path;
|
||||
return recursionPath(parent,path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
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;
|
||||
|
||||
/**
|
||||
* @BelongsProject: srt_cloud
|
||||
* @BelongsPackage: net.srt.vo
|
||||
* @Author: jpz
|
||||
* @CreateTime: 2023/12/24 10:22
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "数据治理-规则配置目录")
|
||||
public class QualityConfigCategoryVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "0-普通目录 1-规则配置目录")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "父级id(顶级为0)")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "目录名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "目录路径")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "序号")
|
||||
private Integer orderNo;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String note;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
Loading…
Reference in New Issue