guhongwei %!s(int64=4) %!d(string=hai) anos
pai
achega
045b2695b8

+ 0 - 40
app/controller/.repair.js

@@ -1,40 +0,0 @@
-module.exports = {
-  create: {
-    requestBody: ["!uid", "name", "type", "parts", "jobdate", "totalmoney", "create_data","finish_date"],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: ["!uid", "name", "type", "parts", "jobdate", "totalmoney", "create_data", "finish_date"],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        name: "name",
-        type: "type",
-        parts: "parts",
-        jobdate: "jobdate",
-        totalmoney: "totalmoney",
-        create_data: "create_data",
-        finish_date: "finish_date",
-        uid: "uid",
-      },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-};

+ 5 - 9
app/controller/.carorder.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["!name", "!license","!mobile","model","carcolor","vin","insurance","drive","travel"],
+    requestBody: ["!name", "mobile", "qqwx", "email", "address"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["!name", "!license","!mobile","model","carcolor","vin","insurance","drive","travel"],
+    requestBody: ["!name", "mobile", "qqwx", "email", "address"],
   },
   show: {
     parameters: {
@@ -20,14 +20,10 @@ module.exports = {
     parameters: {
       query: {
         name: "name",
-        license: "license",
         mobile: "mobile",
-        model: "model",
-        carcolor: "carcolor",
-        vin: "vin",
-        insurance: "insurance",
-        drive: "drive",
-        travel: "travel",
+        qqwx: "qqwx",
+        email: "email",
+        address: "address",
       },
     },
     service: "query",

+ 0 - 16
app/controller/carorder.js

@@ -1,16 +0,0 @@
-'use strict';
-
-const _ = require('lodash');
-const meta = require('./.carorder.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 企业信息表
-class CarorderController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.carorder;
-  }
-}
-
-module.exports = CrudController(CarorderController, meta);

+ 0 - 16
app/controller/repair.js

@@ -1,16 +0,0 @@
-'use strict';
-
-const _ = require('lodash');
-const meta = require('./.repair.js');
-const Controller = require('egg').Controller;
-const { CrudController } = require('naf-framework-mongoose/lib/controller');
-
-// 产品表
-class RepairController extends Controller {
-  constructor(ctx) {
-    super(ctx);
-    this.service = this.ctx.service.repair;
-  }
-}
-
-module.exports = CrudController(RepairController, meta);

+ 16 - 0
app/controller/test.js

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

+ 0 - 24
app/model/carorder.js

@@ -1,24 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-// 接车单
-const CarorderSchema = {
-  name: { type: String, required: true, maxLength: 200 }, // 顾客姓名
-  license : { type: String, required: true, maxLength: 200 }, // 车牌号
-  mobile: { type: Number, required: true, maxLength: 200 }, // 电话
-  model: { type: String, required: false, maxLength: 200 }, // 车型
-  carcolor: { type: String, required: false, maxLength: 200 }, // 车辆颜色
-  vin: { type: String, required: false, maxLength: 200 }, // vin号
-  insurance: { type: String, required: false, maxLength: 200 }, // 保险日期
-  drive: { type: String, required: false, maxLength: 200 }, // 驾驶证日期
-  travel: { type: String, required: false, maxLength: 200 }, // 行驶证日期
-};
-
-const schema = new Schema(CarorderSchema, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Carorder', schema, 'carorder');
-};

+ 0 - 28
app/model/repair.js

@@ -1,28 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const moment = require('moment');
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-const dateNow = function () {
-  return moment().format("YYYY-MM-DD");
-};
-// 维修单
-const RepairSchema = {
-  name: { type: String, required: false, maxLength: 200 }, // 维修项目名
-  type: { type: String, required: false, maxLength: 200 }, // 类型
-  parts: { type: String, required: false, maxLength: 200 }, // 配件
-  jobdate: { type: String, required: false, maxLength: 200 }, // 工时
-  totalmoney: { type: String, required: false, maxLength: 200 }, // 合计
-  create_data: { type: String, required: false, maxLength: 200, default: dateNow }, // 来店时间
-  finish_date: { type: String, required: false, maxLength: 200 }, // 交车时间
-  uid: { type: String, required: true, maxLength: 500 }, // 所属用户id
-  // ref:'Company',关联数据
-};
-
-const schema = new Schema(RepairSchema, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Repair', schema, 'repair');
-};

+ 20 - 0
app/model/test.js

@@ -0,0 +1,20 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 测试接口
+const TestSchema = {
+  name: { type: String, required: true, maxLength: 200 }, // 姓名
+  mobile: { type: String, required: true, maxLength: 200 }, // 电话
+  qqwx: { type: String, required: true, maxLength: 200 }, // qq/微信
+  email: { type: String, required: true, maxLength: 200 }, // 电子邮箱
+  address: { type: String, required: true, maxLength: 200 }, // 联系地址
+};
+
+const schema = new Schema(TestSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Test', schema, 'test');
+};

+ 3 - 6
app/router.js

@@ -5,10 +5,7 @@
  */
 module.exports = app => {
   const { router, controller } = app;
-  // 顾客表
-  router.resources('carorder', '/api/servicetest/carorder', controller.carorder); // index、create、show、destroy
-  router.post('carorder', '/api/servicetest/carorder/update/:id', controller.carorder.update);
-  // 维修表
-  router.resources('repair', '/api/servicetest/repair', controller.repair); // index、create、show、destroy
-  router.post('repair', '/api/servicetest/repair/update/:id', controller.repair.update);
+  // 測試
+  router.resources('test', '/api/study/test', controller.test); // index、create、show、destroy
+  router.post('test', '/api/study/test/update/:id', controller.test.update);
 };

+ 0 - 16
app/service/carorder.js

@@ -1,16 +0,0 @@
-'use strict';
-
-const assert = require('assert');
-const _ = require('lodash');
-const { ObjectId } = require('mongoose').Types;
-const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { CarorderError, ErrorCode } = require('naf-core').Error;
-
-class CarorderService extends CrudService {
-  constructor(ctx) {
-    super(ctx, 'carorder');
-    this.model = this.ctx.model.Carorder;
-  }
-}
-
-module.exports = CarorderService;

+ 5 - 5
app/service/repair.js

@@ -4,13 +4,13 @@ const assert = require('assert');
 const _ = require('lodash');
 const { ObjectId } = require('mongoose').Types;
 const { CrudService } = require('naf-framework-mongoose/lib/service');
-const { CompanyError, ErrorCode } = require('naf-core').Error;
+const { TestError, ErrorCode } = require('naf-core').Error;
 
-class RepairService extends CrudService {
+class TestService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'repair');
-    this.model = this.ctx.model.Repair;
+    super(ctx, 'test');
+    this.model = this.ctx.model.Test;
   }
 }
 
-module.exports = RepairService;
+module.exports = TestService;

+ 3 - 3
config/config.default.js

@@ -26,11 +26,11 @@ module.exports = appInfo => {
   // add your config here
   config.cluster = {
     listen: {
-      port: 8081,
+      port: 9091,
     },
   };
   config.mongoose = {
-    url: 'mongodb://localhost:27017/servicetest',
+    url: 'mongodb://localhost:27017/study',
     options: {
       // user: 'admin',
       // pass: 'admin',
@@ -43,7 +43,7 @@ module.exports = appInfo => {
   config.jwt = {
     ...jwt,
     expiresIn: '1d',
-    issuer: 'servicetest',
+    issuer: 'study',
   };
 
   // config.amqp = {

+ 1 - 1
config/config.local.js

@@ -9,7 +9,7 @@ module.exports = () => {
   };
 
   config.mongoose = {
-    url: 'mongodb://localhost:27017/servicetest',
+    url: 'mongodb://localhost:27017/study',
     options: {
       // user: 'demo',
       // pass: 'demo',

+ 6 - 6
config/config.prod.js

@@ -10,13 +10,13 @@ module.exports = () => {
 
   // mongoose config
   config.mongoose = {
-    url: 'mongodb://localhost:27017/servicetest',
+    url: 'mongodb://localhost:27017/study',
     options: {
-    // user: "admin",
-    // pass: "admin",
-    // authSource: "admin",
-    // useNewUrlParser: true,
-    // useCreateIndex: true,
+      // user: "admin",
+      // pass: "admin",
+      // authSource: "admin",
+      // useNewUrlParser: true,
+      // useCreateIndex: true,
     },
   };
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 4525
test.js