1. notice module
This commit is contained in:
2026-02-11 18:01:30 +08:00
parent add23214ac
commit cd4d535d74
17 changed files with 268 additions and 187 deletions

View File

@@ -40,8 +40,8 @@ public class APPCommonController {
/**
* 获取省市区列表
*/
@GetMapping("/find-region-list")
@ApiOperationSupport(order = 1)
@GetMapping("/region-list")
@ApiOperationSupport(order = 2)
@Operation(summary = "获取省市区列表")
public R<List<AppCommonRegionsInfoVO>> findRegionList(@RequestParam @Min(value = 0 , message = "父级id不能小于0") Long pid ,
@RequestParam @Min(value = 1 , message = "只能选到省") @Max(value = 4 , message = "只能选到街道") Integer level) {

View File

@@ -10,18 +10,21 @@ import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.modules.api.request.AppUserNoticeRequest;
import org.springblade.modules.api.request.NoticeDetailRequest;
import org.springblade.modules.api.request.CreateOrderRequest;
import org.springblade.modules.api.request.PaymentRequest;
import org.springblade.modules.api.response.CreateOrderResponse;
import org.springblade.modules.api.response.PaymentResponse;
import org.springblade.modules.api.vo.AppUserNoticeVO;
import org.springblade.modules.api.vo.CommonUserNoticeApiVO;
import org.springblade.modules.api.vo.CommonUserNoticeDetailApiVO;
import org.springblade.modules.api.vo.CommonUserOrderApiVO;
import org.springblade.modules.common.service.ICommonUserOrderService;
import org.springblade.modules.common.service.ICommonUserNoticeService;
import org.springblade.modules.system.service.IUserService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Hidden
@RestController
@AllArgsConstructor
@@ -91,34 +94,42 @@ public class APPUserController {
*/
@GetMapping("/order-page")
@ApiOperationSupport(order = 6)
@Operation(summary = "用户订单分页列表", description = "传入userAddress")
@Operation(summary = "用户订单分页列表", description = "传入userAddress")
public R<IPage<CommonUserOrderApiVO>> orderList(CommonUserOrderApiVO userOrder, Query query) {
IPage<CommonUserOrderApiVO> pages = orderService.selectOrderApiPage(Condition.getPage(query), userOrder);
return R.data(pages);
}
@GetMapping("/notice-page")
@ApiOperationSupport(order = 6)
@Operation(summary = "用户消息列表", description = "传入userNoticeVO")
public R<IPage<AppUserNoticeVO>> noticePage(Query query) {
IPage<AppUserNoticeVO> pages = userNoticeService.selectAppUserNoticeApiPage(Condition.getPage(query));
@GetMapping("/system-notice")
@ApiOperationSupport(order = 7)
@Operation(summary = "APP系统消息列表")
public R<List<CommonUserNoticeApiVO>> systemNotice() {
return R.data(userNoticeService.appSystemNoticeList());
}
@GetMapping("/user-notice")
@ApiOperationSupport(order = 8)
@Operation(summary = "用户消息列表", description = "传入userNoticeVO")
public R<IPage<CommonUserNoticeApiVO>> noticePage(Query query) {
IPage<CommonUserNoticeApiVO> pages = userNoticeService.selectAppUserNoticeApiPage(Condition.getPage(query), new CommonUserNoticeApiVO());
return R.data(pages);
}
@PostMapping("/notice-detail")
@ApiOperationSupport(order = 6)
@Operation(summary = "用户读取消息", description = "传入request")
public R<Boolean> noticeDetail(@RequestBody AppUserNoticeRequest request) {
return R.status(userNoticeService.appUserReadNotice(request));
@ApiOperationSupport(order = 9)
@Operation(summary = "用户读取消息", description = "传入request")
public R<CommonUserNoticeDetailApiVO> noticeDetail(@RequestBody @Valid NoticeDetailRequest request) {
return R.data(userNoticeService.userNoticeDetail(request.getId()));
}
@GetMapping("/unread-num")
@ApiOperationSupport(order = 6)
@GetMapping("/unread")
@ApiOperationSupport(order = 10)
@Operation(summary = "用户未读消息数量")
public R<Integer> unreadNum() {
return R.data(userNoticeService.appNotReadNoticeNum());
public R<Long> unreadNum() {
return R.data(userNoticeService.appUnreadNoticeNum());
}
}

View File

@@ -6,17 +6,19 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.modules.api.request.AppUserNoticeRequest;
import org.springblade.modules.api.vo.AppUserNoticeVO;
import org.springblade.modules.api.request.NoticeDetailRequest;
import org.springblade.modules.api.vo.CommonUserNoticeApiVO;
import org.springblade.modules.api.vo.CommonUserNoticeDetailApiVO;
import org.springblade.modules.api.vo.MarketDirectInfoApiVO;
import org.springblade.modules.common.service.ICommonUserNoticeService;
import org.springblade.modules.market.manager.MarketUserManager;
import org.springblade.modules.api.vo.MarketBenefitPackageVO;
import org.springblade.modules.api.vo.MarketDirectInfoVO;
import org.springblade.modules.userPackage.service.IUserMarketBenefitPackageService;
import org.springframework.web.bind.annotation.*;
@@ -30,11 +32,13 @@ import java.util.List;
public class MarketUserController {
private final IUserMarketBenefitPackageService userMarketBenefitPackageService;
private final MarketUserManager marketUserManager;
private final ICommonUserNoticeService userNoticeService;
@GetMapping("/find-user-benefit-pack-list")
@GetMapping("/package-list")
@ApiOperationSupport(order = 1)
@Operation(summary = "分页", description = "传入userMarketBenefitPackage")
public R<IPage<MarketBenefitPackageVO>> findUserPackList(MarketBenefitPackageVO userMarketBenefitPackage, Query query) {
@@ -46,7 +50,7 @@ public class MarketUserController {
@GetMapping("/my-team")
@ApiOperationSupport(order = 2)
@Operation(summary = "查直推")
public R<List<MarketDirectInfoVO>> myTeam() {
public R<List<MarketDirectInfoApiVO>> myTeam() {
return R.data(marketUserManager.findUserPackList());
}
@@ -54,17 +58,24 @@ public class MarketUserController {
@GetMapping("/my-invitor")
@ApiOperationSupport(order = 3)
@Operation(summary = "查推荐人信息")
public R<MarketDirectInfoVO> myInvitor() {
public R<MarketDirectInfoApiVO> myInvitor() {
return R.data(marketUserManager.findMarketParent());
}
@GetMapping("/system-notice")
@ApiOperationSupport(order = 4)
@Operation(summary = "Market系统消息列表")
public R<List<CommonUserNoticeApiVO>> systemNotice() {
return R.data(userNoticeService.marketSystemNoticeList());
}
@GetMapping("/notice-page")
@ApiOperationSupport(order = 6)
@Operation(summary = "用户消息列表", description = "传入userNoticeVO")
public R<IPage<AppUserNoticeVO>> noticePage(Query query) {
IPage<AppUserNoticeVO> pages = userNoticeService.selectAppUserNoticeApiPage(Condition.getPage(query));
@GetMapping("/user-notice")
@ApiOperationSupport(order = 5)
@Operation(summary = "Market用户消息列表", description = "传入userNoticeVO")
public R<IPage<CommonUserNoticeApiVO>> noticePage(Query query) {
IPage<CommonUserNoticeApiVO> pages = userNoticeService.selectMarketUserNoticeApiPage(Condition.getPage(query), new CommonUserNoticeApiVO());
return R.data(pages);
}
@@ -72,15 +83,15 @@ public class MarketUserController {
@PostMapping("/notice-detail")
@ApiOperationSupport(order = 6)
@Operation(summary = "用户消息详情", description = "传入request")
public R<Boolean> noticeDetail(@RequestBody AppUserNoticeRequest request) {
return R.status(userNoticeService.appUserReadNotice(request));
public R<CommonUserNoticeDetailApiVO> noticeDetail(@RequestBody @Valid NoticeDetailRequest request) {
return R.data(userNoticeService.userNoticeDetail(request.getId()));
}
@GetMapping("/unread-num")
@ApiOperationSupport(order = 6)
@Operation(summary = "用户未读消息数量")
public R<Integer> unreadNum() {
return R.data(userNoticeService.appNotReadNoticeNum());
@Operation(summary = "APP用户未读消息数量")
public R<Long> unreadNum() {
return R.data(userNoticeService.marketUnreadNoticeNum());
}

View File

@@ -25,21 +25,16 @@
*/
package org.springblade.modules.api.request;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serial;
import java.io.Serializable;
@Data
public class NoticeDetailRequest implements Serializable {
@Accessors(chain = true)
public class AppUserNoticeRequest implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@NotNull(message = "无效消息详情")
private Long id;

View File

@@ -26,51 +26,30 @@
package org.springblade.modules.api.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
@Data
@Accessors(chain = true)
public class AppUserNoticeVO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
public class CommonUserNoticeApiVO implements Serializable {
private Long id;
/**
* 通知类型 0-系统通知 1-app通知 2-market通知
*/
private Integer noticeType;
private Integer moduleType;
/**
* 是否已读 0-否 1-是
*/
private Integer hasRead;
/**
* 阅读时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date releaseTime;
/**
* 标题
*/
private String title;
/**
* 内容
*/
private String content;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
}

View File

@@ -0,0 +1,26 @@
package org.springblade.modules.api.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
public class CommonUserNoticeDetailApiVO implements Serializable {
private Long id;
private Integer moduleType;
private String title;
private String content;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
}

View File

@@ -42,10 +42,11 @@ import java.util.Date;
*/
@Data
@Accessors(chain = true)
public class MarketDirectInfoVO implements Serializable {
private String phone;
private String name;
public class MarketDirectInfoApiVO implements Serializable {
private String phone;
private String name;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@@ -4,7 +4,8 @@ import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import org.springblade.modules.api.request.CreateOrderRequest;
import org.springblade.modules.api.vo.AppUserNoticeVO;
import org.springblade.modules.api.vo.CommonUserNoticeApiVO;
import org.springblade.modules.api.vo.CommonUserNoticeDetailApiVO;
import org.springblade.modules.api.vo.CommonUserOrderApiVO;
import org.springblade.modules.common.pojo.entity.CommonRegionsInfoEntity;
import org.springblade.modules.common.pojo.entity.CommonUserNoticeEntity;
@@ -43,7 +44,9 @@ public interface AppCommonConvert {
List<CommonUserOrderApiVO> convertOrderApiListVO(List<CommonUserOrderVO> voList);
AppUserNoticeVO convertNoticeEntityToVO(CommonUserNoticeEntity commonUserNoticeEntity);
CommonUserNoticeApiVO convertNoticeEntityToVO(CommonUserNoticeEntity commonUserNoticeEntity);
List<CommonUserNoticeApiVO> convertNoticeVOList(List<CommonUserNoticeEntity> list);
CommonUserNoticeDetailApiVO convertNoticeDetailVO(CommonUserNoticeEntity entity);
}

View File

@@ -0,0 +1,55 @@
package org.springblade.modules.common.eums;
import lombok.Getter;
@Getter
public enum NoticeType {
/**
* 全局通知
*/
GLOBAL(0),
/**
* APP系统通知
*/
APP_SYSTEM(1),
/**
* Market系统通知
*/
MARKET_SYSTEM(2),
/**
* APP用户通知
*/
APP_USER(3),
/**
* Market用户通知
*/
MARKET_USER(4);
private final int code;
NoticeType(int code) {
this.code = code;
}
/**
* 根据 code 值获取对应的枚举项
*
* @param code 通知类型代码
* @return 对应的 NotificationType 枚举
* @throws IllegalArgumentException 如果 code 无效
*/
public static NoticeType fromCode(int code) {
for (NoticeType type : NoticeType.values()) {
if (type.code == code) {
return type;
}
}
throw new IllegalArgumentException("Invalid notification type code: " + code);
}
}

View File

@@ -25,6 +25,7 @@
*/
package org.springblade.modules.common.mapper;
import org.springblade.modules.api.vo.CommonUserNoticeApiVO;
import org.springblade.modules.common.pojo.entity.CommonUserNoticeEntity;
import org.springblade.modules.common.pojo.vo.CommonUserNoticeVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -48,5 +49,11 @@ public interface CommonUserNoticeMapper extends BaseMapper<CommonUserNoticeEntit
*/
List<CommonUserNoticeVO> selectUserNoticePage(IPage page, CommonUserNoticeVO userNotice);
List<CommonUserNoticeApiVO> selectAppSystemNoticeVOList();
List<CommonUserNoticeApiVO> selectAppUserNoticeApiPage(IPage page, CommonUserNoticeApiVO vo, Long userId);
List<CommonUserNoticeApiVO> selectMarketSystemNoticeVOList();
List<CommonUserNoticeApiVO> selectMarketUserNoticeApiPage(IPage page, CommonUserNoticeApiVO vo, Long userId);
}

View File

@@ -26,6 +26,38 @@
select * from user_notice where is_deleted = 0
</select>
<select id="selectAppSystemNoticeVOList" resultType="org.springblade.modules.common.pojo.vo.CommonUserNoticeVO">
select id, module_type, has_read, title, create_time
from user_notice
where notice_type in (0, 1)
and is_deleted = 0
order by create_time desc
</select>
<select id="selectAppUserNoticeApiPage" resultType="org.springblade.modules.common.pojo.vo.CommonUserNoticeVO">
select id, module_type, has_read, title, create_time
from user_notice
where user_id = #{userId}
and notice_type = 3
and is_deleted = 0
order by has_read asc, create_time desc
</select>
<select id="selectMarketSystemNoticeVOList" resultType="org.springblade.modules.common.pojo.vo.CommonUserNoticeVO">
select id, module_type, has_read, title, create_time
from user_notice
where notice_type in (0, 2)
and is_deleted = 0
order by create_time desc
</select>
<select id="selectMarketUserNoticeApiPage" resultType="org.springblade.modules.common.pojo.vo.CommonUserNoticeVO">
select id, module_type, has_read, title, create_time
from user_notice
where user_id = #{userId}
and notice_type = 4
and is_deleted = 0
order by has_read asc, create_time desc
</select>
</mapper>

View File

@@ -59,18 +59,18 @@ public class CommonUserNoticeEntity extends BaseEntity {
/**
* 通知类型 0-系统通知 1-app通知 2-market通知
*/
@Schema(description = "通知类型 0-系统通知 1-app通知 2-market通知")
@Schema(description = "通知类型 0-全局通知 1-APP系统通知 2-Market系统通知 3-APP用户通知 4-Market用户通知")
private Integer noticeType;
/**
* 业务类型
*/
@Schema(description = "通知类型 0-全局通知 1-APP系统通知 2-Market系统通知 3-APP用户通知 4-Market用户通知")
private Integer moduleType;
/**
* 是否已读 0-否 1-是
*/
@Schema(description = "是否已读 0-否 1-是")
private Integer hasRead;
/**
* 阅读时间
*/
@Schema(description = "阅读时间")
private Date releaseTime;
/**
* 标题
*/

View File

@@ -26,13 +26,16 @@
package org.springblade.modules.common.service;
import jakarta.validation.Valid;
import org.springblade.modules.api.request.AppUserNoticeRequest;
import org.springblade.modules.api.vo.AppUserNoticeVO;
import org.springblade.modules.api.request.NoticeDetailRequest;
import org.springblade.modules.api.vo.CommonUserNoticeApiVO;
import org.springblade.modules.api.vo.CommonUserNoticeDetailApiVO;
import org.springblade.modules.common.pojo.entity.CommonUserNoticeEntity;
import org.springblade.modules.common.pojo.vo.CommonUserNoticeVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 用户通知 服务类
*
@@ -52,21 +55,18 @@ public interface ICommonUserNoticeService extends BaseService<CommonUserNoticeEn
boolean saveUserNotice(@Valid CommonUserNoticeVO userNotice);
IPage<AppUserNoticeVO> selectAppUserNoticeApiPage(IPage<CommonUserNoticeEntity> page);
IPage<CommonUserNoticeApiVO> selectAppUserNoticeApiPage(IPage<CommonUserNoticeApiVO> page, CommonUserNoticeApiVO vo);
Integer appNotReadNoticeNum();
Long appUnreadNoticeNum();
boolean appUserReadNotice(AppUserNoticeRequest request);
IPage<CommonUserNoticeApiVO> selectMarketUserNoticeApiPage(IPage<CommonUserNoticeApiVO> page, CommonUserNoticeApiVO vo);
Long marketUnreadNoticeNum();
List<CommonUserNoticeApiVO> appSystemNoticeList();
IPage<AppUserNoticeVO> selectMarketUserNoticeApiPage(IPage<CommonUserNoticeEntity> page);
Integer marketNotReadNoticeNum();
boolean marketUserReadNotice(AppUserNoticeRequest request);
CommonUserNoticeDetailApiVO userNoticeDetail(Long id);
List<CommonUserNoticeApiVO> marketSystemNoticeList();
}

View File

@@ -28,8 +28,9 @@ package org.springblade.modules.common.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.api.request.AppUserNoticeRequest;
import org.springblade.modules.api.vo.AppUserNoticeVO;
import org.springblade.modules.api.request.NoticeDetailRequest;
import org.springblade.modules.api.vo.CommonUserNoticeApiVO;
import org.springblade.modules.api.vo.CommonUserNoticeDetailApiVO;
import org.springblade.modules.common.convert.AppCommonConvert;
import org.springblade.modules.common.pojo.entity.CommonUserNoticeEntity;
import org.springblade.modules.common.pojo.vo.CommonUserNoticeVO;
@@ -44,7 +45,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@@ -68,13 +68,13 @@ public class CommonUserNoticeServiceImpl extends BaseServiceImpl<CommonUserNotic
@Transactional(rollbackFor = RuntimeException.class)
@Override
public boolean saveUserNotice(CommonUserNoticeVO userNotice) {
Assert.notNull(userNotice.getNoticeType(), "通知类型不能为空");
Assert.notNull(userNotice.getNoticeType(), "通知类型不能为空");
Assert.notNull(userNotice.getTitle(), "标题不能为空");
Assert.notNull(userNotice.getContent(), "内容不能为空");
if (userNotice.getNoticeRange() == 0){
if (userNotice.getNoticeRange() == 0) {
User user = userService.getById(userNotice.getUserId());
Assert.notNull(user , "用户不存在");
Assert.notNull(user, "用户不存在");
return save(
new CommonUserNoticeEntity()
.setUserId(userNotice.getUserId())
@@ -83,7 +83,7 @@ public class CommonUserNoticeServiceImpl extends BaseServiceImpl<CommonUserNotic
.setNoticeType(userNotice.getNoticeType())
.setHasRead(0)
);
}else if (userNotice.getNoticeRange() == 1){
} else if (userNotice.getNoticeRange() == 1) {
long count = userService.count(
Wrappers.lambdaQuery(User.class)
@@ -91,7 +91,7 @@ public class CommonUserNoticeServiceImpl extends BaseServiceImpl<CommonUserNotic
);
// 向上取整
long pageNun = (count + PAGE_SIZE - 1) / PAGE_SIZE;
long pageNun = (count + PAGE_SIZE - 1) / PAGE_SIZE;
List<CommonUserNoticeEntity> noticeList = new ArrayList<>();
for (int i = 0; i < pageNun; i++) {
@@ -113,101 +113,66 @@ public class CommonUserNoticeServiceImpl extends BaseServiceImpl<CommonUserNotic
.setHasRead(0)
);
});
if (!saveBatch(noticeList)){
if (!saveBatch(noticeList)) {
throw new RuntimeException("批量保存用户通知失败");
}else {
} else {
noticeList.clear();
}
}
}else {
} else {
throw new RuntimeException("通知范围错误");
}
return Boolean.TRUE;
}
@Override
public IPage<AppUserNoticeVO> selectAppUserNoticeApiPage(IPage<CommonUserNoticeEntity> page) {
IPage<CommonUserNoticeEntity> noticeEntityIPage = page(
page,
Wrappers.lambdaQuery(CommonUserNoticeEntity.class)
.eq(CommonUserNoticeEntity::getUserId, AuthUtil.getUserId())
.in(CommonUserNoticeEntity::getNoticeType, List.of(0, 1))
.orderByAsc(CommonUserNoticeEntity::getHasRead)
.orderByDesc(CommonUserNoticeEntity::getCreateTime)
);
return noticeEntityIPage.convert(AppCommonConvert.INSTANCE::convertNoticeEntityToVO);
public IPage<CommonUserNoticeApiVO> selectAppUserNoticeApiPage(IPage<CommonUserNoticeApiVO> page, CommonUserNoticeApiVO vo) {
return page.setRecords(baseMapper.selectAppUserNoticeApiPage(page, vo, AuthUtil.getUserId()));
}
@Override
public Integer appNotReadNoticeNum() {
long count = count(
Wrappers.lambdaQuery(CommonUserNoticeEntity.class)
.eq(CommonUserNoticeEntity::getUserId, AuthUtil.getUserId())
.eq(CommonUserNoticeEntity::getHasRead, 0)
.in(CommonUserNoticeEntity::getNoticeType, List.of(0, 1))
);
return Math.toIntExact(count);
public Long appUnreadNoticeNum() {
return count(Wrappers.<CommonUserNoticeEntity>lambdaQuery()
.eq(CommonUserNoticeEntity::getUserId, AuthUtil.getUserId())
.eq(CommonUserNoticeEntity::getHasRead, 0)
.eq(CommonUserNoticeEntity::getNoticeType, 3)
.eq(CommonUserNoticeEntity::getIsDeleted, 0));
}
@Override
public boolean appUserReadNotice(AppUserNoticeRequest request) {
CommonUserNoticeEntity userNotice = getById(request.getId());
Assert.notNull(userNotice, "通知不存在");
Assert.isTrue(Objects.equals(userNotice.getUserId(), AuthUtil.getUserId()), "无权限阅读其他用户消息");
Assert.isTrue(Objects.equals(userNotice.getNoticeType(), 0) || Objects.equals(userNotice.getNoticeType(), 1), "无效消息类型");
Assert.isTrue(Objects.equals(userNotice.getHasRead(), 0), "消息已读");
return update(
Wrappers.lambdaUpdate(CommonUserNoticeEntity.class)
.eq(CommonUserNoticeEntity::getId, request.getId())
.set(CommonUserNoticeEntity::getHasRead, 1)
.set(CommonUserNoticeEntity::getReleaseTime, new Date())
);
public IPage<CommonUserNoticeApiVO> selectMarketUserNoticeApiPage(IPage<CommonUserNoticeApiVO> page, CommonUserNoticeApiVO vo) {
return page.setRecords(baseMapper.selectMarketUserNoticeApiPage(page, vo, AuthUtil.getUserId()));
}
@Override
public IPage<AppUserNoticeVO> selectMarketUserNoticeApiPage(IPage<CommonUserNoticeEntity> page) {
IPage<CommonUserNoticeEntity> noticeEntityIPage = page(
page,
Wrappers.lambdaQuery(CommonUserNoticeEntity.class)
.eq(CommonUserNoticeEntity::getUserId, AuthUtil.getUserId())
.in(CommonUserNoticeEntity::getNoticeType, List.of(1 , 2))
.orderByAsc(CommonUserNoticeEntity::getHasRead)
.orderByDesc(CommonUserNoticeEntity::getCreateTime)
);
return noticeEntityIPage.convert(AppCommonConvert.INSTANCE::convertNoticeEntityToVO);
public Long marketUnreadNoticeNum() {
return count(Wrappers.<CommonUserNoticeEntity>lambdaQuery()
.eq(CommonUserNoticeEntity::getUserId, AuthUtil.getUserId())
.eq(CommonUserNoticeEntity::getHasRead, 0)
.eq(CommonUserNoticeEntity::getNoticeType, 4)
.eq(CommonUserNoticeEntity::getIsDeleted, 0));
}
@Override
public Integer marketNotReadNoticeNum() {
long count = count(
Wrappers.lambdaQuery(CommonUserNoticeEntity.class)
.eq(CommonUserNoticeEntity::getUserId, AuthUtil.getUserId())
.eq(CommonUserNoticeEntity::getHasRead, 0)
.in(CommonUserNoticeEntity::getNoticeType, List.of(1 ,2))
);
return Math.toIntExact(count);
public List<CommonUserNoticeApiVO> appSystemNoticeList() {
return baseMapper.selectAppSystemNoticeVOList();
}
@Override
public boolean marketUserReadNotice(AppUserNoticeRequest request) {
CommonUserNoticeEntity userNotice = getById(request.getId());
Assert.notNull(userNotice, "通知不存在");
Assert.isTrue(Objects.equals(userNotice.getUserId(), AuthUtil.getUserId()), "无权限阅读其他用户消息");
Assert.isTrue(Objects.equals(userNotice.getNoticeType(), 1) || Objects.equals(userNotice.getNoticeType(), 2), "无效消息类型");
Assert.isTrue(Objects.equals(userNotice.getHasRead(), 0), "消息已读");
return update(
Wrappers.lambdaUpdate(CommonUserNoticeEntity.class)
.eq(CommonUserNoticeEntity::getId, request.getId())
.set(CommonUserNoticeEntity::getHasRead, 1)
.set(CommonUserNoticeEntity::getReleaseTime, new Date())
);
public CommonUserNoticeDetailApiVO userNoticeDetail(Long id) {
CommonUserNoticeEntity notice = getById(id);
Assert.notNull(notice, "无效消息");
Assert.isTrue(Objects.equals(notice.getUserId(), AuthUtil.getUserId()), "无效消息");
if (notice.getHasRead() == 0) {
notice.setHasRead(1);
updateById(notice);
}
return AppCommonConvert.INSTANCE.convertNoticeDetailVO(notice);
}
@Override
public List<CommonUserNoticeApiVO> marketSystemNoticeList() {
return baseMapper.selectMarketSystemNoticeVOList();
}
}

View File

@@ -3,7 +3,7 @@ package org.springblade.modules.market.convert;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import org.springblade.modules.api.vo.MarketDirectInfoVO;
import org.springblade.modules.api.vo.MarketDirectInfoApiVO;
import org.springblade.modules.system.pojo.entity.User;
import java.util.List;
@@ -16,7 +16,7 @@ public interface MarketUserMarketInfoConvert {
@Mapping(target = "phone", expression = "java(org.springblade.core.tool.sensitive.SensitiveUtil.process(entity.getAccount()))")
@Mapping(target = "name", source = "name")
@Mapping(target = "registerTime", source = "createTime")
MarketDirectInfoVO convertMarketUserMarketInfoVO(User entity);
MarketDirectInfoApiVO convertMarketUserMarketInfoVO(User entity);
List<MarketDirectInfoVO> convertMarketUserMarketInfoVOList(List<User> list);
List<MarketDirectInfoApiVO> convertMarketUserMarketInfoVOList(List<User> list);
}

View File

@@ -4,10 +4,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.sensitive.SensitiveType;
import org.springblade.core.tool.sensitive.SensitiveUtil;
import org.springblade.modules.market.convert.MarketUserMarketInfoConvert;
import org.springblade.modules.api.vo.MarketDirectInfoVO;
import org.springblade.modules.api.vo.MarketDirectInfoApiVO;
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
import org.springblade.modules.market.service.IMarketInfoService;
import org.springblade.modules.system.pojo.entity.User;
@@ -28,12 +26,12 @@ public class MarketUserManager {
private final IMarketInfoService marketInfoService;
private final IUserService userService;
public List<MarketDirectInfoVO> findUserPackList() {
public List<MarketDirectInfoApiVO> findUserPackList() {
Long userId = AuthUtil.getUserId();
MarketInfoEntity marketInfoEntity = marketInfoService.getById(userId);
Assert.notNull(marketInfoEntity, "用户不存在");
List<MarketDirectInfoVO> marketDirectInfoVOList = new LinkedList<>();
List<MarketDirectInfoApiVO> marketDirectInfoApiVOList = new LinkedList<>();
List<MarketInfoEntity> marketInfoEntityList = marketInfoService.list(
Wrappers.lambdaQuery(MarketInfoEntity.class)
@@ -60,15 +58,15 @@ public class MarketUserManager {
if (marketInfoEntityMap.containsKey(user.getId())){
MarketInfoEntity marketInfo = marketInfoEntityMap.get(user.getId());
if (marketInfo.getVerified() == 1){
marketDirectInfoVOList.add(
new MarketDirectInfoVO()
marketDirectInfoApiVOList.add(
new MarketDirectInfoApiVO()
.setPhone(SensitiveUtil.process(user.getAccount()))
.setName(desensitizationByPhone(marketInfo.getRealName()))
.setRegisterTime(user.getCreateTime())
);
}else {
marketDirectInfoVOList.add(
new MarketDirectInfoVO()
marketDirectInfoApiVOList.add(
new MarketDirectInfoApiVO()
.setPhone(SensitiveUtil.process(user.getAccount()))
.setName(desensitizationByPhone(user.getName()))
.setRegisterTime(user.getCreateTime())
@@ -79,23 +77,23 @@ public class MarketUserManager {
});
return marketDirectInfoVOList;
return marketDirectInfoApiVOList;
}
public MarketDirectInfoVO findMarketParent() {
public MarketDirectInfoApiVO findMarketParent() {
Long userId = AuthUtil.getUserId();
MarketInfoEntity marketInfoEntity = marketInfoService.getById(userId);
Assert.notNull(marketInfoEntity, "用户不存在");
if (marketInfoEntity.getPid() == null || marketInfoEntity.getPid() <= 0){
return new MarketDirectInfoVO();
return new MarketDirectInfoApiVO();
}
User user = userService.getById(marketInfoEntity.getPid());
if (user == null){
return new MarketDirectInfoVO();
return new MarketDirectInfoApiVO();
}
MarketDirectInfoVO marketDirectInfoVO = new MarketDirectInfoVO()
MarketDirectInfoApiVO marketDirectInfoApiVO = new MarketDirectInfoApiVO()
.setPhone(SensitiveUtil.process(user.getAccount()))
.setName(desensitizationByPhone(user.getName()))
.setRegisterTime(user.getCreateTime());
@@ -104,12 +102,12 @@ public class MarketUserManager {
MarketInfoEntity parentMarketInfoEntity = marketInfoService.getById(marketInfoEntity.getPid());
if(parentMarketInfoEntity != null && parentMarketInfoEntity.getVerified() == 1){
marketDirectInfoVO.setName(desensitizationByPhone(parentMarketInfoEntity.getRealName()));
marketDirectInfoApiVO.setName(desensitizationByPhone(parentMarketInfoEntity.getRealName()));
}
return marketDirectInfoVO;
return marketDirectInfoApiVO;
}