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.

44 lines
1.3 KiB

  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.RateMapper">
  4. <select id="selectAll" resultType="com.example.demo.domain.vo.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. <update id="update">
  13. UPDATE
  14. rate
  15. <set>
  16. <if test="num!=null">
  17. num= #{num},
  18. </if>
  19. <if test="rateName!=null and rateName.length>0">
  20. rate_name= #{rateName},
  21. </if>
  22. <if test="adminId!=null">
  23. admin_id= #{adminId},
  24. </if>
  25. </set>
  26. WHERE
  27. id=#{id}
  28. </update>
  29. <insert id="add">
  30. INSERT INTO rate
  31. (rate_name, num, admin_id, create_time)
  32. VALUES
  33. (#{rateName}, #{num}, #{adminId}, #{createTime})
  34. <selectKey keyProperty="id" resultType="java.lang.Integer" order="AFTER">
  35. SELECT LAST_INSERT_ID()
  36. </selectKey>
  37. </insert>
  38. </mapper>