sysHouseDao.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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="cn.ourwill.module.sys.dao.SysHouseDao">
  4. <resultMap type="cn.ourwill.module.sys.entity.SysHouse" id="baseMap">
  5. <result column="id" property="id"/>
  6. <result column="uuid" property="uuid"/>
  7. <result column="grain_id" property="parentId"/>
  8. <result column="type" property="type"/>
  9. <result column="house_name" property="name"/>
  10. <result column="c_time" property="cTime"/>
  11. <result column="u_time" property="uTime"/>
  12. <result column="u_id" property="uId"/>
  13. <result column="c_id" property="cId"/>
  14. <result column="version" property="version"/>
  15. </resultMap>
  16. <sql id="columns">
  17. id ,
  18. uuid ,
  19. grain_id ,
  20. `type` ,
  21. `house_name` ,
  22. c_time ,
  23. u_time ,
  24. u_id ,
  25. c_id ,
  26. version
  27. </sql>
  28. <sql id="joinCols">
  29. </sql>
  30. <select id="get" resultMap="baseMap">
  31. SELECT
  32. <include refid="columns"/>
  33. FROM house_info a
  34. <include refid="joinCols"/>
  35. WHERE a.id = #{id}
  36. </select>
  37. <select id="findList" resultMap="baseMap">
  38. SELECT
  39. <include refid="columns"/>
  40. FROM house_info a
  41. <include refid="joinCols"/>
  42. <where>
  43. <if test="id !=null">
  44. and id = #{id}
  45. </if>
  46. <if test="uuid !=null">
  47. and uuid = #{uuid}
  48. </if>
  49. <if test="parentId !=null">
  50. and grain_id = #{parentId}
  51. </if>
  52. <if test="type !=null">
  53. and `type` = #{type}
  54. </if>
  55. <if test="name !=null">
  56. and house_name = #{name}
  57. </if>
  58. <if test="cTime !=null">
  59. and c_time = #{cTime}
  60. </if>
  61. <if test="uTime !=null">
  62. and u_time = #{uTime}
  63. </if>
  64. <if test="uId !=null">
  65. and u_id = #{uId}
  66. </if>
  67. <if test="cId !=null">
  68. and c_id = #{cId}
  69. </if>
  70. <if test="version !=null">
  71. and version = #{version}
  72. </if>
  73. </where>
  74. ORDER BY ID DESC
  75. </select>
  76. <select id="findAllList" resultMap="baseMap">
  77. SELECT
  78. <include refid="columns"/>
  79. FROM house_info a
  80. <include refid="joinCols"/>
  81. <where>
  82. <if test="id !=null">
  83. and id = #{id}
  84. </if>
  85. <if test="uuid !=null">
  86. and uuid = #{uuid}
  87. </if>
  88. <if test="parentId !=null">
  89. and grain_id = #{parentId}
  90. </if>
  91. <if test="type !=null">
  92. and `type` = #{type}
  93. </if>
  94. <if test="name !=null">
  95. and house_name = #{name}
  96. </if>
  97. <if test="cTime !=null">
  98. and c_time = #{cTime}
  99. </if>
  100. <if test="uTime !=null">
  101. and u_time = #{uTime}
  102. </if>
  103. <if test="uId !=null">
  104. and u_id = #{uId}
  105. </if>
  106. <if test="cId !=null">
  107. and c_id = #{cId}
  108. </if>
  109. <if test="version !=null">
  110. and version = #{version}
  111. </if>
  112. </where>
  113. ORDER BY ID DESC
  114. </select>
  115. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  116. parameterType="cn.ourwill.module.sys.entity.SysHouse">
  117. INSERT INTO house_info
  118. <trim prefix="(" suffix=")" suffixOverrides=",">
  119. <if test=" id != null">
  120. id,
  121. </if>
  122. <if test=" uuid != null">
  123. uuid,
  124. </if>
  125. <if test=" parentId != null">
  126. grain_id,
  127. </if>
  128. <if test=" type != null">
  129. `type`,
  130. </if>
  131. <if test=" name != null">
  132. house_name,
  133. </if>
  134. <if test=" cTime != null">
  135. c_time,
  136. </if>
  137. <if test=" uTime != null">
  138. u_time,
  139. </if>
  140. <if test=" uId != null">
  141. u_id,
  142. </if>
  143. <if test=" cId != null">
  144. c_id,
  145. </if>
  146. <if test=" version != null">
  147. version
  148. </if>
  149. </trim>
  150. <trim prefix="values (" suffix=")" suffixOverrides=",">
  151. <if test=" id != null">
  152. #{id}, </if>
  153. <if test=" uuid != null">
  154. #{uuid}, </if>
  155. <if test=" parentId != null">
  156. #{parentId}, </if>
  157. <if test=" type != null">
  158. #{type}, </if>
  159. <if test=" name != null">
  160. #{name}, </if>
  161. <if test=" cTime != null">
  162. #{cTime}, </if>
  163. <if test=" uTime != null">
  164. #{uTime}, </if>
  165. <if test=" uId != null">
  166. #{uId}, </if>
  167. <if test=" cId != null">
  168. #{cId}, </if>
  169. <if test=" version != null">
  170. #{version} </if>
  171. </trim>
  172. </insert>
  173. <update id="update" parameterType="cn.ourwill.module.sys.entity.SysHouse">
  174. UPDATE house_info <set>
  175. <if test="id != null">
  176. id= #{id} ,
  177. </if>
  178. <if test="uuid != null">
  179. uuid= #{uuid} ,
  180. </if>
  181. <if test="parentId != null">
  182. grain_id= #{parentId} ,
  183. </if>
  184. <if test="type != null">
  185. `type`= #{type} ,
  186. </if>
  187. <if test="name != null">
  188. house_name = #{name} ,
  189. </if>
  190. <if test="cTime != null">
  191. c_time= #{cTime} ,
  192. </if>
  193. <if test="uTime != null">
  194. u_time= #{uTime} ,
  195. </if>
  196. <if test="uId != null">
  197. u_id= #{uId} ,
  198. </if>
  199. <if test="cId != null">
  200. c_id= #{cId} ,
  201. </if>
  202. <if test="version != null">
  203. version= #{version}
  204. </if>
  205. </set>
  206. WHERE id = #{id}
  207. </update>
  208. <delete id="deleteById" parameterType="java.lang.Long">
  209. DELETE FROM house_info WHERE id = #{id}
  210. </delete>
  211. <delete id="deleteByIds" parameterType="java.util.List">
  212. DELETE FROM house_info WHERE id IN
  213. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  214. #{item}
  215. </foreach>
  216. </delete>
  217. <select id="getByParentId" resultMap="baseMap">
  218. SELECT
  219. <include refid="columns"/>
  220. FROM house_info
  221. WHERE grain_id = #{value}
  222. </select>
  223. <select id="getById" resultType="java.lang.String" >
  224. SELECT
  225. house_name
  226. FROM house_info
  227. WHERE id = #{id}
  228. </select>
  229. </mapper>