SporadicChargeInfo.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
  4. <mapper namespace="com.ym.mec.biz.dal.dao.SporadicChargeInfoDao">
  5. <resultMap type="com.ym.mec.biz.dal.entity.SporadicChargeInfo" id="SporadicChargeInfo">
  6. <result column="id_" property="id" />
  7. <result column="title_" property="title" />
  8. <result column="charge_type_" property="chargeType"/>
  9. <result column="organ_id_" property="organId"/>
  10. <result column="amount_" property="amount" />
  11. <result column="discount_amount_" property="discountAmount" />
  12. <result column="detail_" property="detail" />
  13. <result column="create_time_" property="createTime" />
  14. <result column="update_time_" property="updateTime" />
  15. <result column="operator_id_" property="operatorId" />
  16. <result column="del_flag_" property="delFlag" />
  17. <result column="organ_name_" property="organName" />
  18. <result column="user_id_" property="userId" />
  19. </resultMap>
  20. <!-- 根据主键查询一条记录 -->
  21. <select id="get" resultMap="SporadicChargeInfo">
  22. SELECT * FROM sporadic_charge_info WHERE id_ = #{id}
  23. </select>
  24. <!-- 全查询 -->
  25. <select id="findAll" resultMap="SporadicChargeInfo">
  26. SELECT * FROM sporadic_charge_info ORDER BY id_
  27. </select>
  28. <!-- 向数据库增加一条记录 -->
  29. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SporadicChargeInfo"
  30. useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  31. INSERT INTO sporadic_charge_info
  32. (title_,charge_type_,organ_id_,amount_,discount_amount_,detail_,create_time_,update_time_,operator_id_,user_id_)
  33. VALUES(#{title},#{chargeType},#{organId},#{amount},#{discountAmount},#{detail},now(),now(),#{operatorId},#{userId})
  34. </insert>
  35. <!-- 根据主键查询一条记录 -->
  36. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SporadicChargeInfo">
  37. UPDATE sporadic_charge_info
  38. <set>
  39. <if test="title != null">
  40. title_ = #{title},
  41. </if>
  42. <if test="chargeType != null">
  43. charge_type_ = #{chargeType},
  44. </if>
  45. <if test="organId != null">
  46. organ_id_ = #{organId},
  47. </if>
  48. <if test="amount != null">
  49. amount_ = #{amount},
  50. </if>
  51. <if test="discountAmount != null">
  52. discount_amount_ = #{discountAmount},
  53. </if>
  54. <if test="detail != null">
  55. detail_ = #{detail},
  56. </if>
  57. <if test="updateTime != null">
  58. update_time_ = now(),
  59. </if>
  60. <if test="operatorId != null">
  61. operator_id_ = #{operatorId},
  62. </if>
  63. <if test="userId != null">
  64. user_id_ = #{userId},
  65. </if>
  66. </set>
  67. WHERE id_ = #{id}
  68. </update>
  69. <!-- 根据主键删除一条记录 -->
  70. <update id="delete">
  71. UPDATE sporadic_charge_info SET del_flag_ = 1 WHERE id_ = #{id}
  72. </update>
  73. <!-- 分页查询 -->
  74. <select id="queryPage" resultMap="SporadicChargeInfo" parameterType="map">
  75. SELECT * FROM sporadic_charge_info sci
  76. LEFT JOIN sys_user su ON su.id_ = sci.user_id_
  77. <include refid="queryPageSql"/>
  78. ORDER BY sci.id_ DESC
  79. <include refid="global.limit" />
  80. </select>
  81. <sql id="queryPageSql">
  82. <where>
  83. sci.del_flag_ != 1
  84. <if test="organId != null">
  85. AND FIND_IN_SET(sci.organ_id_,#{organId})
  86. </if>
  87. <if test="chargeType != null">
  88. AND sci.charge_type_ = #{chargeType}
  89. </if>
  90. <if test="type == 'personal'">
  91. AND sci.user_id_ IS NOT NULL
  92. </if>
  93. <if test="type == 'common'">
  94. AND sci.user_id_ IS NULL
  95. </if>
  96. <if test="search != null">
  97. AND (sci.title_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%'))
  98. </if>
  99. </where>
  100. </sql>
  101. <!-- 查询当前表的总记录数 -->
  102. <select id="queryCount" resultType="int">
  103. SELECT COUNT(sci.id_) FROM sporadic_charge_info sci
  104. LEFT JOIN sys_user su ON su.id_ = sci.user_id_
  105. <include refid="queryPageSql"/>
  106. </select>
  107. <select id="findInfoById" resultMap="SporadicChargeInfo">
  108. SELECT * FROM sporadic_charge_info where id_ = #{id}
  109. </select>
  110. <!-- 根据类型和分部id查询活动 -->
  111. <select id="findByOrganIdAndType" resultMap="SporadicChargeInfo">
  112. SELECT * FROM sporadic_charge_info where organ_id_=#{organId} AND charge_type_=#{chargeType} AND del_flag_=0
  113. </select>
  114. </mapper>