金币系统后端
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.

69 lines
2.5 KiB

8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
  1. package com.example.demo.mapper;
  2. import com.example.demo.domain.entity.Rate;
  3. import org.apache.ibatis.annotations.*;
  4. import org.apache.ibatis.annotations.Mapper;
  5. import java.util.List;
  6. @Mapper
  7. public interface RateMapper {
  8. @Insert({
  9. "insert into rate",
  10. "(start_time,end_time,currency,exchange_rate,create_time,update_time,admin_id,flag)",
  11. "values",
  12. "(#{startTime},#{endTime},#{currency},#{exchangeRate},now(),#{updateTime},#{adminId},1)"
  13. })
  14. // 获取自增主键
  15. @Options(useGeneratedKeys = true,keyColumn = "rate_id",keyProperty = "rateId")
  16. int insert(Rate rate);
  17. //软删除
  18. @Update({
  19. "update rate set flag = 0 where rate_id=#{rateId}"
  20. })
  21. int deleteById(Integer rateId);
  22. @Update({
  23. "<script>",
  24. "update rate",
  25. "<set>",
  26. "<if test='startTime!=null'>start_time=#{startTime},</if>",
  27. "<if test='endTime!=null'>end_time=#{endTime},</if>",
  28. "<if test='currency!=null and currency.length>0'>currency=#{currency},</if>",
  29. "<if test='exchangeRate!=null'>exchange_rate=#{exchangeRate},</if>",
  30. "<if test='updateTime!=null'>update_time=#{updateTime},</if>",
  31. "<if test='adminId!=null'>admin_id=#{adminId},</if>",
  32. "</set>",
  33. "where rate_id = #{rateId}", "</script>"
  34. })
  35. int update(Rate rate);
  36. @Select({
  37. "select * from rate where rate_id=#{rateId}"
  38. })
  39. Rate selectById(Integer rateId);
  40. @Select({
  41. "<script>",
  42. "SELECT r.*, a.name AS adminName",
  43. "FROM rate r",
  44. "LEFT JOIN admin a ON r.admin_id = a.admin_id",
  45. "LEFT JOIN admin u ON r.admin_id = u.admin_id",
  46. "WHERE r.flag =1 ",
  47. "<if test='rateId != null'>AND r.rate_id = #{rateId}</if>",
  48. "<if test='startTime != null'>AND r.start_time &gt;= #{startTime}</if>",
  49. "<if test='endTime != null'>AND r.end_time &lt;= #{endTime}</if>",
  50. "<if test='currency != null and currency.length > 0'>AND r.currency LIKE CONCAT('%', #{currency}, '%')</if>",
  51. "<if test='exchangeRate != null'>AND r.exchange_rate LIKE CONCAT('%', #{exchangeRate}, '%')</if>",
  52. "<if test='updateTime != null'>AND r.update_time LIKE CONCAT('%', #{updateTime}, '%')</if>",
  53. "<if test='adminId != null'>AND r.admin_id = #{adminId}</if>",
  54. "<if test='updateId != null'>AND r.update_id = #{updateId}</if>",
  55. "</script>"
  56. })
  57. List<Rate> select(Rate rate);
  58. }