<?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.GoodsMapper"> <resultMap type="Goods" id="GoodsResult"> <result property="id" column="id" /> <result property="name" column="name" /> <result property="category" column="category" /> <result property="price" column="price" /> <result property="discount" column="discount" /> <result property="takeTime" column="take_time" /> <result property="spec" column="spec" /> <result property="pics" column="pics" /> <result property="desc" column="desc" /> <result property="remarks" column="remarks" /> <result property="state" column="state" /> <result property="isDeleted" column="is_deleted" /> <result property="createdAt" column="created_at" /> <result property="updatedAt" column="updated_at" /> <result property="code" column="code" /> <result property="shelfAt" column="shelf_at"/> </resultMap> <sql id="selectGoodsVo"> select id, name, category, price, discount, take_time, spec, pics, `desc`, remarks, state, is_deleted, created_at, updated_at, code,shelf_at from goods </sql> <select id="selectGoodsList" parameterType="Goods" resultMap="GoodsResult"> <include refid="selectGoodsVo"/> <where> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> <if test="category != null and category != ''"> and category = #{category}</if> <if test="price != null "> and price = #{price}</if> <if test="discount != null "> and discount = #{discount}</if> <if test="takeTime != null "> and take_time = #{takeTime}</if> <if test="spec != null and spec != ''"> and spec = #{spec}</if> <if test="pics != null and pics != ''"> and pics = #{pics}</if> <if test="desc != null and desc != ''"> and `desc` = #{desc}</if> <if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if> <if test="state != null and state != ''"> and state = #{state}</if> <if test="isDeleted != null "> and is_deleted = #{isDeleted}</if> <if test="createdAt != null "> and created_at = #{createdAt}</if> <if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="code != null and code != ''"> and code = #{code}</if> </where> </select> <select id="selectGoodsById" parameterType="String" resultMap="GoodsResult"> <include refid="selectGoodsVo"/> where id = #{id} </select> <insert id="insertGoods" parameterType="Goods" useGeneratedKeys="true" keyProperty="id"> insert into goods <trim prefix="(" suffix=")" suffixOverrides=","> <if test="name != null and name != ''">name,</if> <if test="category != null and category != ''">category,</if> <if test="price != null">price,</if> <if test="discount != null">discount,</if> <if test="takeTime != null">take_time,</if> <if test="spec != null and spec != ''">spec,</if> <if test="pics != null and pics != ''">pics,</if> <if test="desc != null">`desc`,</if> <if test="remarks != null">remarks,</if> <if test="state != null and state != ''">state,</if> <if test="isDeleted != null">is_deleted,</if> <if test="createdAt != null">created_at,</if> <if test="updatedAt != null">updated_at,</if> <if test="code != null">code,</if> <if test="shelfAt != null">shelf_at,</if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="name != null and name != ''">#{name},</if> <if test="category != null and category != ''">#{category},</if> <if test="price != null">#{price},</if> <if test="discount != null">#{discount},</if> <if test="takeTime != null">#{takeTime},</if> <if test="spec != null and spec != ''">#{spec},</if> <if test="pics != null and pics != ''">#{pics},</if> <if test="desc != null">#{desc},</if> <if test="remarks != null">#{remarks},</if> <if test="state != null and state != ''">#{state},</if> <if test="isDeleted != null">#{isDeleted},</if> <if test="createdAt != null">#{createdAt},</if> <if test="updatedAt != null">#{updatedAt},</if> <if test="code != null">#{code},</if> <if test="shelfAt != null">#{shelfAt},</if> </trim> </insert> <update id="updateGoods" parameterType="Goods"> update goods <trim prefix="SET" suffixOverrides=","> <if test="name != null and name != ''">name = #{name},</if> <if test="category != null and category != ''">category = #{category},</if> <if test="price != null">price = #{price},</if> <if test="discount != null">discount = #{discount},</if> <if test="takeTime != null">take_time = #{takeTime},</if> <if test="spec != null and spec != ''">spec = #{spec},</if> <if test="pics != null and pics != ''">pics = #{pics},</if> <if test="desc != null">`desc` = #{desc},</if> <if test="remarks != null">remarks = #{remarks},</if> <if test="state != null and state != ''">state = #{state},</if> <if test="isDeleted != null">is_deleted = #{isDeleted},</if> <if test="createdAt != null">created_at = #{createdAt},</if> <if test="updatedAt != null">updated_at = #{updatedAt},</if> <if test="code != null">code = #{code},</if> <if test="shelfAt != null">shelf_at = #{shelfAt},</if> </trim> where id = #{id} </update> <delete id="deleteGoodsById" parameterType="String"> delete from goods where id = #{id} </delete> <delete id="deleteGoodsByIds" parameterType="String"> delete from goods where id in <foreach item="id" collection="array" open="(" separator="," close=")"> #{id} </foreach> </delete> <select id="selectCount" resultType="integer"> select count(*) from goods where category=#{id} </select> </mapper>