|
@@ -11,18 +11,35 @@ class ChatService extends CrudService {
|
|
|
super(ctx, 'dock');
|
|
|
this.model = this.ctx.model.Dock;
|
|
|
}
|
|
|
- // async create(query, { sender_id, sender_name, content }) {
|
|
|
- // assert(sender_name, '缺少发言人信息');
|
|
|
- // assert(content, '缺少发言内容');
|
|
|
- // const send_time = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
|
- // const res = await this.model.create({
|
|
|
- // sender_id,
|
|
|
- // sender_name,
|
|
|
- // content,
|
|
|
- // send_time,
|
|
|
- // });
|
|
|
- // return res;
|
|
|
- // }
|
|
|
+ async create(body) {
|
|
|
+ const res = await this.model.create(body);
|
|
|
+ if (res) {
|
|
|
+ const url = this.ctx.app.config.axios.auth.baseUrl;
|
|
|
+ const newdata = {
|
|
|
+ name: body.adminuser,
|
|
|
+ phone: body.phone,
|
|
|
+ passwd: body.passwd,
|
|
|
+ uid: res.id,
|
|
|
+ role: '4',
|
|
|
+ pid: body.pid,
|
|
|
+ code: body.code,
|
|
|
+ };
|
|
|
+ const user = await this.ctx.curl(url, {
|
|
|
+ method: 'post',
|
|
|
+ headers: {
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ },
|
|
|
+ dataType: 'json',
|
|
|
+ data: JSON.stringify(newdata),
|
|
|
+ });
|
|
|
+ if (user.data.errcode === 0) {
|
|
|
+ const result = await this.model.findById(res.id);
|
|
|
+ result.u_id = user.data.data.id;
|
|
|
+ result.save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
async apply({ id }, body) {
|
|
|
const dock = await this.model.findOne({ _id: ObjectId(id) });
|
|
|
if (!dock) {
|