guhongwei vor 2 Jahren
Ursprung
Commit
a2b9e1c001

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

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["name", "brief", "path", "is_use", "sort"],
+    requestBody: ["type", "name", "brief", "path", "is_use", "sort"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["name", "brief", "path", "is_use", "sort"],
+    requestBody: ["type", "name", "brief", "path", "is_use", "sort"],
   },
   show: {
     parameters: {
@@ -21,6 +21,7 @@ module.exports = {
       query: {
         "meta.createdAt@start": "meta.createdAt@start",
         "meta.createdAt@end": "meta.createdAt@end",
+        type: "type",
         name: "name",
         brief: "brief",
         path: "path",

+ 15 - 0
app/controller/program.js

@@ -0,0 +1,15 @@
+'use strict';
+const meta = require('./config/.program.js');
+const Controller = require('egg').Controller;
+const {
+  CrudController,
+} = require('naf-framework-mongoose-free/lib/controller');
+
+// 节目表
+class ProgramController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.program;
+  }
+}
+module.exports = CrudController(ProgramController, meta);

+ 0 - 15
app/controller/test.js

@@ -1,15 +0,0 @@
-'use strict';
-const meta = require('./config/.test.js');
-const Controller = require('egg').Controller;
-const {
-  CrudController,
-} = require('naf-framework-mongoose-free/lib/controller');
-
-// 测试接口
-class TestController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.test;
-  }
-}
-module.exports = CrudController(TestController, meta);

+ 5 - 4
app/model/test.js

@@ -3,15 +3,16 @@ const Schema = require('mongoose').Schema;
 const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 
 
-// 测试接口
-const test = {
+// 节目表
+const program = {
+  type: { type: String, required: false, zh: '节目类型' }, //
   name: { type: String, required: false, zh: '名称' }, //
   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 } });
+const schema = new Schema(program, { toJSON: { getters: true, virtuals: true } });
 schema.index({ id: 1 });
 schema.index({ 'meta.createdAt': 1 });
 schema.index({ name: 1 });
@@ -23,5 +24,5 @@ schema.plugin(metaPlugin);
 
 module.exports = app => {
   const { mongoose } = app;
-  return mongoose.model('Test', schema, 'test');
+  return mongoose.model('Program', schema, 'program');
 };

+ 1 - 1
app/router.js

@@ -8,5 +8,5 @@ module.exports = app => {
   const { routePrefix } = app.config;
   router.get('/', controller.home.index);
   require('./z_router/admin')(app); // 管理員
-  require('./z_router/test')(app); // 测试接口
+  require('./z_router/program')(app); // 节目表
 };

+ 5 - 6
app/service/test.js

@@ -4,13 +4,12 @@ const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const assert = require('assert');
 
-// 测试接口
-
-class TestService extends CrudService {
+// 节目表
+class ProgramService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'test');
-    this.model = this.ctx.model.Test;
+    super(ctx, 'program');
+    this.model = this.ctx.model.Program;
   }
 }
 
-module.exports = TestService;
+module.exports = ProgramService;

+ 3 - 3
app/z_router/test.js

@@ -1,8 +1,8 @@
 'use strict';
 // 测试接口
-const rKey = 'test'; // routerKey,路由前缀变量
-const cKey = 'test'; // controllerKey,controller名
-const zhKey = '测试接口';
+const rKey = 'program'; // routerKey,路由前缀变量
+const cKey = 'program'; // controllerKey,controller名
+const zhKey = '节目表';
 const routes = [
   { method: 'get', path: `/${rKey}`, controller: `${cKey}.index`, name: `${cKey}Query`, zh: `${zhKey}列表查询` },
   { method: 'get', path: `/${rKey}/:id`, controller: `${cKey}.show`, name: `${cKey}Show`, zh: `${zhKey}查询` },