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.

52 lines
1.6 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  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.example.demo.mapper.coin.RateMapper">
  4. <select id="selectAll" resultType="com.example.demo.domain.vo.coin.RateDetail">
  5. SELECT
  6. r.id,r.rate_name rateName,r.num,r.admin_id adminId,r.create_time createTime,r.update_time updateTime
  7. FROM rate r
  8. </select>
  9. <select id="selectById" resultType="com.example.demo.domain.entity.Rate">
  10. SELECT * FROM rate WHERE id= #{id}
  11. </select>
  12. <select id="listRateName" resultType="com.example.demo.domain.entity.Rate">
  13. SELECT
  14. id , rate_name rateName
  15. FROM rate
  16. </select>
  17. <select id="getIdByName" resultType="java.lang.Integer">
  18. SELECT id FROM rate WHERE rate_name = #{rateName}
  19. </select>
  20. <update id="update">
  21. UPDATE
  22. rate
  23. <set>
  24. <if test="num!=null">
  25. num= #{num},
  26. </if>
  27. <if test="rateName!=null and rateName.length>0">
  28. rate_name= #{rateName},
  29. </if>
  30. <if test="adminId!=null">
  31. admin_id= #{adminId},
  32. </if>
  33. </set>
  34. WHERE
  35. id=#{id}
  36. </update>
  37. <insert id="add">
  38. INSERT INTO rate
  39. (rate_name, num, admin_id, create_time)
  40. VALUES
  41. (#{rateName}, #{num}, #{adminId}, #{createTime})
  42. <selectKey keyProperty="id" resultType="java.lang.Integer" order="AFTER">
  43. SELECT LAST_INSERT_ID()
  44. </selectKey>
  45. </insert>
  46. </mapper>