MedicineStoreDao.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  2. <mapper namespace="cn.ourwill.module.house.dao.dm.MedicineStoreDao">
  3. <resultMap type="cn.ourwill.module.house.entity.dm.MedicineStore" id="baseMap">
  4. <result column="id" property="id"/>
  5. <result column="grain_id" property="grainId"/>
  6. <result column="medicine_id" property="medicineId"/>
  7. <result column="number" property="number"/>
  8. <result column="c_id" property="cId"/>
  9. <result column="c_time" property="cTime"/>
  10. <result column="u_id" property="uId"/>
  11. <result column="u_time" property="uTime"/>
  12. <result column="uuid" property="uuid"/>
  13. </resultMap>
  14. <sql id="columns">
  15. id ,
  16. grain_id ,
  17. medicine_id ,
  18. `number` ,
  19. c_id ,
  20. c_time ,
  21. u_id ,
  22. u_time,
  23. uuid
  24. </sql>
  25. <sql id="joinCols">
  26. </sql>
  27. <select id="get" resultMap="baseMap">
  28. SELECT
  29. <include refid="columns"/>
  30. FROM dm_medicine_store a
  31. <include refid="joinCols"/>
  32. WHERE a.id = #{id}
  33. </select>
  34. <select id="findList" resultMap="baseMap">
  35. SELECT
  36. <include refid="columns"/>
  37. FROM dm_medicine_store a
  38. <include refid="joinCols"/>
  39. <where>
  40. <if test="id !=null">
  41. and id = #{id}
  42. </if>
  43. <if test="grainId !=null">
  44. and grain_id = #{grainId}
  45. </if>
  46. <if test="medicineId !=null">
  47. and medicine_id = #{medicineId}
  48. </if>
  49. <if test="number !=null">
  50. and `number` = #{number}
  51. </if>
  52. <if test="cId !=null">
  53. and c_id = #{cId}
  54. </if>
  55. <if test="cTime !=null">
  56. and c_time = #{cTime}
  57. </if>
  58. <if test="uId !=null">
  59. and u_id = #{uId}
  60. </if>
  61. <if test="uTime !=null">
  62. and u_time = #{uTime}
  63. </if>
  64. <if test="uuid !=null">
  65. and uuid = #{uuid}
  66. </if>
  67. </where>
  68. <choose>
  69. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  70. ORDER BY ${page.orderBy}
  71. </when>
  72. <otherwise>
  73. </otherwise>
  74. </choose>
  75. </select>
  76. <select id="findAllList" resultMap="baseMap">
  77. SELECT
  78. <include refid="columns"/>
  79. FROM dm_medicine_store a
  80. <include refid="joinCols"/>
  81. <where>
  82. <if test="id !=null">
  83. and id = #{id}
  84. </if>
  85. <if test="grainId !=null">
  86. and grain_id = #{grainId}
  87. </if>
  88. <if test="medicineId !=null">
  89. and medicine_id = #{medicineId}
  90. </if>
  91. <if test="number !=null">
  92. and `number` = #{number}
  93. </if>
  94. <if test="cId !=null">
  95. and c_id = #{cId}
  96. </if>
  97. <if test="cTime !=null">
  98. and c_time = #{cTime}
  99. </if>
  100. <if test="uId !=null">
  101. and u_id = #{uId}
  102. </if>
  103. <if test="uTime !=null">
  104. and u_time = #{uTime}
  105. </if>
  106. <if test="uuid !=null">
  107. and uuid = #{uuid}
  108. </if>
  109. </where>
  110. <choose>
  111. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  112. ORDER BY ${page.orderBy}
  113. </when>
  114. <otherwise>
  115. </otherwise>
  116. </choose>
  117. </select>
  118. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  119. parameterType="cn.ourwill.module.house.entity.dm.MedicineStore">
  120. INSERT INTO dm_medicine_store
  121. <trim prefix="(" suffix=")" suffixOverrides=",">
  122. <if test=" id != null">
  123. id,
  124. </if>
  125. <if test=" grainId != null">
  126. grain_id,
  127. </if>
  128. <if test=" medicineId != null">
  129. medicine_id,
  130. </if>
  131. <if test=" number != null">
  132. `number`,
  133. </if>
  134. <if test=" cId != null">
  135. c_id,
  136. </if>
  137. <if test=" cTime != null">
  138. c_time,
  139. </if>
  140. <if test=" uId != null">
  141. u_id,
  142. </if>
  143. <if test=" uTime != null">
  144. u_time,
  145. </if>
  146. <if test=" uuid != null">
  147. uuid
  148. </if>
  149. </trim>
  150. <trim prefix="values (" suffix=")" suffixOverrides=",">
  151. <if test=" id != null">
  152. #{id}, </if>
  153. <if test=" grainId != null">
  154. #{grainId}, </if>
  155. <if test=" medicineId != null">
  156. #{medicineId}, </if>
  157. <if test=" number != null">
  158. #{number}, </if>
  159. <if test=" cId != null">
  160. #{cId}, </if>
  161. <if test=" cTime != null">
  162. #{cTime}, </if>
  163. <if test=" uId != null">
  164. #{uId}, </if>
  165. <if test=" uTime != null">
  166. #{uTime}, </if>
  167. <if test=" uuid != null">
  168. #{uuid} </if>
  169. </trim>
  170. </insert>
  171. <update id="update" parameterType="cn.ourwill.module.house.entity.dm.MedicineStore">
  172. UPDATE dm_medicine_store <set>
  173. <if test="id != null">
  174. id= #{id} ,
  175. </if>
  176. <if test="grainId != null">
  177. grain_id= #{grainId} ,
  178. </if>
  179. <if test="medicineId != null">
  180. medicine_id= #{medicineId} ,
  181. </if>
  182. <if test="number != null">
  183. `number`= #{number} ,
  184. </if>
  185. <if test="cId != null">
  186. c_id= #{cId} ,
  187. </if>
  188. <if test="cTime != null">
  189. c_time= #{cTime} ,
  190. </if>
  191. <if test="uId != null">
  192. u_id= #{uId} ,
  193. </if>
  194. <if test="uTime != null">
  195. u_time= #{uTime} ,
  196. </if>
  197. <if test="uuid != null">
  198. uuid= #{uuid}
  199. </if>
  200. </set>
  201. WHERE id = #{id}
  202. </update>
  203. <delete id="deleteById" parameterType="java.lang.Long">
  204. DELETE FROM dm_medicine_store WHERE id = #{id}
  205. </delete>
  206. <delete id="deleteByIds" parameterType="java.util.List">
  207. DELETE FROM dm_medicine_store WHERE id IN
  208. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  209. #{item}
  210. </foreach>
  211. </delete>
  212. <select id="getByUUid" resultMap="baseMap">
  213. SELECT
  214. <include refid="columns"/>
  215. FROM dm_medicine_store a
  216. <include refid="joinCols"/>
  217. WHERE a.uuid= #{uuid}
  218. </select>
  219. <select id="getByuuid" resultType="cn.ourwill.module.house.entity.dm.MedicineStore" >
  220. SELECT * FROM dm_medicine_store WHERE grain_id= #{grainId} and medicine_id=#{medicineId} ORDER BY id DESC LIMIT 1
  221. </select>
  222. <update id="updateByUuid" parameterType="cn.ourwill.module.house.entity.dm.MedicineStore">
  223. UPDATE dm_medicine_store <set>
  224. <if test="id != null">
  225. id= #{id} ,
  226. </if>
  227. <if test="grainId != null">
  228. grain_id= #{grainId} ,
  229. </if>
  230. <if test="medicineId != null">
  231. medicine_id= #{medicineId} ,
  232. </if>
  233. <if test="number != null">
  234. `number`= #{number} ,
  235. </if>
  236. <if test="cId != null">
  237. c_id= #{cId} ,
  238. </if>
  239. <if test="cTime != null">
  240. c_time= #{cTime} ,
  241. </if>
  242. <if test="uId != null">
  243. u_id= #{uId} ,
  244. </if>
  245. <if test="uTime != null">
  246. u_time= #{uTime} ,
  247. </if>
  248. <if test="uuid != null">
  249. uuid= #{uuid}
  250. </if>
  251. </set>
  252. WHERE uuid= #{uuid}
  253. </update>
  254. <update id="updateByUuid1" parameterType="cn.ourwill.module.house.entity.dm.MedicineStore">
  255. UPDATE dm_medicine_store <set>
  256. <if test="id != null">
  257. id= #{id} ,
  258. </if>
  259. <if test="grainId != null">
  260. grain_id= #{grainId} ,
  261. </if>
  262. <if test="medicineId != null">
  263. medicine_id= #{medicineId} ,
  264. </if>
  265. <if test="number != null">
  266. `number`= #{number} ,
  267. </if>
  268. <if test="cId != null">
  269. c_id= #{cId} ,
  270. </if>
  271. <if test="cTime != null">
  272. c_time= #{cTime} ,
  273. </if>
  274. <if test="uId != null">
  275. u_id= #{uId} ,
  276. </if>
  277. <if test="uTime != null">
  278. u_time= #{uTime} ,
  279. </if>
  280. <if test="uuid != null">
  281. uuid= #{uuid}
  282. </if>
  283. </set>
  284. WHERE id= #{id}
  285. </update>
  286. </mapper>