guhongwei 2 년 전
부모
커밋
74c06fa019
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      app/controller/config/.test.js
  2. 2 0
      app/model/test.js

+ 4 - 3
app/controller/config/.test.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["name", "brief", "path", "is_use"],
+    requestBody: ["name", "brief", "path", "is_use", "sort"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["name", "brief", "path", "is_use"],
+    requestBody: ["name", "brief", "path", "is_use", "sort"],
   },
   show: {
     parameters: {
@@ -25,6 +25,7 @@ module.exports = {
         brief: "brief",
         path: "path",
         is_use: "is_use",
+        sort: "sort",
       },
       // options: {
       //   "meta.state": 0 // 默认条件
@@ -33,7 +34,7 @@ module.exports = {
     service: "query",
     options: {
       query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
+      sort: ["sort"],
       desc: true,
       count: true,
     },

+ 2 - 0
app/model/test.js

@@ -9,6 +9,7 @@ const test = {
   brief: { type: String, required: false, zh: '简介' }, //
   path: { type: String, required: false, zh: '视频流' }, //
   is_use: { type: String, required: false, zh: '是否启用', default: '0' }, //
+  sort: { type: Number, required: false, zh: '排序', default: 1 }, //
 };
 const schema = new Schema(test, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
@@ -17,6 +18,7 @@ schema.index({ name: 1 });
 schema.index({ brief: 1 });
 schema.index({ path: 1 });
 schema.index({ is_use: 1 });
+schema.index({ sort: 1 });
 schema.plugin(metaPlugin);
 
 module.exports = app => {