61 lines
2.2 KiB
Java
61 lines
2.2 KiB
Java
|
|
package com.gunshi.project.xyt.service;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||
|
|
import com.gunshi.project.xyt.entity.so.MessageCenterPageSo;
|
||
|
|
import com.gunshi.project.xyt.mapper.MessageCenterMapper;
|
||
|
|
import com.gunshi.project.xyt.model.MessageCenter;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
import org.springframework.transaction.annotation.Transactional;
|
||
|
|
|
||
|
|
import java.util.Date;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 描述: 消息中心
|
||
|
|
* author: xusan
|
||
|
|
* date: 2024-09-19 10:39:29
|
||
|
|
*/
|
||
|
|
@Service
|
||
|
|
@Slf4j
|
||
|
|
@Transactional(rollbackFor = Exception.class)
|
||
|
|
public class MessageCenterService extends ServiceImpl<MessageCenterMapper, MessageCenter>
|
||
|
|
{
|
||
|
|
|
||
|
|
public void insertMessage(List<MessageCenter> messageCenters){
|
||
|
|
for(MessageCenter messageCenter : messageCenters){
|
||
|
|
messageCenter.setId(IdWorker.getId());
|
||
|
|
messageCenter.setPublishTime(new Date());
|
||
|
|
messageCenter.setStatus(0);
|
||
|
|
}
|
||
|
|
this.saveBatch(messageCenters);
|
||
|
|
}
|
||
|
|
|
||
|
|
public Page<MessageCenter> listPage(MessageCenterPageSo page) {
|
||
|
|
LambdaQueryWrapper<MessageCenter> queryWrapper = Wrappers.lambdaQuery();
|
||
|
|
queryWrapper.eq(MessageCenter::getReceiveUserId,page.getReceiveUserId())
|
||
|
|
.eq(MessageCenter::getStatus,page.getStatus());
|
||
|
|
if (ObjectUtils.isNotNull(page.getTitle())) {
|
||
|
|
queryWrapper.like(MessageCenter::getTitle, page.getTitle());
|
||
|
|
}
|
||
|
|
if (ObjectUtils.isNotNull(page.getPublishUserName())) {
|
||
|
|
queryWrapper.like(MessageCenter::getPublishUserName, page.getPublishUserName());
|
||
|
|
}
|
||
|
|
return this.page(page.getPageSo().toPage(),queryWrapper);
|
||
|
|
}
|
||
|
|
|
||
|
|
public Boolean allRead(Long receiveUserId) {
|
||
|
|
return this.lambdaUpdate()
|
||
|
|
.set(MessageCenter::getStatus, 1)
|
||
|
|
.eq(MessageCenter::getReceiveUserId, receiveUserId)
|
||
|
|
.update();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|