1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?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.phm.manage.mapper.ProductMapper">
-
- <resultMap type="Product" id="ProductResult">
- <result property="id" column="id" />
- <result property="parentId" column="parent_id" />
- <result property="name" column="name" />
- <result property="snsId" column="sns_id" />
- <result property="isDelete" column="is_delete" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- </resultMap>
- <sql id="selectProductVo">
- select id, parent_id, name, sns_id, is_delete, create_by, create_time, update_by, update_time from phm_product
- </sql>
- <select id="selectProductList" parameterType="Product" resultMap="ProductResult">
- <include refid="selectProductVo"/>
- <where>
- <if test="parentId != null "> and parent_id = #{parentId}</if>
- <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
- <if test="snsId != null and snsId != ''"> and sns_id = #{snsId}</if>
- </where>
- </select>
-
- <select id="selectProductById" parameterType="Long" resultMap="ProductResult">
- <include refid="selectProductVo"/>
- where id = #{id}
- </select>
-
- <insert id="insertProduct" parameterType="Product" useGeneratedKeys="true" keyProperty="id">
- insert into phm_product
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="parentId != null">parent_id,</if>
- <if test="name != null">name,</if>
- <if test="snsId != null">sns_id,</if>
- <if test="isDelete != null">is_delete,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="parentId != null">#{parentId},</if>
- <if test="name != null">#{name},</if>
- <if test="snsId != null">#{snsId},</if>
- <if test="isDelete != null">#{isDelete},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- </trim>
- </insert>
- <update id="updateProduct" parameterType="Product">
- update phm_product
- <trim prefix="SET" suffixOverrides=",">
- <if test="parentId != null">parent_id = #{parentId},</if>
- <if test="name != null">name = #{name},</if>
- <if test="snsId != null">sns_id = #{snsId},</if>
- <if test="isDelete != null">is_delete = #{isDelete},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteProductById" parameterType="Long">
- delete from phm_product where id = #{id}
- </delete>
- <delete id="deleteProductByIds" parameterType="String">
- delete from phm_product where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|