184 lines
7.7 KiB
XML
184 lines
7.7 KiB
XML
<?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="com.solution.rule.mapper.RuleConfigMapper">
|
|
|
|
<resultMap id="RuleConfigMap" type="com.solution.rule.domain.config.RuleConfig">
|
|
<id property="id" column="id"/>
|
|
<result property="ruleCode" column="rule_code"/>
|
|
<result property="ruleName" column="rule_name"/>
|
|
<result property="levelCode" column="level_code"/>
|
|
<result property="kindCode" column="kind_code"/>
|
|
<result property="moduleCode" column="module_code"/>
|
|
<result property="priorityNo" column="priority_no"/>
|
|
<result property="conditionExpr" column="condition_expr"/>
|
|
<result property="actionExpr" column="action_expr"/>
|
|
<result property="versionNo" column="version_no"/>
|
|
<result property="enabled" column="enabled"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="createdAt" column="created_at"/>
|
|
<result property="updatedAt" column="updated_at"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="RuleConfigParamMap" type="com.solution.rule.domain.config.RuleConfigParam">
|
|
<result property="ruleCode" column="rule_code"/>
|
|
<result property="paramKey" column="param_key"/>
|
|
<result property="paramVal" column="param_val"/>
|
|
<result property="valType" column="val_type"/>
|
|
<result property="paramName" column="param_name"/>
|
|
<result property="sortNo" column="sort_no"/>
|
|
<result property="enabled" column="enabled"/>
|
|
<result property="remark" column="remark"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="RuleDictItemMap" type="com.solution.rule.domain.config.RuleDictItem">
|
|
<result property="dictType" column="dict_type"/>
|
|
<result property="dictCode" column="dict_code"/>
|
|
<result property="dictName" column="dict_name"/>
|
|
<result property="sortNo" column="sort_no"/>
|
|
<result property="enabled" column="enabled"/>
|
|
<result property="remark" column="remark"/>
|
|
</resultMap>
|
|
|
|
<select id="selectRuleConfigList" resultMap="RuleConfigMap">
|
|
SELECT id, rule_code, rule_name, level_code, kind_code, module_code, priority_no,
|
|
condition_expr, action_expr, version_no, enabled, remark, created_at, updated_at
|
|
FROM rule_item
|
|
<where>
|
|
<if test="ruleCode != null and ruleCode != ''">
|
|
AND rule_code = #{ruleCode}
|
|
</if>
|
|
<if test="ruleName != null and ruleName != ''">
|
|
AND rule_name LIKE CONCAT('%', #{ruleName}, '%')
|
|
</if>
|
|
<if test="levelCode != null and levelCode != ''">
|
|
AND level_code = #{levelCode}
|
|
</if>
|
|
<if test="kindCode != null and kindCode != ''">
|
|
AND kind_code = #{kindCode}
|
|
</if>
|
|
<if test="moduleCode != null and moduleCode != ''">
|
|
AND module_code = #{moduleCode}
|
|
</if>
|
|
<if test="enabled != null">
|
|
AND enabled = #{enabled}
|
|
</if>
|
|
</where>
|
|
ORDER BY priority_no ASC, updated_at DESC
|
|
</select>
|
|
|
|
<select id="selectRuleConfigByCode" resultMap="RuleConfigMap">
|
|
SELECT id, rule_code, rule_name, level_code, kind_code, module_code, priority_no,
|
|
condition_expr, action_expr, version_no, enabled, remark, created_at, updated_at
|
|
FROM rule_item
|
|
WHERE rule_code = #{ruleCode}
|
|
</select>
|
|
|
|
<select id="countByRuleCode" resultType="int">
|
|
SELECT COUNT(1)
|
|
FROM rule_item
|
|
WHERE rule_code = #{ruleCode}
|
|
</select>
|
|
|
|
<insert id="insertRuleConfig" parameterType="com.solution.rule.domain.config.RuleConfig">
|
|
INSERT INTO rule_item
|
|
(rule_code, rule_name, level_code, kind_code, module_code, priority_no, condition_expr,
|
|
action_expr, version_no, enabled, remark, created_at, updated_at)
|
|
VALUES
|
|
(#{ruleCode}, #{ruleName}, #{levelCode}, #{kindCode}, #{moduleCode}, #{priorityNo}, #{conditionExpr},
|
|
#{actionExpr}, #{versionNo}, #{enabled}, #{remark}, NOW(), NOW())
|
|
</insert>
|
|
|
|
<update id="updateRuleConfig" parameterType="com.solution.rule.domain.config.RuleConfig">
|
|
UPDATE rule_item
|
|
<set>
|
|
<if test="ruleName != null">rule_name = #{ruleName},</if>
|
|
<if test="levelCode != null">level_code = #{levelCode},</if>
|
|
<if test="kindCode != null">kind_code = #{kindCode},</if>
|
|
<if test="moduleCode != null">module_code = #{moduleCode},</if>
|
|
<if test="priorityNo != null">priority_no = #{priorityNo},</if>
|
|
<if test="conditionExpr != null">condition_expr = #{conditionExpr},</if>
|
|
<if test="actionExpr != null">action_expr = #{actionExpr},</if>
|
|
<if test="versionNo != null">version_no = #{versionNo},</if>
|
|
<if test="enabled != null">enabled = #{enabled},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
updated_at = NOW()
|
|
</set>
|
|
WHERE rule_code = #{ruleCode}
|
|
</update>
|
|
|
|
<delete id="deleteRuleConfigByCodes">
|
|
DELETE FROM rule_item
|
|
WHERE rule_code IN
|
|
<foreach item="code" collection="ruleCodes" open="(" separator="," close=")">
|
|
#{code}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectParamsByRuleCode" resultMap="RuleConfigParamMap">
|
|
SELECT rule_code, param_key, param_val, val_type, param_name, sort_no, enabled, remark
|
|
FROM rule_item_param
|
|
WHERE rule_code = #{ruleCode}
|
|
ORDER BY sort_no ASC, id ASC
|
|
</select>
|
|
|
|
<delete id="deleteParamsByRuleCodes">
|
|
DELETE FROM rule_item_param
|
|
WHERE rule_code IN
|
|
<foreach item="code" collection="ruleCodes" open="(" separator="," close=")">
|
|
#{code}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<insert id="insertParamsBatch">
|
|
INSERT INTO rule_item_param
|
|
(rule_code, param_key, param_val, val_type, param_name, sort_no, enabled, remark, created_at, updated_at)
|
|
VALUES
|
|
<foreach item="item" collection="params" separator=",">
|
|
(#{item.ruleCode}, #{item.paramKey}, #{item.paramVal}, #{item.valType}, #{item.paramName},
|
|
#{item.sortNo}, #{item.enabled}, #{item.remark}, NOW(), NOW())
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="selectTaskTypesByRuleCode" resultType="string">
|
|
SELECT task_type_code
|
|
FROM rule_item_task_type
|
|
WHERE rule_code = #{ruleCode}
|
|
ORDER BY id ASC
|
|
</select>
|
|
|
|
<delete id="deleteTaskTypesByRuleCodes">
|
|
DELETE FROM rule_item_task_type
|
|
WHERE rule_code IN
|
|
<foreach item="code" collection="ruleCodes" open="(" separator="," close=")">
|
|
#{code}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<insert id="insertTaskTypesBatch">
|
|
INSERT INTO rule_item_task_type (rule_code, task_type_code, created_at)
|
|
VALUES
|
|
<foreach item="taskType" collection="taskTypes" separator=",">
|
|
(#{ruleCode}, #{taskType}, NOW())
|
|
</foreach>
|
|
</insert>
|
|
|
|
<select id="selectDictByType" resultMap="RuleDictItemMap">
|
|
SELECT dict_type, dict_code, dict_name, sort_no, enabled, remark
|
|
FROM rule_dict
|
|
WHERE dict_type = #{dictType}
|
|
ORDER BY sort_no ASC, id ASC
|
|
</select>
|
|
|
|
<select id="selectEnabledParamsForGlobal" resultMap="RuleConfigParamMap">
|
|
SELECT p.rule_code, p.param_key, p.param_val, p.val_type, p.param_name, p.sort_no, p.enabled, p.remark
|
|
FROM rule_item_param p
|
|
INNER JOIN rule_item r ON p.rule_code = r.rule_code
|
|
WHERE r.enabled = 1
|
|
AND p.enabled = 1
|
|
ORDER BY r.priority_no ASC, p.sort_no ASC, p.id ASC
|
|
</select>
|
|
|
|
</mapper>
|