Merge pull request #151 from Kkuil/main

feat: 新增撤销管理员与退群功能
This commit is contained in:
zongzibinbin
2023-11-06 21:47:24 +08:00
committed by GitHub
22 changed files with 365 additions and 120 deletions

View File

@@ -2,6 +2,12 @@ package com.abin.mallchat.common.chat.controller;
import com.abin.mallchat.common.chat.domain.vo.request.*;
import com.abin.mallchat.common.chat.domain.vo.request.admin.AdminAddReq;
import com.abin.mallchat.common.chat.domain.vo.request.admin.AdminRevokeReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberAddReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberDelReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberExitReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberReq;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberListResp;
import com.abin.mallchat.common.chat.domain.vo.response.MemberResp;
import com.abin.mallchat.common.chat.service.IGroupMemberService;
@@ -66,6 +72,14 @@ public class RoomController {
return ApiResult.success();
}
@DeleteMapping("/group/member/exit")
@ApiOperation("退出群聊")
public ApiResult<Boolean> exitGroup(@Valid @RequestBody MemberExitReq request) {
Long uid = RequestHolder.get().getUid();
groupMemberService.exitGroup(uid, request);
return ApiResult.success();
}
@PostMapping("/group")
@ApiOperation("新增群组")
public ApiResult<IdRespVO> addGroup(@Valid @RequestBody GroupAddReq request) {
@@ -89,4 +103,12 @@ public class RoomController {
groupMemberService.addAdmin(uid, request);
return ApiResult.success();
}
@DeleteMapping("/group/admin")
@ApiOperation("撤销管理员")
public ApiResult<Boolean> revokeAdmin(@Valid @RequestBody AdminRevokeReq request) {
Long uid = RequestHolder.get().getUid();
groupMemberService.revokeAdmin(uid, request);
return ApiResult.success();
}
}

View File

@@ -6,6 +6,9 @@ import com.abin.mallchat.common.chat.mapper.ContactMapper;
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
import com.abin.mallchat.common.common.utils.CursorUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@@ -33,7 +36,7 @@ public class ContactDao extends ServiceImpl<ContactMapper, Contact> {
public Integer getReadCount(Message message) {
return lambdaQuery()
.eq(Contact::getRoomId, message.getRoomId())
.ne(Contact::getUid, message.getFromUid())//不需要查询出自己
.ne(Contact::getUid, message.getFromUid())// 不需要查询出自己
.ge(Contact::getReadTime, message.getCreateTime())
.count();
}
@@ -54,16 +57,16 @@ public class ContactDao extends ServiceImpl<ContactMapper, Contact> {
public CursorPageBaseResp<Contact> getReadPage(Message message, CursorPageBaseReq cursorPageBaseReq) {
return CursorUtils.getCursorPageByMysql(this, cursorPageBaseReq, wrapper -> {
wrapper.eq(Contact::getRoomId, message.getRoomId());
wrapper.ne(Contact::getUid, message.getFromUid());//不需要查询出自己
wrapper.ge(Contact::getReadTime, message.getCreateTime());//已读时间大于等于消息发送时间
wrapper.ne(Contact::getUid, message.getFromUid());// 不需要查询出自己
wrapper.ge(Contact::getReadTime, message.getCreateTime());// 已读时间大于等于消息发送时间
}, Contact::getReadTime);
}
public CursorPageBaseResp<Contact> getUnReadPage(Message message, CursorPageBaseReq cursorPageBaseReq) {
return CursorUtils.getCursorPageByMysql(this, cursorPageBaseReq, wrapper -> {
wrapper.eq(Contact::getRoomId, message.getRoomId());
wrapper.ne(Contact::getUid, message.getFromUid());//不需要查询出自己
wrapper.lt(Contact::getReadTime, message.getCreateTime());//已读时间小于消息发送时间
wrapper.ne(Contact::getUid, message.getFromUid());// 不需要查询出自己
wrapper.lt(Contact::getReadTime, message.getCreateTime());// 已读时间小于消息发送时间
}, Contact::getReadTime);
}
@@ -89,4 +92,16 @@ public class ContactDao extends ServiceImpl<ContactMapper, Contact> {
public void refreshOrCreateActiveTime(Long roomId, List<Long> memberUidList, Long msgId, Date activeTime) {
baseMapper.refreshOrCreateActiveTime(roomId, memberUidList, msgId, activeTime);
}
/**
* 根据房间ID删除会话
*
* @param roomId 房间ID
* @return 是否删除成功
*/
public Boolean removeByRoomId(Long roomId) {
LambdaQueryWrapper<Contact> wrapper = new QueryWrapper<Contact>().lambda()
.eq(Contact::getRoomId, roomId);
return this.remove(wrapper);
}
}

View File

@@ -1,12 +1,16 @@
package com.abin.mallchat.common.chat.dao;
import cn.hutool.core.util.ObjectUtil;
import com.abin.mallchat.common.chat.domain.entity.Contact;
import com.abin.mallchat.common.chat.domain.entity.GroupMember;
import com.abin.mallchat.common.chat.domain.enums.GroupRoleEnum;
import com.abin.mallchat.common.chat.mapper.GroupMemberMapper;
import com.abin.mallchat.common.chat.service.cache.GroupMemberCache;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
@@ -144,7 +148,7 @@ public class GroupMemberDao extends ServiceImpl<GroupMemberMapper, GroupMember>
/**
* 增加管理员
*
* @param id 群ID
* @param id 群ID
* @param uidList 用户列表
*/
public void addAdmin(Long id, List<Long> uidList) {
@@ -154,4 +158,31 @@ public class GroupMemberDao extends ServiceImpl<GroupMemberMapper, GroupMember>
.set(GroupMember::getRole, GroupRoleEnum.MANAGER.getType());
this.update(wrapper);
}
/**
* 撤销管理员
*
* @param id 群组ID
* @param uidList 用户列表
*/
public void revokeAdmin(Long id, List<Long> uidList) {
LambdaUpdateWrapper<GroupMember> wrapper = new UpdateWrapper<GroupMember>().lambda()
.eq(GroupMember::getGroupId, id)
.in(GroupMember::getUid, uidList)
.set(GroupMember::getRole, GroupRoleEnum.MEMBER.getType());
this.update(wrapper);
}
/**
* 根据群组ID删除群成员
*
* @param groupId 群组ID
* @return 是否删除成功
*/
public Boolean removeByGroupId(Long groupId) {
LambdaQueryWrapper<GroupMember> wrapper = new QueryWrapper<GroupMember>()
.lambda()
.eq(GroupMember::getGroupId, groupId);
return this.remove(wrapper);
}
}

View File

@@ -1,11 +1,16 @@
package com.abin.mallchat.common.chat.dao;
import com.abin.mallchat.common.chat.domain.entity.Contact;
import com.abin.mallchat.common.chat.domain.entity.Message;
import com.abin.mallchat.common.chat.domain.enums.MessageStatusEnum;
import com.abin.mallchat.common.chat.mapper.MessageMapper;
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
import com.abin.mallchat.common.common.utils.CursorUtils;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
@@ -63,4 +68,17 @@ public class MessageDao extends ServiceImpl<MessageMapper, Message> {
.gt(Objects.nonNull(readTime), Message::getCreateTime, readTime)
.count();
}
/**
* 根据房间ID逻辑删除消息
*
* @param roomId 房间ID
* @return 是否删除成功
*/
public Boolean removeByRoomId(Long roomId) {
LambdaUpdateWrapper<Message> wrapper = new UpdateWrapper<Message>().lambda()
.eq(Message::getRoomId, roomId)
.set(Message::getStatus, MessageStatusEnum.DELETE.getStatus());
return this.update(wrapper);
}
}

View File

@@ -1,4 +1,4 @@
package com.abin.mallchat.common.chat.domain.vo.request;
package com.abin.mallchat.common.chat.domain.vo.request.admin;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

View File

@@ -0,0 +1,25 @@
package com.abin.mallchat.common.chat.domain.vo.request.admin;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
/**
* @Author Kkuil
* @Date 2023/10/24 12:46
* @Description 撤销管理员请求信息
*/
@Data
public class AdminRevokeReq {
@NotNull
@ApiModelProperty("房间号")
private Long roomId;
@NotNull
@Size(min = 1, max = 3)
@ApiModelProperty("需要撤销管理的列表")
private List<Long> uidList;
}

View File

@@ -1,4 +1,4 @@
package com.abin.mallchat.common.chat.domain.vo.request;
package com.abin.mallchat.common.chat.domain.vo.request.member;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;

View File

@@ -1,4 +1,4 @@
package com.abin.mallchat.common.chat.domain.vo.request;
package com.abin.mallchat.common.chat.domain.vo.request.member;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;

View File

@@ -0,0 +1,24 @@
package com.abin.mallchat.common.chat.domain.vo.request.member;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
/**
* @Author Kkuil
* @Date 2023/10/30 11:49
* @Description 退出群聊
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class MemberExitReq {
@NotNull
@ApiModelProperty("会话id")
private Long roomId;
}

View File

@@ -1,4 +1,4 @@
package com.abin.mallchat.common.chat.domain.vo.request;
package com.abin.mallchat.common.chat.domain.vo.request.member;
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
import io.swagger.annotations.ApiModelProperty;

View File

@@ -3,11 +3,11 @@ package com.abin.mallchat.common.chat.service;
import com.abin.mallchat.common.chat.domain.dto.MsgReadInfoDTO;
import com.abin.mallchat.common.chat.domain.entity.Message;
import com.abin.mallchat.common.chat.domain.vo.request.*;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberReq;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberListResp;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberStatisticResp;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMessageReadResp;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMessageResp;
import com.abin.mallchat.common.common.domain.vo.request.CursorPageBaseReq;
import com.abin.mallchat.common.common.domain.vo.response.CursorPageBaseResp;
import com.abin.mallchat.common.user.domain.vo.response.ws.ChatMemberResp;

View File

@@ -1,8 +1,8 @@
package com.abin.mallchat.common.chat.service;
import com.abin.mallchat.common.chat.domain.entity.GroupMember;
import com.abin.mallchat.common.chat.domain.vo.request.AdminAddReq;
import com.baomidou.mybatisplus.extension.service.IService;
import com.abin.mallchat.common.chat.domain.vo.request.admin.AdminAddReq;
import com.abin.mallchat.common.chat.domain.vo.request.admin.AdminRevokeReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberExitReq;
/**
* <p>
@@ -20,4 +20,14 @@ public interface IGroupMemberService {
* @param request 请求信息
*/
void addAdmin(Long uid, AdminAddReq request);
/**
* 撤销管理员
*
* @param uid 用户ID
* @param request 请求信息
*/
void revokeAdmin(Long uid, AdminRevokeReq request);
void exitGroup(Long uid, MemberExitReq request);
}

View File

@@ -1,6 +1,9 @@
package com.abin.mallchat.common.chat.service;
import com.abin.mallchat.common.chat.domain.vo.request.*;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberAddReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberDelReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberReq;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberListResp;
import com.abin.mallchat.common.chat.domain.vo.response.ChatRoomResp;
import com.abin.mallchat.common.chat.domain.vo.response.MemberResp;

View File

@@ -11,6 +11,7 @@ import com.abin.mallchat.common.chat.domain.entity.*;
import com.abin.mallchat.common.chat.domain.enums.MessageMarkActTypeEnum;
import com.abin.mallchat.common.chat.domain.enums.MessageTypeEnum;
import com.abin.mallchat.common.chat.domain.vo.request.*;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberReq;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberListResp;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberStatisticResp;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMessageReadResp;
@@ -41,7 +42,6 @@ import com.abin.mallchat.common.user.domain.enums.RoleEnum;
import com.abin.mallchat.common.user.domain.vo.response.ws.ChatMemberResp;
import com.abin.mallchat.common.user.service.IRoleService;
import com.abin.mallchat.common.user.service.cache.UserCache;
import com.abin.mallchat.transaction.service.MQProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -52,7 +52,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**

View File

@@ -1,15 +1,25 @@
package com.abin.mallchat.common.chat.service.impl;
import com.abin.mallchat.common.chat.dao.GroupMemberDao;
import com.abin.mallchat.common.chat.dao.RoomGroupDao;
import com.abin.mallchat.common.chat.dao.*;
import com.abin.mallchat.common.chat.domain.entity.Room;
import com.abin.mallchat.common.chat.domain.entity.RoomGroup;
import com.abin.mallchat.common.chat.domain.vo.request.AdminAddReq;
import com.abin.mallchat.common.chat.domain.vo.request.admin.AdminAddReq;
import com.abin.mallchat.common.chat.domain.vo.request.admin.AdminRevokeReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberExitReq;
import com.abin.mallchat.common.chat.service.IGroupMemberService;
import com.abin.mallchat.common.chat.service.adapter.MemberAdapter;
import com.abin.mallchat.common.chat.service.cache.GroupMemberCache;
import com.abin.mallchat.common.common.exception.CommonErrorEnum;
import com.abin.mallchat.common.common.exception.GroupErrorEnum;
import com.abin.mallchat.common.common.utils.AssertUtil;
import com.abin.mallchat.common.user.domain.enums.WSBaseResp;
import com.abin.mallchat.common.user.domain.vo.response.ws.WSMemberChange;
import com.abin.mallchat.common.user.service.impl.PushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -29,6 +39,21 @@ public class GroupMemberServiceImpl implements IGroupMemberService {
@Autowired
private RoomGroupDao roomGroupDao;
@Autowired
private RoomDao roomDao;
@Autowired
private ContactDao contactDao;
@Autowired
private MessageDao messageDao;
@Autowired
private GroupMemberCache groupMemberCache;
@Autowired
private PushService pushService;
/**
* 增加管理员
*
@@ -60,4 +85,77 @@ public class GroupMemberServiceImpl implements IGroupMemberService {
// 5. 增加管理员
groupMemberDao.addAdmin(roomGroup.getId(), request.getUidList());
}
/**
* 撤销管理员
*
* @param uid 用户ID
* @param request 请求信息
*/
@Override
public void revokeAdmin(Long uid, AdminRevokeReq request) {
// 1. 判断群聊是否存在
RoomGroup roomGroup = roomGroupDao.getByRoomId(request.getRoomId());
AssertUtil.isNotEmpty(roomGroup, GroupErrorEnum.GROUP_NOT_EXIST);
// 2. 判断该用户是否是群主
Boolean isLord = groupMemberDao.isLord(roomGroup.getId(), uid);
AssertUtil.isTrue(isLord, GroupErrorEnum.NOT_ALLOWED_OPERATION);
// 3. 判断群成员是否在群中
Boolean isGroupShip = groupMemberDao.isGroupShip(roomGroup.getRoomId(), request.getUidList());
AssertUtil.isTrue(isGroupShip, GroupErrorEnum.USER_NOT_IN_GROUP);
// 4. 撤销管理员
groupMemberDao.revokeAdmin(roomGroup.getId(), request.getUidList());
}
/**
* 退出群聊
*
* @param uid 需要退出的用户ID
* @param request 请求信息
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void exitGroup(Long uid, MemberExitReq request) {
Long roomId = request.getRoomId();
// 1. 判断群聊是否存在
RoomGroup roomGroup = roomGroupDao.getByRoomId(roomId);
AssertUtil.isNotEmpty(roomGroup, GroupErrorEnum.GROUP_NOT_EXIST);
// 2. 判断房间是否是大群聊 (大群聊禁止退出)
Room room = roomDao.getById(roomId);
AssertUtil.isFalse(room.isHotRoom(), GroupErrorEnum.NOT_ALLOWED_FOR_EXIT_GROUP);
// 3. 判断群成员是否在群中
Boolean isGroupShip = groupMemberDao.isGroupShip(roomGroup.getRoomId(), Collections.singletonList(uid));
AssertUtil.isTrue(isGroupShip, GroupErrorEnum.USER_NOT_IN_GROUP);
// 4. 判断该用户是否是群主
Boolean isLord = groupMemberDao.isLord(roomGroup.getId(), uid);
if (isLord) {
// 4.1 删除房间
boolean isDelRoom = roomDao.removeById(roomId);
AssertUtil.isTrue(isDelRoom, CommonErrorEnum.SYSTEM_ERROR);
// 4.2 删除会话
Boolean isDelContact = contactDao.removeByRoomId(roomId);
AssertUtil.isTrue(isDelContact, CommonErrorEnum.SYSTEM_ERROR);
// 4.3 删除群成员
Boolean isDelGroupMember = groupMemberDao.removeByGroupId(roomGroup.getId());
AssertUtil.isTrue(isDelGroupMember, CommonErrorEnum.SYSTEM_ERROR);
// 4.4 删除消息记录 (逻辑删除)
Boolean isDelMessage = messageDao.removeByRoomId(roomId);
AssertUtil.isTrue(isDelMessage, CommonErrorEnum.SYSTEM_ERROR);
// TODO 这里也可以告知群成员 群聊已被删除的消息
} else {
// 4.5 删除成员
groupMemberDao.removeById(uid);
// 发送移除事件告知群成员
List<Long> memberUidList = groupMemberCache.getMemberUidList(roomGroup.getRoomId());
WSBaseResp<WSMemberChange> ws = MemberAdapter.buildMemberRemoveWS(roomGroup.getRoomId(), uid);
pushService.sendPushMsg(ws, memberUidList);
groupMemberCache.evictMemberUidList(room.getId());
}
}
}

View File

@@ -12,6 +12,9 @@ import com.abin.mallchat.common.chat.domain.enums.GroupRoleEnum;
import com.abin.mallchat.common.chat.domain.enums.HotFlagEnum;
import com.abin.mallchat.common.chat.domain.enums.RoomTypeEnum;
import com.abin.mallchat.common.chat.domain.vo.request.*;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberAddReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberDelReq;
import com.abin.mallchat.common.chat.domain.vo.request.member.MemberReq;
import com.abin.mallchat.common.chat.domain.vo.response.ChatMemberListResp;
import com.abin.mallchat.common.chat.domain.vo.response.ChatRoomResp;
import com.abin.mallchat.common.chat.domain.vo.response.MemberResp;

View File

@@ -19,6 +19,7 @@ public enum GroupErrorEnum implements ErrorEnum {
MANAGE_COUNT_EXCEED(9003, "群管理员数量达到上限,请先删除后再操作~"),
USER_NOT_IN_GROUP(9004, "非法操作,用户不存在群聊中~"),
NOT_ALLOWED_FOR_REMOVE(9005, "非法操作,你没有移除该成员的权限"),
NOT_ALLOWED_FOR_EXIT_GROUP(9006, "非法操作,不允许退出大群聊"),
;
private final Integer code;
private final String msg;

View File

@@ -46,12 +46,6 @@ public class JwtUtils {
return token;
}
public static void main(String[] args) {
JwtUtils jwtUtils = new JwtUtils();
String token = jwtUtils.createToken(123L);
System.out.println(token);
}
/**
* 解密Token
*

View File

@@ -10,7 +10,7 @@ mallchat.redis.host=127.0.0.1
mallchat.redis.port=6379
mallchat.redis.password=123456
##################jwt##################
mallchat.jwt.secret=dsfsdfsdfsdfsd
mallchat.jwt.secret=dsadsaddddddasas
##################微信公众号信息##################
mallchat.wx.callback=http://127.0.0.1:8080
mallchat.wx.appId=appid

View File

@@ -1,36 +1,32 @@
#todo 记得把这些配置信息补充了
##################mysql配置##################
##################mysql??##################
mallchat.mysql.ip=127.0.0.1
mallchat.mysql.port=3306
mallchat.mysql.db=mallchat
mallchat.mysql.username=root
mallchat.mysql.password=123456
##################redis配置##################
##################redis??##################
mallchat.redis.host=127.0.0.1
mallchat.redis.port=6379
mallchat.redis.password=123456
##################jwt##################
mallchat.jwt.secret=dsfsdfsdfsdfsd
##################微信公众号信息##################
##################???????##################
mallchat.wx.callback=http://limeng-test.nat300.top/
mallchat.wx.appId=wx6cb0974bff30cce0
mallchat.wx.secret=072c615d9704d2e9bf0a048407928258
# 接口配置里的Token
# ??????Token?
mallchat.wx.token=sdfsf
# 接口配置里的EncodingAESKey
# ??????EncodingAESKey?
mallchat.wx.aesKey=sha1
##################OSS配置##################
##################OSS??##################
oss.enabled=true
oss.type=minio
oss.endpoint=http://localhost:9000
oss.access-key=BEZ213
oss.secret-key=Ii4vCMIXuFe241dsfEZ8e7RXI2342342kV
oss.bucketName=default
##################rocketmq##################
@@ -30,11 +29,11 @@ oss.bucketName=default
rocketmq.name-server=127.0.0.1:9876
rocketmq.access-key=root
rocketmq.secret-key=123456
##################gpt配置##################
##################gpt??##################
mallchat.chatgpt.use=false
mallchat.chatgpt.uid=10001
mallchat.chatgpt.key=sk-wvWM0xGcxFfsddfsgxixbXK5tHovM

View File

@@ -1,87 +1,87 @@
logging:
level:
org.springframework.web: INFO
com.github.binarywang.demo.wx.mp: DEBUG
me.chanjar.weixin: DEBUG
level:
org.springframework.web: INFO
com.github.binarywang.demo.wx.mp: DEBUG
me.chanjar.weixin: DEBUG
mybatis-plus:
mapper-locations: classpath:mapper/**/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
mapper-locations: classpath:mapper/**/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
spring:
profiles:
#运行的环境
active: my-test
application:
name: mallchat
datasource:
url: jdbc:mysql://${mallchat.mysql.ip}:${mallchat.mysql.port}/${mallchat.mysql.db}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: ${mallchat.mysql.username}
password: ${mallchat.mysql.password}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
minimum-idle: 3
maximum-pool-size: 10
max-lifetime: 30000 #不能小于30秒否则默认回到1800秒
connection-test-query: SELECT 1
mvc:
pathmatch:
matching-strategy: ANT_PATH_MATCHER
redis:
# Redis服务器地址
host: ${mallchat.redis.host}
# Redis服务器端口号
port: ${mallchat.redis.port}
# 使用的数据库索引默认是0
database: 0
# 连接超时时间
timeout: 1800000
# 设置密码
password: ${mallchat.redis.password}
jackson:
serialization:
write-dates-as-timestamps: true
profiles:
#运行的环境
active: my-test
application:
name: mallchat
datasource:
url: jdbc:mysql://${mallchat.mysql.ip}:${mallchat.mysql.port}/${mallchat.mysql.db}?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: ${mallchat.mysql.username}
password: ${mallchat.mysql.password}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
minimum-idle: 3
maximum-pool-size: 10
max-lifetime: 30000 #不能小于30秒否则默认回到1800秒
connection-test-query: SELECT 1
mvc:
pathmatch:
matching-strategy: ANT_PATH_MATCHER
redis:
# Redis服务器地址
host: ${mallchat.redis.host}
# Redis服务器端口号
port: ${mallchat.redis.port}
# 使用的数据库索引默认是0
database: 0
# 连接超时时间
timeout: 1800000
# 设置密码
password: ${mallchat.redis.password}
jackson:
serialization:
write-dates-as-timestamps: true
jwt:
secret: ${mallchat.jwt.secret}
secret: ${mallchat.jwt.secret}
wx:
mp:
# callback: http://f4cd-113-92-129-127.ngrok.io
callback: ${mallchat.wx.callback}
configs:
- appId: ${mallchat.wx.appId} # 第一个公众号的appid
secret: ${mallchat.wx.secret} # 公众号的appsecret
token: ${mallchat.wx.token} # 接口配置里的Token值
aesKey: ${mallchat.wx.aesKey} # 接口配置里的EncodingAESKey值
mp:
# callback: http://f4cd-113-92-129-127.ngrok.io
callback: ${mallchat.wx.callback}
configs:
- appId: ${mallchat.wx.appId} # 第一个公众号的appid
secret: ${mallchat.wx.secret} # 公众号的appsecret
token: ${mallchat.wx.token} # 接口配置里的Token值
aesKey: ${mallchat.wx.aesKey} # 接口配置里的EncodingAESKey值
chatai:
chatgpt:
use: ${mallchat.chatgpt.use}
AIUserId: ${mallchat.chatgpt.uid}
key: ${mallchat.chatgpt.key}
proxyUrl: ${mallchat.chatgpt.proxyUrl}
chatglm2:
use: ${mallchat.chatglm2.use}
url: ${mallchat.chatglm2.url}
minute: 3 # 每个用户每3分钟可以请求一次
AIUserId: ${mallchat.chatglm2.uid}
chatgpt:
use: ${mallchat.chatgpt.use}
AIUserId: ${mallchat.chatgpt.uid}
key: ${mallchat.chatgpt.key}
proxyUrl: ${mallchat.chatgpt.proxyUrl}
chatglm2:
use: ${mallchat.chatglm2.use}
url: ${mallchat.chatglm2.url}
minute: 3 # 每个用户每3分钟可以请求一次
AIUserId: ${mallchat.chatglm2.uid}
rocketmq:
name-server: ${rocketmq.name-server}
# 默认的消息组
producer:
group: chatGroup
send-message-timeout: 3000 # 发送消息超时时间,单位:毫秒。默认为 3000 。
compress-message-body-threshold: 4096 # 消息压缩阀值,当消息体的大小超过该阀值后,进行消息压缩。默认为 4 * 1024B
max-message-size: 4194304 # 消息体的最大允许大小。。默认为 4 * 1024 * 1024B
retry-times-when-send-failed: 2 # 同步发送消息时,失败重试次数。默认为 2 次。
retry-times-when-send-async-failed: 2 # 异步发送消息时,失败重试次数。默认为 2 次。
retry-next-server: false # 发送消息给 Broker 时,如果发送失败,是否重试另外一台 Broker 。默认为 false
access-key: ${rocketmq.access-key} # Access Key ,可阅读 https://github.com/apache/rocketmq/blob/master/docs/cn/acl/user_guide.md 文档
secret-key: ${rocketmq.secret-key} # Secret Key
enable-msg-trace: true # 是否开启消息轨迹功能。默认为 true 开启。可阅读 https://github.com/apache/rocketmq/blob/master/docs/cn/msg_trace/user_guide.md 文档
customized-trace-topic: RMQ_SYS_TRACE_TOPIC # 自定义消息轨迹的 Topic 。默认为 RMQ_SYS_TRACE_TOPIC 。
# Consumer 配置项
consumer:
access-key: ${rocketmq.access-key} # Access Key ,可阅读 https://github.com/apache/rocketmq/blob/master/docs/cn/acl/user_guide.md 文档
secret-key: ${rocketmq.secret-key} # Secret Key
listeners: # 配置某个消费分组,是否监听指定 Topic 。结构为 Map<消费者分组, <Topic, Boolean>> 。默认情况下,不配置表示监听。
erbadagang-consumer-group:
topic1: false # 关闭 test-consumer-group 对 topic1 的监听消费
name-server: ${rocketmq.name-server}
# 默认的消息组
producer:
group: chatGroup
send-message-timeout: 3000 # 发送消息超时时间,单位:毫秒。默认为 3000 。
compress-message-body-threshold: 4096 # 消息压缩阀值,当消息体的大小超过该阀值后,进行消息压缩。默认为 4 * 1024B
max-message-size: 4194304 # 消息体的最大允许大小。。默认为 4 * 1024 * 1024B
retry-times-when-send-failed: 2 # 同步发送消息时,失败重试次数。默认为 2 次。
retry-times-when-send-async-failed: 2 # 异步发送消息时,失败重试次数。默认为 2 次。
retry-next-server: false # 发送消息给 Broker 时,如果发送失败,是否重试另外一台 Broker 。默认为 false
access-key: ${rocketmq.access-key} # Access Key ,可阅读 https://github.com/apache/rocketmq/blob/master/docs/cn/acl/user_guide.md 文档
secret-key: ${rocketmq.secret-key} # Secret Key
enable-msg-trace: true # 是否开启消息轨迹功能。默认为 true 开启。可阅读 https://github.com/apache/rocketmq/blob/master/docs/cn/msg_trace/user_guide.md 文档
customized-trace-topic: RMQ_SYS_TRACE_TOPIC # 自定义消息轨迹的 Topic 。默认为 RMQ_SYS_TRACE_TOPIC 。
# Consumer 配置项
consumer:
access-key: ${rocketmq.access-key} # Access Key ,可阅读 https://github.com/apache/rocketmq/blob/master/docs/cn/acl/user_guide.md 文档
secret-key: ${rocketmq.secret-key} # Secret Key
listeners: # 配置某个消费分组,是否监听指定 Topic 。结构为 Map<消费者分组, <Topic, Boolean>> 。默认情况下,不配置表示监听。
erbadagang-consumer-group:
topic1: false # 关闭 test-consumer-group 对 topic1 的监听消费

View File

@@ -108,4 +108,10 @@ public class DaoTest {
String url = wxMpQrCodeTicket.getUrl();
System.out.println(url);
}
@Test
public void testCreateToken() {
String token = loginService.login(10276L);
System.out.println("token = " + token);
}
}