enable / disable notice&&push

main
wangqing 8 months ago
parent d31b360af2
commit 4f89b4d8df

@ -136,4 +136,13 @@ public class UserInfo implements Serializable {
private int onlineStatus;
private String badges;
/**
*
*/
private int enableNotice;
/**
*
*/
private int enablePush;
}

@ -106,7 +106,12 @@ public class CommentService {
commentHis.setJournalId(parentComment.getJournalId());
commentHis.setJournalImage(parentComment.getJournalImage());
commentHis.setCreateTime(new Date());
commentHisDao.save(commentHis);
UserInfo parentCommentUser =userInfoService.findById(parentComment.getUserId());
if (0 != parentCommentUser.getEnableNotice()) {
commentHisDao.save(commentHis);
}
comment.setJournalId("");//如果有父节点,将期刊号置为空
// 将parentComment的rootID值带过来
@ -134,7 +139,10 @@ public class CommentService {
userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX+userLoginDto.getAvatar());
userMessageDto.setSendUserId(userLoginDto.getUserId());
userMessageDto.setSendUserNickName(userLoginDto.getNickName());
rabbitTemplate.convertAndSend("userMessage",userMessageDto);
if (0 != parentCommentUser.getEnableNotice()) {
rabbitTemplate.convertAndSend("userMessage",userMessageDto);
}
@ -232,18 +240,22 @@ public class CommentService {
mongoTemplate.updateFirst(query,update,"comment");
Comment parentComment = commentDao.findById(commentId).get();
/**
*
*/
UserMessageDto userMessageDto = new UserMessageDto();
userMessageDto.setType(MessageTypeEnum.THUMB_UP.getType()); //消息类型 1私信 2新赞3新关注 4新评论 5.系统消息
userMessageDto.setUserId(parentComment.getUserId());
userMessageDto.setContent(userLoginDto.getNickName()+" 点赞了你的评论");
userMessageDto.setTitle("您有新的点赞");
userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX+userLoginDto.getAvatar());
userMessageDto.setSendUserId(userLoginDto.getUserId());
userMessageDto.setSendUserNickName(userLoginDto.getNickName());
rabbitTemplate.convertAndSend("userMessage",userMessageDto);
UserInfo parentCommentUser =userInfoService.findById(parentComment.getUserId());
if (0 != parentCommentUser.getEnableNotice()) {
/**
*
*/
UserMessageDto userMessageDto = new UserMessageDto();
userMessageDto.setType(MessageTypeEnum.THUMB_UP.getType()); //消息类型 1私信 2新赞3新关注 4新评论 5.系统消息
userMessageDto.setUserId(parentComment.getUserId());
userMessageDto.setContent(userLoginDto.getNickName()+" 点赞了你的评论");
userMessageDto.setTitle("您有新的点赞");
userMessageDto.setSendUserAvatar(Constants.RESOURCE_PREFIX+userLoginDto.getAvatar());
userMessageDto.setSendUserId(userLoginDto.getUserId());
userMessageDto.setSendUserNickName(userLoginDto.getNickName());
rabbitTemplate.convertAndSend("userMessage",userMessageDto);
}
}
public Page<Comment> search(int page, int size) {

@ -121,6 +121,14 @@ public class MyController extends BaseController {
userRespDTO.setAppleId(user.getAppleId());
userRespDTO.setWxNickname(user.getWxNickname());
userRespDTO.setAppleEmail(user.getAppleEmail());
userRespDTO.setEnableNotice(1);
userRespDTO.setEnablePush(1);
if (0 ==user.getEnableNotice()) {
userRespDTO.setEnableNotice(0);
}
if (0 == user.getEnablePush()) {
userRespDTO.setEnablePush(0);
}
return Result.success(userRespDTO);
}
@ -514,8 +522,35 @@ public class MyController extends BaseController {
return Result.success(token);
}
@ApiOperation(value = "14.1 启用/停用 消息, 0为停用1为启用", notes = "启用/停用 消息, 0为停用1为启用")
@PutMapping("/enableNotice/{flag}")
public Result<Void> updateEnableNotice(@RequestHeader(value = "Authorization", required = true) String authorization,@PathVariable int flag){
//验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) {
return Result.unauthorized(null);
}
String userId = userLoginDto.getUserId();
UserInfo userInfo = userInfoService.findById(userId);
userInfo.setEnableNotice(flag);
userInfoService.update(userInfo);
return Result.success();
}
@ApiOperation(value = "14.2 启用/停用 推送, 0为停用1为启用", notes = "启用/停用 推送, 0为停用1为启用")
@PutMapping("/enablePush/{flag}")
public Result<Void> updateEnablePush(@RequestHeader(value = "Authorization", required = true) String authorization,@PathVariable int flag){
//验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization);
if (null == userLoginDto) {
return Result.unauthorized(null);
}
String userId = userLoginDto.getUserId();
UserInfo userInfo = userInfoService.findById(userId);
userInfo.setEnablePush(flag);
userInfoService.update(userInfo);
return Result.success();
}
private Integer getIndex(UserInfo u) {
return Integer.valueOf(Arrays.stream(u.getBadges().split(",")).filter(s->s.startsWith(String.valueOf(UserBadgeEnum.CONTRIBUTOR.getCode()))).findFirst().get().split("_")[1]);
}

@ -59,4 +59,15 @@ public class UserRespDTO implements Serializable {
@ApiModelProperty(value = "apple绑定的邮箱")
private String appleEmail;
/**
*
*/
@ApiModelProperty(value = "是否启用通知0为关闭1为启用默认启用")
private int enableNotice;
/**
*
*/
@ApiModelProperty(value = "是否启用推送0为关闭1为启用默认启用")
private int enablePush;
}

@ -160,4 +160,13 @@ public class UserInfo implements Serializable {
private int onlineStatus;
private String badges;
/**
*
*/
private int enableNotice;
/**
*
*/
private int enablePush;
}

@ -277,7 +277,12 @@ public class UserCollectInfoService {
userInfoDao.save(other);
// 向他人发送 新粉丝 消息
sendMessageToFollows(user, objectId);
UserInfo followUserInfo =userInfoDao.findById(objectId).get();
if (0 != followUserInfo.getEnableNotice()) {
sendMessageToFollows(user, objectId);
}
}
private void sendMessageToFollows(UserInfo userInfo, String followId) {

@ -275,7 +275,7 @@ public class WeChatAouth2Service {
log.info("getWechatName:" + string);
Aouth2WeChatUserinfoResponse aouth2WeChatTokenResponse = JSON.parseObject(string, Aouth2WeChatUserinfoResponse.class);
return aouth2WeChatTokenResponse.getNickname();
return new String(aouth2WeChatTokenResponse.getNickname().getBytes(StandardCharsets.ISO_8859_1),StandardCharsets.UTF_8);
}
public Aouth2WeChatTokenResponse refreshAccessToken(String refresh_token) {

Loading…
Cancel
Save