|
@@ -9,7 +9,7 @@ const jwt = require('jsonwebtoken');
|
|
|
|
|
|
class UserService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
- super(ctx, "user");
|
|
|
+ super(ctx, 'user');
|
|
|
this.model = this.ctx.model.User;
|
|
|
this.rmodel = this.ctx.model.Role;
|
|
|
}
|
|
@@ -18,8 +18,8 @@ class UserService extends CrudService {
|
|
|
async create(data) {
|
|
|
const { name, phone, passwd } = data;
|
|
|
console.log(data);
|
|
|
- assert(name && phone && passwd, "缺少部分信息项");
|
|
|
- assert(/^\d{11}$/i.test(phone), "phone无效");
|
|
|
+ assert(name && phone && passwd, '缺少部分信息项');
|
|
|
+ assert(/^\d{11}$/i.test(phone), 'phone无效');
|
|
|
// const user = await this.model.findOne({ phone });
|
|
|
// if (user) {
|
|
|
// throw new BusinessError(ErrorCode.DATA_EXISTED);
|
|
@@ -53,7 +53,7 @@ class UserService extends CrudService {
|
|
|
deptname,
|
|
|
pid,
|
|
|
} = data;
|
|
|
- const user = await this.model.findById(id, "+passwd");
|
|
|
+ const user = await this.model.findById(id, '+passwd');
|
|
|
if (name) {
|
|
|
user.name = name;
|
|
|
}
|
|
@@ -94,9 +94,9 @@ class UserService extends CrudService {
|
|
|
// 用户修改密码
|
|
|
async uppasswd(data) {
|
|
|
const { id, oldpasswd, newpasswd } = data;
|
|
|
- assert(id && oldpasswd && newpasswd, "缺少部分信息项");
|
|
|
+ assert(id && oldpasswd && newpasswd, '缺少部分信息项');
|
|
|
// 根据用户id查询其他用户表中是否存在相应数据
|
|
|
- const user = await this.model.findById(id, "+passwd");
|
|
|
+ const user = await this.model.findById(id, '+passwd');
|
|
|
// 如果用户不存在抛出异常
|
|
|
if (!user) {
|
|
|
throw new BusinessError(ErrorCode.USER_NOT_EXIST);
|
|
@@ -155,7 +155,7 @@ class UserService extends CrudService {
|
|
|
async finduserlist({ skip, limit, ...info }) {
|
|
|
const query = {
|
|
|
...info,
|
|
|
- $or: [{ role: "4" }, { role: "5" }, { role: "6" }],
|
|
|
+ $or: [{ role: '4' }, { role: '5' }, { role: '6' }],
|
|
|
};
|
|
|
const total = await this.model.count(query);
|
|
|
const data = await this.model
|
|
@@ -166,7 +166,7 @@ class UserService extends CrudService {
|
|
|
}
|
|
|
async businessuser({ pid, skip, limit }) {
|
|
|
const query = { code: { $regex: /^.{9}$/ } };
|
|
|
- pid ? (query.pid = pid) : "";
|
|
|
+ pid ? (query.pid = pid) : '';
|
|
|
const total = await this.model.count(query);
|
|
|
const data = await this.model
|
|
|
.find(query)
|