SpecificationDao.xml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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
  36. </select>
  37. <insert id="save" parameterType="com.kmall.admin.entity.SpecificationEntity" useGeneratedKeys="true" keyProperty="id">
  38. insert into mall_specification
  39. (
  40. `name`,
  41. `sort_order`
  42. )
  43. values
  44. (
  45. #{name},
  46. #{sortOrder}
  47. )
  48. </insert>
  49. <update id="update" parameterType="com.kmall.admin.entity.SpecificationEntity">
  50. update mall_specification
  51. <set>
  52. <if test="name != null">`name` = #{name}, </if>
  53. <if test="sortOrder != null">`sort_order` = #{sortOrder}</if>
  54. </set>
  55. where id = #{id}
  56. </update>
  57. <delete id="delete">
  58. delete from mall_specification where id = #{value}
  59. </delete>
  60. <delete id="deleteBatch">
  61. delete from mall_specification where id in
  62. <foreach item="id" collection="array" open="(" separator="," close=")">
  63. #{id}
  64. </foreach>
  65. </delete>
  66. </mapper>