javacodeadmin/ruoyi-system/src/main/resources/mapper/system/QuoteMaterialMapper.xml

96 lines
4.1 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.ruoyi.system.mapper.QuoteMaterialMapper">
<resultMap type="QuoteMaterial" id="QuoteMaterialResult">
<result property="id" column="id" />
<result property="goodId" column="good_id" />
<result property="typeId" column="type_id" />
<result property="title" column="title" />
<result property="price" column="price" />
<result property="unit" column="unit" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
</resultMap>
<sql id="selectQuoteMaterialVo">
select id, good_id, type_id, title, price, unit, created_at, updated_at from quote_material
</sql>
<select id="selectQuoteMaterialList" parameterType="QuoteMaterial" resultMap="QuoteMaterialResult">
<include refid="selectQuoteMaterialVo"/>
<where>
<if test="goodId != null and goodId != ''"> and good_id like concat('%', #{goodId}, '%')</if>
<if test="typeId != null and typeId != ''">
and type_id like concat('%', #{typeId}, '%') </if>
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="priceMin != null and priceMax != null">
and price BETWEEN #{priceMin} AND #{priceMax}
</if>
<if test="priceMin != null and priceMax == null">
and price >= #{priceMin}
</if>
<if test="priceMax != null and priceMin == null">
and price &lt;= #{priceMax}
</if>
<if test="unit != null and unit != ''"> and unit = #{unit}</if>
</where>
order by id desc
</select>
<select id="selectQuoteMaterialById" parameterType="Long" resultMap="QuoteMaterialResult">
<include refid="selectQuoteMaterialVo"/>
where id = #{id}
</select>
<insert id="insertQuoteMaterial" parameterType="QuoteMaterial" useGeneratedKeys="true" keyProperty="id">
insert into quote_material
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="goodId != null and goodId != ''">good_id,</if>
<if test="typeId != null and typeId != ''">type_id,</if>
<if test="title != null and title != ''">title,</if>
<if test="price != null">price,</if>
<if test="unit != null and unit != ''">unit,</if>
created_at,
updated_at
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="goodId != null and goodId != ''">#{goodId},</if>
<if test="typeId != null and typeId != ''">#{typeId},</if>
<if test="title != null and title != ''">#{title},</if>
<if test="price != null">#{price},</if>
<if test="unit != null and unit != ''">#{unit},</if>
NOW(),
NOW()
</trim>
</insert>
<update id="updateQuoteMaterial" parameterType="QuoteMaterial">
update quote_material
<trim prefix="SET" suffixOverrides=",">
<if test="goodId != null and goodId != ''">good_id = #{goodId},</if>
<if test="typeId != null and typeId != ''">type_id = #{typeId},</if>
<if test="title != null and title != ''">title = #{title},</if>
<if test="price != null">price = #{price},</if>
<if test="unit != null and unit != ''">unit = #{unit},</if>
updated_at = NOW()
</trim>
where id = #{id}
</update>
<delete id="deleteQuoteMaterialById" parameterType="Long">
delete from quote_material where id = #{id}
</delete>
<delete id="deleteQuoteMaterialByIds" parameterType="String">
delete from quote_material where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>