master:app消息部分调整;

pull/1121/head
liujiang 2025-07-22 15:41:33 +08:00
parent 28b82073d7
commit 56f8abbc12
8 changed files with 88 additions and 26 deletions

View File

@ -17,14 +17,14 @@ public class LoginByUsernameVO {
*
*/
@NotEmpty(message = "用户名不能为空")
@ApiModelProperty("用户名")
@ApiModelProperty(value = "用户名", required = true)
private String username;
/**
*
*/
@NotEmpty(message = "用户密码不能为空")
@ApiModelProperty("用户密码")
@ApiModelProperty(value = "用户密码", required = true)
private String password;
/**

View File

@ -26,7 +26,7 @@ import java.util.List;
* @author ruoyi
* @date 2025-03-26
*/
@Api(tags = "用户所有通知")
@Api(tags = "用户消息通知")
@RestController
@RequiredArgsConstructor
@RequestMapping("/rest/v1/user-notices")
@ -52,4 +52,17 @@ public class UserNoticeController extends XktBaseController {
return R.ok(userNoticeService.appTypePage(BeanUtil.toBean(pageVO, UserNoticeAppTypePageDTO.class)));
}
@ApiOperation(value = "APP - 全部已读", httpMethod = "PUT", response = R.class)
@PutMapping("/app/read/all")
public R<Integer> appAllRead() {
return R.ok(userNoticeService.appBatchRead());
}
@ApiOperation(value = "APP - 未读的分类,点击进入分类列表时调用变为已读", httpMethod = "PUT", response = R.class)
@PutMapping("/app/read/type/{targetNoticeType}")
public R<Integer> appTypeRead(@PathVariable Integer targetNoticeType) {
return R.ok(userNoticeService.appTypeRead(targetNoticeType));
}
}

View File

@ -27,7 +27,5 @@ public class UserNoticeAppListResVO {
private Date createTime;
@ApiModelProperty(value = "是否已读 0未读 1已读")
private Integer readStatus;
@ApiModelProperty(value = "公告状态 0不提醒 1提醒")
private Integer remindStatus;
}

View File

@ -27,7 +27,5 @@ public class UserNoticeAppListResDTO {
private Date createTime;
@ApiModelProperty(value = "是否已读 0未读 1已读")
private Integer readStatus;
@ApiModelProperty(value = "公告状态 0不提醒 1提醒")
private Integer remindStatus;
}

View File

@ -35,4 +35,19 @@ public interface IUserNoticeService {
* @return List<UserNoticeAppResDTO>
*/
Page<UserNoticeAppResDTO> appTypePage(UserNoticeAppTypePageDTO pageDTO);
/**
* app
*
* @return Integer
*/
Integer appBatchRead();
/**
* app
*
* @param targetNoticeType type
* @return
*/
Integer appTypeRead(Integer targetNoticeType);
}

View File

@ -1,15 +1,21 @@
package com.ruoyi.xkt.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.page.Page;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.xkt.domain.UserNotice;
import com.ruoyi.xkt.dto.userNotice.*;
import com.ruoyi.xkt.enums.UserNoticeType;
import com.ruoyi.xkt.mapper.UserNoticeMapper;
import com.ruoyi.xkt.service.IUserNoticeService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -81,4 +87,50 @@ public class UserNoticeServiceImpl implements IUserNoticeService {
return Page.convert(new PageInfo<>(list));
}
/**
* app
*
* @return Integer
*/
@Override
@Transactional
public Integer appBatchRead() {
Long userId = SecurityUtils.getUserIdSafe();
if (ObjectUtils.isEmpty(userId)) {
throw new ServiceException("用户未登录,请先登录!", HttpStatus.ERROR);
}
List<UserNotice> unReadList = this.userNoticeMapper.selectList(new LambdaQueryWrapper<UserNotice>()
.eq(UserNotice::getUserId, userId).eq(UserNotice::getReadStatus, 0)
.eq(UserNotice::getDelFlag, Constants.UNDELETED));
if (CollectionUtils.isEmpty(unReadList)) {
return 0;
}
unReadList.forEach(x -> x.setReadStatus(1));
return this.userNoticeMapper.updateById(unReadList).size();
}
/**
* app
*
* @param targetNoticeType type
* @return
*/
@Override
@Transactional
public Integer appTypeRead(Integer targetNoticeType) {
Long userId = SecurityUtils.getUserIdSafe();
if (ObjectUtils.isEmpty(userId)) {
throw new ServiceException("用户未登录,请先登录!", HttpStatus.ERROR);
}
List<UserNotice> unReadList = this.userNoticeMapper.selectList(new LambdaQueryWrapper<UserNotice>()
.eq(UserNotice::getUserId, userId).eq(UserNotice::getReadStatus, 0)
.eq(UserNotice::getTargetNoticeType, targetNoticeType)
.eq(UserNotice::getDelFlag, Constants.UNDELETED));
if (CollectionUtils.isEmpty(unReadList)) {
return 0;
}
unReadList.forEach(x -> x.setReadStatus(1));
return this.userNoticeMapper.updateById(unReadList).size();
}
}

View File

@ -34,25 +34,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
un.target_notice_type,
n.notice_content,
un.create_time,
un.read_status,
CASE
un.target_notice_type
WHEN 1 THEN
uns.sys_msg_notice
WHEN 2 THEN
uns.order_notice
WHEN 3 THEN
uns.focus_notice
WHEN 4 THEN
uns.favorite_notice
END AS remindStatus
un.read_status
FROM
user_notice un
LEFT JOIN user_notice_setting uns ON un.user_id = uns.user_id
LEFT JOIN notice n ON un.notice_id = n.id
WHERE
un.del_flag = 0
AND un.user_id = #{userId}
un.del_flag = 0 AND un.user_id = #{userId}
ORDER BY
un.target_notice_type
</select>
<select id="selectAppTypePage" resultType="com.ruoyi.xkt.dto.userNotice.UserNoticeAppResDTO">

View File

@ -65,11 +65,8 @@
us.user_id
FROM
user_subscriptions us
JOIN user_notice_setting uns ON us.user_id = uns.user_id
WHERE
us.store_id = #{storeId}
AND us.del_flag = 0
AND uns.focus_notice = 1
us.store_id = #{storeId} AND us.del_flag = 0
</select>
<select id="selectFocusAndFavUserIdList" resultType="com.ruoyi.xkt.dto.userNotice.UserFocusAndFavUserIdDTO">