GoodsMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.hssx.pcbms.mapper.GoodsMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.hssx.pcbms.entity.Goods">
  6. <id column="id" property="id" />
  7. <result column="name" property="name" />
  8. <result column="tag_id" property="tagId" />
  9. <result column="model_number" property="modelNumber" />
  10. <result column="unit" property="unit" />
  11. <result column="address" property="address" />
  12. <result column="factory" property="factory" />
  13. <result column="pic" property="pic" />
  14. <result column="service_life" property="serviceLife" />
  15. <result column="next_indate" property="nextIndate" />
  16. <result column="is_delete" property="isDelete" />
  17. <result column="creator_id" property="creatorId" />
  18. <result column="division_code" property="divisionCode" />
  19. <result column="suffix_code" property="suffixCode" />
  20. </resultMap>
  21. <!-- 通用查询结果列 -->
  22. <sql id="Base_Column_List">
  23. id, name, tag_id, model_number, unit, address, factory, pic, service_life, next_indate, is_delete, creator_id, division_code, suffix_code
  24. </sql>
  25. <resultMap id="BaseResultMapVO" type="com.hssx.pcbms.entity.vo.GoodsVO">
  26. <id column="id" property="id"/>
  27. <result column="name" property="name"/>
  28. <result column="tag_id" property="tagId"/>
  29. <result column="model_number" property="modelNumber"/>
  30. <result column="unit" property="unit"/>
  31. <result column="address" property="address"/>
  32. <result column="factory" property="factory"/>
  33. <result column="pic" property="pic"/>
  34. <result column="service_life" property="serviceLife"/>
  35. <result column="next_indate" property="nextIndate"/>
  36. <collection property="goodsNos" select="selectGoodsNoByGoodsId" javaType="java.util.List" column="{goodId = id}"
  37. ofType="com.hssx.pcbms.entity.GoodsNo">
  38. </collection>
  39. </resultMap>
  40. <!-- 我的资产查询映射结果 -->
  41. <resultMap id="BaseResultMapMyList" type="com.hssx.pcbms.entity.vo.GoodsVO">
  42. <id column="id" property="id"/>
  43. <result column="name" property="name"/>
  44. <result column="tag_id" property="tagId"/>
  45. <result column="model_number" property="modelNumber"/>
  46. <result column="unit" property="unit"/>
  47. <result column="address" property="address"/>
  48. <result column="factory" property="factory"/>
  49. <result column="pic" property="pic"/>
  50. <result column="service_life" property="serviceLife"/>
  51. <result column="next_indate" property="nextIndate"/>
  52. <result column="divisioncode" property="divisionCode"/>
  53. <result column="suffixcode" property="suffixCode"/>
  54. <collection property="goodsNos" ofType="com.hssx.pcbms.entity.GoodsNo">
  55. <id column="nid" property="id"/>
  56. <result column="model_no" property="modelNo"/>
  57. <result column="division_code" property="divisionCode"/>
  58. <result column="suffix_code" property="suffixCode"/>
  59. <result column="state" property="state"/>
  60. <result column="indate" property="indate"/>
  61. <result column="goods_id" property="goodsId"/>
  62. <result column="user_id" property="userId"/>
  63. <result column="is_maintain" property="isMaintain" />
  64. </collection>
  65. </resultMap>
  66. <!-- 通用查询映射结果 -->
  67. <resultMap id="BaseResultMapDetail" type="com.hssx.pcbms.entity.vo.GoodsVO">
  68. <id column="id" property="id"/>
  69. <result column="name" property="name"/>
  70. <result column="tag_id" property="tagId"/>
  71. <result column="model_number" property="modelNumber"/>
  72. <result column="unit" property="unit"/>
  73. <result column="address" property="address"/>
  74. <result column="factory" property="factory"/>
  75. <result column="pic" property="pic"/>
  76. <result column="service_life" property="serviceLife"/>
  77. <result column="next_indate" property="nextIndate"/>
  78. <result column="divisioncode" property="divisionCode"/>
  79. <result column="suffixcode" property="suffixCode"/>
  80. <collection property="goodsNosVO" ofType="com.hssx.pcbms.entity.vo.GoodsNoVO">
  81. <id column="nid" property="id"/>
  82. <result column="model_no" property="modelNo"/>
  83. <result column="division_code" property="divisionCode"/>
  84. <result column="suffix_code" property="suffixCode"/>
  85. <result column="state" property="state"/>
  86. <result column="indate" property="indate"/>
  87. <result column="goods_id" property="goodsId"/>
  88. <result column="user_id" property="userId"/>
  89. <result column="username" property="username"/>
  90. <result column="is_maintain" property="isMaintain" />
  91. <result column="phone" property="phone" />
  92. </collection>
  93. </resultMap>
  94. <select id="getListBycondition" resultMap="BaseResultMapVO">
  95. select
  96. id, name, tag_id, model_number, unit, address, factory, pic, service_life, next_indate
  97. from
  98. goods
  99. <where>
  100. is_delete = 0
  101. <if test="keyName != null and keyName != ''">
  102. and name like concat('%',#{keyName},'%')
  103. </if>
  104. <if test="tagId != null">
  105. and tag_id = #{tagId}
  106. </if>
  107. </where>
  108. </select>
  109. <select id="selectGoodsNoByGoodsId" resultType="com.hssx.pcbms.entity.GoodsNo">
  110. select
  111. id, model_no, state, indate, goods_id,is_maintain
  112. from
  113. goods_no
  114. where
  115. goods_id = #{goodId}
  116. </select>
  117. <select id="getDetail" resultMap="BaseResultMapDetail">
  118. select
  119. g.id, g.name, g.tag_id, g.model_number, g.unit,g.address, g.factory, g.pic, g.service_life, g.next_indate,g.division_code divisioncode,g.suffix_code suffixcode,
  120. g.is_delete,gn.id nid,
  121. gn.model_no, gn.division_code, gn.suffix_code, gn.state, gn.indate, gn.goods_id, gn.user_id,u.name username,gn.is_maintain,u.phone
  122. from
  123. goods g
  124. left join
  125. goods_no gn
  126. on g.id = gn.goods_id
  127. left join user u
  128. on u.id = gn.user_id
  129. <where>
  130. g.id = #{id}
  131. </where>
  132. </select>
  133. <select id="selectMyList" resultMap="BaseResultMapMyList">
  134. select
  135. g.id, g.name, g.tag_id, g.model_number, g.unit,g.address, g.factory, g.pic, g.service_life, g.next_indate,g.division_code divisioncode,g.suffix_code suffixcode,
  136. g.is_delete,gn.id nid,
  137. gn.model_no, gn.division_code, gn.suffix_code, gn.state, gn.indate, gn.goods_id, gn.user_id,u.name username,gn.is_maintain,u.phone
  138. from
  139. goods g
  140. left join
  141. goods_no gn
  142. on g.id = gn.goods_id
  143. left join user u
  144. on u.id = gn.user_id
  145. <where>
  146. AND gn.user_id = #{uid,jdbcType=INTEGER}
  147. </where>
  148. <if test="start != null and pageSize != null">
  149. limit #{start,jdbcType=INTEGER} ,#{pageSize,jdbcType=INTEGER}
  150. </if>
  151. </select>
  152. </mapper>