131 lines
5.9 KiB
XML
131 lines
5.9 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.bms.system.mapper.BmsBizRuleMapper">
|
|
|
|
<resultMap type="BmsBizRule" id="BmsBizRuleResult">
|
|
<id property="ruleId" column="rule_id" />
|
|
<result property="ruleName" column="rule_name" />
|
|
<result property="ruleType" column="rule_type" />
|
|
<result property="productCode" column="product_code" />
|
|
<result property="countryCode" column="country_code" />
|
|
<result property="customerCode" column="customer_code" />
|
|
<result property="weightMin" column="weight_min" />
|
|
<result property="weightMax" column="weight_max" />
|
|
<result property="weightSource" column="weight_source" />
|
|
<result property="sideSumMax" column="side_sum_max" />
|
|
<result property="status" column="status" />
|
|
<result property="remark" column="remark" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="delFlag" column="del_flag" />
|
|
</resultMap>
|
|
|
|
<sql id="selectVo">
|
|
select rule_id, rule_name, rule_type, product_code, country_code, customer_code,
|
|
weight_min, weight_max, weight_source, side_sum_max,
|
|
status, remark, create_by, create_time, update_by, update_time, del_flag
|
|
from biz_rule
|
|
</sql>
|
|
|
|
<select id="selectList" parameterType="BmsBizRule" resultMap="BmsBizRuleResult">
|
|
<include refid="selectVo"/>
|
|
<where>
|
|
del_flag = '0'
|
|
<if test="ruleName != null and ruleName != ''">
|
|
and rule_name like concat('%', #{ruleName}, '%')
|
|
</if>
|
|
<if test="ruleType != null and ruleType != ''">
|
|
and rule_type = #{ruleType}
|
|
</if>
|
|
<if test="productCode != null and productCode != ''">
|
|
and product_code = #{productCode}
|
|
</if>
|
|
<if test="countryCode != null and countryCode != ''">
|
|
and country_code = #{countryCode}
|
|
</if>
|
|
<if test="customerCode != null and customerCode != ''">
|
|
and customer_code = #{customerCode}
|
|
</if>
|
|
<if test="weightSource != null and weightSource != ''">
|
|
and weight_source = #{weightSource}
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
and status = #{status}
|
|
</if>
|
|
</where>
|
|
order by product_code asc, country_code asc, customer_code asc, rule_id desc
|
|
</select>
|
|
|
|
<select id="selectById" parameterType="Long" resultMap="BmsBizRuleResult">
|
|
<include refid="selectVo"/>
|
|
where rule_id = #{ruleId} and del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectActiveByType" parameterType="String" resultMap="BmsBizRuleResult">
|
|
<include refid="selectVo"/>
|
|
where del_flag = '0' and status = '0'
|
|
and rule_type = #{ruleType}
|
|
order by
|
|
(case when product_code is null or product_code = '' then 0 else 1 end
|
|
+ case when country_code is null or country_code = '' then 0 else 1 end
|
|
+ case when customer_code is null or customer_code = '' then 0 else 1 end) desc,
|
|
rule_id asc
|
|
</select>
|
|
|
|
<select id="countByDim" resultType="int">
|
|
select count(1) from biz_rule
|
|
where del_flag = '0'
|
|
and rule_type = #{ruleType}
|
|
and ifnull(product_code,'') = ifnull(#{productCode},'')
|
|
and ifnull(country_code,'') = ifnull(#{countryCode},'')
|
|
and ifnull(customer_code,'') = ifnull(#{customerCode},'')
|
|
and ((#{weightMin} is null and weight_min is null) or weight_min = #{weightMin})
|
|
and ((#{weightMax} is null and weight_max is null) or weight_max = #{weightMax})
|
|
<if test="excludeId != null">and rule_id != #{excludeId}</if>
|
|
</select>
|
|
|
|
<insert id="insert" parameterType="BmsBizRule" useGeneratedKeys="true" keyProperty="ruleId">
|
|
insert into biz_rule (
|
|
rule_name, rule_type, product_code, country_code, customer_code, weight_min, weight_max,
|
|
weight_source, side_sum_max, status, remark, create_by, create_time, del_flag
|
|
) values (
|
|
#{ruleName}, #{ruleType}, #{productCode}, #{countryCode}, #{customerCode}, #{weightMin}, #{weightMax},
|
|
#{weightSource}, #{sideSumMax}, #{status}, #{remark}, #{createBy}, sysdate(), '0'
|
|
)
|
|
</insert>
|
|
|
|
<update id="update" parameterType="BmsBizRule">
|
|
update biz_rule
|
|
<set>
|
|
<if test="ruleName != null and ruleName != ''">rule_name = #{ruleName},</if>
|
|
<if test="ruleType != null and ruleType != ''">rule_type = #{ruleType},</if>
|
|
product_code = #{productCode},
|
|
country_code = #{countryCode},
|
|
customer_code = #{customerCode},
|
|
weight_min = #{weightMin},
|
|
weight_max = #{weightMax},
|
|
<if test="weightSource != null and weightSource != ''">weight_source = #{weightSource},</if>
|
|
side_sum_max = #{sideSumMax},
|
|
<if test="status != null and status != ''">status = #{status},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
update_time = sysdate()
|
|
</set>
|
|
where rule_id = #{ruleId} and del_flag = '0'
|
|
</update>
|
|
|
|
<update id="deleteByIds" parameterType="Long">
|
|
update biz_rule
|
|
set del_flag = '1',
|
|
update_time = sysdate()
|
|
where rule_id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
</mapper>
|