|
@@ -12,22 +12,22 @@ class AnswerService extends CrudService {
|
|
|
}
|
|
|
|
|
|
async create(body) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ const { phone, user_id, create_user = true } = body;
|
|
|
+ if (!user_id && phone && create_user) {
|
|
|
+
|
|
|
+
|
|
|
+ let user = await this.ctx.service.util.httpUtil.cpost('/spm', 'live', { model: 'personal', method: 'findOne', query: { phone } }, { method: 'useModel' });
|
|
|
+ if (user) {
|
|
|
+ body.user_id = user._id;
|
|
|
+ delete body.phone;
|
|
|
+ } else {
|
|
|
+ user = await this.ctx.service.util.httpUtil.cpost('/spm', 'live', { service: 'users.personal', method: 'create', body: { phone, name: '个人', code: 'WJDCXT', password: '123456', status: '1' } }, { method: 'useService' });
|
|
|
+ if (user) {
|
|
|
+ body.user_id = user._id;
|
|
|
+ delete body.phone;
|
|
|
+ } else throw new BusinessError(ErrorCode.SERVICE_FAULT, '创建用户失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
const res = await this.model.create(body);
|
|
|
return res;
|
|
|
}
|