|
@@ -21,6 +21,29 @@ class LookuserService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async update({ id }, data) {
|
|
|
+ const { switchrole } = data;
|
|
|
+ const lookuser = await this.model.findById(id);
|
|
|
+ if (!lookuser) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST);
|
|
|
+ }
|
|
|
+ lookuser.switchrole = switchrole;
|
|
|
+ const res = await lookuser.save();
|
|
|
+ if (res) {
|
|
|
+ const { mq } = this.ctx;
|
|
|
+ if (mq) {
|
|
|
+ const exchange = 'switch_role_' + res.userid;
|
|
|
+ const parm = {
|
|
|
+ durable: true,
|
|
|
+ headers: {
|
|
|
+ userid: res.userid,
|
|
|
+ } };
|
|
|
+ await mq.fanout(exchange, res.userid, JSON.stringify(res), parm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
async roomcount(data) {
|
|
|
const { roomname } = data;
|
|
|
const total = await this.model.count({ roomname });
|