From 8f976621536007db7380d187b315460eb8ebd2c7 Mon Sep 17 00:00:00 2001 From: chenruilong Date: Thu, 30 Mar 2023 17:36:31 +0800 Subject: [PATCH] feat: uni-cms schema --- collection/uni-cms-articles/collection.json | 166 ++++++++++++++++++ collection/uni-cms-articles/package.json | 17 ++ collection/uni-cms-categories/collection.json | 56 ++++++ collection/uni-cms-categories/package.json | 17 ++ collection/uni-cms-search-hot/collection.json | 30 ++++ collection/uni-cms-search-hot/package.json | 17 ++ .../uni-cms-search-logs/collection.json | 34 ++++ collection/uni-cms-search-logs/package.json | 17 ++ .../uni-cms-unlock-record/collection.json | 67 +++++++ collection/uni-cms-unlock-record/package.json | 17 ++ 10 files changed, 438 insertions(+) create mode 100644 collection/uni-cms-articles/collection.json create mode 100644 collection/uni-cms-articles/package.json create mode 100644 collection/uni-cms-categories/collection.json create mode 100644 collection/uni-cms-categories/package.json create mode 100644 collection/uni-cms-search-hot/collection.json create mode 100644 collection/uni-cms-search-hot/package.json create mode 100644 collection/uni-cms-search-logs/collection.json create mode 100644 collection/uni-cms-search-logs/package.json create mode 100644 collection/uni-cms-unlock-record/collection.json create mode 100644 collection/uni-cms-unlock-record/package.json diff --git a/collection/uni-cms-articles/collection.json b/collection/uni-cms-articles/collection.json new file mode 100644 index 0000000..14e6beb --- /dev/null +++ b/collection/uni-cms-articles/collection.json @@ -0,0 +1,166 @@ +{ + "schema": { + "bsonType": "object", + "required": ["user_id", "title", "content"], + "permission": { + "read": "doc.user_id == auth.uid && doc.article_status == 0 || doc.article_status == 1", + "create": "auth.uid != null", + "update": "doc.user_id == auth.uid", + "delete": "doc.user_id == auth.uid" + }, + "properties": { + "_id": { + "description": "存储文档 ID(用户 ID),系统自动生成" + }, + "user_id": { + "bsonType": "string", + "description": "文章作者ID, 参考`uni-id-users` 表", + "foreignKey": "uni-id-users._id", + "defaultValue": { + "$env": "uid" + } + }, + "category_id": { + "bsonType": "string", + "title": "分类", + "description": "分类 id,参考`uni-news-categories`表", + "foreignKey": "uni-cms-categories._id", + "enum": { + "collection": "uni-cms-categories", + "field": "name as text, _id as value" + } + }, + "title": { + "bsonType": "string", + "title": "标题", + "description": "标题", + "label": "标题", + "trim": "both" + }, + "content": { + "bsonType": "object", + "title": "文章内容", + "description": "文章内容; 格式为Quill编辑器的Delta格式", + "label": "文章内容" + }, + "excerpt": { + "bsonType": "string", + "title": "文章摘录", + "description": "文章摘录", + "label": "摘要", + "trim": "both" + }, + "article_status": { + "bsonType": "int", + "title": "文章状态", + "description": "文章状态:0 草稿箱 1 已发布", + "defaultValue": 0, + "enum": [{ + "value": 0, + "text": "草稿箱" + }, + { + "value": 1, + "text": "已发布" + } + ] + }, + "view_count": { + "bsonType": "int", + "title": "阅读数量", + "description": "阅读数量", + "permission": { + "write": false + } + }, + "like_count": { + "bsonType": "int", + "description": "喜欢数、点赞数", + "permission": { + "write": false + } + }, + "is_sticky": { + "bsonType": "bool", + "title": "是否置顶", + "description": "是否置顶", + "permission": { + "write": false + } + }, + "is_essence": { + "bsonType": "bool", + "title": "阅读加精", + "description": "阅读加精", + "permission": { + "write": false + } + }, + "comment_status": { + "bsonType": "int", + "title": "开放评论", + "description": "评论状态:0 关闭 1 开放", + "enum": [{ + "value": 0, + "text": "关闭" + }, + { + "value": 1, + "text": "开放" + } + ] + }, + "comment_count": { + "bsonType": "int", + "description": "评论数量", + "permission": { + "write": false + } + }, + "last_comment_user_id": { + "bsonType": "string", + "description": "最后回复用户 id,参考`uni-id-users` 表", + "foreignKey": "uni-id-users._id" + }, + "thumbnail": { + "bsonType": "string", + "title": "封面大图", + "description": "缩略图地址", + "label": "封面大图", + "trim": "both" + }, + "publish_date": { + "bsonType": "timestamp", + "title": "发表时间", + "description": "发表时间", + "defaultValue": { + "$env": "now" + } + }, + "publish_ip": { + "bsonType": "string", + "title": "发布文章时IP地址", + "description": "发表时 IP 地址", + "forceDefaultValue": { + "$env": "clientIP" + } + }, + "last_modify_date": { + "bsonType": "timestamp", + "title": "最后修改时间", + "description": "最后修改时间", + "defaultValue": { + "$env": "now" + } + }, + "last_modify_ip": { + "bsonType": "string", + "description": "最后修改时 IP 地址", + "forceDefaultValue": { + "$env": "clientIP" + } + } + } + }, + "index": [] +} diff --git a/collection/uni-cms-articles/package.json b/collection/uni-cms-articles/package.json new file mode 100644 index 0000000..f322b4a --- /dev/null +++ b/collection/uni-cms-articles/package.json @@ -0,0 +1,17 @@ +{ + "name": "@opendb/uni-cms-articles", + "version": "0.0.1", + "description": "uni-cms-articles", + "keywords": ["文章&评论", "文章表", "uni-CMS", "CMS"], + "opendb": { + "title": "文章", + "type": "collection", + "contributors": [ + { + "name": "DCloud", + "email": "", + "homepage": "https://gitee.com/dcloud/opendb" + } + ] + } +} diff --git a/collection/uni-cms-categories/collection.json b/collection/uni-cms-categories/collection.json new file mode 100644 index 0000000..e1b42ee --- /dev/null +++ b/collection/uni-cms-categories/collection.json @@ -0,0 +1,56 @@ +{ + "schema": { + "bsonType": "object", + "required": [ + "name" + ], + "permission": { + "read": true, + "create": false, + "update": false, + "delete": false + }, + "properties": { + "_id": { + "description": "存储文档 ID(文章 ID),系统自动生成" + }, + "name": { + "bsonType": "string", + "description": "类别名称", + "label": "名称", + "trim": "both" + }, + "description": { + "bsonType": "string", + "description": "类别描述", + "label": "描述", + "trim": "both" + }, + "icon": { + "bsonType": "string", + "description": "类别图标地址", + "label": "图标地址", + "pattern": "^(http://|https://|/|./|@/)\\S", + "trim": "both" + }, + "sort": { + "bsonType": "int", + "description": "类别显示顺序", + "label": "排序" + }, + "article_count": { + "bsonType": "int", + "description": "该类别下文章数量" + }, + "create_date": { + "bsonType": "timestamp", + "description": "创建时间", + "forceDefaultValue": { + "$env": "now" + } + } + } + }, + "data": [], + "index": [] +} diff --git a/collection/uni-cms-categories/package.json b/collection/uni-cms-categories/package.json new file mode 100644 index 0000000..eeba2be --- /dev/null +++ b/collection/uni-cms-categories/package.json @@ -0,0 +1,17 @@ +{ + "name": "@opendb/uni-cms-categories", + "version": "0.0.1", + "description": "uni-cms-categories", + "keywords": ["文章&评论", "文章类别", "uni-CMS", "CMS"], + "opendb": { + "title": "文章类别", + "type": "collection", + "contributors": [ + { + "name": "DCloud", + "email": "", + "homepage": "https://gitee.com/dcloud/opendb" + } + ] + } +} diff --git a/collection/uni-cms-search-hot/collection.json b/collection/uni-cms-search-hot/collection.json new file mode 100644 index 0000000..3525c7d --- /dev/null +++ b/collection/uni-cms-search-hot/collection.json @@ -0,0 +1,30 @@ +{ + "schema": { + "bsonType": "object", + "permission": { + "create": false, + "delete": false, + "read": true, + "update": false + }, + "properties": { + "_id": { + "description": "ID,系统自动生成" + }, + "content": { + "bsonType": "string", + "description": "搜索内容" + }, + "count": { + "bsonType": "long", + "description": "搜索次数" + }, + "create_date": { + "bsonType": "timestamp", + "description": "统计时间" + } + }, + "required": ["content", "count"] + }, + "index": [] +} diff --git a/collection/uni-cms-search-hot/package.json b/collection/uni-cms-search-hot/package.json new file mode 100644 index 0000000..f66181e --- /dev/null +++ b/collection/uni-cms-search-hot/package.json @@ -0,0 +1,17 @@ +{ + "name": "@opendb/uni-cms-search-hot", + "version": "0.0.1", + "description": "uni-cms-search-hot", + "keywords": ["热搜词", "uni-CMS", "CMS"], + "opendb": { + "title": "热搜词", + "type": "collection", + "contributors": [ + { + "name": "DCloud", + "email": "", + "homepage": "https://gitee.com/dcloud/opendb" + } + ] + } +} diff --git a/collection/uni-cms-search-logs/collection.json b/collection/uni-cms-search-logs/collection.json new file mode 100644 index 0000000..f9a587a --- /dev/null +++ b/collection/uni-cms-search-logs/collection.json @@ -0,0 +1,34 @@ +{ + "schema": { + "bsonType": "object", + "permission": { + "create": true, + "delete": false, + "read": false, + "update": false + }, + "properties": { + "_id": { + "description": "ID,系统自动生成" + }, + "content": { + "bsonType": "string", + "description": "搜索内容" + }, + "create_date": { + "bsonType": "timestamp", + "description": "统计时间" + }, + "device_id": { + "bsonType": "string", + "description": "设备id" + }, + "user_id": { + "bsonType": "string", + "description": "收藏者id,参考uni-id-users表" + } + }, + "required": ["content"] + }, + "index": [] +} diff --git a/collection/uni-cms-search-logs/package.json b/collection/uni-cms-search-logs/package.json new file mode 100644 index 0000000..f603797 --- /dev/null +++ b/collection/uni-cms-search-logs/package.json @@ -0,0 +1,17 @@ +{ + "name": "@opendb/uni-cms-search-log", + "version": "0.0.1", + "description": "uni-cms-search-log", + "keywords": ["搜索记录", "uni-CMS", "CMS"], + "opendb": { + "title": "搜索记录", + "type": "collection", + "contributors": [ + { + "name": "DCloud", + "email": "", + "homepage": "https://gitee.com/dcloud/opendb" + } + ] + } +} diff --git a/collection/uni-cms-unlock-record/collection.json b/collection/uni-cms-unlock-record/collection.json new file mode 100644 index 0000000..a6c9906 --- /dev/null +++ b/collection/uni-cms-unlock-record/collection.json @@ -0,0 +1,67 @@ +{ + "schema": { + "bsonType": "object", + "required": [ + "user_id", + "trans_id", + "content_id" + ], + "permission": { + "read": "doc.user_id == auth.uid && doc.article_status == 0 || doc.article_status == 1", + "create": "auth.uid != null", + "update": "doc.user_id == auth.uid", + "delete": "doc.user_id == auth.uid" + }, + "properties": { + "_id": { + "description": "存储文档 ID(用户 ID),系统自动生成" + }, + "user_id": { + "bsonType": "string", + "description": "用户ID, 参考`uni-id-users` 表", + "foreignKey": "uni-id-users._id", + "defaultValue": { + "$env": "uid" + } + }, + "trans_id": { + "bsonType": "string", + "title": "交易ID", + "description": "广告回调传回的交易ID", + "label": "内容id", + "trim": "both" + }, + "content_id": { + "bsonType": "string", + "title": "内容id", + "description": "内容(文章)ID", + "label": "内容id", + "trim": "both" + }, + "create_date": { + "bsonType": "timestamp", + "title": "创建时间", + "description": "创建时间", + "defaultValue": { + "$env": "now" + } + } + } + }, + "index": [{ + "IndexName": "user_article_trans_", + "MgoKeySchema": { + "MgoIndexKeys": [{ + "Name": "user_id", + "Direction": "1" + },{ + "Name": "article_id", + "Direction": "1" + },{ + "Name": "trans_id", + "Direction": "1" + }], + "MgoIsUnique": false + } + }] +} diff --git a/collection/uni-cms-unlock-record/package.json b/collection/uni-cms-unlock-record/package.json new file mode 100644 index 0000000..caf2b60 --- /dev/null +++ b/collection/uni-cms-unlock-record/package.json @@ -0,0 +1,17 @@ +{ + "name": "@opendb/uni-cms-unlock-record", + "version": "0.0.1", + "description": "uni-cms-unlock-record", + "keywords": ["解锁记录", "内容解锁表", "uni-CMS", "CMS"], + "opendb": { + "title": "文章", + "type": "collection", + "contributors": [ + { + "name": "DCloud", + "email": "", + "homepage": "https://gitee.com/dcloud/opendb" + } + ] + } +}