AccountMapper.xml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.collectfee.dao.AccountDao">
  8. <resultMap type="com.ym.mec.collectfee.entity.Account" id="Account">
  9. <result column="id" property="id" />
  10. <result column="branch_id" property="branchId" />
  11. <result column="seller_no" property="sellerNo" />
  12. <result column="max_routing" property="maxRouting" />
  13. <result column="has_routing" property="hasRouting" />
  14. <result column="version" property="version" />
  15. </resultMap>
  16. <!-- 根据主键查询一条记录 -->
  17. <select id="get" resultMap="Account" >
  18. SELECT * FROM `account` WHERE id = #{id}
  19. </select>
  20. <!-- 全查询 -->
  21. <select id="findAll" resultMap="Account">
  22. SELECT * FROM `account` ORDER BY id
  23. </select>
  24. <!-- 向数据库增加一条记录 -->
  25. <insert id="insert" parameterType="com.ym.mec.collectfee.entity.Account" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  26. <!--
  27. <selectKey resultClass="int" keyProperty="id" >
  28. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  29. </selectKey>
  30. -->
  31. INSERT INTO `account` (id,branch_id,seller_no,max_routing,has_routing) VALUES(#{id},#{branchId},#{sellerNo},#{maxRouting},#{hasRouting})
  32. </insert>
  33. <!-- 根据主键查询一条记录 -->
  34. <update id="update" parameterType="com.ym.mec.collectfee.entity.Account">
  35. UPDATE `account` SET has_routing = #{hasRouting},seller_no = #{sellerNo},max_routing = #{maxRouting},branch_id = #{branchId},id = #{id} WHERE id = #{id}
  36. </update>
  37. <!-- 根据主键删除一条记录 -->
  38. <delete id="delete" >
  39. DELETE FROM `account` WHERE id = #{id}
  40. </delete>
  41. <!-- 分页查询 -->
  42. <select id="queryPage" resultMap="Account" parameterType="map">
  43. SELECT * FROM `account` ORDER BY id <include refid="global.limit"/>
  44. </select>
  45. <!-- 查询当前表的总记录数 -->
  46. <select id="queryCount" resultType="int">
  47. SELECT COUNT(*) FROM `account`
  48. </select>
  49. <!-- 根据分部id获取分部收款账户 -->
  50. <select id="getAccountByBranchId" resultMap="Account" >
  51. SELECT * FROM `account` WHERE branch_id = #{branchId} AND `max_routing` > `has_routing` ORDER BY `id` ASC LIMIT 1
  52. </select>
  53. <!-- 根据id和version更新已收金额 -->
  54. <update id="upByIdAndVersion" parameterType="com.ym.mec.collectfee.entity.Account">
  55. UPDATE `account` SET `has_routing` = #{hasRouting},`version` = `version`+1 WHERE id = #{id} AND `version`=#{version}
  56. </update>
  57. </mapper>