|
- module.exports = class extends think.Model {
- /**
- * 分页列表
- */
- async getList({ keyword, status, page = 1, pageSize = 10 }) {
- const where = { is_deleted: 0 };
- if (keyword) {
- where._complex = {
- title: ['like', `%${keyword}%`],
- content_key: ['like', `%${keyword}%`],
- _logic: 'or'
- };
- }
- if (status !== undefined && status !== '') {
- where.status = status;
- }
- return this.where(where)
- .order('sort DESC, id DESC')
- .page(page, pageSize)
- .countSelect();
- }
-
- /**
- * 根据 content_key 获取内容
- */
- async getByKey(contentKey) {
- return this.where({ content_key: contentKey, status: 1, is_deleted: 0 })
- .field('title, content')
- .find();
- }
- };
|