Sfoglia il codice sorgente

科技超市服务端更新

reloaded 5 anni fa
parent
commit
d6c84850ee

+ 91 - 0
app/controller/.enterprise.js

@@ -0,0 +1,91 @@
+module.exports = {
+  create: {
+    requestBody: [
+      '!code',
+      'dtype',
+      'xtype',
+      '!name',
+      'pinyin',
+      'logo',
+      'license',
+      'file_path',
+      'contact',
+      'addr',
+      'introduction',
+      'ishomepage',
+      'homepage',
+      'longitude',
+      'latitude',
+      'map_info',
+      'state',
+      'is_del',
+      'sort'
+    ]
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete'
+  },
+  update: {
+    params: ['!id'],
+    requestBody: [
+      'code',
+      'dtype',
+      'xtype',
+      'name',
+      'pinyin',
+      'logo',
+      'license',
+      'file_path',
+      'contact',
+      'addr',
+      'introduction',
+      'ishomepage',
+      'homepage',
+      'longitude',
+      'latitude',
+      'map_info',
+      'state',
+      'is_del',
+      'sort'
+    ]
+  },
+  show: {
+    parameters: {
+      params: ['!id']
+    },
+    service: 'fetch'
+  },
+  index: {
+    parameters: {
+      query: {
+        code : 'code',
+        dtype : 'dtype',
+        xtype : 'xtype',
+        name : 'name',
+        pinyin : 'pinyin',
+        logo : 'logo',
+        license: 'license',
+        file_path : 'file_path',
+        contact : 'contact',
+        addr : 'addr',
+        introduction: 'introduction',
+        ishomepage : 'ishomepage',
+        homepage : 'homepage',
+        longitude: 'longitude',
+        latitude : 'latitude',
+        map_info : 'map_info',
+        state : 'state',
+        is_del : 'is_del',
+        sort : 'sort'
+      }
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true
+    }
+  },
+};

+ 19 - 0
app/controller/enterprise.js

@@ -0,0 +1,19 @@
+'use strict';
+
+const _ = require('lodash');
+const meta = require('./.enterprise.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 科技企业表管理
+class EnterpriseController extends Controller {
+
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.enterprise;
+  }
+
+
+}
+
+module.exports = CrudController(EnterpriseController, meta);

+ 35 - 0
app/model/enterprise.js

@@ -0,0 +1,35 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+
+// 科技企业表
+const EnterpriseSchema = {
+  code: { type: String, required: true, maxLength: 500 }, // 编号
+  dtype: { type: String, required: false, maxLength: 500 }, // 大类别
+  xtype: { type: String, required: false, maxLength: 500 }, // 小类别
+  name: { type: String, required: true, maxLength: 500 }, // 名称
+  pinyin: { type: String, required: false, maxLength: 500 }, // 拼音
+  logo: { type: String, required: false, maxLength: 500 }, // 类别名称
+  license: { type: String, required: false, maxLength: 500 }, // 执照
+  file_path: { type: String, required: false, maxLength: 500 }, // 证照图片
+  contact: { type: String, required: false, maxLength: 500 }, // 联系方式
+  addr: { type: String, required: false, maxLength: 500 }, // 地址
+  introduction: { type: String, required: false }, // 简介
+  ishomepage: { type: String, required: false, maxLength: 500 }, // 是否显示,0-否,1-是
+  homepage: { type: String, required: false, maxLength: 500 }, // 主页地址
+  longitude: { type: String, required: false, maxLength: 500 }, // 经度
+  latitude: { type: String, required: false, maxLength: 500 }, // 纬度
+  map_info: { type: String, required: false }, // 地图信息
+  state: { type: String, required: false, maxLength: 500 }, // 状态0、未审1、已审2、拒绝
+  is_del: { type: String, required: false, maxLength: 500 }, // 是否删除
+  sort: { type: String, required: false, maxLength: 500 }, // 排序
+};
+
+const schema = new Schema(EnterpriseSchema, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.plugin(metaPlugin);
+
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Enterprise', schema, 'market_enterprise');
+};

+ 4 - 0
app/router.js

@@ -30,4 +30,8 @@ module.exports = app => {
   // 交易审核表设置路由
   router.resources('tranaudit', '/api/market/tranaudit', controller.tranaudit); // index、create、show、destroy
   router.post('tranaudit', '/api/market/tranaudit/update/:id', controller.tranaudit.update);
+
+  // 科技企业表设置路由
+  router.resources('enterprise', '/api/market/enterprise', controller.enterprise); // index、create、show、destroy
+  router.post('enterprise', '/api/market/enterprise/update/:id', controller.enterprise.update);
 };

+ 18 - 0
app/service/enterprise.js

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