|
@@ -51,7 +51,7 @@ class PersonalService extends CrudService {
|
|
const { secret } = op;
|
|
const { secret } = op;
|
|
if (status !== '1') throw new BusinessError(ErrorCode.ACCESS_DENIED, '拒绝访问!');
|
|
if (status !== '1') throw new BusinessError(ErrorCode.ACCESS_DENIED, '拒绝访问!');
|
|
if (secret !== password) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
|
|
if (secret !== password) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
|
|
- const data = _.omit(JSON.parse(JSON.stringify(object)), ['meta', 'password', '__v']);
|
|
|
|
|
|
+ const data = _.omit(JSON.parse(JSON.stringify(object)), [ 'meta', 'password', '__v' ]);
|
|
const { secret: secrets } = this.config.jwt;
|
|
const { secret: secrets } = this.config.jwt;
|
|
const token = jwt.sign(data, secrets);
|
|
const token = jwt.sign(data, secrets);
|
|
// 记录登陆
|
|
// 记录登陆
|
|
@@ -76,7 +76,7 @@ class PersonalService extends CrudService {
|
|
assert(id, '缺少个人用户ID');
|
|
assert(id, '缺少个人用户ID');
|
|
const user = await this.model.findOne({ _id: ObjectId(id) }, '+password');
|
|
const user = await this.model.findOne({ _id: ObjectId(id) }, '+password');
|
|
if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
|
|
if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户的信息');
|
|
- data = _.omit(data, ['meta', '__v']);
|
|
|
|
|
|
+ data = _.omit(data, [ 'meta', '__v' ]);
|
|
data.user_id = id;
|
|
data.user_id = id;
|
|
// 创建专家
|
|
// 创建专家
|
|
const is_expert = await this.ctx.model.Expert.count({ user_id: ObjectId(id) });
|
|
const is_expert = await this.ctx.model.Expert.count({ user_id: ObjectId(id) });
|
|
@@ -88,7 +88,7 @@ class PersonalService extends CrudService {
|
|
|
|
|
|
async import({ uri }) {
|
|
async import({ uri }) {
|
|
assert(uri, '未获取到文件地址');
|
|
assert(uri, '未获取到文件地址');
|
|
- let domain = 'http://127.0.0.1';
|
|
|
|
|
|
+ const domain = 'http://127.0.0.1';
|
|
const file = await this.ctx.curl(`${domain}${uri}`);
|
|
const file = await this.ctx.curl(`${domain}${uri}`);
|
|
if (!(file && file.data)) {
|
|
if (!(file && file.data)) {
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定文件');
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到指定文件');
|
|
@@ -102,11 +102,11 @@ class PersonalService extends CrudService {
|
|
for (let i = 0; i < head.length; i++) {
|
|
for (let i = 0; i < head.length; i++) {
|
|
const e = head[i];
|
|
const e = head[i];
|
|
if (!e) continue;
|
|
if (!e) continue;
|
|
- const r = meta.find((f) => f.column === e);
|
|
|
|
|
|
+ const r = meta.find(f => f.column === e);
|
|
if (r) r.index = i;
|
|
if (r) r.index = i;
|
|
}
|
|
}
|
|
// 过滤出列表中不必要且不存在的字段
|
|
// 过滤出列表中不必要且不存在的字段
|
|
- meta = meta.filter((f) => f.required || f.index);
|
|
|
|
|
|
+ meta = meta.filter(f => f.required || f.index);
|
|
const errorList = [];
|
|
const errorList = [];
|
|
const dataList = [];
|
|
const dataList = [];
|
|
sheet.eachRow(async (row, index) => {
|
|
sheet.eachRow(async (row, index) => {
|
|
@@ -145,7 +145,7 @@ class PersonalService extends CrudService {
|
|
{ required: true, column: '手机号', key: 'phone' },
|
|
{ required: true, column: '手机号', key: 'phone' },
|
|
{ required: true, column: '登录密码', key: 'password' },
|
|
{ required: true, column: '登录密码', key: 'password' },
|
|
{ required: true, column: '邀请码', key: 'code' },
|
|
{ required: true, column: '邀请码', key: 'code' },
|
|
- { required: true, column: '身份证号', key: 'card' },
|
|
|
|
|
|
+ { column: '身份证号', key: 'card' },
|
|
{ column: '电子邮箱', key: 'email' },
|
|
{ column: '电子邮箱', key: 'email' },
|
|
{ column: '联系地址', key: 'addr' },
|
|
{ column: '联系地址', key: 'addr' },
|
|
{ column: '办公电话', key: 'office_phone' },
|
|
{ column: '办公电话', key: 'office_phone' },
|
|
@@ -186,7 +186,7 @@ class PersonalService extends CrudService {
|
|
const workbook = new Excel.stream.xlsx.WorkbookWriter(options);
|
|
const workbook = new Excel.stream.xlsx.WorkbookWriter(options);
|
|
const sheet = workbook.addWorksheet('sheet');
|
|
const sheet = workbook.addWorksheet('sheet');
|
|
const eMeta = this.exportMeta();
|
|
const eMeta = this.exportMeta();
|
|
- const eColumn = eMeta.map((i) => i.key);
|
|
|
|
|
|
+ const eColumn = eMeta.map(i => i.key);
|
|
let needDeal = eMeta.map((i, index) => {
|
|
let needDeal = eMeta.map((i, index) => {
|
|
if (_.isFunction(_.get(i, 'method'))) {
|
|
if (_.isFunction(_.get(i, 'method'))) {
|
|
i.index = index;
|
|
i.index = index;
|
|
@@ -196,7 +196,7 @@ class PersonalService extends CrudService {
|
|
needDeal = _.compact(needDeal);
|
|
needDeal = _.compact(needDeal);
|
|
for (let i = 1; i <= times; i++) {
|
|
for (let i = 1; i <= times; i++) {
|
|
if (i === 1) {
|
|
if (i === 1) {
|
|
- const head = eMeta.map((i) => i.zh);
|
|
|
|
|
|
+ const head = eMeta.map(i => i.zh);
|
|
sheet.addRow(head).commit();
|
|
sheet.addRow(head).commit();
|
|
}
|
|
}
|
|
const data = await this.model.find({ isdel: 0 }, '+password').skip(skip).limit(limit);
|
|
const data = await this.model.find({ isdel: 0 }, '+password').skip(skip).limit(limit);
|
|
@@ -221,7 +221,7 @@ class PersonalService extends CrudService {
|
|
return [
|
|
return [
|
|
{ key: 'name', zh: '用户名' },
|
|
{ key: 'name', zh: '用户名' },
|
|
{ key: 'phone', zh: '手机号' },
|
|
{ key: 'phone', zh: '手机号' },
|
|
- { key: 'password', zh: '登录密码', method: (i) => _.get(i, 'secret') },
|
|
|
|
|
|
+ { key: 'password', zh: '登录密码', method: i => _.get(i, 'secret') },
|
|
{ key: 'code', zh: '邀请码' },
|
|
{ key: 'code', zh: '邀请码' },
|
|
{ key: 'card', zh: '身份证号' },
|
|
{ key: 'card', zh: '身份证号' },
|
|
{ key: 'email', zh: '邮箱' },
|
|
{ key: 'email', zh: '邮箱' },
|