lrf 3 vuotta sitten
vanhempi
commit
3a4176de1b

+ 0 - 69
app/controller/.user.js

@@ -1,69 +0,0 @@
-module.exports = {
-  create: {
-    requestBody: [
-      "phone",
-      "password",
-      "type",
-      "icon",
-      "nickname",
-      "gender",
-      "work",
-      "status",
-    ],
-  },
-  destroy: {
-    params: ["!id"],
-    service: "delete",
-  },
-  update: {
-    params: ["!id"],
-    requestBody: [
-      "phone",
-      "password",
-      "type",
-      "icon",
-      "nickname",
-      "gender",
-      "work",
-      "status",
-    ],
-  },
-  show: {
-    parameters: {
-      params: ["!id"],
-    },
-    service: "fetch",
-  },
-  index: {
-    parameters: {
-      query: {
-        phone: "phone",
-        type: "type",
-        nickname: "nickname",
-        gender: "gender",
-        work: "work",
-        email: "email",
-        status: "status",
-        "meta.createdAt@start": "meta.createdAt@start",
-        "meta.createdAt@end": "meta.createdAt@end",
-      },
-      // options: {
-      //   "meta.state": 0 // 默认条件
-      // },
-    },
-    service: "query",
-    options: {
-      query: ["skip", "limit"],
-      sort: ["meta.createdAt"],
-      desc: true,
-      count: true,
-    },
-  },
-  login: {
-    requestBody: ["!phone", "!password"],
-  },
-  updatePwd: {
-    params: ['!id'],
-    requestBody: ['!password'],
-  },
-};

+ 1 - 1
app/controller/admin.js

@@ -1,5 +1,5 @@
 'use strict';
-const meta = require('./.admin.js');
+const meta = require('./config/.admin.js');
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
 

+ 13 - 0
app/controller/apply.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.apply.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 申报
+class ApplyController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.apply;
+  }
+}
+module.exports = CrudController(ApplyController, meta);

+ 48 - 0
app/controller/config/.admin.js

@@ -0,0 +1,48 @@
+module.exports = {
+  create: {
+    requestBody: ['name', 'phone', 'password', 'card', 'email', 'addr'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['name', 'phone', 'card', 'email', 'addr'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        phone: 'phone',
+        name: 'name',
+        card: 'card',
+        addr: '%addr%',
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+  login: {
+    requestBody: ['!phone', '!password'],
+  },
+  updatePwd: {
+    params: ['!id'],
+    requestBody: ['!password'],
+  },
+};

+ 38 - 0
app/controller/config/.apply.js

@@ -0,0 +1,38 @@
+module.exports = {
+  create: {
+    requestBody: ['user_id', 'status', 'basic', 'brief', 'research', 'datalist', 'file', 'remark', 'create_time'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['user_id', 'status', 'basic', 'brief', 'research', 'datalist', 'file', 'remark', 'create_time'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        user_id: 'user_id',
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+};

+ 90 - 0
app/controller/config/.expert.js

@@ -0,0 +1,90 @@
+module.exports = {
+  create: {
+    requestBody: [
+      'name',
+      'phone',
+      'password',
+      'card',
+      'birth',
+      'qqwx',
+      'email',
+      'zwzc',
+      'education',
+      'school',
+      'major',
+      'company',
+      'icon',
+      'expertise',
+      'workexperience',
+      'scientific',
+      'undertakingproject',
+      'scienceaward',
+      'social',
+      'status',
+    ],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: [
+      'name',
+      'phone',
+      'card',
+      'birth',
+      'qqwx',
+      'email',
+      'zwzc',
+      'education',
+      'school',
+      'major',
+      'company',
+      'icon',
+      'expertise',
+      'workexperience',
+      'scientific',
+      'undertakingproject',
+      'scienceaward',
+      'social',
+      'status',
+    ],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        name: 'name',
+        phone: 'phone',
+        card: 'card',
+        education: 'education',
+        status: 'status',
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+  login: {
+    requestBody: ['!phone', '!password'],
+  },
+  updatePwd: {
+    params: ['!id'],
+    requestBody: ['!password'],
+  },
+};

app/controller/.menu.js → app/controller/config/.menu.js


+ 6 - 2
app/controller/.admin.js

@@ -1,6 +1,6 @@
 module.exports = {
   create: {
-    requestBody: ['name', 'account', 'password'],
+    requestBody: ['expert_id', 'apply_id', 'verify', 'type'],
   },
   destroy: {
     params: ['!id'],
@@ -8,7 +8,7 @@ module.exports = {
   },
   update: {
     params: ['!id'],
-    requestBody: ['name', 'account', 'password'],
+    requestBody: ['expert_id', 'apply_id', 'verify', 'type'],
   },
   show: {
     parameters: {
@@ -19,6 +19,10 @@ module.exports = {
   index: {
     parameters: {
       query: {
+        expert_id: 'expert_id',
+        apply_id: 'apply_id',
+        verify: 'verify',
+        type: 'type',
         'meta.createdAt@start': 'meta.createdAt@start',
         'meta.createdAt@end': 'meta.createdAt@end',
       },

+ 54 - 0
app/controller/config/.user.js

@@ -0,0 +1,54 @@
+module.exports = {
+  create: {
+    requestBody: ['profession', 'name', 'phone', 'password', 'card', 'email', 'addr', 'school', 'major', 'status', 'zwzc'],
+  },
+  destroy: {
+    params: ['!id'],
+    service: 'delete',
+  },
+  update: {
+    params: ['!id'],
+    requestBody: ['profession', 'name', 'phone', 'card', 'email', 'addr', 'school', 'major', 'status', 'zwzc'],
+  },
+  show: {
+    parameters: {
+      params: ['!id'],
+    },
+    service: 'fetch',
+  },
+  index: {
+    parameters: {
+      query: {
+        name: 'name',
+        phone: 'phone',
+        card: 'card',
+        addr: 'addr',
+        school: 'school',
+        major: 'major',
+        email: 'email',
+        status: 'status',
+        zwzc: 'zwzc',
+        profession: 'profession',
+        'meta.createdAt@start': 'meta.createdAt@start',
+        'meta.createdAt@end': 'meta.createdAt@end',
+      },
+      // options: {
+      //   "meta.state": 0 // 默认条件
+      // },
+    },
+    service: 'query',
+    options: {
+      query: ['skip', 'limit'],
+      sort: ['meta.createdAt'],
+      desc: true,
+      count: true,
+    },
+  },
+  login: {
+    requestBody: ['!phone', '!password'],
+  },
+  updatePwd: {
+    params: ['!id'],
+    requestBody: ['!password'],
+  },
+};

+ 13 - 0
app/controller/expert.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.expert.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 专家
+class ExpertController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.expert;
+  }
+}
+module.exports = CrudController(ExpertController, meta);

+ 1 - 1
app/controller/menu.js

@@ -1,5 +1,5 @@
 'use strict';
-const meta = require('./.menu.js');
+const meta = require('./config/.menu.js');
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
 

+ 13 - 0
app/controller/review_expert.js

@@ -0,0 +1,13 @@
+'use strict';
+const meta = require('./config/.review_expert.js');
+const Controller = require('egg').Controller;
+const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
+
+// 专家评审
+class Review_expertController extends Controller {
+  constructor(ctx) {
+    super(ctx);
+    this.service = this.ctx.service.reviewExpert;
+  }
+}
+module.exports = CrudController(Review_expertController, meta);

+ 1 - 1
app/controller/user.js

@@ -1,5 +1,5 @@
 'use strict';
-const meta = require('./.user.js');
+const meta = require('./config/.user.js');
 const Controller = require('egg').Controller;
 const { CrudController } = require('naf-framework-mongoose-free/lib/controller');
 

+ 9 - 4
app/model/admin.js

@@ -4,13 +4,18 @@ const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
 const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
 // 系统管理员表
 const admin = {
-  name: { type: String, default: '系统管理员' }, // 显示名称
-  account: { type: String }, // 账号
-  password: { type: Secret, select: false }, // 密码
-  remark: { type: String },
+  name: { type: String, required: true }, // 用户名
+  phone: { type: String, required: false, maxLength: 200 }, // 电话号码
+  password: { type: Secret, required: true, select: false }, // 登录密码
+  card: { type: String, required: false, maxLength: 200 }, // 身份证号
+  email: { type: String, required: false, maxLength: 200 }, // 邮箱
+  addr: { type: String, required: false, maxLength: 500 }, // 地址
+  remark: { type: String, maxLength: 200 },
 };
 const schema = new Schema(admin, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ phone: 1 });
+schema.index({ card: 1 });
 schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {

+ 145 - 0
app/model/apply.js

@@ -0,0 +1,145 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 基本信息
+const basic = new Schema({
+  achieve_name: { type: String }, // 成果名称
+  achieve_type: { type: Array }, // 成果类别
+  achieve_num: { type: String }, // 成果编号
+  achieve_date: { type: String }, // 成果取得时间
+  achieve_form: { type: Array }, // 成果形式
+  apply_personal: { type: String }, // 申请人
+  apply_phone: { type: String }, // 申请人
+  apply_company: { type: String }, // 申请单位
+  address: { type: String }, // 地址
+  apply_nature: { type: String }, // 申请单位/申请人属性
+  contacts: { type: String }, // 联系人
+  phone: { type: String }, // 联系电话
+  email: { type: String }, // 邮箱
+  fax: { type: String }, // 传真
+  objective: { type: String }, // 评价目的
+  stage: { type: String }, // 成果所处阶段
+  output: { type: String }, // 经济效益产值
+  profit: { type: String }, // 经济效益利润
+  revenue: { type: String }, // 经济效益税收
+  // 2021-04-13添加
+  cert_jfh: { type: String }, // 吉发号
+  cert_num: { type: String }, // 第几号
+  cert_sign: { type: String }, // 签字
+
+  szd: { type: String }, // 所在地
+  yb: { type: String }, // 邮编
+  ls: { type: String }, // 隶属
+  oneCom_name: { type: String }, // 参加单位1——名称
+  oneCom_szd: { type: String }, // 参加单位1——所在地
+  twoCom_name: { type: String }, // 参加单位2——名称
+  twoCom_szd: { type: String }, // 参加单位2——所在地
+
+  shxy: { type: String }, // 社会效益
+  // 国家奖励
+  gjjl_num: { type: String }, // 国家奖励项
+  gjjl_name: { type: String }, // 国家奖励名称
+  gjjl_grade: { type: String }, // 国家奖励等级
+
+  sjjl_num: { type: String }, // 省级奖励项
+  sjjl_name: { type: String }, // 省级奖励名称
+  sjjl_grade: { type: String }, // 省级奖励等级
+  // 计划支持
+  gjjh_num: { type: String }, // 国家计划项
+  gjjh_money: { type: String }, // 国家计划经费
+
+  sjjh_num: { type: String }, // 省级计划项
+  sjjh_money: { type: String }, // 省级计划经费
+  achieve_influence: { type: Array }, // 成果的影响及作用
+});
+basic.index({ id: 1 });
+basic.index({ achieve_num: 1 });
+
+// 内容简介
+const brief = new Schema({
+  achieve_brief: { type: String }, // 成果简介
+  field: { type: String }, // 应用领域和技术原理
+  kpi_index: { type: String }, // 性能指标
+  compare: { type: String }, // 与国内外同类技术比较
+  advanced: { type: String }, // 成果的创造性,先进性
+  sense: { type: String }, // 作用意义
+  prospect: { type: String }, // 推广应用的范围,条件和前景
+  opinion: { type: String }, // 存在的问题和改进意见
+});
+brief.index({ id: 1 });
+
+// 主研人员名单
+const research = new Schema({
+  name: { type: String }, // 姓名
+  gender: { type: String }, // 性别
+  card: { type: String }, // 证件号码
+  birth: { type: String }, // 出生年月
+  age: { type: String }, // 年龄
+  education: { type: String }, // 文化程度
+  degree: { type: String }, // 学位
+  major: { type: String }, // 从事专业
+  zw: { type: String }, // 职务
+  zc: { type: String }, // 职称
+  company: { type: String }, // 工作单位
+  abroad: { type: String }, // 是否留学归国
+  work: { type: String }, // 项目中所承担的主要工作
+  devote: { type: String }, // 对成果创造性贡献
+  phone: { type: String }, // 电话
+  email: { type: String }, // 邮箱
+});
+research.index({ id: 1 });
+
+// 委托方提供资料清单
+const datalist = new Schema({
+  work_report: { type: Object }, // 工作报告(必备)
+  techol_report: { type: Object }, // 技术报告(必备)
+  compare_report: { type: Object }, // 国内外对比报告(必备)
+  benefit: { type: Object }, // 经济效益分析(必备)
+  science_report: { type: Object }, // 科技查新报告(必备)
+  techol_detect_report: { type: Object }, // 技术检测报告
+  user_prove: { type: Object }, // 用户证明
+  patent_cert: { type: Object }, // 专利证书
+  software_copyright: { type: Object }, // 软著
+  treatise: { type: Object }, // 论文
+  gf: { type: Object }, // 工法
+  company_standard: { type: Object }, // 企业标准等证明材料
+});
+datalist.index({ id: 1 });
+
+// 上传文件
+const file = new Schema({
+  page5: { type: String }, // 现场测试(检测,测产)意见
+  page6: { type: String }, // 评价意见
+  nameList: { type: String }, // 评价专家组名单
+});
+file.index({ id: 1 });
+
+// 成果评价申请表
+const apply = {
+  user_id: { type: ObjectId }, // 关联用户
+  status: { type: String, default: '0' }, // 状态
+  // 1=>初审通过(待评分);-1=>初审失败
+  // 2=>评分通过(待缴费);-2=>评分失败
+  // 3=>已缴费(状态)
+  // 4=>补充资料
+  // 5=>会审通过;-5=>会审失败(不能改了,没机会了)
+  // 6=>证书发放
+  basic: { type: basic },
+  brief: { type: brief },
+  research: { type: [ research ] },
+  datalist: { type: datalist },
+  file: { type: file, default: {} }, // 上传文件
+  remark: { type: String, maxLength: 200 },
+  create_time: { type: String, default: moment().format('YYYY-MM-DD HH:mm:ss') },
+};
+const schema = new Schema(apply, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ user_id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Apply', schema, 'apply');
+};

+ 43 - 0
app/model/expert.js

@@ -0,0 +1,43 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
+const { ObjectId } = require('mongoose').Types;
+// 专家表
+const expert = {
+  name: { type: String, required: true }, // 用户名
+  phone: { type: String, required: false, maxLength: 200 }, // 电话号码
+  password: { type: Secret, required: true, select: false }, // 登录密码
+  card: { type: String, required: false, maxLength: 200 }, // 身份证号
+  birth: { type: String, required: false, maxLength: 500 }, // 出生日期
+  qqwx: { type: String, required: false, maxLength: 500 }, // qq&微信
+  email: { type: String, required: false, maxLength: 500 }, // 邮箱
+  zwzc: { type: String, required: false, maxLength: 500 }, // 职务职称
+  education: { type: String, required: false, maxLength: 500 }, // 最高学历
+  school: { type: String, required: false, maxLength: 500 }, // 毕业院校
+  major: { type: String, required: false, maxLength: 200 }, // 专业
+  company: { type: String, required: false, maxLength: 500 }, // 单位名称
+  icon: { type: Array, required: false }, // 头像图片
+  expertise: { type: String, required: false, maxLength: 500 }, // 擅长领域
+  workexperience: { type: String, required: false, maxLength: 500 }, // 工作经历
+  scientific: { type: String, required: false, maxLength: 500 }, // 科研综述
+  undertakingproject: { type: String, required: false, maxLength: 500 }, // 承担项目
+  scienceaward: { type: String, required: false, maxLength: 500 }, // 科技奖励
+  social: { type: String, required: false, maxLength: 500 }, // 社会任职
+  status: { type: String, required: false, default: '0', maxLength: 500 }, // 审核状态,0-注册,1-通过,2-拒绝
+  remark: { type: String, maxLength: 200 },
+};
+const schema = new Schema(expert, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ name: 1 });
+schema.index({ phone: 1 });
+schema.index({ card: 1 });
+schema.index({ education: 1 });
+schema.index({ status: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Expert', schema, 'expert');
+};

+ 23 - 0
app/model/review_expert.js

@@ -0,0 +1,23 @@
+'use strict';
+const Schema = require('mongoose').Schema;
+const moment = require('moment');
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
+const { ObjectId } = require('mongoose').Types;
+// 评审专家表
+const review_expert = {
+  expert_id: { type: String, required: false }, // 专家id
+  apply_id: { type: String, required: false }, // 成果申请id
+  verify: { type: Object }, // 评审详情:分数:score;意见:content
+  type: { type: String }, // 工作类型:1=>评分;2=>会审
+  remark: { type: String },
+};
+const schema = new Schema(review_expert, { toJSON: { virtuals: true } });
+schema.index({ id: 1 });
+schema.index({ expert_id: 1 });
+schema.index({ apply_id: 1 });
+schema.index({ 'meta.createdAt': 1 });
+schema.plugin(metaPlugin);
+module.exports = app => {
+  const { mongoose } = app;
+  return mongoose.model('Review_expert', schema, 'review_expert');
+};

+ 11 - 9
app/model/user.js

@@ -5,24 +5,26 @@ const { ObjectId } = require('mongoose').Types;
 const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
 // 用户表(分站模式)
 const user = {
+  name: { type: String, required: false }, // 名称
   phone: { type: String, required: false }, // 手机号
   password: { type: Secret, select: false }, // 密码
-  type: { type: String, required: false }, // 用户类型
-  icon: { type: Array, required: false }, // 头像
-  nickname: { type: String, required: false }, // 昵称
-  gender: { type: String, required: false }, // 性别
-  work: { type: String, required: false }, // 岗位
+  card: { type: String, required: false }, // 身份证
   email: { type: String, required: false }, // 邮箱
+  addr: { type: Array, required: false }, // 地址
+  school: { type: String, required: false }, // 院系
+  major: { type: String, required: false }, // 专业
+  zwzc: { type: String, required: false }, // 职务职称
+  office_phone: { type: String, required: false }, // 办公电话
+  profession: { type: String, required: false }, // 所属行业
   status: { type: String, required: false, default: '0' }, // 状态,0-待审,1:审核通过,2:审核拒绝
-  // account: { type: String, required: false }, // 账号
-  // uid: { type: String }, // 关联id,与各自业务有关的用户id
   remark: { type: String },
 };
 const schema = new Schema(user, { 'multi-tenancy': true, toJSON: { virtuals: true } });
 schema.index({ id: 1 });
 schema.index({ phone: 1 });
-schema.index({ type: 1 });
-schema.index({ gender: 1 });
+schema.index({ card: 1 });
+schema.index({ major: 1 });
+schema.index({ school: 1 });
 schema.index({ status: 1 });
 schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);

+ 6 - 2
app/router.js

@@ -6,8 +6,12 @@
 module.exports = app => {
   const { router, controller } = app;
   router.get('/', controller.home.index);
-  router.post('/courtAdmin/api/admin/login', controller.home.login);
-  router.get('/courtAdmin/api/useradmin', controller.admin.index);
+  // router.post('/courtAdmin/api/admin/login', controller.home.login);
+  // router.get('/courtAdmin/api/useradmin', controller.admin.index);
   require('./z_router/menu')(app); // 菜单
   require('./z_router/user')(app); // 用户
+  require('./z_router/admin')(app); // 管理员
+  require('./z_router/apply')(app); // 申报
+  require('./z_router/expert')(app); // 专家
+  require('./z_router/review_expert')(app); // 专家评审
 };

+ 26 - 0
app/service/admin.js

@@ -10,6 +10,32 @@ class AdminService extends CrudService {
     super(ctx, 'admin');
     this.model = this.ctx.model.Admin;
   }
+  /**
+   * 登陆
+   * @param {Object} body 登陆参数
+   */
+  async login({ phone, password }) {
+    let user = await this.model.findOne({ phone }, '+password');
+    if (!user) throw new BusinessError(ErrorCode.USER_NOT_EXIST);
+    const { password: upwd, status } = user;
+    if (status !== '1') throw new BusinessError(ErrorCode.USER_NOT_BIND, '该账号处于禁止使用状态');
+    if (password !== upwd.secret) throw new BusinessError(ErrorCode.BAD_PASSWORD);
+    user = JSON.parse(JSON.stringify(user));
+    delete user.meta;
+    delete user.__v;
+    delete user.password;
+    // 用户信息toekn解密。小程序不适用
+    const token = this.ctx.service.util.jwt.encrypt(user);
+    return token;
+    // return user;
+  }
+  // 修改密码
+  async updatePwd({ id }, { password }) {
+    const data = await this.model.findById(id);
+    if (!data) throw new BusinessError(ErrorCode.USER_NOT_EXIST);
+    data.password = { secret: password };
+    await data.save();
+  }
 }
 
 module.exports = AdminService;

+ 15 - 0
app/service/apply.js

@@ -0,0 +1,15 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 申报
+class ApplyService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'apply');
+    this.model = this.ctx.model.Apply;
+  }
+}
+
+module.exports = ApplyService;

+ 42 - 0
app/service/expert.js

@@ -0,0 +1,42 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 专家
+class ExpertService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'expert');
+    this.model = this.ctx.model.Expert;
+  }
+
+  /**
+   * 登陆
+   * @param {Object} body 登陆参数
+   */
+  async login({ phone, password }) {
+    let user = await this.model.findOne({ phone }, '+password');
+    if (!user) throw new BusinessError(ErrorCode.USER_NOT_EXIST);
+    const { password: upwd, status } = user;
+    if (status !== '1') throw new BusinessError(ErrorCode.USER_NOT_BIND, '该账号处于禁止使用状态');
+    if (password !== upwd.secret) throw new BusinessError(ErrorCode.BAD_PASSWORD);
+    user = JSON.parse(JSON.stringify(user));
+    delete user.meta;
+    delete user.__v;
+    delete user.password;
+    // 用户信息toekn解密。小程序不适用
+    const token = this.ctx.service.util.jwt.encrypt(user);
+    return token;
+    // return user;
+  }
+  // 修改密码
+  async updatePwd({ id }, { password }) {
+    const data = await this.model.findById(id);
+    if (!data) throw new BusinessError(ErrorCode.USER_NOT_EXIST);
+    data.password = { secret: password };
+    await data.save();
+  }
+}
+
+module.exports = ExpertService;

+ 15 - 0
app/service/review_expert.js

@@ -0,0 +1,15 @@
+'use strict';
+const { CrudService } = require('naf-framework-mongoose-free/lib/service');
+const { BusinessError, ErrorCode } = require('naf-core').Error;
+const _ = require('lodash');
+const assert = require('assert');
+
+// 专家评审
+class Review_expertService extends CrudService {
+  constructor(ctx) {
+    super(ctx, 'review_expert');
+    this.model = this.ctx.model.ReviewExpert;
+  }
+}
+
+module.exports = Review_expertService;

+ 3 - 2
app/service/user.js

@@ -27,8 +27,9 @@ class UserService extends CrudService {
     delete user.__v;
     delete user.password;
     // 用户信息toekn解密。小程序不适用
-    // const token = this.ctx.service.util.jwt.encrypt(user);
-    return user;
+    const token = this.ctx.service.util.jwt.encrypt(user);
+    return token;
+    // return user;
   }
   // 修改密码
   async updatePwd({ id }, { password }) {

+ 30 - 0
app/z_router/admin.js

@@ -0,0 +1,30 @@
+'use strict';
+// 路由配置
+const rkey = 'admin';
+const ckey = 'admin';
+const keyZh = '管理员';
+const routes = [
+  { method: 'post', path: `${rkey}/login`, controller: `${ckey}.login`, name: `${ckey}Login`, zh: `${keyZh}登陆` },
+  { method: 'post', path: `${rkey}/updatePwd/:id`, controller: `${ckey}.updatePwd`, name: `${ckey}UpdatePwd`, zh: `修改密码${keyZh}` },
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  const { router, config } = app;
+  const mwares = app.middleware;
+  for (const route of routes) {
+    const { method, path, controller: ctl, zh } = route;
+    let { middleware = [] } = route;
+    if (!method || !path || !ctl) continue;
+    // 拼全路径
+    const allPath = `${config.routePrefix}/${path}`;
+    // 处理中间件
+    if (middleware.length > 0) middleware = middleware.map(i => mwares[i]({ enable: true }));
+    // 注册路由
+    router[method](zh, allPath, ...middleware, ctl);
+  }
+};

+ 28 - 0
app/z_router/apply.js

@@ -0,0 +1,28 @@
+'use strict';
+// 路由配置
+const rkey = 'apply';
+const ckey = 'apply';
+const keyZh = '申报';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  const { router, config } = app;
+  const mwares = app.middleware;
+  for (const route of routes) {
+    const { method, path, controller: ctl, zh } = route;
+    let { middleware = [] } = route;
+    if (!method || !path || !ctl) continue;
+    // 拼全路径
+    const allPath = `${config.routePrefix}/${path}`;
+    // 处理中间件
+    if (middleware.length > 0) middleware = middleware.map(i => mwares[i]({ enable: true }));
+    // 注册路由
+    router[method](zh, allPath, ...middleware, ctl);
+  }
+};

+ 30 - 0
app/z_router/expert.js

@@ -0,0 +1,30 @@
+'use strict';
+// 路由配置
+const rkey = 'expert';
+const ckey = 'expert';
+const keyZh = '专家';
+const routes = [
+  { method: 'post', path: `${rkey}/login`, controller: `${ckey}.login`, name: `${ckey}Login`, zh: `${keyZh}登陆` },
+  { method: 'post', path: `${rkey}/updatePwd/:id`, controller: `${ckey}.updatePwd`, name: `${ckey}UpdatePwd`, zh: `修改密码${keyZh}` },
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, middleware: [ 'password' ], name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  const { router, config } = app;
+  const mwares = app.middleware;
+  for (const route of routes) {
+    const { method, path, controller: ctl, zh } = route;
+    let { middleware = [] } = route;
+    if (!method || !path || !ctl) continue;
+    // 拼全路径
+    const allPath = `${config.routePrefix}/${path}`;
+    // 处理中间件
+    if (middleware.length > 0) middleware = middleware.map(i => mwares[i]({ enable: true }));
+    // 注册路由
+    router[method](zh, allPath, ...middleware, ctl);
+  }
+};

+ 28 - 0
app/z_router/review_expert.js

@@ -0,0 +1,28 @@
+'use strict';
+// 路由配置
+const rkey = 'reviewExpert';
+const ckey = 'reviewExpert';
+const keyZh = '专家评审';
+const routes = [
+  { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
+  { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
+  { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, name: `${ckey}Create`, zh: `创建${keyZh}` },
+  { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
+  { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
+];
+
+module.exports = app => {
+  const { router, config } = app;
+  const mwares = app.middleware;
+  for (const route of routes) {
+    const { method, path, controller: ctl, zh } = route;
+    let { middleware = [] } = route;
+    if (!method || !path || !ctl) continue;
+    // 拼全路径
+    const allPath = `${config.routePrefix}/${path}`;
+    // 处理中间件
+    if (middleware.length > 0) middleware = middleware.map(i => mwares[i]({ enable: true }));
+    // 注册路由
+    router[method](zh, allPath, ...middleware, ctl);
+  }
+};

+ 1 - 1
package.json

@@ -13,7 +13,7 @@
     "egg-scripts": "^2.11.0",
     "lodash": "^4.17.21",
     "moment": "^2.29.1",
-    "naf-framework-mongoose-free": "^0.0.15"
+    "naf-framework-mongoose-free": "^0.0.18"
   },
   "devDependencies": {
     "autod": "^3.0.1",