<?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.soss.system.mapper.SpecRuleMapper"> <resultMap type="SpecRule" id="SpecRuleResult"> <result property="id" column="id" /> <result property="name" column="name" /> <result property="specId" column="spec_id" /> <result property="amount" column="amount" /> <result property="turn" column="turn" /> <result property="isRecommend" column="is_recommend" /> <result property="isDefault" column="is_default" /> <result property="isDeleted" column="is_deleted" /> <result property="createdAt" column="created_at" /> <result property="updatedAt" column="updated_at" /> </resultMap> <sql id="selectSpecRuleVo"> select id, name, spec_id, amount, turn, is_recommend, is_default, is_deleted, created_at, updated_at from spec_rule </sql> <select id="selectSpecRuleList" parameterType="SpecRule" resultMap="SpecRuleResult"> <include refid="selectSpecRuleVo"/> <where> and is_deleted = 0 <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="specId != null and specId != ''"> and spec_id = #{specId}</if> <if test="amount != null "> and amount = #{amount}</if> <if test="turn != null and turn != ''"> and turn = #{turn}</if> <if test="isRecommend != null and isRecommend != ''"> and is_recommend = #{isRecommend}</if> <if test="createdAt != null "> and created_at = #{createdAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if> </where> </select> <select id="selectSpecRuleById" parameterType="String" resultMap="SpecRuleResult"> <include refid="selectSpecRuleVo"/> where id = #{id} and is_deleted = 0 </select> <insert id="insertSpecRule" parameterType="SpecRule" useGeneratedKeys="true" keyProperty="id"> insert into spec_rule <trim prefix="(" suffix=")" suffixOverrides=","> <if test="name != null and name != ''">name,</if> <if test="specId != null and specId != ''">spec_id,</if> <if test="amount != null">amount,</if> <if test="turn != null and turn != ''">turn,</if> <if test="isRecommend != null and isRecommend != ''">is_recommend,</if> <if test="isDefault != null">is_default,</if> <if test="isDeleted != null and isDeleted != ''">is_deleted,</if> <if test="createdAt != null">created_at,</if> <if test="updatedAt != null">updated_at,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="name != null and name != ''">#{name},</if> <if test="specId != null and specId != ''">#{specId},</if> <if test="amount != null">#{amount},</if> <if test="turn != null and turn != ''">#{turn},</if> <if test="isRecommend != null and isRecommend != ''">#{isRecommend},</if> <if test="isDefault != null">#{isDefault},</if> <if test="isDeleted != null and isDeleted != ''">#{isDeleted},</if> <if test="createdAt != null">#{createdAt},</if> <if test="updatedAt != null">#{updatedAt},</if> </trim> </insert> <update id="updateSpecRule" parameterType="SpecRule"> update spec_rule <trim prefix="SET" suffixOverrides=","> <if test="name != null and name != ''">name = #{name},</if> <if test="specId != null and specId != ''">spec_id = #{specId},</if> <if test="amount != null">amount = #{amount},</if> <if test="turn != null and turn != ''">turn = #{turn},</if> <if test="isRecommend != null and isRecommend != ''">is_recommend = #{isRecommend},</if> <if test="isDefault != null">is_default = #{isDefault},</if> <if test="isDeleted != null and isDeleted != ''">is_deleted = #{isDeleted},</if> <if test="updatedAt != null">updated_at = #{updatedAt},</if> </trim> where id = #{id} </update> <delete id="deleteSpecRuleById" parameterType="String"> delete from spec_rule where id = #{id} </delete> <delete id="deleteSpecRuleByIds" parameterType="String"> delete from spec_rule where id in <foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> </delete> <update id="deleteSpecRuleBySpecId"> update spec_rule set is_deleted = 1,updated_at =now() where spec_id =#{spec_id} </update> </mapper>