refactor: add group.addMember which replace group.joinGroup

more easy to call
pull/105/merge
moonrailgun 2 years ago
parent e91182c684
commit 3d9efbded0

@ -12,7 +12,7 @@ class WelcomeService extends TcService {
} }
onInit() { onInit() {
this.registryAfterActionHook('group.joinGroup', 'joinGroupCallback'); // not work this.registryAfterActionHook('group.joinGroup', 'joinGroupCallback');
this.registerAction('joinGroupCallback', this.joinGroupCallback, { this.registerAction('joinGroupCallback', this.joinGroupCallback, {
params: { params: {

@ -84,6 +84,13 @@ class GroupService extends TcService {
groupId: 'string', groupId: 'string',
}, },
}); });
this.registerAction('addMember', this.addMember, {
params: {
groupId: 'string',
userId: 'string',
},
visibility: 'public',
});
this.registerAction('joinGroup', this.joinGroup, { this.registerAction('joinGroup', this.joinGroup, {
params: { params: {
groupId: 'string', groupId: 'string',
@ -493,15 +500,15 @@ class GroupService extends TcService {
} }
/** /**
* *
*/ */
async joinGroup( async addMember(
ctx: TcContext<{ ctx: TcContext<{
groupId: string; groupId: string;
userId: string;
}> }>
) { ) {
const groupId = ctx.params.groupId; const { groupId, userId } = ctx.params;
const userId = ctx.meta.userId;
if (!isValidStr(userId)) { if (!isValidStr(userId)) {
throw new EntityError('用户id为空'); throw new EntityError('用户id为空');
@ -550,6 +557,24 @@ class GroupService extends TcService {
return group; return group;
} }
/**
*
* @deprecated 使 addMember
*/
async joinGroup(
ctx: TcContext<{
groupId: string;
}>
) {
const groupId = ctx.params.groupId;
const userId = ctx.meta.userId;
return this.localCall('addMember', {
groupId,
userId,
});
}
/** /**
* 退 * 退
*/ */

Loading…
Cancel
Save