guhongwei 4 tahun lalu
induk
melakukan
c3ec9030f7

+ 42 - 0
app/controller/.carorder.js

@@ -0,0 +1,42 @@
+module.exports = {
+  create: {
+    requestBody: ["!name", "!license","!mobile","model","carcolor","mileage","vin","insurance","drive","travel"],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["!name", "!license","!mobile","model","carcolor","mileage","vin","insurance","drive","travel"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        name: "name",
+        license: "license",
+        mobile: "mobile",
+        model: "model",
+        carcolor: "carcolor",
+        mileage: "mileage",
+        vin: "vin",
+        insurance: "insurance",
+        drive: "drive",
+        travel: "travel",
+      },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 0 - 34
app/controller/.company.js

@@ -1,34 +0,0 @@
-module.exports = {
-  create: {
-    requestBody: ["!company", "mobile"],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: ["!company", "mobile"],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        company: "company",
-        mobile: "mobile",
-      },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-};

+ 7 - 4
app/controller/.product.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ["!name", "!money","!uid"],
+    requestBody: ["!uid","name", "type","parts", "jobdate","totalmoney"],
   },
   destroy: {
     params: ["!id"],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ["!id"],
-    requestBody: ["!name", "!mobile","!uid"],
+    requestBody: ["!uid","name", "type","parts", "jobdate","totalmoney"],
   },
   show: {
     parameters: {
@@ -20,8 +20,11 @@ module.exports = {
     parameters: {
       query: {
         name: "name",
-        money: "money",
-         uid: "uid",
+        type: "type",
+        parts: "parts",
+        jobdate: "jobdate",
+        totalmoney: "totalmoney",
+        uid: "uid",
       },
     },
     service: "query",

+ 4 - 4
app/controller/company.js

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

+ 4 - 4
app/controller/product.js

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

+ 25 - 0
app/model/carorder.js

@@ -0,0 +1,25 @@
+'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 }, // 车辆颜色
+  mileage: { 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 - 17
app/model/company.js

@@ -1,17 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-// 企业信息
-const CompanySchema = {
-  company: { type: String, required: true, maxLength: 200 }, // 名称
-  mobile: { type: String, required: false, maxLength: 500 }, // 电话
-};
-
-const schema = new Schema(CompanySchema, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Company', schema, 'company');
-};

+ 0 - 18
app/model/product.js

@@ -1,18 +0,0 @@
-'use strict';
-const Schema = require('mongoose').Schema;
-const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
-// 产品表
-const ProductSchema = {
-  name: { type: String, required: true, maxLength: 200 }, // 名称
-  money: { type: String, required: false, maxLength: 500 }, // 钱
-  uid: { type: String, required: false, maxLength: 500 }, // 所属用户id
-};
-
-const schema = new Schema(ProductSchema, { toJSON: { virtuals: true } });
-schema.index({ id: 1 });
-schema.plugin(metaPlugin);
-
-module.exports = app => {
-  const { mongoose } = app;
-  return mongoose.model('Product', schema, 'product');
-};

+ 22 - 0
app/model/repair.js

@@ -0,0 +1,22 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+// 维修单
+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 }, // 合计
+  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');
+};

+ 6 - 6
app/router.js

@@ -5,10 +5,10 @@
  */
 module.exports = app => {
   const { router, controller } = app;
-  // 用户
-  router.resources('company', '/api/servicetest/company', controller.company); // index、create、show、destroy
-  router.post('company', '/api/servicetest/company/update/:id', controller.company.update);
-  // 产品
-  router.resources('product', '/api/servicetest/product', controller.product); // index、create、show、destroy
-  router.post('product', '/api/servicetest/product/update/:id', controller.product.update);
+  // 顾客
+  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);
 };

+ 5 - 5
app/service/company.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 { CarorderError, ErrorCode } = require('naf-core').Error;
 
-class CompanyService extends CrudService {
+class CarorderService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'company');
-    this.model = this.ctx.model.Company;
+    super(ctx, 'carorder');
+    this.model = this.ctx.model.Carorder;
   }
 }
 
-module.exports = CompanyService;
+module.exports = CarorderService;

+ 4 - 4
app/service/product.js

@@ -6,11 +6,11 @@ const { ObjectId } = require('mongoose').Types;
 const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { CompanyError, ErrorCode } = require('naf-core').Error;
 
-class ProductService extends CrudService {
+class RepairService extends CrudService {
   constructor(ctx) {
-    super(ctx, 'product');
-    this.model = this.ctx.model.Product;
+    super(ctx, 'repair');
+    this.model = this.ctx.model.Repair;
   }
 }
 
-module.exports = ProductService;
+module.exports = RepairService;