-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
heavyrian2012
committed
Oct 10, 2023
1 parent
7727fad
commit c17a5be
Showing
8 changed files
with
156 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
broker/src/main/java/com/xiaoleilu/loServer/action/admin/GetUserGroupsByTypeAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* This file is part of the Wildfire Chat package. | ||
* (c) Heavyrain2012 <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
package com.xiaoleilu.loServer.action.admin; | ||
|
||
import cn.wildfirechat.common.APIPath; | ||
import cn.wildfirechat.common.ErrorCode; | ||
import cn.wildfirechat.pojos.InputGetUserGroupByType; | ||
import cn.wildfirechat.pojos.InputUserId; | ||
import cn.wildfirechat.pojos.OutputGroupIds; | ||
import com.xiaoleilu.loServer.RestResult; | ||
import com.xiaoleilu.loServer.annotation.HttpMethod; | ||
import com.xiaoleilu.loServer.annotation.Route; | ||
import com.xiaoleilu.loServer.handler.Request; | ||
import com.xiaoleilu.loServer.handler.Response; | ||
import io.netty.handler.codec.http.FullHttpRequest; | ||
import io.netty.util.internal.StringUtil; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Set; | ||
|
||
@Route(APIPath.Get_User_Groups_By_Type) | ||
@HttpMethod("POST") | ||
public class GetUserGroupsByTypeAction extends AdminAction { | ||
|
||
@Override | ||
public boolean isTransactionAction() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean action(Request request, Response response) { | ||
if (request.getNettyRequest() instanceof FullHttpRequest) { | ||
InputGetUserGroupByType input = getRequestBody(request.getNettyRequest(), InputGetUserGroupByType.class); | ||
if (input != null | ||
&& (!StringUtil.isNullOrEmpty(input.getUserId()))) { | ||
|
||
Set<String> groupIds = messagesStore.getUserGroupIds(input.getUserId(), input.getGroupMemberTypes()); | ||
OutputGroupIds outputGroupIds = new OutputGroupIds(); | ||
outputGroupIds.setGroupIds(new ArrayList<>(groupIds)); | ||
RestResult result = RestResult.ok(outputGroupIds); | ||
setResponseContent(result, response); | ||
} else { | ||
setResponseContent(RestResult.resultOf(ErrorCode.INVALID_PARAMETER), response); | ||
} | ||
|
||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
common/src/main/java/cn/wildfirechat/pojos/InputGetUserGroupByType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This file is part of the Wildfire Chat package. | ||
* (c) Heavyrain2012 <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
package cn.wildfirechat.pojos; | ||
|
||
import java.util.List; | ||
|
||
public class InputGetUserGroupByType { | ||
private String userId; | ||
private List<Integer> groupMemberTypes; | ||
|
||
public InputGetUserGroupByType() { | ||
} | ||
|
||
public InputGetUserGroupByType(String userId, List<Integer> groupMemberTypes) { | ||
this.userId = userId; | ||
this.groupMemberTypes = groupMemberTypes; | ||
} | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public void setUserId(String userId) { | ||
this.userId = userId; | ||
} | ||
|
||
public List<Integer> getGroupMemberTypes() { | ||
return groupMemberTypes; | ||
} | ||
|
||
public void setGroupMemberTypes(List<Integer> groupMemberTypes) { | ||
this.groupMemberTypes = groupMemberTypes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters