GoodsMapper.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. </resultMap>
  19. <!-- 通用查询结果列 -->
  20. <sql id="Base_Column_List">
  21. id, name, tag_id, model_number, unit, address, factory, pic, service_life, next_indate, is_delete, creator_id
  22. </sql>
  23. <!-- 通用查询映射结果 -->
  24. <resultMap id="BaseResultMapVO" type="com.hssx.pcbms.entity.vo.GoodsVO">
  25. <id column="id" property="id" />
  26. <result column="name" property="name" />
  27. <result column="tag_id" property="tagId" />
  28. <result column="model_number" property="modelNumber" />
  29. <result column="unit" property="unit" />
  30. <result column="address" property="address" />
  31. <result column="factory" property="factory" />
  32. <result column="pic" property="pic" />
  33. <result column="service_life" property="serviceLife" />
  34. <result column="next_indate" property="nextIndate" />
  35. <!--<collection property="goodsNos" select="selectGoodsNoByGoodsId" column="{goodId = id}" ofType="com.hssx.pcbms.entity.GoodsNo">-->
  36. <!--</collection>-->
  37. <collection property="goodsNos" ofType="com.hssx.pcbms.entity.GoodsNo">
  38. <id column="nid" property="id" />
  39. <result column="model_no" property="modelNo" />
  40. <result column="division_code" property="divisionCode" />
  41. <result column="suffix_code" property="suffixCode" />
  42. <result column="state" property="state" />
  43. <result column="indate" property="indate" />
  44. <result column="goods_id" property="goodsId" />
  45. <result column="user_id" property="userId" />
  46. </collection>
  47. </resultMap>
  48. <select id="getListBycondition" resultMap="BaseResultMapVO">
  49. select
  50. g.id, g.name, g.tag_id, g.model_number, g.unit,gn.id nid,
  51. gn.model_no, gn.division_code, gn.suffix_code, gn.state, gn.indate, gn.goods_id, gn.user_id
  52. from
  53. goods g
  54. left join
  55. goods_no gn
  56. on g.id = gn.goods_id
  57. <where>
  58. is_delete = 0
  59. <if test="keyName != null and keyName != ''">
  60. and name like concat('%',#{keyName},'%')
  61. </if>
  62. <if test="tagId != null">
  63. and tag_id = #{tagId}
  64. </if>
  65. </where>
  66. </select>
  67. <select id="getDetail" resultMap="BaseResultMapVO">
  68. select
  69. 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.is_delete,gn.id nid,
  70. gn.model_no, gn.division_code, gn.suffix_code, gn.state, gn.indate, gn.goods_id, gn.user_id
  71. from
  72. goods g
  73. left join
  74. goods_no gn
  75. on g.id = gn.goods_id
  76. <where>
  77. g.id = #{id}
  78. </where>
  79. </select>
  80. </mapper>