TbLocationMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.ruoyi.asset.mapper.TbLocationMapper">
  6. <resultMap type="TbLocation" id="TbLocationResult">
  7. <result property="id" column="id" />
  8. <result property="number" column="number" />
  9. <result property="name" column="name" />
  10. <result property="parentId" column="parent_id" />
  11. <result property="sequence" column="sequence" />
  12. <result property="label" column="label" />
  13. <result property="remark" column="remark" />
  14. <result property="createBy" column="create_by" />
  15. <result property="createTime" column="create_time" />
  16. <result property="updateBy" column="update_by" />
  17. <result property="updateTime" column="update_time" />
  18. </resultMap>
  19. <sql id="selectTbLocationVo">
  20. select id, number, name, parent_id, sequence, label, remark, create_by, create_time, update_by, update_time from tb_location
  21. </sql>
  22. <select id="selectTbLocationList" parameterType="TbLocation" resultMap="TbLocationResult">
  23. <include refid="selectTbLocationVo"/>
  24. <where>
  25. <if test="number != null and number != ''"> and number = #{number}</if>
  26. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  27. <if test="parentId != null"> and parent_id = #{parentId}</if>
  28. <if test="label != null and label != ''"> and label = #{label}</if>
  29. </where>
  30. </select>
  31. <select id="selectTbLocationById" parameterType="Long" resultMap="TbLocationResult">
  32. <include refid="selectTbLocationVo"/>
  33. where id = #{id}
  34. </select>
  35. <!--selectTbLocationByNumber-->
  36. <select id="selectTbLocationByNumber" parameterType="String" resultMap="TbLocationResult">
  37. <include refid="selectTbLocationVo"/>
  38. where number = #{number}
  39. </select>
  40. <select id="selectNumberByFather" parameterType="String" resultType="String">
  41. select a.number, a.id, a.name from tb_location a
  42. where a.number = #{number}
  43. or a.parent_id = (select b.id from tb_location b where b.number = #{number})
  44. </select>
  45. <insert id="insertTbLocation" parameterType="TbLocation" useGeneratedKeys="true" keyProperty="id">
  46. insert into tb_location
  47. <trim prefix="(" suffix=")" suffixOverrides=",">
  48. <if test="number != null and number != ''">number,</if>
  49. <if test="name != null">name,</if>
  50. <if test="parentId != null">parent_id,</if>
  51. <if test="sequence != null and sequence != ''">sequence,</if>
  52. <if test="label != null and label != ''">label,</if>
  53. <if test="remark != null">remark,</if>
  54. <if test="createBy != null and createBy != ''">create_by,</if>
  55. <if test="createTime != null">create_time,</if>
  56. <if test="updateBy != null">update_by,</if>
  57. <if test="updateTime != null">update_time,</if>
  58. </trim>
  59. <trim prefix="values (" suffix=")" suffixOverrides=",">
  60. <if test="number != null and number != ''">#{number},</if>
  61. <if test="name != null">#{name},</if>
  62. <if test="parentId != null">#{parentId},</if>
  63. <if test="sequence != null and sequence != ''">#{sequence},</if>
  64. <if test="label != null and label != ''">#{label},</if>
  65. <if test="remark != null">#{remark},</if>
  66. <if test="createBy != null and createBy != ''">#{createBy},</if>
  67. <if test="createTime != null">#{createTime},</if>
  68. <if test="updateBy != null">#{updateBy},</if>
  69. <if test="updateTime != null">#{updateTime},</if>
  70. </trim>
  71. </insert>
  72. <update id="updateTbLocation" parameterType="TbLocation">
  73. update tb_location
  74. <trim prefix="SET" suffixOverrides=",">
  75. <if test="number != null and number != ''">number = #{number},</if>
  76. <if test="name != null">name = #{name},</if>
  77. <if test="parentId != null">parent_id = #{parentId},</if>
  78. <if test="sequence != null and sequence != ''">sequence = #{sequence},</if>
  79. <if test="label != null and label != ''">label = #{label},</if>
  80. <if test="remark != null">remark = #{remark},</if>
  81. <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
  82. <if test="createTime != null">create_time = #{createTime},</if>
  83. <if test="updateBy != null">update_by = #{updateBy},</if>
  84. <if test="updateTime != null">update_time = #{updateTime},</if>
  85. </trim>
  86. where id = #{id}
  87. </update>
  88. <delete id="deleteTbLocationById" parameterType="Long">
  89. delete from tb_location where id = #{id}
  90. </delete>
  91. <delete id="deleteTbLocationByIds" parameterType="String">
  92. delete from tb_location where id in
  93. <foreach item="id" collection="array" open="(" separator="," close=")">
  94. #{id}
  95. </foreach>
  96. </delete>
  97. </mapper>