Commit 3f89b1b1 by 刘泽志

规则

parent 38599d76
...@@ -20,9 +20,11 @@ import com.tbyf.his.web.dataImport.domain.param.*; ...@@ -20,9 +20,11 @@ import com.tbyf.his.web.dataImport.domain.param.*;
import com.tbyf.his.web.dataImport.entity.DataDict; import com.tbyf.his.web.dataImport.entity.DataDict;
import com.tbyf.his.web.dataImport.entity.DataField; import com.tbyf.his.web.dataImport.entity.DataField;
import com.tbyf.his.web.dataImport.entity.DataImportTemplate; import com.tbyf.his.web.dataImport.entity.DataImportTemplate;
import com.tbyf.his.web.dataImport.entity.DataRule;
import com.tbyf.his.web.dataImport.service.DataDictService; import com.tbyf.his.web.dataImport.service.DataDictService;
import com.tbyf.his.web.dataImport.service.DataFieldService; import com.tbyf.his.web.dataImport.service.DataFieldService;
import com.tbyf.his.web.dataImport.service.DataImportTemplateService; import com.tbyf.his.web.dataImport.service.DataImportTemplateService;
import com.tbyf.his.web.dataImport.service.DataRuleService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -63,6 +65,9 @@ public class DataImportController { ...@@ -63,6 +65,9 @@ public class DataImportController {
@Autowired @Autowired
private DataFieldService dataFieldService; private DataFieldService dataFieldService;
@Autowired
private DataRuleService dataRuleService;
@IgnoreWebSecurity @IgnoreWebSecurity
@GetMapping("/template") @GetMapping("/template")
@ApiOperation("模板查询") @ApiOperation("模板查询")
...@@ -253,4 +258,55 @@ public class DataImportController { ...@@ -253,4 +258,55 @@ public class DataImportController {
return AjaxResult.success(); return AjaxResult.success();
} }
@IgnoreWebSecurity
@GetMapping("/rule")
@ApiOperation("规则查询")
public TableDataInfo queryRule(@Validated QueryRuleParam param) {
final Page<DataRule> page = Page.of(param.getPageNum(), param.getPageSize());
final LambdaQueryWrapper<DataRule> queryWrapper = Wrappers.lambdaQuery(DataRule.class);
queryWrapper.like(StringUtils.isNotBlank(param.getName()), DataRule::getName, param.getName())
.eq(StringUtils.isNotBlank(param.getType()), DataRule::getType, param.getType())
.in(DataRule::getType, "基础规则", "组合规则");
final Page<DataRule> templatePage = dataRuleService.page(page, queryWrapper);
return param.convert(templatePage);
}
@IgnoreWebSecurity
@GetMapping("/rule/dict")
@ApiOperation("规则字典")
public AjaxResult queryRuleDict() {
final LambdaQueryWrapper<DataRule> queryWrapper = Wrappers.lambdaQuery(DataRule.class);
queryWrapper.in(DataRule::getType, "基础规则", "组合规则")
.select(DataRule::getId, DataRule::getName);
return AjaxResult.success(dataRuleService.list(queryWrapper));
}
@IgnoreWebSecurity
@PostMapping("/rule")
@ApiOperation("规则新增")
public AjaxResult addRule(@RequestBody @Validated AddRuleParam param) {
DataRule rule = new DataRule();
BeanUtils.copyProperties(param, rule);
dataRuleService.save(rule);
return AjaxResult.success();
}
@IgnoreWebSecurity
@PutMapping("/rule")
@ApiOperation("修改规则")
public AjaxResult updateRule(@RequestBody @Validated UpdateRuleParam param) {
DataRule rule = new DataRule();
BeanUtils.copyProperties(param, rule);
dataRuleService.updateById(rule);
return AjaxResult.success();
}
@IgnoreWebSecurity
@DeleteMapping("/rule")
@ApiOperation("删除规则")
public AjaxResult deleteRule(@RequestParam String ruleId) {
dataRuleService.removeById(ruleId);
return AjaxResult.success();
}
} }
package com.tbyf.his.web.dataImport.domain.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @author lzz
* @date 2023/1/10 15:36
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "新增规则", description = "新增规则")
public class AddRuleParam implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "规则名称")
private String name;
@ApiModelProperty(value = "规则类型 1-基础规则 2-组合规则 3-字段复合规则")
private String type;
@ApiModelProperty(value = "规则验证模式")
private String mode;
@ApiModelProperty(value = "规则验证内容")
private String content;
@ApiModelProperty(value = "备注")
private String remarks;
}
package com.tbyf.his.web.dataImport.domain.param;
import com.tbyf.his.web.dataImport.domain.ParamMp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @author lzz
* @date 2023/1/10 17:01
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@ApiModel(value = "规则查询参数", description = "规则查询参数")
public class QueryRuleParam extends ParamMp {
@ApiModelProperty(value = "规则名称")
private String name;
@ApiModelProperty(value = "规则类型")
private String type;
}
package com.tbyf.his.web.dataImport.domain.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @author lzz
* @date 2023/1/10 15:36
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "修改字段", description = "修改字段")
public class UpdateRuleParam implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "规则id")
@NotBlank(message = "规则id不能为空")
private String id;
@ApiModelProperty(value = "规则名称")
private String name;
@ApiModelProperty(value = "规则类型 1-基础规则 2-组合规则 3-字段复合规则")
private String type;
@ApiModelProperty(value = "规则验证模式")
private String mode;
@ApiModelProperty(value = "规则验证内容")
private String content;
@ApiModelProperty(value = "备注")
private String remarks;
}
package com.tbyf.his.web.dataImport.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @author lzz
* @date 2023/1/10 15:36
*/
@Data
@Accessors(chain = true)
@TableName(value = "bind_rule", autoResultMap = true)
@ApiModel(value = "数据规则绑定表", description = "数据规则绑定表")
public class BindRule implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "数据ID")
@TableField("data_id")
private String dataId;
@ApiModelProperty(value = "规则ID")
@TableField("rule_id")
private String ruleId;
}
package com.tbyf.his.web.dataImport.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @author lzz
* @date 2023/1/10 15:36
*/
@Data
@Accessors(chain = true)
@TableName(value = "data_rule", autoResultMap = true)
@ApiModel(value = "数据规则表", description = "数据规则表")
public class DataRule implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
@ApiModelProperty(value = "规则名称")
@TableField("name")
private String name;
@ApiModelProperty(value = "规则类型 1-基础规则 2-组合规则 3-字段复合规则")
@TableField("type")
private String type;
@ApiModelProperty(value = "规则验证模式")
@TableField("mode")
private String mode;
@ApiModelProperty(value = "规则验证内容")
@TableField("content")
private String content;
@ApiModelProperty(value = "备注")
@TableField("remarks")
private String remarks;
}
package com.tbyf.his.web.dataImport.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tbyf.his.web.dataImport.entity.DataRule;
/**
* @author lzz
* @date 2023/2/7 11:22
*/
public interface DataRuleMapper extends BaseMapper<DataRule> {
}
package com.tbyf.his.web.dataImport.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tbyf.his.web.dataImport.entity.DataRule;
/**
* @author lzz
* @date 2023/2/7 11:23
*/
public interface DataRuleService extends IService<DataRule> {
}
package com.tbyf.his.web.dataImport.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tbyf.his.common.annotation.DataSource;
import com.tbyf.his.common.enums.DataSourceType;
import com.tbyf.his.web.dataImport.entity.DataRule;
import com.tbyf.his.web.dataImport.mapper.DataRuleMapper;
import com.tbyf.his.web.dataImport.service.DataRuleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @author lzz
* @date 2023/2/7 11:24
*/
@Slf4j
@Service
@DataSource(DataSourceType.MASTER)
public class DataRuleServiceImpl extends ServiceImpl<DataRuleMapper, DataRule> implements DataRuleService {
}
...@@ -38,4 +38,18 @@ create table data_field ...@@ -38,4 +38,18 @@ create table data_field
field varchar(32) null comment '数据库字段名' field varchar(32) null comment '数据库字段名'
) comment '数据字段表'; ) comment '数据字段表';
create table data_rule
(
id varchar(32) not null primary key,
name varchar(64) null comment '规则名称',
type varchar(64) null comment '规则类型 1-基础规则 2-组合规则 3-字段复合规则',
mode varchar(64) null comment '规则验证模式',
content varchar(256) null comment '规则验证内容',
remarks text null comment '备注'
) comment '数据规则表';
create table bind_rule
(
data_id varchar(32) null comment '数据ID',
rule_id varchar(32) null comment '规则ID'
) comment '规则绑定表';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment