lrf402788946 4 years ago
parent
commit
cf97155238

+ 13 - 1
app/controller/.expert.js

@@ -23,6 +23,7 @@ module.exports = {
       'addr',
       'addr',
       'office_phone',
       'office_phone',
       'profession',
       'profession',
+      'passwd',
     ],
     ],
   },
   },
   destroy: {
   destroy: {
@@ -57,7 +58,7 @@ module.exports = {
   },
   },
   show: {
   show: {
     parameters: {
     parameters: {
-      params: ["!user_id"],
+      params: ["!id"],
     },
     },
     service: "fetch",
     service: "fetch",
   },
   },
@@ -84,4 +85,15 @@ module.exports = {
       count: true,
       count: true,
     },
     },
   },
   },
+  //修改密码
+  password: {
+    params: ["!id"],
+    requestBody: ["passwd"],
+    service: "password",
+  },
+  // 登陆
+  login: {
+    requestBody: ["phone", "passwd"],
+    service: "login",
+  }
 };
 };

+ 58 - 0
app/controller/.mechanism.js

@@ -0,0 +1,58 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "name",
+      "contacts",
+      "phone",
+      "passwd",
+      "email",
+      "address",
+      "industry",
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: ["name", "contacts", "phone", "email", "address", "industry"],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        name: "name",
+        industry: "industry",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+  //修改密码
+  password: {
+    params: ["!id"],
+    requestBody: ["passwd"],
+    service: "password",
+  },
+  // 登陆
+  login: {
+    requestBody: ["phone", "passwd"],
+    service: "login",
+  }
+};

+ 99 - 0
app/controller/.organization.js

@@ -0,0 +1,99 @@
+module.exports = {
+  create: {
+    requestBody: [
+      "!name",
+      "!passwd",
+      "phone",
+      "email",
+      "addr",
+      "code",
+      "office_phone",
+      "profession",
+      'institution_code',
+      'companytype',
+      'companydate',
+      'companycapital',
+      'companyperson',
+      'sndqyzsr',
+      'sndyffy',
+      'companytotal',
+      'zjzyfrs',
+      'companybrief',
+      'mainproduct',
+      'qualifications',
+      'remark',
+      'status',
+    ],
+  },
+  destroy: {
+    params: ["!id"],
+    service: "delete",
+  },
+  update: {
+    params: ["!id"],
+    requestBody: [
+      "name",
+      "phone",
+      "email",
+      "addr",
+      "code",
+      "office_phone",
+      "profession",
+      'institution_code',
+      'companytype',
+      'companydate',
+      'companycapital',
+      'companyperson',
+      'sndqyzsr',
+      'sndyffy',
+      'companytotal',
+      'zjzyfrs',
+      'companybrief',
+      'mainproduct',
+      'qualifications',
+      'remark',
+      'status'
+    ],
+  },
+  show: {
+    parameters: {
+      params: ["!id"],
+    },
+    service: "fetch",
+  },
+  index: {
+    parameters: {
+      query: {
+        phone:"phone",
+        code:"code",
+        profession:"profession",
+        institution_code:"institution_code",
+        companyperson:"companyperson",
+        status:"status",
+        "create_time@start": "create_time@start",
+        "create_time@end": "create_time@end",
+      },
+      options: {
+        "isdel": '0' // 默认条件
+      },
+    },
+    service: "query",
+    options: {
+      query: ["skip", "limit"],
+      sort: ["meta.createdAt"],
+      desc: true,
+      count: true,
+    },
+  },
+  //修改密码
+  password: {
+    params: ["!id"],
+    requestBody: ["passwd"],
+    service: "password",
+  },
+  // 登陆
+  login: {
+    requestBody: ["institution_code", "passwd"],
+    service: "login",
+  }
+};

+ 1 - 1
app/controller/.product.js

@@ -85,7 +85,7 @@ module.exports = {
   index: {
   index: {
     parameters: {
     parameters: {
       query: {
       query: {
-        name: "%name%",
+        name: "name",
         code:"code",
         code:"code",
         qqwx: "qqwx",
         qqwx: "qqwx",
         type: "type",
         type: "type",

+ 9 - 0
app/controller/home.js

@@ -7,6 +7,15 @@ class HomeController extends Controller {
     const { ctx } = this;
     const { ctx } = this;
     ctx.body = 'hi, egg';
     ctx.body = 'hi, egg';
   }
   }
+
+  async utilMethod() {
+    const res = await this.ctx.model.Expert.find();
+    for (const i of res) {
+      i.passwd = { secret: '111111' };
+      await i.save();
+    }
+    this.ctx.ok();
+  }
 }
 }
 
 
 module.exports = HomeController;
 module.exports = HomeController;

+ 13 - 0
app/controller/mechanism.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.mechanism.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 机构
+class MechanismController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.mechanism;
+  }
+}
+module.exports = CrudController(MechanismController, meta);

+ 13 - 0
app/controller/organization.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./.organization.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose/lib/controller');
+
+// 机构
+class OrganizationController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.organization;
+  }
+}
+module.exports = CrudController(OrganizationController, meta);

+ 20 - 19
app/model/expert.js

@@ -10,29 +10,30 @@ const expert = {
   user_id: { type: ObjectId }, // 关联的personal的id
   user_id: { type: ObjectId }, // 关联的personal的id
   // user
   // user
   name: { type: String, required: true }, // 用户名
   name: { type: String, required: true }, // 用户名
-  phone: { type: String, required: false, maxLength: 200 }, // 电话号码
-  addr: { type: String, required: false, maxLength: 500 }, // 地址
-  office_phone: { type: String, required: false, maxLength: 500 }, // 办公电话
-  profession: { type: String, required: false, maxLength: 500 }, // 所属行业
+  phone: { type: String, required: false }, // 电话号码
+  passwd: { type: Secret, required: true, select: false }, // 登录密码
+  addr: { type: String, required: false }, // 地址
+  office_phone: { type: String, required: false }, // 办公电话
+  profession: { type: String, required: false }, // 所属行业
 
 
-  education: { type: String, required: false, maxLength: 200 }, // 最高学历
-  school: { type: String, required: false, maxLength: 200 }, // 毕业院校
-  birthDate: { type: String, required: false, maxLength: 200 }, // 出生日期
-  qqwx: { type: String, required: false, maxLength: 200 }, // qq&微信
-  email: { type: String, required: false, maxLength: 200 }, // 邮箱
-  company: { type: String, required: false, maxLength: 500 }, // 单位名称
-  zwzc: { type: String, required: false, maxLength: 200 }, // 职务职称
-  expertise: { type: String, required: false, maxLength: 200 }, // 擅长领域
-  img_path: { type: String, required: false }, // 头像图片
-  workexperience: { type: String, required: false, maxLength: 500 }, // 工作经历
+  education: { type: String, required: false }, // 最高学历
+  school: { type: String, required: false }, // 毕业院校
+  birthDate: { type: String, required: false }, // 出生日期
+  qqwx: { type: String, required: false }, // qq&微信
+  email: { type: String, required: false }, // 邮箱
+  company: { type: String, required: false }, // 单位名称
+  zwzc: { type: String, required: false }, // 职务职称
+  expertise: { type: String, required: false }, // 擅长领域
+  img_path: { type: Array, required: false }, // 头像图片
+  workexperience: { type: String, required: false }, // 工作经历
   scientific: { type: String, required: false, maxLength: 300 }, // 科研综述
   scientific: { type: String, required: false, maxLength: 300 }, // 科研综述
-  undertakingproject: { type: String, required: false, maxLength: 200 }, // 承担项目
-  scienceaward: { type: String, required: false, maxLength: 200 }, // 科技奖励
-  social: { type: String, required: false, maxLength: 200 }, // 社会任职
-  // status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
+  undertakingproject: { type: String, required: false }, // 承担项目
+  scienceaward: { type: String, required: false }, // 科技奖励
+  social: { type: String, required: false }, // 社会任职
+  status: { type: String, required: false, default: '0' }, // 审核状态,0-注册,1-通过,2-拒绝
 
 
   isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
   isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
-  remark: { type: String, maxLength: 200 },
+  remark: { type: String },
   create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
   create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
 };
 };
 const schema = new Schema(expert, { toJSON: { virtuals: true } });
 const schema = new Schema(expert, { toJSON: { virtuals: true } });

+ 30 - 0
app/model/mechanism.js

@@ -0,0 +1,30 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
+// 机构表
+const mechanism = {
+  name: { type: String }, // 机构名
+  contacts: { type: String }, // 联系人
+  phone: { type: String }, // 联系电话
+  passwd: { type: Secret, select: false }, // 密码
+  email: { type: String }, // 电子邮箱
+  address: { type: String }, // 联系地址
+  industry: { type: String }, // 所属行业
+  status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
+  isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
+  remark: { type: String },
+  create_time: { type: String, default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss') },
+};
+const schema = new Schema(mechanism, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ name: 1 });
+schema.index({ industry: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Mechanism', schema, 'mechanism');
+};

+ 47 - 0
app/model/organization.js

@@ -0,0 +1,47 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
+
+// 机构表
+const organization = {
+  name: { type: String, required: true, maxLength: 200 }, // 用户名
+  passwd: { type: Secret, required: true, select: false }, // 登录密码
+  phone: { type: String, required: false, maxLength: 200 }, // 电话号码
+  email: { type: String, required: false, maxLength: 200 }, // 邮箱
+  addr: { type: String, required: false, maxLength: 500 }, // 地址
+  office_phone: { type: String, required: false, maxLength: 500 }, // 办公电话
+  profession: { type: String, required: false, maxLength: 500 }, // 所属行业
+  institution_code: { type: String, required: false, maxLength: 500 }, // 机构代码
+  code: { type: String, required: false, default: 'INVESTORS' }, // 邀请码
+
+  companytype: { type: String, required: false, maxLength: 300 }, // 注册类型
+  companydate: { type: String, required: false, maxLength: 300 }, // 注册时间
+  companycapital: { type: String, required: false, maxLength: 300 }, // 注册资金
+  companyperson: { type: String, required: false, maxLength: 300 }, // 企业法人
+  sndqyzsr: { type: String, required: false, maxLength: 300 }, // 上年度企业总收入
+  sndyffy: { type: String, required: false, maxLength: 300 }, // 上年度研发费用
+  companytotal: { type: String, required: false, maxLength: 300 }, // 企业总人数
+  zjzyfrs: { type: String, required: false, maxLength: 300 }, // 专&兼职研发人数
+  companybrief: { type: String, required: false }, // 企业简介
+  mainproduct: { type: String, required: false, maxLength: 300 }, // 主要产品
+  qualifications: { type: String, required: false, maxLength: 300 }, // 企业资质&荣誉
+  status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
+
+  isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
+  remark: { type: String, maxLength: 200 },
+  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
+};
+const schema = new Schema(organization, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ phone: 1 });
+schema.index({ profession: 1 });
+schema.index({ institution_code: 1 });
+schema.index({ companyperson: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Organization', schema, 'organization');
+};

+ 2 - 2
app/model/road_show.js

@@ -13,8 +13,8 @@ const road_show = {
   origin: { type: String, required: false, maxLength: 500, default: '网站管理员' }, // 来源
   origin: { type: String, required: false, maxLength: 500, default: '网站管理员' }, // 来源
   publish_time: { type: String, required: false, maxLength: 500 }, // 发布时间
   publish_time: { type: String, required: false, maxLength: 500 }, // 发布时间
   content: { type: String, required: false }, // 正文
   content: { type: String, required: false }, // 正文
-  picture: { type: String, required: false }, // 图片路径
-  filepath: { type: String, required: false }, // 文件路径
+  picture: { type: Array, required: false }, // 图片路径
+  filepath: { type: Array, required: false }, // 文件路径
   remark: { type: String, maxLength: 200 },
   remark: { type: String, maxLength: 200 },
   create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
   create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
 };
 };

+ 3 - 0
app/router.js

@@ -6,10 +6,13 @@
 module.exports = app => {
 module.exports = app => {
   const { router, controller } = app;
   const { router, controller } = app;
   router.get('/', controller.home.index);
   router.get('/', controller.home.index);
+  router.post('/util', controller.home.utilMethod);
   require('./router/news')(app); // 新闻
   require('./router/news')(app); // 新闻
   require('./router/product')(app); // 产品
   require('./router/product')(app); // 产品
   require('./router/patent')(app); // 专利
   require('./router/patent')(app); // 专利
   require('./router/road_show')(app); // 路演
   require('./router/road_show')(app); // 路演
   require('./router/expert')(app); // 专家
   require('./router/expert')(app); // 专家
   require('./router/admin')(app); // 管理员
   require('./router/admin')(app); // 管理员
+  require('./router/organization')(app); // 企业
+  require('./router/mechanism')(app); // 机构
 };
 };

+ 2 - 0
app/router/expert.js

@@ -4,6 +4,8 @@
 module.exports = app => {
 module.exports = app => {
   const { router, controller } = app;
   const { router, controller } = app;
   const prefix = 'expert';
   const prefix = 'expert';
+  router.post(prefix, `/${prefix}/login`, controller[prefix].login);
+  router.post(prefix, `/${prefix}/password/:id`, controller[prefix].password);
   router.resources(prefix, `/${prefix}`, controller[prefix]); // index、create、show、destroy
   router.resources(prefix, `/${prefix}`, controller[prefix]); // index、create、show、destroy
   router.post(prefix, `/${prefix}/update/:id`, controller[prefix].update);
   router.post(prefix, `/${prefix}/update/:id`, controller[prefix].update);
 };
 };

+ 11 - 0
app/router/mechanism.js

@@ -0,0 +1,11 @@
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const prefix = 'mechanism';
+  router.post(prefix, `/${prefix}/login`, controller[prefix].login);
+  router.post(prefix, `/${prefix}/password/:id`, controller[prefix].password);
+  router.resources(prefix, `/${prefix}`, controller[prefix]); // index、create、show、destroy
+  router.post(prefix, `/${prefix}/update/:id`, controller[prefix].update);
+};

+ 11 - 0
app/router/organization.js

@@ -0,0 +1,11 @@
+'use strict';
+
+
+module.exports = app => {
+  const { router, controller } = app;
+  const prefix = 'organization';
+  router.post(prefix, `/${prefix}/login`, controller[prefix].login);
+  router.post(prefix, `/${prefix}/password/:id`, controller[prefix].password);
+  router.resources(prefix, `/${prefix}`, controller[prefix]); // index、create、show、destroy
+  router.post(prefix, `/${prefix}/update/:id`, controller[prefix].update);
+};

+ 43 - 0
app/service/expert.js

@@ -3,6 +3,7 @@ const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { BusinessError, ErrorCode } = require('naf-core').Error;
 const { BusinessError, ErrorCode } = require('naf-core').Error;
 const _ = require('lodash');
 const _ = require('lodash');
 const assert = require('assert');
 const assert = require('assert');
+const jwt = require('jsonwebtoken');
 
 
 // 专家
 // 专家
 class ExpertService extends CrudService {
 class ExpertService extends CrudService {
@@ -10,6 +11,48 @@ class ExpertService extends CrudService {
     super(ctx, 'expert');
     super(ctx, 'expert');
     this.model = this.ctx.model.Expert;
     this.model = this.ctx.model.Expert;
   }
   }
+  /**
+   * 创建专家
+   * @param {Object} params 用户信息
+   */
+  async create({ passwd, ...data }) {
+    data.passwd = { secret: passwd };
+    const { phone } = data;
+    // 检查手机号
+    const num = await this.model.count({ phone });
+    if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '该手机号已有专家');
+    const res = await this.model.create(data);
+    return res;
+  }
+
+  /**
+   * 修改密码
+   * @param {Object} {id,passwd} 用户id和密码
+   */
+  async password({ id, passwd }) {
+    const object = await this.model.findById(id);
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
+    object.passwd = { secret: passwd };
+    await object.save();
+  }
+
+  /**
+   * 专家登陆
+   * @param {Object} params 登陆信息
+   * @property phone 电话号
+   * @property passwd 密码
+   */
+  async login({ phone, passwd }) {
+    const object = await this.model.findOne({ phone }, '+passwd');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
+    const { passwd: op } = object;
+    const { secret } = op;
+    if (secret !== passwd) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
+    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'passwd', '__v' ]);
+    const { secret: secrets } = this.config.jwt;
+    const token = jwt.sign(data, secrets);
+    return token;
+  }
 }
 }
 
 
 module.exports = ExpertService;
 module.exports = ExpertService;

+ 66 - 0
app/service/mechanism.js

@@ -0,0 +1,66 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const jwt = require('jsonwebtoken');
+// 机构
+class MechanismService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'Mechanism');
+    this.redis = this.app.redis;
+    this.model = this.ctx.model.Mechanism;
+  }
+  /**
+   * 创建用户
+   * @param {Object} params 用户信息
+   */
+  async create({ passwd, ...data }) {
+    data.passwd = { secret: passwd };
+    const { phone } = data;
+    // 检查是否重复
+    const num = await this.model.count({ phone, isdel: '0' });
+    if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '已有机构使用该电话号码');
+    return await this.model.create(data);
+  }
+  /**
+   * 修改密码
+   * @param {Object} {id,passwd} 用户id和密码
+   */
+  async password({ id, passwd }) {
+    const object = await this.model.findById(id);
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
+    object.passwd = { secret: passwd };
+    await object.save();
+  }
+  /**
+   * 登陆
+   * @param {Object} params 登陆信息
+   * @property phone 手机号
+   * @property passwd 密码
+   */
+  async login({ phone, passwd }) {
+    const object = await this.model.findOne({ phone, isdel: '0' }, '+passwd');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
+    const { passwd: op, status } = object;
+    const { secret } = op;
+    if (status !== '1') throw new BusinessError(ErrorCode.ACCESS_DENIED, '拒绝访问!');
+    if (secret !== passwd) throw new BusinessError(ErrorCode.BAD_passwd, '密码错误');
+    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'passwd', '__v' ]);
+    const { secret: secrets } = this.config.jwt;
+    const token = jwt.sign(data, secrets);
+    // 记录登陆
+    // let number = await this.redis.get('login_number') || 0;
+    // number++;
+    // await this.redis.set('login_number', number);
+    return token;
+  }
+
+  async delete({ id }) {
+    const object = await this.model.findById(id);
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
+    object.isdel = '1';
+    await object.save();
+  }
+}
+
+module.exports = MechanismService;

+ 67 - 0
app/service/organization.js

@@ -0,0 +1,67 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const jwt = require('jsonwebtoken');
+// 机构
+class OrganizationService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'organization');
+    this.redis = this.app.redis;
+    this.model = this.ctx.model.Organization;
+  }
+  /**
+   * 创建用户
+   * @param {Object} params 用户信息
+   */
+  async create({ passwd, ...data }) {
+    data.passwd = { secret: passwd };
+    const { institution_code } = data;
+    // 检查是否重复
+    const num = await this.model.count({ institution_code, isdel: '0' });
+    if (num > 0) throw new BusinessError(ErrorCode.DATA_EXISTED, '已有个企业使用该 统一社会信用代码');
+    return await this.model.create(data);
+  }
+  /**
+   * 修改密码
+   * @param {Object} {id,passwd} 用户id和密码
+   */
+  async password({ id, passwd }) {
+    const object = await this.model.findById(id);
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
+    object.passwd = { secret: passwd };
+    await object.save();
+  }
+  /**
+   * 登陆
+   * @param {Object} params 登陆信息
+   * @property institution_code 手机号
+   * @property passwd 密码
+   */
+  async login({ institution_code, passwd }) {
+    console.log(institution_code, passwd);
+    const object = await this.model.findOne({ institution_code, isdel: '0' }, '+passwd');
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
+    const { passwd: op, status } = object;
+    const { secret } = op;
+    if (status !== '1') throw new BusinessError(ErrorCode.ACCESS_DENIED, '拒绝访问!');
+    if (secret !== passwd) throw new BusinessError(ErrorCode.BAD_passwd, '密码错误');
+    const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'passwd', '__v' ]);
+    const { secret: secrets } = this.config.jwt;
+    const token = jwt.sign(data, secrets);
+    // 记录登陆
+    // let number = await this.redis.get('login_number') || 0;
+    // number++;
+    // await this.redis.set('login_number', number);
+    return token;
+  }
+
+  async delete({ id }) {
+    const object = await this.model.findById(id);
+    if (!object) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
+    object.isdel = '1';
+    await object.save();
+  }
+}
+
+module.exports = OrganizationService;