CrawlerXiaoeknowCourseMapper.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package top.lvzhiqiang.mapper;
  2. import org.apache.ibatis.annotations.*;
  3. import top.lvzhiqiang.entity.CrawlerXiaoeknowCourse;
  4. import java.util.List;
  5. import java.util.Map;
  6. /**
  7. * 爬虫小鹅通课程表Mapper
  8. *
  9. * @author lvzhiqiang
  10. * 2022/9/10 21:24
  11. */
  12. public interface CrawlerXiaoeknowCourseMapper {
  13. /**
  14. * 删除所有
  15. */
  16. @Delete("DELETE FROM crawler_xiaoeknow_course where 1=1")
  17. void deleteAll();
  18. /**
  19. * 批量新增
  20. *
  21. * @param crawlerXiaoeknowCourseList
  22. */
  23. @Insert({"<script>" +
  24. "INSERT INTO crawler_xiaoeknow_course(app_id, column_id, resource_id, resource_title, resource_type, view_count, start_at, create_time, modify_time) " +
  25. "VALUES " +
  26. "<foreach collection='list' item='cxc' index=\"index\" separator=\",\">" +
  27. " (#{cxc.appId}, #{cxc.columnId}, #{cxc.resourceId}, #{cxc.resourceTitle}, #{cxc.resourceType}, #{cxc.viewCount}, #{cxc.startAt}, #{cxc.createTime}, now())" +
  28. " </foreach>" +
  29. "</script>"})
  30. int insertList(List<CrawlerXiaoeknowCourse> crawlerXiaoeknowCourseList);
  31. /**
  32. * 新增
  33. *
  34. * @param crawlerXiaoeknowCourse
  35. */
  36. @Insert("INSERT INTO crawler_xiaoeknow_course(app_id, column_id, resource_id, resource_title, resource_type, view_count, start_at, create_time, modify_time) " +
  37. "VALUES (#{appId}, #{columnId}, #{issueDate}, #{resourceId}, #{resourceTitle}, #{resourceType}, #{viewCount}, #{startAt}, #{createTime}, now())")
  38. @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
  39. int insert(CrawlerXiaoeknowCourse crawlerXiaoeknowCourse);
  40. /**
  41. * 查询所有
  42. */
  43. @Select("SELECT * FROM crawler_xiaoeknow_course WHERE delete_flag = 1")
  44. List<CrawlerXiaoeknowCourse> findAll();
  45. /**
  46. * 查询最新的一条
  47. */
  48. @Select("SELECT * FROM crawler_xiaoeknow_course WHERE delete_flag = 1 and app_id=#{appId} and column_id=#{columnId} order by start_at desc limit 1")
  49. CrawlerXiaoeknowCourse findLatestInfo(String appId, String columnId);
  50. @Select({"<script>" +
  51. "select * from crawler_xiaoeknow_course WHERE delete_flag = 1" +
  52. "<if test=\"title != null and title != ''\">" +
  53. " and resource_title like concat('%',#{title},'%')" +
  54. "</if>" +
  55. "<if test=\"type != null and type != ''\">" +
  56. " and resource_type = #{type}" +
  57. "</if>" +
  58. "<if test=\"order != null and order != ''\">" +
  59. " order by ${orderField} ${order}" +
  60. "</if>" +
  61. "</script>"})
  62. List<CrawlerXiaoeknowCourse> findXiaoeknowCourse4MultipleParams(Map<String, Object> params);
  63. }