Skip to content

Commit eced63e

Browse files
committed
fix: 修复匿名群聊相关bug
1 parent b8603f6 commit eced63e

File tree

17 files changed

+213
-28
lines changed

17 files changed

+213
-28
lines changed

docs/db/db.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,8 @@ ALTER TABLE `im_user`
8383
ADD COLUMN `account_type` int NULL DEFAULT 0 COMMENT '账号类型:0正常,1匿名' AFTER `oauth_src`,
8484
ADD COLUMN `anonymou_id` varchar(255) NULL COMMENT '匿名id' AFTER `account_type`;
8585

86-
INSERT INTO `im_group` (`id`, `name`, `owner_id`, `head_image`, `head_image_thumb`, `notice`, `remark`, `deleted`, `created_time`) VALUES (0, '万人大群聊', 1, '', '', '', '', 0, '2023-06-17 11:43:40');
86+
ALTER TABLE `im_group`
87+
ADD COLUMN `group_type` int NULL DEFAULT 0 COMMENT '群类型:0正常,1匿名群';
88+
89+
INSERT INTO `im_group` (`id`, `name`, `owner_id`, `head_image`, `head_image_thumb`, `notice`, `remark`, `deleted`, `created_time`,`group_type`) VALUES (0, '万人大群聊', 1, '', '', '', '', 0, '2023-06-17 11:43:40',1);
90+

im-commom/im-common-log/src/main/java/io/pisceshub/muchat/common/log/aop/ApiLogAspect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private TPair<String, String> buildApiInfo(ProceedingJoinPoint joinPoint) throws
9494
Method targetMethod = joinPoint.getTarget().getClass().getDeclaredMethod(methodSignature.getName(),
9595
methodSignature.getMethod().getParameterTypes());
9696
ApiOperation apiOperation = targetMethod.getAnnotation(ApiOperation.class);
97-
if(apiAnnotation!=null){
97+
if(apiOperation!=null){
9898
apiName = apiOperation.value();
9999
}
100100
return new TPair<>(moduleName,apiName);

im-server/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,24 @@
150150

151151
<build>
152152
<finalName>${project.artifactId}</finalName>
153+
<resources>
154+
<resource>
155+
<directory>src/main/java</directory>
156+
<includes>
157+
<include>**/*.yml</include>
158+
</includes>
159+
<!--是否替换资源中的属性-->
160+
<filtering>false</filtering>
161+
</resource>
162+
<resource>
163+
<directory>src/main/resources</directory>
164+
<includes>
165+
<include>**/*.*</include>
166+
</includes>
167+
<!--是否替换资源中的属性-->
168+
<filtering>false</filtering>
169+
</resource>
170+
</resources>
153171
<plugins>
154172
<plugin>
155173
<groupId>org.springframework.boot</groupId>

im-server/src/main/java/io/pisceshub/muchat/server/common/entity/Group.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public class Group extends Model<Group> {
7171
@TableField("created_time")
7272
private Date createdTime;
7373

74+
@TableField("group_type")
75+
private Integer groupType;
7476

7577
@Override
7678
protected Serializable pkVal() {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.pisceshub.muchat.server.common.enums;
2+
3+
import lombok.Getter;
4+
5+
6+
public interface GroupEnum {
7+
8+
@Getter
9+
enum GroupType{
10+
Plain(0,"正常"),
11+
Anonymous(1,"匿名"),
12+
;
13+
private Integer code;
14+
15+
private String msg;
16+
17+
GroupType(Integer code,String msg){
18+
this.code = code;
19+
this.msg = msg;
20+
}
21+
22+
}
23+
24+
}

im-server/src/main/java/io/pisceshub/muchat/server/controller/ChatSessionController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.pisceshub.muchat.server.controller;
22

3+
import io.pisceshub.muchat.common.log.annotation.ApiLog;
34
import io.pisceshub.muchat.server.aop.annotation.AnonymousUserCheck;
45
import io.pisceshub.muchat.server.common.vo.user.ChatSessionInfoResp;
56
import io.pisceshub.muchat.server.util.SessionContext;
@@ -42,6 +43,7 @@ public Result<String> save(@RequestBody @Valid ChatSessionAddReq vo){
4243
* 查询聊天会话
4344
* @return
4445
*/
46+
@ApiLog
4547
@GetMapping("/list")
4648
public Result<Set<ChatSessionInfoResp>> pages(){
4749
return iChatSessionService.list();
@@ -53,6 +55,7 @@ public Result<Set<ChatSessionInfoResp>> pages(){
5355
* @param vo
5456
* @return
5557
*/
58+
5659
@AnonymousUserCheck
5760
@DeleteMapping("/del")
5861
public Result<String> del(@RequestBody @Valid ChatSessionAddReq vo){

im-server/src/main/java/io/pisceshub/muchat/server/controller/GroupMessageController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public Result pullUnreadMessage(){
4747
return ResultUtils.success();
4848
}
4949

50+
@ApiLog
5051
@GetMapping("/history")
5152
@ApiOperation(value = "查询聊天记录",notes="查询聊天记录")
5253
public Result<List<GroupMessageInfo>> recallMessage(@NotNull(message = "群聊id不能为空") @RequestParam Long groupId,

im-server/src/main/java/io/pisceshub/muchat/server/mapper/GroupMessageMapper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22

33
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
44
import io.pisceshub.muchat.server.common.entity.GroupMessage;
5+
import org.apache.ibatis.annotations.Param;
6+
7+
import java.util.Date;
8+
import java.util.List;
59

610

711
public interface GroupMessageMapper extends BaseMapper<GroupMessage> {
812

13+
List<GroupMessage> findHistoryMessage(@Param("groupId") Long groupId,
14+
@Param("startTime") Date startTime,
15+
@Param("beforeMessageId") Long beforeMessageId,
16+
@Param("count") Integer count);
917
}

im-server/src/main/java/io/pisceshub/muchat/server/service/IGroupMemberService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.baomidou.mybatisplus.extension.service.IService;
44
import io.pisceshub.muchat.server.common.entity.GroupMember;
5+
import io.pisceshub.muchat.server.common.entity.User;
56

67
import java.util.List;
78

@@ -25,4 +26,8 @@ public interface IGroupMemberService extends IService<GroupMember> {
2526
void removeByGroupId(Long groupId);
2627

2728
void removeByGroupAndUserId(Long groupId,Long userId);
29+
30+
boolean joinGroup(Long groupId, User user);
31+
32+
boolean memberExsit(Long userId, Long targetId);
2833
}

im-server/src/main/java/io/pisceshub/muchat/server/service/IGroupService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.baomidou.mybatisplus.extension.service.IService;
44
import io.pisceshub.muchat.server.common.entity.Group;
5+
import io.pisceshub.muchat.server.common.entity.GroupMember;
56
import io.pisceshub.muchat.server.common.vo.user.GroupInviteReq;
67
import io.pisceshub.muchat.server.common.vo.user.GroupMemberResp;
78
import io.pisceshub.muchat.server.common.vo.user.GroupVO;
@@ -31,4 +32,6 @@ public interface IGroupService extends IService<Group> {
3132
GroupVO findById(Long groupId);
3233

3334
List<GroupMemberResp> findGroupMembers(Long groupId);
35+
36+
List<Group> findByGroupType(Integer code);
3437
}

0 commit comments

Comments
 (0)