You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
976 B

3 months ago
  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.example.demo.mapper.Temporary.RedMapper">
  6. <insert id="upsertAndAdd" parameterType="map">
  7. INSERT INTO red (jwcode, type, sum)
  8. VALUES (
  9. #{jwcode},
  10. #{type},
  11. #{sum}
  12. )
  13. ON DUPLICATE KEY UPDATE
  14. sum = sum + #{sum}
  15. </insert>
  16. <update id="update">
  17. update red set sum = sum - #{sum} where jwcode = #{jwcode} and type = #{type}
  18. </update>
  19. <select id="selectSum" resultType="java.math.BigDecimal">
  20. select sum from red where jwcode=#{jwcode} and type=#{type}
  21. </select>
  22. <select id="selectJwcode" resultType="boolean">
  23. SELECT EXISTS(
  24. SELECT 1 FROM red WHERE jwcode = #{jwcode}
  25. )
  26. </select>
  27. </mapper>