通知中心接口
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.SyncNotice;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-07
|
||||
*/
|
||||
public interface SyncNoticeMapper extends BaseMapper<SyncNotice> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.product.dto.SyncNoticeReadDTO;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.SyncNotice;
|
||||
import com.czg.account.service.SyncNoticeService;
|
||||
import com.czg.service.account.mapper.SyncNoticeMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-07
|
||||
*/
|
||||
@Service
|
||||
public class SyncNoticeServiceImpl extends ServiceImpl<SyncNoticeMapper, SyncNotice> implements SyncNoticeService {
|
||||
|
||||
@Override
|
||||
public void addNotice(Long shopId, Long sysUserId, String name, Long id, Integer type) {
|
||||
SyncNotice syncNotice = new SyncNotice();
|
||||
syncNotice.setShopId(shopId);
|
||||
syncNotice.setSysUserId(sysUserId);
|
||||
syncNotice.setName(name);
|
||||
syncNotice.setSourceId(id);
|
||||
syncNotice.setType(type);
|
||||
save(syncNotice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SyncNotice> pageInfo(Long shopId, String name, String startTime, String endTime, Integer type, Integer isRead) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper().eq(SyncNotice::getShopId, shopId);
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
queryWrapper.like(SyncNotice::getName, name);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(startTime)) {
|
||||
queryWrapper.ge(SyncNotice::getCreateTime, startTime);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(endTime)) {
|
||||
queryWrapper.le(SyncNotice::getCreateTime, endTime);
|
||||
}
|
||||
queryWrapper.eq(SyncNotice::getType, type);
|
||||
queryWrapper.eq(SyncNotice::getIsRead, isRead);
|
||||
queryWrapper.orderBy(SyncNotice::getCreateTime, false);
|
||||
return page(PageUtil.buildPage(), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean read(Long shopId, SyncNoticeReadDTO syncNoticeReadDTO) {
|
||||
List<SyncNotice> listed = list(new QueryWrapper().eq(SyncNotice::getShopId, shopId).in(SyncNotice::getId, syncNoticeReadDTO.getNoticeIdList()));
|
||||
listed.forEach(item -> {
|
||||
if (item.getIsRead() == 0) {
|
||||
item.setIsRead(1);
|
||||
item.setReadTime(DateUtil.date().toLocalDateTime());
|
||||
}
|
||||
});
|
||||
return updateBatch(listed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.SyncNoticeMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user