|
@@ -16,7 +16,28 @@ class ExpertService extends CrudService {
|
|
|
|
|
|
async update({ id }, data) {
|
|
async update({ id }, data) {
|
|
const expert = await this.model.findById(id);
|
|
const expert = await this.model.findById(id);
|
|
- const { name, gender, id_number, phone, address, birthday, email, img_url, level, levelname, position, school, education, degree, major, profession, resume, project, academic, status } = data;
|
|
|
|
|
|
+ const {
|
|
|
|
+ name,
|
|
|
|
+ gender,
|
|
|
|
+ id_number,
|
|
|
|
+ phone,
|
|
|
|
+ address,
|
|
|
|
+ birthday,
|
|
|
|
+ email,
|
|
|
|
+ img_url,
|
|
|
|
+ level,
|
|
|
|
+ levelname,
|
|
|
|
+ position,
|
|
|
|
+ school,
|
|
|
|
+ education,
|
|
|
|
+ degree,
|
|
|
|
+ major,
|
|
|
|
+ profession,
|
|
|
|
+ resume,
|
|
|
|
+ project,
|
|
|
|
+ academic,
|
|
|
|
+ status,
|
|
|
|
+ } = data;
|
|
const user = (await this.umodel.find({ userid: id }))[0];
|
|
const user = (await this.umodel.find({ userid: id }))[0];
|
|
|
|
|
|
if (name) {
|
|
if (name) {
|
|
@@ -29,7 +50,10 @@ class ExpertService extends CrudService {
|
|
}
|
|
}
|
|
if (phone) {
|
|
if (phone) {
|
|
const _user = await this.umodel.find({ phone });
|
|
const _user = await this.umodel.find({ phone });
|
|
- if (_.isEqual(_user.length, 0) || (_.isEqual(_user.length, 1) && _.isEqual(_user[0].id, user.id))) {
|
|
|
|
|
|
+ if (
|
|
|
|
+ _.isEqual(_user.length, 0) ||
|
|
|
|
+ (_.isEqual(_user.length, 1) && _.isEqual(_user[0].id, user.id))
|
|
|
|
+ ) {
|
|
user.phone = phone;
|
|
user.phone = phone;
|
|
expert.phone = phone;
|
|
expert.phone = phone;
|
|
await user.save();
|
|
await user.save();
|
|
@@ -93,6 +117,10 @@ class ExpertService extends CrudService {
|
|
return res;
|
|
return res;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async delete({ id }) {
|
|
|
|
+ await this.model.findByIdAndDelete(id);
|
|
|
|
+ await this.umodel.findOneAndDelete({ userid: id });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = ExpertService;
|
|
module.exports = ExpertService;
|