GrainBinDao.xml 5.7 KB

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