ProductMapper.xml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.phm.manage.mapper.ProductMapper">
  6. <resultMap type="Product" id="ProductResult">
  7. <result property="id" column="id" />
  8. <result property="parentId" column="parent_id" />
  9. <result property="name" column="name" />
  10. <result property="snsId" column="sns_id" />
  11. <result property="isDelete" column="is_delete" />
  12. <result property="createBy" column="create_by" />
  13. <result property="createTime" column="create_time" />
  14. <result property="updateBy" column="update_by" />
  15. <result property="updateTime" column="update_time" />
  16. </resultMap>
  17. <sql id="selectProductVo">
  18. select id, parent_id, name, sns_id, is_delete, create_by, create_time, update_by, update_time from phm_product
  19. </sql>
  20. <select id="selectProductList" parameterType="Product" resultMap="ProductResult">
  21. <include refid="selectProductVo"/>
  22. <where>
  23. <if test="parentId != null "> and parent_id = #{parentId}</if>
  24. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  25. <if test="snsId != null and snsId != ''"> and sns_id = #{snsId}</if>
  26. </where>
  27. </select>
  28. <select id="selectProductById" parameterType="Long" resultMap="ProductResult">
  29. <include refid="selectProductVo"/>
  30. where id = #{id}
  31. </select>
  32. <insert id="insertProduct" parameterType="Product" useGeneratedKeys="true" keyProperty="id">
  33. insert into phm_product
  34. <trim prefix="(" suffix=")" suffixOverrides=",">
  35. <if test="parentId != null">parent_id,</if>
  36. <if test="name != null">name,</if>
  37. <if test="snsId != null">sns_id,</if>
  38. <if test="isDelete != null">is_delete,</if>
  39. <if test="createBy != null">create_by,</if>
  40. <if test="createTime != null">create_time,</if>
  41. <if test="updateBy != null">update_by,</if>
  42. <if test="updateTime != null">update_time,</if>
  43. </trim>
  44. <trim prefix="values (" suffix=")" suffixOverrides=",">
  45. <if test="parentId != null">#{parentId},</if>
  46. <if test="name != null">#{name},</if>
  47. <if test="snsId != null">#{snsId},</if>
  48. <if test="isDelete != null">#{isDelete},</if>
  49. <if test="createBy != null">#{createBy},</if>
  50. <if test="createTime != null">#{createTime},</if>
  51. <if test="updateBy != null">#{updateBy},</if>
  52. <if test="updateTime != null">#{updateTime},</if>
  53. </trim>
  54. </insert>
  55. <update id="updateProduct" parameterType="Product">
  56. update phm_product
  57. <trim prefix="SET" suffixOverrides=",">
  58. <if test="parentId != null">parent_id = #{parentId},</if>
  59. <if test="name != null">name = #{name},</if>
  60. <if test="snsId != null">sns_id = #{snsId},</if>
  61. <if test="isDelete != null">is_delete = #{isDelete},</if>
  62. <if test="createBy != null">create_by = #{createBy},</if>
  63. <if test="createTime != null">create_time = #{createTime},</if>
  64. <if test="updateBy != null">update_by = #{updateBy},</if>
  65. <if test="updateTime != null">update_time = #{updateTime},</if>
  66. </trim>
  67. where id = #{id}
  68. </update>
  69. <delete id="deleteProductById" parameterType="Long">
  70. delete from phm_product where id = #{id}
  71. </delete>
  72. <delete id="deleteProductByIds" parameterType="String">
  73. delete from phm_product where id in
  74. <foreach item="id" collection="array" open="(" separator="," close=")">
  75. #{id}
  76. </foreach>
  77. </delete>
  78. </mapper>