|
@@ -36,14 +36,30 @@ class Achieve_expertService extends CrudService {
|
|
|
return await this.model.findById(id);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 冻结账号
|
|
|
+ * @param {Object} id 数据id
|
|
|
+ */
|
|
|
+ async delete({ id }) {
|
|
|
+ await this.model.updateOne({ _id: id }, { status: '1' });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解冻账号
|
|
|
+ * @param {Object} id 数据id
|
|
|
+ */
|
|
|
+ async restore({ id }) {
|
|
|
+ await this.model.updateOne({ _id: id }, { status: '0' });
|
|
|
+ }
|
|
|
/**
|
|
|
* 临时专家账号登录
|
|
|
* @param {Object} params 手机号,密码
|
|
|
*/
|
|
|
async login({ phone, password }) {
|
|
|
- const expert = await this.model.findOne({ phone, status: '0' }, '+password');
|
|
|
- if (!expert) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '您不存在未完成的工作,无需登录');
|
|
|
- const { password: op } = expert;
|
|
|
+ const expert = await this.model.findOne({ phone }, '+password');
|
|
|
+ if (!expert) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到您的临时账号,如有疑问,请联系管理员');
|
|
|
+ const { password: op, status } = expert;
|
|
|
+ if (status !== '0') throw new BusinessError(ErrorCode.ACCESS_DENIED, '您的临时账号已被注销,如有疑问,请联系管理员');
|
|
|
const { secret } = op;
|
|
|
if (secret !== password) throw new BusinessError(ErrorCode.BAD_PASSWORD, '密码错误');
|
|
|
const data = _.omit(JSON.parse(JSON.stringify(expert)), [ 'expert_name', 'meta', 'password', '__v', 'verify' ]);
|