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.
 
 
 
 
 

32 lines
757 B

  1. module.exports = class extends think.Model {
  2. /**
  3. * 分页列表
  4. */
  5. async getList({ keyword, status, page = 1, pageSize = 10 }) {
  6. const where = { is_deleted: 0 };
  7. if (keyword) {
  8. where._complex = {
  9. title: ['like', `%${keyword}%`],
  10. content_key: ['like', `%${keyword}%`],
  11. _logic: 'or'
  12. };
  13. }
  14. if (status !== undefined && status !== '') {
  15. where.status = status;
  16. }
  17. return this.where(where)
  18. .order('sort DESC, id DESC')
  19. .page(page, pageSize)
  20. .countSelect();
  21. }
  22. /**
  23. * 根据 content_key 获取内容
  24. */
  25. async getByKey(contentKey) {
  26. return this.where({ content_key: contentKey, status: 1, is_deleted: 0 })
  27. .field('title, content')
  28. .find();
  29. }
  30. };