系统消息接口开发
parent
3cb2c3201a
commit
60eab94dc6
|
@ -0,0 +1,78 @@
|
|||
package com.jinhaiqimeng.sysManageMicroservice.web.controller;
|
||||
|
||||
|
||||
import com.jinhaiqimeng.sysManageMicroservice.result.ResponseResult;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.IdDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageListDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageSaveDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageUpdateDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.entity.PushMessage;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.service.PushMessageService;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.vo.PushMessageVO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.vo.common.BaseListDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.vo.common.ListVO;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息推送表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author zp
|
||||
* @since 2023-12-07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/push-message")
|
||||
public class PushMessageController {
|
||||
@Autowired
|
||||
private PushMessageService pushMessageService;
|
||||
|
||||
@RequestMapping(value = "/list",method = RequestMethod.POST)
|
||||
@ApiOperation("消息推送列表查询")
|
||||
public ResponseResult<ListVO<PushMessage>> list(@RequestBody PushMessageListDTO dto){
|
||||
return pushMessageService.pushMessageList(dto);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/save",method = RequestMethod.POST)
|
||||
@ApiOperation("保存消息推送")
|
||||
public ResponseResult save(@RequestBody PushMessageSaveDTO dto){
|
||||
return pushMessageService.savePushMessage(dto);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/get",method = RequestMethod.POST)
|
||||
@ApiOperation("查看消息推送")
|
||||
public ResponseResult<PushMessageVO> save(@RequestBody IdDTO dto){
|
||||
return pushMessageService.getPushMessage(dto);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update",method = RequestMethod.POST)
|
||||
@ApiOperation("更新消息推送")
|
||||
public ResponseResult update(@RequestBody PushMessageUpdateDTO dto){
|
||||
return pushMessageService.updatePushMessage(dto);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/enable",method = RequestMethod.POST)
|
||||
@ApiOperation("启用消息推送")
|
||||
public ResponseResult enable(@RequestBody IdDTO dto){
|
||||
return pushMessageService.enable(dto);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/stop",method = RequestMethod.POST)
|
||||
@ApiOperation("停用消息推送")
|
||||
public ResponseResult stop(@RequestBody IdDTO dto){
|
||||
return pushMessageService.stop(dto);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete",method = RequestMethod.POST)
|
||||
@ApiOperation("删除消息推送")
|
||||
public ResponseResult delete(@RequestBody IdDTO dto){
|
||||
return pushMessageService.delete(dto);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.jinhaiqimeng.sysManageMicroservice.web.dao;
|
||||
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.entity.PushMessage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息推送表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zp
|
||||
* @since 2023-12-07
|
||||
*/
|
||||
public interface PushMessageDao extends BaseMapper<PushMessage> {
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.jinhaiqimeng.sysManageMicroservice.web.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息推送表
|
||||
* </p>
|
||||
*
|
||||
* @author zp
|
||||
* @since 2023-12-07
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_sysmanage_microservice_push_message")
|
||||
@ApiModel(value="PushMessage对象", description="消息推送表")
|
||||
public class PushMessage extends Model<PushMessage> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
@TableId(value = "f_id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "消息描述")
|
||||
@TableField("f_message_description")
|
||||
private String messageDescription;
|
||||
|
||||
@ApiModelProperty(value = "消息操作时间")
|
||||
@TableField("f_message_operation_time")
|
||||
private LocalDateTime messageOperationTime;
|
||||
|
||||
@ApiModelProperty(value = "消息推送状态1已推送2末推送")
|
||||
@TableField("f_message_push_status")
|
||||
private Integer messagePushStatus;
|
||||
|
||||
@ApiModelProperty(value = "消息推送时间")
|
||||
@TableField("f_message_push_time")
|
||||
private LocalDateTime messagePushTime;
|
||||
|
||||
@ApiModelProperty(value = "消息状态1启用2停用")
|
||||
@TableField("f_message_status")
|
||||
private Integer messageStatus;
|
||||
|
||||
@ApiModelProperty(value = "消息标题")
|
||||
@TableField("f_message_title")
|
||||
private String messageTitle;
|
||||
|
||||
|
||||
@Override
|
||||
protected Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.jinhaiqimeng.sysManageMicroservice.web.service;
|
||||
|
||||
import com.jinhaiqimeng.sysManageMicroservice.result.ResponseResult;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.IdDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageListDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageSaveDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageUpdateDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.entity.PushMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.vo.PushMessageVO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.vo.common.ListVO;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息推送表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zp
|
||||
* @since 2023-12-07
|
||||
*/
|
||||
public interface PushMessageService extends IService<PushMessage> {
|
||||
|
||||
ResponseResult<ListVO<PushMessage>> pushMessageList(PushMessageListDTO dto);
|
||||
|
||||
ResponseResult savePushMessage(PushMessageSaveDTO dto);
|
||||
|
||||
ResponseResult<PushMessageVO> getPushMessage(IdDTO dto);
|
||||
|
||||
ResponseResult updatePushMessage(PushMessageUpdateDTO dto);
|
||||
|
||||
ResponseResult enable(IdDTO dto);
|
||||
|
||||
ResponseResult stop(IdDTO dto);
|
||||
|
||||
ResponseResult delete(IdDTO dto);
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
package com.jinhaiqimeng.sysManageMicroservice.web.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.result.ResponseResult;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.util.DateUtils;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.IdDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageListDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageSaveDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dto.PushMessageUpdateDTO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.entity.PushMessage;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.dao.PushMessageDao;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.service.PushMessageService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.vo.PushMessageVO;
|
||||
import com.jinhaiqimeng.sysManageMicroservice.web.vo.common.ListVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 消息推送表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zp
|
||||
* @since 2023-12-07
|
||||
*/
|
||||
@Service
|
||||
public class PushMessageServiceImpl extends ServiceImpl<PushMessageDao, PushMessage> implements PushMessageService {
|
||||
|
||||
@Override
|
||||
public ResponseResult<ListVO<PushMessage>> pushMessageList(PushMessageListDTO dto) {
|
||||
QueryWrapper<PushMessage> pushMessageVOQueryWrapper = new QueryWrapper<>();
|
||||
pushMessageVOQueryWrapper.lambda()
|
||||
.eq(dto.getMessagePushStatus()==1||dto.getMessagePushStatus()==2,PushMessage::getMessagePushStatus,dto.getMessagePushStatus())
|
||||
.between(StrUtil.isNotBlank(dto.getMessageOperationStartTime())&&StrUtil.isNotBlank(dto.getMessageOperationEndTime()),
|
||||
PushMessage::getMessageOperationTime,dto.getMessageOperationStartTime(),dto.getMessageOperationEndTime())
|
||||
.between(StrUtil.isNotBlank(dto.getMessagePushStartTime())&&StrUtil.isNotBlank(dto.getMessagePushEndTime()),
|
||||
PushMessage::getMessagePushTime,dto.getMessagePushStartTime(),dto.getMessagePushEndTime())
|
||||
.like(StrUtil.isNotBlank(dto.getMessageTitle()),PushMessage::getMessageTitle,dto.getMessageTitle())
|
||||
.orderByDesc(PushMessage::getMessageOperationTime);
|
||||
|
||||
|
||||
Page<PushMessage> reportPage = new Page<PushMessage>(dto.getPageNum(), dto.getPageSize());
|
||||
Page<PushMessage> page = page(reportPage,pushMessageVOQueryWrapper);
|
||||
List<PushMessage> records = page.getRecords();
|
||||
return ResponseResult.success(new ListVO<>(records,page.getTotal(),(int)page.getCurrent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult savePushMessage(PushMessageSaveDTO dto) {
|
||||
PushMessage pushMessage=new PushMessage();
|
||||
pushMessage.setMessagePushStatus(2);
|
||||
pushMessage.setMessagePushTime(DateUtils.getLocalDateTime(dto.getMessagePushTime()));
|
||||
pushMessage.setMessageStatus(1);
|
||||
pushMessage.setMessageTitle(dto.getMessageTitle());
|
||||
pushMessage.setMessageDescription(dto.getMessageDescription());
|
||||
pushMessage.setMessageOperationTime(LocalDateTime.now());
|
||||
save(pushMessage);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult<PushMessageVO> getPushMessage(IdDTO dto) {
|
||||
PushMessage pushMessage=getById(dto.getId());
|
||||
PushMessageVO pushMessageVO=new PushMessageVO();
|
||||
BeanUtils.copyProperties(pushMessage,pushMessageVO);
|
||||
return ResponseResult.success(pushMessageVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult updatePushMessage(PushMessageUpdateDTO dto) {
|
||||
PushMessage pushMessage = getById(dto.getMessageld());
|
||||
if (pushMessage==null){
|
||||
return ResponseResult.failed("未找到消息推送信息!");
|
||||
}
|
||||
LocalDateTime localDateTime=null;
|
||||
if(StringUtils.isNotBlank(dto.getMessagePushTime()))
|
||||
localDateTime=DateUtils.getLocalDateTime(dto.getMessagePushTime());
|
||||
|
||||
UpdateWrapper<PushMessage> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.lambda()
|
||||
.set(StringUtils.isNotBlank(dto.getMessageTitle()),PushMessage::getMessageTitle,dto.getMessageTitle())
|
||||
.set(StringUtils.isNotBlank(dto.getMessageDescription()),PushMessage::getMessageDescription,dto.getMessageDescription())
|
||||
.set(StringUtils.isNotBlank(dto.getMessagePushTime()),PushMessage::getMessagePushTime,localDateTime)
|
||||
.eq(PushMessage::getId,dto.getMessageld());
|
||||
update(updateWrapper);
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult enable(IdDTO dto) {
|
||||
ResponseResult<Object> failed = updateMessageStatus(dto,1);
|
||||
if (failed != null) return failed;
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult stop(IdDTO dto) {
|
||||
ResponseResult<Object> failed = updateMessageStatus(dto,2);
|
||||
if (failed != null) return failed;
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseResult delete(IdDTO dto) {
|
||||
removeById(dto.getId());
|
||||
return ResponseResult.success();
|
||||
}
|
||||
|
||||
private ResponseResult<Object> updateMessageStatus(IdDTO dto,int status) {
|
||||
PushMessage pushMessage = getById(dto.getId());
|
||||
if (pushMessage==null){
|
||||
return ResponseResult.failed("未找到消息推送信息!");
|
||||
}
|
||||
UpdateWrapper<PushMessage> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.lambda()
|
||||
.set(PushMessage::getMessageStatus,status)
|
||||
.eq(PushMessage::getId, dto.getId());
|
||||
update(updateWrapper);
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.jinhaiqimeng.sysManageMicroservice.web.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author cxt
|
||||
* @date 2023-10-16 13:26
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "PushMessageVO",description = "消息推送VO")
|
||||
public class PushMessageVO {
|
||||
|
||||
@ApiModelProperty(value = "主键")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "消息描述")
|
||||
private String messageDescription;
|
||||
|
||||
@ApiModelProperty(value = "消息操作时间")
|
||||
private LocalDateTime messageOperationTime;
|
||||
|
||||
@ApiModelProperty(value = "消息推送状态1已推送2末推送")
|
||||
private Integer messagePushStatus;
|
||||
|
||||
@ApiModelProperty(value = "消息推送时间")
|
||||
private LocalDateTime messagePushTime;
|
||||
|
||||
@ApiModelProperty(value = "消息状态1启用2停用")
|
||||
private Integer messageStatus;
|
||||
|
||||
@ApiModelProperty(value = "消息标题")
|
||||
private String messageTitle;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?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.jinhaiqimeng.sysManageMicroservice.web.dao.PushMessageDao">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.jinhaiqimeng.sysManageMicroservice.web.entity.PushMessage">
|
||||
<id column="f_id" property="id" />
|
||||
<result column="f_message_description" property="messageDescription" />
|
||||
<result column="f_message_operation_time" property="messageOperationTime" />
|
||||
<result column="f_message_push_status" property="messagePushStatus" />
|
||||
<result column="f_message_push_time" property="messagePushTime" />
|
||||
<result column="f_message_status" property="messageStatus" />
|
||||
<result column="f_message_title" property="messageTitle" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
f_id, f_message_description, f_message_operation_time, f_message_push_status, f_message_push_time, f_message_status, f_message_title
|
||||
</sql>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue