ExamNumberGoodsMapper.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.exam.mapper.ExamNumberGoodsMapper">
  6. <resultMap type="com.zhongzheng.modules.exam.domain.ExamNumberGoods" id="ExamNumberGoodsResult">
  7. <result property="id" column="id"/>
  8. <result property="examNumberId" column="exam_number_id"/>
  9. <result property="createTime" column="create_time"/>
  10. <result property="updateTime" column="update_time"/>
  11. <result property="goodsId" column="goods_id"/>
  12. </resultMap>
  13. <resultMap type="com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo" id="ExamNumberGoodsVoResult">
  14. <result property="id" column="id"/>
  15. <result property="examNumberId" column="exam_number_id"/>
  16. <result property="goodsId" column="goods_id"/>
  17. <result property="goodsName" column="goods_name"/>
  18. <result property="code" column="code"/>
  19. <result property="standPrice" column="stand_price"/>
  20. <result property="goodsStatus" column="goods_status"/>
  21. </resultMap>
  22. <select id="ListExamNumber" parameterType="com.zhongzheng.modules.exam.bo.ExamNumberQueryBo" resultMap="ExamNumberGoodsVoResult">
  23. SELECT
  24. *,
  25. (SELECT goods_name FROM goods g where eng.goods_id = g.goods_id) as goods_name,
  26. (SELECT code FROM goods g where eng.goods_id = g.goods_id) as code,
  27. (SELECT stand_price FROM goods g where eng.goods_id = g.goods_id) as stand_price
  28. FROM
  29. exam_number_goods eng
  30. WHERE
  31. 1=1
  32. <if test="examNumberId != null and examNumberId != ''">
  33. AND eng.exam_number_id = #{examNumberId}
  34. </if>
  35. </select>
  36. <select id="listGoods" parameterType="com.zhongzheng.modules.exam.bo.ExamNumberQueryBo" resultMap="ExamNumberGoodsVoResult">
  37. SELECT
  38. goods_id,
  39. goods_name,
  40. CODE,
  41. stand_price,
  42. (case WHEN (SELECT COUNT(en.exam_number_id) FROM exam_number en LEFT JOIN exam_number_goods eng on en.exam_number_id =eng.exam_number_id where 1=1 and eng.goods_id = g.goods_id and en.status in (0,1)) >0 then 0 ELSE 1 end) as goods_status
  43. FROM
  44. goods g
  45. WHERE
  46. 1 = 1
  47. and g.status in(1)
  48. <if test="businessId != null and businessId != ''">
  49. and g.business_id = #{businessId}
  50. </if>
  51. <if test="projectId != null and projectId != ''">
  52. and g.project_id = #{projectId}
  53. </if>
  54. <if test="goodsType != null and goodsType != ''">
  55. and g.goods_type = #{goodsType}
  56. </if>
  57. order by g.create_time desc
  58. </select>
  59. </mapper>