diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/controller/PushMessageController.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/controller/PushMessageController.java new file mode 100644 index 0000000..3f85f5f --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/controller/PushMessageController.java @@ -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; + +/** + *

+ * 消息推送表 前端控制器 + *

+ * + * @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> 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 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); + } +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dao/PushMessageDao.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dao/PushMessageDao.java new file mode 100644 index 0000000..726c8ba --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/dao/PushMessageDao.java @@ -0,0 +1,16 @@ +package com.jinhaiqimeng.sysManageMicroservice.web.dao; + +import com.jinhaiqimeng.sysManageMicroservice.web.entity.PushMessage; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 消息推送表 Mapper 接口 + *

+ * + * @author zp + * @since 2023-12-07 + */ +public interface PushMessageDao extends BaseMapper { + +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/entity/PushMessage.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/entity/PushMessage.java new file mode 100644 index 0000000..bb9c28f --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/entity/PushMessage.java @@ -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; + +/** + *

+ * 消息推送表 + *

+ * + * @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 { + + 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; + } + +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/PushMessageService.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/PushMessageService.java new file mode 100644 index 0000000..4141b6c --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/PushMessageService.java @@ -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; + +/** + *

+ * 消息推送表 服务类 + *

+ * + * @author zp + * @since 2023-12-07 + */ +public interface PushMessageService extends IService { + + ResponseResult> pushMessageList(PushMessageListDTO dto); + + ResponseResult savePushMessage(PushMessageSaveDTO dto); + + ResponseResult getPushMessage(IdDTO dto); + + ResponseResult updatePushMessage(PushMessageUpdateDTO dto); + + ResponseResult enable(IdDTO dto); + + ResponseResult stop(IdDTO dto); + + ResponseResult delete(IdDTO dto); +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/PushMessageServiceImpl.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/PushMessageServiceImpl.java new file mode 100644 index 0000000..0b25a26 --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/service/impl/PushMessageServiceImpl.java @@ -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; + +/** + *

+ * 消息推送表 服务实现类 + *

+ * + * @author zp + * @since 2023-12-07 + */ +@Service +public class PushMessageServiceImpl extends ServiceImpl implements PushMessageService { + + @Override + public ResponseResult> pushMessageList(PushMessageListDTO dto) { + QueryWrapper 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 reportPage = new Page(dto.getPageNum(), dto.getPageSize()); + Page page = page(reportPage,pushMessageVOQueryWrapper); + List 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 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 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 failed = updateMessageStatus(dto,1); + if (failed != null) return failed; + return ResponseResult.success(); + } + + @Override + public ResponseResult stop(IdDTO dto) { + ResponseResult 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 updateMessageStatus(IdDTO dto,int status) { + PushMessage pushMessage = getById(dto.getId()); + if (pushMessage==null){ + return ResponseResult.failed("未找到消息推送信息!"); + } + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.lambda() + .set(PushMessage::getMessageStatus,status) + .eq(PushMessage::getId, dto.getId()); + update(updateWrapper); + return null; + } +} diff --git a/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/PushMessageVO.java b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/PushMessageVO.java new file mode 100644 index 0000000..366f67a --- /dev/null +++ b/src/main/java/com/jinhaiqimeng/sysManageMicroservice/web/vo/PushMessageVO.java @@ -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; +} diff --git a/src/main/resources/mapping/PushMessageDao.xml b/src/main/resources/mapping/PushMessageDao.xml new file mode 100644 index 0000000..389cee9 --- /dev/null +++ b/src/main/resources/mapping/PushMessageDao.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + f_id, f_message_description, f_message_operation_time, f_message_push_status, f_message_push_time, f_message_status, f_message_title + + +