Commit 2caf2fc6 authored by 赵建伟's avatar 赵建伟

add sql format codes

parent b3efe042
......@@ -9,6 +9,10 @@ public class Constants {
public static final String CHECK_UNBLANK = "unblank_check";
// 参照性校验
public static final String CHECK_REFER = "refer_check";
// 波动性校验
public static final String CHECK_VOLATILITY = "volatility_check";
// 特殊性校验
public static final String CHECK_SPECIAL = "special_check";
// ***************监控指标类型******************
// 波动性监控-PV
......
......@@ -23,7 +23,7 @@ public class RuleTemplateController {
@ResponseBody
@RequestMapping(value = "/find", method = RequestMethod.POST)
public RuleTemplateVo findRuleTmpls(@RequestBody RuleTemplateVo ruleTemplateVo) {
List<RuleTemplateDto> findRuleTmpls = ruleTemplateService.findRuleTmpls(ruleTemplateVo.getType());
List<RuleTemplateDto> findRuleTmpls = ruleTemplateService.findRuleTmpls(ruleTemplateVo.getCheckType());
return new RuleTemplateVo(findRuleTmpls);
}
......
......@@ -3,12 +3,12 @@ package com.gmei.data.dqmp.domain;
public class TblRuleTemplate {
private Integer id;
private String type;
private String content;
private String checkType;
private String comment;
private String tpltContent;
public Integer getId() {
return id;
}
......@@ -17,20 +17,12 @@ public class TblRuleTemplate {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getContent() {
return content;
public String getCheckType() {
return checkType;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
public void setCheckType(String checkType) {
this.checkType = checkType == null ? null : checkType.trim();
}
public String getComment() {
......@@ -40,4 +32,12 @@ public class TblRuleTemplate {
public void setComment(String comment) {
this.comment = comment == null ? null : comment.trim();
}
public String getTpltContent() {
return tpltContent;
}
public void setTpltContent(String tpltContent) {
this.tpltContent = tpltContent == null ? null : tpltContent.trim();
}
}
\ No newline at end of file
......@@ -164,143 +164,73 @@ public class TblRuleTemplateCriteria {
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
public Criteria andCheckTypeIsNull() {
addCriterion("check_type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
public Criteria andCheckTypeIsNotNull() {
addCriterion("check_type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("type =", value, "type");
public Criteria andCheckTypeEqualTo(String value) {
addCriterion("check_type =", value, "checkType");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("type <>", value, "type");
public Criteria andCheckTypeNotEqualTo(String value) {
addCriterion("check_type <>", value, "checkType");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("type >", value, "type");
public Criteria andCheckTypeGreaterThan(String value) {
addCriterion("check_type >", value, "checkType");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("type >=", value, "type");
public Criteria andCheckTypeGreaterThanOrEqualTo(String value) {
addCriterion("check_type >=", value, "checkType");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("type <", value, "type");
public Criteria andCheckTypeLessThan(String value) {
addCriterion("check_type <", value, "checkType");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("type <=", value, "type");
public Criteria andCheckTypeLessThanOrEqualTo(String value) {
addCriterion("check_type <=", value, "checkType");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("type like", value, "type");
public Criteria andCheckTypeLike(String value) {
addCriterion("check_type like", value, "checkType");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("type not like", value, "type");
public Criteria andCheckTypeNotLike(String value) {
addCriterion("check_type not like", value, "checkType");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("type in", values, "type");
public Criteria andCheckTypeIn(List<String> values) {
addCriterion("check_type in", values, "checkType");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("type not in", values, "type");
public Criteria andCheckTypeNotIn(List<String> values) {
addCriterion("check_type not in", values, "checkType");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("type between", value1, value2, "type");
public Criteria andCheckTypeBetween(String value1, String value2) {
addCriterion("check_type between", value1, value2, "checkType");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andContentIsNull() {
addCriterion("content is null");
return (Criteria) this;
}
public Criteria andContentIsNotNull() {
addCriterion("content is not null");
return (Criteria) this;
}
public Criteria andContentEqualTo(String value) {
addCriterion("content =", value, "content");
return (Criteria) this;
}
public Criteria andContentNotEqualTo(String value) {
addCriterion("content <>", value, "content");
return (Criteria) this;
}
public Criteria andContentGreaterThan(String value) {
addCriterion("content >", value, "content");
return (Criteria) this;
}
public Criteria andContentGreaterThanOrEqualTo(String value) {
addCriterion("content >=", value, "content");
return (Criteria) this;
}
public Criteria andContentLessThan(String value) {
addCriterion("content <", value, "content");
return (Criteria) this;
}
public Criteria andContentLessThanOrEqualTo(String value) {
addCriterion("content <=", value, "content");
return (Criteria) this;
}
public Criteria andContentLike(String value) {
addCriterion("content like", value, "content");
return (Criteria) this;
}
public Criteria andContentNotLike(String value) {
addCriterion("content not like", value, "content");
return (Criteria) this;
}
public Criteria andContentIn(List<String> values) {
addCriterion("content in", values, "content");
return (Criteria) this;
}
public Criteria andContentNotIn(List<String> values) {
addCriterion("content not in", values, "content");
return (Criteria) this;
}
public Criteria andContentBetween(String value1, String value2) {
addCriterion("content between", value1, value2, "content");
return (Criteria) this;
}
public Criteria andContentNotBetween(String value1, String value2) {
addCriterion("content not between", value1, value2, "content");
public Criteria andCheckTypeNotBetween(String value1, String value2) {
addCriterion("check_type not between", value1, value2, "checkType");
return (Criteria) this;
}
......
......@@ -4,9 +4,9 @@ public class RuleTemplateDto {
private Integer id;
private String type;
private String checkType;
private String content;
private String tpltContent;
private String comment;
......@@ -18,27 +18,28 @@ public class RuleTemplateDto {
this.id = id;
}
public String getType() {
return type;
}
public String getCheckType() {
return checkType;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public void setCheckType(String checkType) {
this.checkType = checkType;
}
public String getContent() {
return content;
}
public String getTpltContent() {
return tpltContent;
}
public void setContent(String content) {
this.content = content == null ? null : content.trim();
}
public void setTpltContent(String tpltContent) {
this.tpltContent = tpltContent;
}
public String getComment() {
return comment;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public void setComment(String comment) {
this.comment = comment == null ? null : comment.trim();
}
}
......@@ -16,15 +16,21 @@ public interface TblRuleTemplateMapper {
int insertSelective(TblRuleTemplate record);
List<TblRuleTemplate> selectByExampleWithBLOBs(TblRuleTemplateCriteria example);
List<TblRuleTemplate> selectByExample(TblRuleTemplateCriteria example);
TblRuleTemplate selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") TblRuleTemplate record, @Param("example") TblRuleTemplateCriteria example);
int updateByExampleWithBLOBs(@Param("record") TblRuleTemplate record, @Param("example") TblRuleTemplateCriteria example);
int updateByExample(@Param("record") TblRuleTemplate record, @Param("example") TblRuleTemplateCriteria example);
int updateByPrimaryKeySelective(TblRuleTemplate record);
int updateByPrimaryKeyWithBLOBs(TblRuleTemplate record);
int updateByPrimaryKey(TblRuleTemplate record);
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ import com.gmei.data.dqmp.vo.RuleTemplateVo;
public interface RuleTemplateService {
List<RuleTemplateDto> findRuleTmpls(String tmplType);
List<RuleTemplateDto> findRuleTmpls(String checkType);
Integer addRuleTmpl(RuleTemplateVo ruleTemplateVo);
......
......@@ -25,23 +25,18 @@ public class FormatServiceImpl implements FormatService {
}
public static void main(String[] args) {
String removeNewlineSymbol = new FormatServiceImpl().removeNewlineSymbol("SELECT 'online' AS db_name,\n" +
"\n" +
" 'test' AS tb_name,\n" +
"\n" +
" 'age' AS time_col_name,\n" +
"\n" +
" '23' AS start_time,\n" +
"\n" +
" '66' AS end_time,\n" +
"\n" +
" COUNT(*) as count_num,date_add(from_unixtime(unix_timestamp(),'yyyy-MM-dd'),-1) as partition_date,from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') as create_time\n" +
"\n" +
" FROM online.test\n" +
"\n" +
"WHERE name >=11\n" +
"\n" +
" AND name <=12");
String removeNewlineSymbol = new FormatServiceImpl().removeNewlineSymbol("SELECT '$db_name' AS DB_NAME,\n" +
" '$tb_name' AS TB_NAME,\n" +
" '$time_col_name' AS TIME_COL_NAME,\n" +
" '$start_time' AS START_TIME,\n" +
" '$end_time' AS END_TIME,\n" +
" COUNT(*) AS COUNT_NUM,\n" +
" DATE_ADD(from_unixtime(unix_timestamp(), 'yyyy-MM-dd'), -1) AS PARTITION_DATE,\n" +
" FROM_UNIXTIME(unix_timestamp(), 'yyyy-MM-dd HH:mm:ss') AS CREATE_TIME\n" +
" FROM $db_name.$tb_name\n" +
" WHERE $time_col_name >= $start_time\n" +
" AND $time_col_name < $end_time\n" +
" $filters");
System.out.println(removeNewlineSymbol);
}
}
......@@ -22,10 +22,10 @@ public class RuleTemplateServiceImpl implements RuleTemplateService {
private TblRuleTemplateMapper tblRuleTemplateMapper;
@Override
public List<RuleTemplateDto> findRuleTmpls(String tmplType) {
public List<RuleTemplateDto> findRuleTmpls(String checkType) {
List<RuleTemplateDto> rsList = new ArrayList<>();
TblRuleTemplateCriteria tblDqRuleTemplateCriteria = new TblRuleTemplateCriteria();
tblDqRuleTemplateCriteria.createCriteria().andTypeEqualTo(tmplType);
tblDqRuleTemplateCriteria.createCriteria().andCheckTypeEqualTo(checkType);
List<TblRuleTemplate> list = tblRuleTemplateMapper.selectByExample(tblDqRuleTemplateCriteria);
for(TblRuleTemplate tblDqRuleTemplate : list) {
rsList.add(BeanUtils.map(tblDqRuleTemplate, RuleTemplateDto.class));
......
......@@ -6,59 +6,47 @@ import com.gmei.data.dqmp.dto.RuleTemplateDto;
public class RuleTemplateVo extends BaseVo{
private String type;
private String content;
private String comment;
private List<RuleTemplateDto> ruleTemplates;
private String checkType;
private String tpltContent;
private String comment;
private List<RuleTemplateDto> ruleTemplates;
public RuleTemplateVo() {
super();
}
public RuleTemplateVo(Integer status, String msg) {
public RuleTemplateVo(Integer status,String msg) {
super(status,msg);
}
public RuleTemplateVo(String type) {
super();
this.type = type;
}
public RuleTemplateVo(String type, String content, String comment) {
public RuleTemplateVo(List<RuleTemplateDto> ruleTemplates) {
super();
this.type = type;
this.content = content;
this.comment = comment;
this.ruleTemplates = ruleTemplates;
}
public String getType() {
return type;
}
public String getCheckType() {
return checkType;
}
public void setType(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setCheckType(String checkType) {
this.checkType = checkType == null ? null : checkType.trim();
}
public void setContent(String content) {
this.content = content;
}
public String getTpltContent() {
return tpltContent;
}
public String getComment() {
return comment;
}
public void setTpltContent(String tpltContent) {
this.tpltContent = tpltContent == null ? null : tpltContent.trim();
}
public void setComment(String comment) {
this.comment = comment;
}
public String getComment() {
return comment;
}
public RuleTemplateVo(List<RuleTemplateDto> ruleTemplates) {
super();
this.ruleTemplates = ruleTemplates;
}
public void setComment(String comment) {
this.comment = comment == null ? null : comment.trim();
}
public List<RuleTemplateDto> getRuleTemplates() {
return ruleTemplates;
......@@ -67,5 +55,5 @@ public class RuleTemplateVo extends BaseVo{
public void setRuleTemplates(List<RuleTemplateDto> ruleTemplates) {
this.ruleTemplates = ruleTemplates;
}
}
......@@ -34,16 +34,19 @@
</javaClientGenerator>
<!-- 需要生成的数据库表 -->
<!-- <table tableName="tbl_rule_template" domainObjectName="TblRuleTemplate"/> -->
<!-- <table tableName="tbl_client_version_info" domainObjectName="TblClientVersionInfo"/> -->
<!-- <table tableName="tbl_check_single_sql" domainObjectName="TblCheckSingleSql"/> -->
<!-- <table tableName="tbl_check_multiple_sql" domainObjectName="TblCheckMultipleSql"/> -->
<!-- <table tableName="tbl_monitor_volatility_sql" domainObjectName="TblMonitorVolatilitySql"/> -->
<!-- <table tableName="tbl_monitor_special_sql" domainObjectName="TblMonitorSpecialSql"/> -->
<!-- <table tableName="tbl_result_check_unique" domainObjectName="TblResultCheckUnique"/> -->
<!-- <table tableName="tbl_result_check_unblank" domainObjectName="TblResultCheckUnblank"/> -->
<!-- <table tableName="tbl_client_version_info" domainObjectName="TblClientVersionInfo"/> -->
<!-- <table tableName="tbl_result_check_refer" domainObjectName="TblResultCheckRefer"/> -->
<!-- <table tableName="tbl_check_multiple_sql" domainObjectName="TblCheckMultipleSql"/> -->
<!-- <table tableName="tbl_monitor_volatility_sql" domainObjectName="TblMonitorVolatilitySql"/> -->
<!-- <table tableName="tbl_result_monitor_volatility" domainObjectName="TblResultMonitorVolatility"/> -->
<table tableName="tbl_monitor_special_sql" domainObjectName="TblMonitorSpecialSql"/>
<table tableName="tbl_result_monitor_special" domainObjectName="TblResultMonitorSpecial"/>
<!-- <table tableName="tbl_result_monitor_special" domainObjectName="TblResultMonitorSpecial"/> -->
<!-- <table tableName="tbl_indicator_operator_info" domainObjectName="TblIndicatorOperatorInfo"/> -->
<!-- <table tableName="tbl_rule_template" domainObjectName="TblRuleTemplate"/> -->
<table tableName="tbl_rule_simple_info" domainObjectName="TblRuleSimpleInfo"/>
<table tableName="tbl_rule_duplex_info" domainObjectName="TblRuleDuplexInfo"/>
</context>
</generatorConfiguration>
......@@ -3,10 +3,12 @@
<mapper namespace="com.gmei.data.dqmp.mapper.TblRuleTemplateMapper" >
<resultMap id="BaseResultMap" type="com.gmei.data.dqmp.domain.TblRuleTemplate" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="VARCHAR" />
<result column="content" property="content" jdbcType="VARCHAR" />
<result column="check_type" property="checkType" jdbcType="VARCHAR" />
<result column="comment" property="comment" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.gmei.data.dqmp.domain.TblRuleTemplate" extends="BaseResultMap" >
<result column="tplt_content" property="tpltContent" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
......@@ -66,8 +68,27 @@
</where>
</sql>
<sql id="Base_Column_List" >
id, type, content, comment
id, check_type, comment
</sql>
<sql id="Blob_Column_List" >
tplt_content
</sql>
<select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs" parameterType="com.gmei.data.dqmp.domain.TblRuleTemplateCriteria" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from tbl_rule_template
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.gmei.data.dqmp.domain.TblRuleTemplateCriteria" >
select
<if test="distinct" >
......@@ -82,9 +103,11 @@
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from tbl_rule_template
where id = #{id,jdbcType=INTEGER}
</select>
......@@ -99,10 +122,10 @@
</if>
</delete>
<insert id="insert" parameterType="com.gmei.data.dqmp.domain.TblRuleTemplate" >
insert into tbl_rule_template (id, type, content,
comment)
values (#{id,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR},
#{comment,jdbcType=VARCHAR})
insert into tbl_rule_template (id, check_type, comment,
tplt_content)
values (#{id,jdbcType=INTEGER}, #{checkType,jdbcType=VARCHAR}, #{comment,jdbcType=VARCHAR},
#{tpltContent,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.gmei.data.dqmp.domain.TblRuleTemplate" >
insert into tbl_rule_template
......@@ -110,29 +133,29 @@
<if test="id != null" >
id,
</if>
<if test="type != null" >
type,
</if>
<if test="content != null" >
content,
<if test="checkType != null" >
check_type,
</if>
<if test="comment != null" >
comment,
</if>
<if test="tpltContent != null" >
tplt_content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="type != null" >
#{type,jdbcType=VARCHAR},
</if>
<if test="content != null" >
#{content,jdbcType=VARCHAR},
<if test="checkType != null" >
#{checkType,jdbcType=VARCHAR},
</if>
<if test="comment != null" >
#{comment,jdbcType=VARCHAR},
</if>
<if test="tpltContent != null" >
#{tpltContent,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.gmei.data.dqmp.domain.TblRuleTemplateCriteria" resultType="java.lang.Integer" >
......@@ -147,25 +170,34 @@
<if test="record.id != null" >
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.type != null" >
type = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.content != null" >
content = #{record.content,jdbcType=VARCHAR},
<if test="record.checkType != null" >
check_type = #{record.checkType,jdbcType=VARCHAR},
</if>
<if test="record.comment != null" >
comment = #{record.comment,jdbcType=VARCHAR},
</if>
<if test="record.tpltContent != null" >
tplt_content = #{record.tpltContent,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map" >
update tbl_rule_template
set id = #{record.id,jdbcType=INTEGER},
check_type = #{record.checkType,jdbcType=VARCHAR},
comment = #{record.comment,jdbcType=VARCHAR},
tplt_content = #{record.tpltContent,jdbcType=LONGVARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
update tbl_rule_template
set id = #{record.id,jdbcType=INTEGER},
type = #{record.type,jdbcType=VARCHAR},
content = #{record.content,jdbcType=VARCHAR},
check_type = #{record.checkType,jdbcType=VARCHAR},
comment = #{record.comment,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
......@@ -174,22 +206,28 @@
<update id="updateByPrimaryKeySelective" parameterType="com.gmei.data.dqmp.domain.TblRuleTemplate" >
update tbl_rule_template
<set >
<if test="type != null" >
type = #{type,jdbcType=VARCHAR},
</if>
<if test="content != null" >
content = #{content,jdbcType=VARCHAR},
<if test="checkType != null" >
check_type = #{checkType,jdbcType=VARCHAR},
</if>
<if test="comment != null" >
comment = #{comment,jdbcType=VARCHAR},
</if>
<if test="tpltContent != null" >
tplt_content = #{tpltContent,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.gmei.data.dqmp.domain.TblRuleTemplate" >
update tbl_rule_template
set check_type = #{checkType,jdbcType=VARCHAR},
comment = #{comment,jdbcType=VARCHAR},
tplt_content = #{tpltContent,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gmei.data.dqmp.domain.TblRuleTemplate" >
update tbl_rule_template
set type = #{type,jdbcType=VARCHAR},
content = #{content,jdbcType=VARCHAR},
set check_type = #{checkType,jdbcType=VARCHAR},
comment = #{comment,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
......
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