【8.1.0】【message】更新获取个人信息列表

pull/60/head
fengshuonan 2024-01-12 18:19:44 +08:00
parent 9f8c94c4c9
commit 6161e8bd89
4 changed files with 30 additions and 165 deletions

View File

@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
@ -30,18 +29,6 @@ public class SysMessageController {
@Resource
private SysMessageService sysMessageService;
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@PostResource(name = "添加系统消息", path = "/sysMessage/add")
public ResponseData<SysMessage> add(@RequestBody @Validated(SysMessageRequest.add.class) SysMessageRequest sysMessageRequest) {
sysMessageService.add(sysMessageRequest);
return new SuccessResponseData<>();
}
/**
*
*
@ -49,32 +36,19 @@ public class SysMessageController {
* @since 2024/01/12 17:31
*/
@PostResource(name = "删除系统消息", path = "/sysMessage/delete")
public ResponseData<?> delete(@RequestBody @Validated(SysMessageRequest.delete.class) SysMessageRequest sysMessageRequest) {
public ResponseData<?> delete(@RequestBody @Validated(BaseRequest.detail.class) SysMessageRequest sysMessageRequest) {
sysMessageService.del(sysMessageRequest);
return new SuccessResponseData<>();
}
/**
*
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
* @since 2024-01-12 18:12
*/
@PostResource(name = "批量删除系统消息", path = "/sysMessage/batchDelete")
public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) SysMessageRequest sysMessageRequest) {
sysMessageService.batchDelete(sysMessageRequest);
return new SuccessResponseData<>();
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@PostResource(name = "编辑系统消息", path = "/sysMessage/edit")
public ResponseData<?> edit(@RequestBody @Validated(SysMessageRequest.edit.class) SysMessageRequest sysMessageRequest) {
sysMessageService.edit(sysMessageRequest);
@PostResource(name = "设为已读消息", path = "/sysMessage/setRead")
public ResponseData<?> setRead(@RequestBody @Validated(BaseRequest.detail.class) SysMessageRequest sysMessageRequest) {
return new SuccessResponseData<>();
}
@ -90,23 +64,12 @@ public class SysMessageController {
}
/**
*
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@GetResource(name = "获取系统消息列表", path = "/sysMessage/list")
public ResponseData<List<SysMessage>> list(SysMessageRequest sysMessageRequest) {
return new SuccessResponseData<>(sysMessageService.findList(sysMessageRequest));
}
/**
*
*
* @author fengshuonan
* @since 2024/01/12 17:31
*/
@GetResource(name = "获取系统消息列表(带分页)", path = "/sysMessage/page")
@GetResource(name = "获取个人系统消息列表(带分页)", path = "/sysMessage/page")
public ResponseData<PageResult<SysMessage>> page(SysMessageRequest sysMessageRequest) {
return new SuccessResponseData<>(sysMessageService.findPage(sysMessageRequest));
}

View File

@ -76,7 +76,7 @@ public class SysMessageRequest extends BaseRequest {
*
*/
@ChineseDescription("消息发送时间")
private String messageSendTime;
private String messageSendTime;
/**
* id
@ -96,26 +96,6 @@ public class SysMessageRequest extends BaseRequest {
@ChineseDescription("阅读状态0-未读1-已读")
private Integer readFlag;
/**
*
*/
@ChineseDescription("乐观锁")
private Long versionFlag;
/**
* Y-N-
*/
@NotBlank(message = "是否删除Y-被删除N-未删除不能为空", groups = {add.class, edit.class})
@ChineseDescription("是否删除Y-被删除N-未删除")
private String delFlag;
/**
*
*/
@ChineseDescription("租户号")
private Long tenantId;
/**
* id
*/

View File

@ -5,8 +5,6 @@ import cn.stylefeng.roses.kernel.sys.modular.message.entity.SysMessage;
import cn.stylefeng.roses.kernel.sys.modular.message.pojo.request.SysMessageRequest;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
*
*
@ -15,15 +13,6 @@ import java.util.List;
*/
public interface SysMessageService extends IService<SysMessage> {
/**
*
*
* @param sysMessageRequest
* @author fengshuonan
* @since 2024/01/12 17:31
*/
void add(SysMessageRequest sysMessageRequest);
/**
*
*
@ -33,24 +22,6 @@ public interface SysMessageService extends IService<SysMessage> {
*/
void del(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @author fengshuonan
* @since 2024/01/12 17:31
*/
void batchDelete(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @author fengshuonan
* @since 2024/01/12 17:31
*/
void edit(SysMessageRequest sysMessageRequest);
/**
*
*
@ -60,20 +31,10 @@ public interface SysMessageService extends IService<SysMessage> {
*/
SysMessage detail(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @return List<SysMessage>
* @author fengshuonan
* @since 2024/01/12 17:31
*/
List<SysMessage> findList(SysMessageRequest sysMessageRequest);
/**
*
*
* @param sysMessageRequest
* @param sysMessageRequest
* @return PageResult<SysMessage>
* @author fengshuonan
* @since 2024/01/12 17:31

View File

@ -1,7 +1,7 @@
package cn.stylefeng.roses.kernel.sys.modular.message.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
@ -15,9 +15,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
*
@ -28,32 +25,12 @@ import java.util.List;
@Service
public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMessage> implements SysMessageService {
@Override
public void add(SysMessageRequest sysMessageRequest) {
SysMessage sysMessage = new SysMessage();
BeanUtil.copyProperties(sysMessageRequest, sysMessage);
this.save(sysMessage);
}
@Override
public void del(SysMessageRequest sysMessageRequest) {
SysMessage sysMessage = this.querySysMessage(sysMessageRequest);
this.removeById(sysMessage.getMessageId());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchDelete(SysMessageRequest sysMessageRequest) {
this.removeByIds(sysMessageRequest.getBatchDeleteIdList());
}
@Override
public void edit(SysMessageRequest sysMessageRequest) {
SysMessage sysMessage = this.querySysMessage(sysMessageRequest);
BeanUtil.copyProperties(sysMessageRequest, sysMessage);
this.updateById(sysMessage);
}
@Override
public SysMessage detail(SysMessageRequest sysMessageRequest) {
return this.querySysMessage(sysMessageRequest);
@ -62,16 +39,14 @@ public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMess
@Override
public PageResult<SysMessage> findPage(SysMessageRequest sysMessageRequest) {
LambdaQueryWrapper<SysMessage> wrapper = createWrapper(sysMessageRequest);
// 查询关键字段
wrapper.select(SysMessage::getMessageId, SysMessage::getMessageTitle, SysMessage::getPriorityLevel, SysMessage::getMessageSendTime);
Page<SysMessage> pageList = this.page(PageFactory.defaultPage(), wrapper);
return PageResultFactory.createPageResult(pageList);
}
@Override
public List<SysMessage> findList(SysMessageRequest sysMessageRequest) {
LambdaQueryWrapper<SysMessage> wrapper = this.createWrapper(sysMessageRequest);
return this.list(wrapper);
}
/**
*
*
@ -95,37 +70,23 @@ public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMess
private LambdaQueryWrapper<SysMessage> createWrapper(SysMessageRequest sysMessageRequest) {
LambdaQueryWrapper<SysMessage> queryWrapper = new LambdaQueryWrapper<>();
Long messageId = sysMessageRequest.getMessageId();
Long receiveUserId = sysMessageRequest.getReceiveUserId();
Long sendUserId = sysMessageRequest.getSendUserId();
String messageTitle = sysMessageRequest.getMessageTitle();
String messageContent = sysMessageRequest.getMessageContent();
String messageType = sysMessageRequest.getMessageType();
String messageUrl = sysMessageRequest.getMessageUrl();
String priorityLevel = sysMessageRequest.getPriorityLevel();
String messageSendTime = sysMessageRequest.getMessageSendTime();
String businessId = sysMessageRequest.getBusinessId();
String businessType = sysMessageRequest.getBusinessType();
Integer readFlag = sysMessageRequest.getReadFlag();
Long versionFlag = sysMessageRequest.getVersionFlag();
String delFlag = sysMessageRequest.getDelFlag();
Long tenantId = sysMessageRequest.getTenantId();
// 根据标题查询
String searchText = sysMessageRequest.getSearchText();
if (StrUtil.isNotBlank(searchText)) {
queryWrapper.like(SysMessage::getMessageTitle, searchText);
}
queryWrapper.eq(ObjectUtil.isNotNull(messageId), SysMessage::getMessageId, messageId);
queryWrapper.eq(ObjectUtil.isNotNull(receiveUserId), SysMessage::getReceiveUserId, receiveUserId);
queryWrapper.eq(ObjectUtil.isNotNull(sendUserId), SysMessage::getSendUserId, sendUserId);
queryWrapper.like(ObjectUtil.isNotEmpty(messageTitle), SysMessage::getMessageTitle, messageTitle);
queryWrapper.like(ObjectUtil.isNotEmpty(messageContent), SysMessage::getMessageContent, messageContent);
queryWrapper.like(ObjectUtil.isNotEmpty(messageType), SysMessage::getMessageType, messageType);
queryWrapper.like(ObjectUtil.isNotEmpty(messageUrl), SysMessage::getMessageUrl, messageUrl);
queryWrapper.like(ObjectUtil.isNotEmpty(priorityLevel), SysMessage::getPriorityLevel, priorityLevel);
queryWrapper.eq(ObjectUtil.isNotNull(messageSendTime), SysMessage::getMessageSendTime, messageSendTime);
queryWrapper.like(ObjectUtil.isNotEmpty(businessId), SysMessage::getBusinessId, businessId);
queryWrapper.like(ObjectUtil.isNotEmpty(businessType), SysMessage::getBusinessType, businessType);
queryWrapper.eq(ObjectUtil.isNotNull(readFlag), SysMessage::getReadFlag, readFlag);
queryWrapper.eq(ObjectUtil.isNotNull(versionFlag), SysMessage::getVersionFlag, versionFlag);
queryWrapper.like(ObjectUtil.isNotEmpty(delFlag), SysMessage::getDelFlag, delFlag);
queryWrapper.eq(ObjectUtil.isNotNull(tenantId), SysMessage::getTenantId, tenantId);
// 根据优先级查询
String priorityLevel = sysMessageRequest.getPriorityLevel();
if (ObjectUtil.isNotEmpty(priorityLevel)) {
queryWrapper.eq(SysMessage::getPriorityLevel, priorityLevel);
}
// 根据已读状态
Integer readFlag = sysMessageRequest.getReadFlag();
if (ObjectUtil.isNotEmpty(readFlag)) {
queryWrapper.eq(SysMessage::getReadFlag, readFlag);
}
return queryWrapper;
}