1
0

SpecificationDao.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.admin.dao.SpecificationDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.SpecificationEntity" id="specificationMap">
  6. <result property="id" column="id"/>
  7. <result property="name" column="name"/>
  8. <result property="sortOrder" column="sort_order"/>
  9. </resultMap>
  10. <select id="queryObject" resultType="com.kmall.admin.entity.SpecificationEntity">
  11. select * from mall_specification where id = #{value}
  12. </select>
  13. <select id="queryList" resultType="com.kmall.admin.entity.SpecificationEntity">
  14. select * from mall_specification a
  15. WHERE 1=1
  16. <if test="ids != null">
  17. and a.id in
  18. <foreach item="item" collection="ids" open="(" separator="," close=")">
  19. #{item}
  20. </foreach>
  21. </if>
  22. <choose>
  23. <when test="sidx != null and sidx.trim() != ''">
  24. order by ${sidx} ${order}
  25. </when>
  26. <otherwise>
  27. order by id desc
  28. </otherwise>
  29. </choose>
  30. <if test="offset != null and limit != null">
  31. limit #{offset}, #{limit}
  32. </if>
  33. </select>
  34. <select id="queryTotal" resultType="int">
  35. select count(*) from mall_specification a
  36. WHERE 1=1
  37. <if test="ids != null">
  38. and a.id in
  39. <foreach item="item" collection="ids" open="(" separator="," close=")">
  40. #{item}
  41. </foreach>
  42. </if>
  43. </select>
  44. <insert id="save" parameterType="com.kmall.admin.entity.SpecificationEntity" useGeneratedKeys="true" keyProperty="id">
  45. insert into mall_specification
  46. (
  47. `name`,
  48. `sort_order`
  49. )
  50. values
  51. (
  52. #{name},
  53. #{sortOrder}
  54. )
  55. </insert>
  56. <update id="update" parameterType="com.kmall.admin.entity.SpecificationEntity">
  57. update mall_specification
  58. <set>
  59. <if test="name != null">`name` = #{name}, </if>
  60. <if test="sortOrder != null">`sort_order` = #{sortOrder}</if>
  61. </set>
  62. where id = #{id}
  63. </update>
  64. <delete id="delete">
  65. delete from mall_specification where id = #{value}
  66. </delete>
  67. <delete id="deleteBatch">
  68. delete from mall_specification where id in
  69. <foreach item="id" collection="array" open="(" separator="," close=")">
  70. #{id}
  71. </foreach>
  72. </delete>
  73. </mapper>