DictValueMapper.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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.jeeplus.modules.sys.mapper.DictValueMapper">
  4. <sql id="dictValueColumns">
  5. a.id AS "id",
  6. a.label AS "label",
  7. a.value AS "value",
  8. a.sort AS "sort",
  9. a.dict_type_id AS "dictType.id",
  10. a.create_by AS "createBy.id",
  11. a.create_date AS "createDate",
  12. a.update_by AS "updateBy.id",
  13. a.update_date AS "updateDate",
  14. a.del_flag AS "delFlag"
  15. </sql>
  16. <sql id="dictValueJoins">
  17. LEFT JOIN sys_dict_type b ON b.id = a.dict_type_id
  18. </sql>
  19. <select id="get" resultType="DictValue" >
  20. SELECT
  21. <include refid="dictValueColumns"/>
  22. FROM sys_dict_value a
  23. <include refid="dictValueJoins"/>
  24. WHERE a.id = #{id}
  25. </select>
  26. <select id="findList" resultType="DictValue" >
  27. SELECT
  28. <include refid="dictValueColumns"/>
  29. FROM sys_dict_value a
  30. <include refid="dictValueJoins"/>
  31. <where>
  32. a.del_flag = #{DEL_FLAG_NORMAL}
  33. <if test="label != null and label != ''">
  34. AND a.label LIKE
  35. <if test="dbName == 'oracle'">'%'||#{label}||'%'</if>
  36. <if test="dbName == 'mssql'">'%'+#{label}+'%'</if>
  37. <if test="dbName == 'mysql'">concat('%',#{label},'%')</if>
  38. </if>
  39. <if test="value != null and value != ''">
  40. AND a.value = #{value}
  41. </if>
  42. <if test="dictType != null and dictType.id != null and dictType.id != ''">
  43. AND a.dict_type_id = #{dictType.id}
  44. </if>
  45. </where>
  46. <choose>
  47. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  48. ORDER BY ${page.orderBy}
  49. </when>
  50. <otherwise>
  51. ORDER BY a.sort ASC
  52. </otherwise>
  53. </choose>
  54. </select>
  55. <select id="findAllList" resultType="DictValue" >
  56. SELECT
  57. <include refid="dictValueColumns"/>
  58. FROM sys_dict_value a
  59. <include refid="dictValueJoins"/>
  60. <where>
  61. a.del_flag = #{DEL_FLAG_NORMAL}
  62. </where>
  63. <choose>
  64. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  65. ORDER BY ${page.orderBy}
  66. </when>
  67. <otherwise>
  68. ORDER BY a.create_date ASC
  69. </otherwise>
  70. </choose>
  71. </select>
  72. <insert id="insert">
  73. INSERT INTO sys_dict_value(
  74. id,
  75. label,
  76. value,
  77. sort,
  78. dict_type_id,
  79. create_by,
  80. create_date,
  81. update_by,
  82. update_date,
  83. del_flag
  84. ) VALUES (
  85. #{id},
  86. #{label},
  87. #{value},
  88. #{sort},
  89. #{dictType.id},
  90. #{createBy.id},
  91. #{createDate},
  92. #{updateBy.id},
  93. #{updateDate},
  94. #{delFlag}
  95. )
  96. </insert>
  97. <update id="update">
  98. UPDATE sys_dict_value SET
  99. label = #{label},
  100. value = #{value},
  101. sort = #{sort},
  102. dict_type_id = #{dictType.id},
  103. update_by = #{updateBy.id},
  104. update_date = #{updateDate}
  105. WHERE id = #{id}
  106. </update>
  107. <!--物理删除-->
  108. <update id="delete">
  109. DELETE FROM sys_dict_value
  110. <choose>
  111. <when test="id !=null and id != ''">
  112. WHERE id = #{id}
  113. </when>
  114. <otherwise>
  115. WHERE dict_type_id = #{dictType.id}
  116. </otherwise>
  117. </choose>
  118. </update>
  119. <!--逻辑删除-->
  120. <update id="deleteByLogic">
  121. UPDATE sys_dict_value SET
  122. del_flag = #{DEL_FLAG_DELETE}
  123. <choose>
  124. <when test="id !=null and id != ''">
  125. WHERE id = #{id}
  126. </when>
  127. <otherwise>
  128. WHERE dict_type_id = #{dictType.id}
  129. </otherwise>
  130. </choose>
  131. </update>
  132. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  133. <select id="findUniqueByProperty" resultType="DictValue" statementType="STATEMENT">
  134. select * FROM sys_dict_value where ${propertyName} = '${value}'
  135. </select>
  136. </mapper>