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() {
this.registryAfterActionHook('group.joinGroup', 'joinGroupCallback'); // not work
this.registryAfterActionHook('group.joinGroup', 'joinGroupCallback');
this.registerAction('joinGroupCallback', this.joinGroupCallback, {
params: {

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