增加消息板块
This commit is contained in:
@ -0,0 +1,108 @@
|
||||
package com.ruoyi.web.controller.wgz.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.ruoyi.wgz.domain.WgzMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.wgz.bo.WgzMessageQueryBo;
|
||||
import com.ruoyi.wgz.service.IWgzMessageService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* 消息Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-02-24
|
||||
*/
|
||||
@Api(value = "消息控制器", tags = {"消息管理"})
|
||||
@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
||||
@RestController
|
||||
@RequestMapping("/wgz/message")
|
||||
public class WgzMessageController extends BaseController {
|
||||
|
||||
private final IWgzMessageService iWgzMessageService;
|
||||
|
||||
/**
|
||||
* 查询消息列表
|
||||
*/
|
||||
@ApiOperation("查询消息列表")
|
||||
@PreAuthorize("@ss.hasPermi('wgz:message:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WgzMessage> list(@Validated WgzMessageQueryBo bo) {
|
||||
return iWgzMessageService.queryPageList(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出消息列表
|
||||
*/
|
||||
@ApiOperation("导出消息列表")
|
||||
@PreAuthorize("@ss.hasPermi('wgz:message:export')")
|
||||
@Log(title = "消息", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult<WgzMessage> export(@Validated WgzMessageQueryBo bo) {
|
||||
List<WgzMessage> list = iWgzMessageService.queryList(bo);
|
||||
ExcelUtil<WgzMessage> util = new ExcelUtil<WgzMessage>(WgzMessage.class);
|
||||
return util.exportExcel(list, "消息");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息详细信息
|
||||
*/
|
||||
@ApiOperation("获取消息详细信息")
|
||||
@PreAuthorize("@ss.hasPermi('wgz:message:query')")
|
||||
@GetMapping("/{id}")
|
||||
public AjaxResult<WgzMessage> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
return AjaxResult.success(iWgzMessageService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增消息
|
||||
*/
|
||||
@ApiOperation("新增消息")
|
||||
@PreAuthorize("@ss.hasPermi('wgz:message:add')")
|
||||
@Log(title = "消息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit
|
||||
@PostMapping()
|
||||
public AjaxResult<Void> add(@Validated @RequestBody WgzMessage bo) {
|
||||
return toAjax(iWgzMessageService.insert(bo) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改消息
|
||||
*/
|
||||
@ApiOperation("修改消息")
|
||||
@PreAuthorize("@ss.hasPermi('wgz:message:edit')")
|
||||
@Log(title = "消息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit
|
||||
@PutMapping()
|
||||
public AjaxResult<Void> edit(@Validated @RequestBody WgzMessage bo) {
|
||||
return toAjax(iWgzMessageService.update(bo) ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除消息
|
||||
*/
|
||||
@ApiOperation("删除消息")
|
||||
@PreAuthorize("@ss.hasPermi('wgz:message:remove')")
|
||||
@Log(title = "消息" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iWgzMessageService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.ruoyi.wgz.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.LocalDate;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 消息分页查询对象 wgz_message
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-02-24
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("消息分页查询对象")
|
||||
public class WgzMessageQueryBo extends BaseEntity {
|
||||
|
||||
/** 分页大小 */
|
||||
@ApiModelProperty("分页大小")
|
||||
private Integer pageSize;
|
||||
/** 当前页数 */
|
||||
@ApiModelProperty("当前页数")
|
||||
private Integer pageNum;
|
||||
/** 排序列 */
|
||||
@ApiModelProperty("排序列")
|
||||
private String orderByColumn;
|
||||
/** 排序的方向desc或者asc */
|
||||
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
|
||||
private String isAsc;
|
||||
|
||||
|
||||
/** 发送类型(0系统 1务工者 2包工头) */
|
||||
@ApiModelProperty("发送类型(0系统 1务工者 2包工头)")
|
||||
private String senderType;
|
||||
/** 发送人 */
|
||||
@ApiModelProperty("发送人")
|
||||
private Long senderId;
|
||||
/** 接收类型(1务工者 2包工头) */
|
||||
@ApiModelProperty("接收类型(1务工者 2包工头)")
|
||||
private String recipientType;
|
||||
/** 接收人 */
|
||||
@ApiModelProperty("接收人")
|
||||
private Long recipientId;
|
||||
/** 标题 */
|
||||
@ApiModelProperty("标题")
|
||||
private String headline;
|
||||
/** 副标题 */
|
||||
@ApiModelProperty("副标题")
|
||||
private String subheading;
|
||||
/** 表ID */
|
||||
@ApiModelProperty("表ID")
|
||||
private Long tableId;
|
||||
/** 表名 */
|
||||
@ApiModelProperty("表名")
|
||||
private String tableName;
|
||||
/** 大类型(字典) */
|
||||
@ApiModelProperty("大类型(字典)")
|
||||
private String messageLargeType;
|
||||
/** 小类型(字典) */
|
||||
@ApiModelProperty("小类型(字典)")
|
||||
private String messageSmallType;
|
||||
/** 读状态(0未读 1已读) */
|
||||
@ApiModelProperty("读状态(0未读 1已读)")
|
||||
private String readStatus;
|
||||
|
||||
}
|
128
ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzMessage.java
Normal file
128
ruoyi-system/src/main/java/com/ruoyi/wgz/domain/WgzMessage.java
Normal file
@ -0,0 +1,128 @@
|
||||
package com.ruoyi.wgz.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 消息对象 wgz_message
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-02-24
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@TableName("wgz_message")
|
||||
@ApiModel("消息视图对象")
|
||||
public class WgzMessage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/** 主键自增ID */
|
||||
@ApiModelProperty("主键自增ID")
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/** 发送类型(0系统 1务工者 2包工头) */
|
||||
@Excel(name = "发送类型" , readConverterExp = "0=系统,1=务工者,2=包工头")
|
||||
@ApiModelProperty("发送类型(0系统 1务工者 2包工头)")
|
||||
private String senderType;
|
||||
|
||||
/** 发送人 */
|
||||
@Excel(name = "发送人")
|
||||
@ApiModelProperty("发送人")
|
||||
private Long senderId;
|
||||
|
||||
/** 接收类型(1务工者 2包工头) */
|
||||
@Excel(name = "接收类型" , readConverterExp = "1=务工者,2=包工头")
|
||||
@ApiModelProperty("接收类型(1务工者 2包工头)")
|
||||
private String recipientType;
|
||||
|
||||
/** 接收人 */
|
||||
@Excel(name = "接收人")
|
||||
@ApiModelProperty("接收人")
|
||||
private Long recipientId;
|
||||
|
||||
/** 标题 */
|
||||
@Excel(name = "标题")
|
||||
@ApiModelProperty("标题")
|
||||
private String headline;
|
||||
|
||||
/** 副标题 */
|
||||
@Excel(name = "副标题")
|
||||
@ApiModelProperty("副标题")
|
||||
private String subheading;
|
||||
|
||||
/** 表ID */
|
||||
@Excel(name = "表ID")
|
||||
@ApiModelProperty("表ID")
|
||||
private Long tableId;
|
||||
|
||||
/** 表名 */
|
||||
@Excel(name = "表名")
|
||||
@ApiModelProperty("表名")
|
||||
private String tableName;
|
||||
|
||||
/** 大类型(字典) */
|
||||
@Excel(name = "大类型" , readConverterExp = "字=典")
|
||||
@ApiModelProperty("大类型(字典)")
|
||||
private String messageLargeType;
|
||||
|
||||
/** 小类型(字典) */
|
||||
@Excel(name = "小类型" , readConverterExp = "字=典")
|
||||
@ApiModelProperty("小类型(字典)")
|
||||
private String messageSmallType;
|
||||
|
||||
/** 读状态(0未读 1已读) */
|
||||
@Excel(name = "读状态" , readConverterExp = "0=未读,1=已读")
|
||||
@ApiModelProperty("读状态(0未读 1已读)")
|
||||
private String readStatus;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
@Excel(name = "删除标志" , readConverterExp = "0=代表存在,2=代表删除")
|
||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||
private String delFlag;
|
||||
|
||||
/** 创建者 */
|
||||
@Excel(name = "创建者")
|
||||
@ApiModelProperty("创建者")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
@Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 更新者 */
|
||||
@Excel(name = "更新者")
|
||||
@ApiModelProperty("更新者")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@Excel(name = "更新时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/** 备注 */
|
||||
@Excel(name = "备注")
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.ruoyi.wgz.mapper;
|
||||
|
||||
import com.ruoyi.wgz.domain.WgzMessage;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
|
||||
/**
|
||||
* 消息Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-02-24
|
||||
*/
|
||||
// 如使需切换数据源 请勿使用缓存 会造成数据不一致现象
|
||||
@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class)
|
||||
public interface WgzMessageMapper extends BaseMapperPlus<WgzMessage> {
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.ruoyi.wgz.service;
|
||||
|
||||
import com.ruoyi.wgz.domain.WgzMessage;
|
||||
import com.ruoyi.wgz.bo.WgzMessageQueryBo;
|
||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-02-24
|
||||
*/
|
||||
public interface IWgzMessageService extends IServicePlus<WgzMessage> {
|
||||
/**
|
||||
* 查询单个
|
||||
* @return
|
||||
*/
|
||||
WgzMessage queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
TableDataInfo<WgzMessage> queryPageList(WgzMessageQueryBo bo);
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
List<WgzMessage> queryList(WgzMessageQueryBo bo);
|
||||
|
||||
/**
|
||||
* 根据新增业务对象插入消息
|
||||
* @param bo 消息新增业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean insert(WgzMessage bo);
|
||||
|
||||
/**
|
||||
* 根据编辑业务对象修改消息
|
||||
* @param bo 消息编辑业务对象
|
||||
* @return
|
||||
*/
|
||||
Boolean update(WgzMessage bo);
|
||||
|
||||
/**
|
||||
* 校验并删除数据
|
||||
* @param ids 主键集合
|
||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.ruoyi.wgz.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.core.page.PagePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.wgz.bo.WgzMessageQueryBo;
|
||||
import com.ruoyi.wgz.domain.WgzMessage;
|
||||
import com.ruoyi.wgz.mapper.WgzMessageMapper;
|
||||
import com.ruoyi.wgz.service.IWgzMessageService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 消息Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-02-24
|
||||
*/
|
||||
@Service
|
||||
public class WgzMessageServiceImpl extends ServicePlusImpl<WgzMessageMapper, WgzMessage> implements IWgzMessageService {
|
||||
|
||||
@Override
|
||||
public WgzMessage queryById(Long id){
|
||||
return getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WgzMessage> queryPageList(WgzMessageQueryBo bo) {
|
||||
Page<WgzMessage> result = page(PageUtils.buildPage(), buildQueryWrapper(bo));
|
||||
return PageUtils.buildDataInfo(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WgzMessage> queryList(WgzMessageQueryBo bo) {
|
||||
return list(buildQueryWrapper(bo));
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WgzMessage> buildQueryWrapper(WgzMessageQueryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<WgzMessage> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getSenderType()), WgzMessage::getSenderType, bo.getSenderType());
|
||||
lqw.eq(bo.getSenderId() != null, WgzMessage::getSenderId, bo.getSenderId());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getRecipientType()), WgzMessage::getRecipientType, bo.getRecipientType());
|
||||
lqw.eq(bo.getRecipientId() != null, WgzMessage::getRecipientId, bo.getRecipientId());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getHeadline()), WgzMessage::getHeadline, bo.getHeadline());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getSubheading()), WgzMessage::getSubheading, bo.getSubheading());
|
||||
lqw.eq(bo.getTableId() != null, WgzMessage::getTableId, bo.getTableId());
|
||||
lqw.like(StrUtil.isNotBlank(bo.getTableName()), WgzMessage::getTableName, bo.getTableName());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getMessageLargeType()), WgzMessage::getMessageLargeType, bo.getMessageLargeType());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getMessageSmallType()), WgzMessage::getMessageSmallType, bo.getMessageSmallType());
|
||||
lqw.eq(StrUtil.isNotBlank(bo.getReadStatus()), WgzMessage::getReadStatus, bo.getReadStatus());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insert(WgzMessage bo) {
|
||||
WgzMessage add = BeanUtil.toBean(bo, WgzMessage.class);
|
||||
validEntityBeforeSave(add);
|
||||
return save(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(WgzMessage bo) {
|
||||
WgzMessage update = BeanUtil.toBean(bo, WgzMessage.class);
|
||||
validEntityBeforeSave(update);
|
||||
return updateById(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*
|
||||
* @param entity 实体类数据
|
||||
*/
|
||||
private void validEntityBeforeSave(WgzMessage entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return removeByIds(ids);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?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.ruoyi.wgz.mapper.WgzMessageMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.wgz.domain.WgzMessage" id="WgzMessageResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="senderType" column="sender_type"/>
|
||||
<result property="senderId" column="sender_id"/>
|
||||
<result property="recipientType" column="recipient_type"/>
|
||||
<result property="recipientId" column="recipient_id"/>
|
||||
<result property="headline" column="headline"/>
|
||||
<result property="subheading" column="subheading"/>
|
||||
<result property="tableId" column="table_id"/>
|
||||
<result property="tableName" column="table_name"/>
|
||||
<result property="messageLargeType" column="message_large_type"/>
|
||||
<result property="messageSmallType" column="message_small_type"/>
|
||||
<result property="readStatus" column="read_status"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user