Browse Source

构建消息信息相关model

1021934019@qq.com 4 years ago
parent
commit
7595162707

+ 34 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/dto/MessageDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.dto;
+
+import org.springblade.client.entity.Message;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2021-12-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class MessageDTO extends Message {
+	private static final long serialVersionUID = 1L;
+
+}

+ 106 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/entity/Message.java

@@ -0,0 +1,106 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ * @since 2021-12-20
+ */
+@Data
+@TableName("blade_message")
+@ApiModel(value = "Message对象", description = "Message对象")
+public class Message implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+    @TableId
+	private Long id;
+	/**
+	* 发起人id
+	*/
+		@ApiModelProperty(value = "发起人id")
+		private Long userId;
+	/**
+	* 发起人名称
+	*/
+		@ApiModelProperty(value = "发起人名称")
+		private String userName;
+	/**
+	* 接收者id
+	*/
+		@ApiModelProperty(value = "接收者id")
+		private Long toUserId;
+	/**
+	* 接收者名称
+	*/
+		@ApiModelProperty(value = "接收者名称")
+		private String toUserName;
+	/**
+	* 消息类型 : 1.普通消息 2.系统消息
+	*/
+		@ApiModelProperty(value = "消息类型 : 1.普通消息 2.系统消息")
+		private Integer messageType;
+	/**
+	* 消息体: 可以为字符串, 可以是json串
+	*/
+		@ApiModelProperty(value = "消息体: 可以为字符串, 可以是json串")
+		private String messageBody;
+	/**
+	* 接收者是否已读: 0 未读 1已读
+	*/
+		@ApiModelProperty(value = "接收者是否已读: 0 未读 1已读")
+		private Integer isRead;
+	/**
+	* 创建人
+	*/
+		@ApiModelProperty(value = "创建人")
+		private Long createUser;
+	/**
+	* 创建部门
+	*/
+		@ApiModelProperty(value = "创建部门")
+		private Long createDept;
+	/**
+	* 创建时间
+	*/
+		@ApiModelProperty(value = "创建时间")
+		private Date createTime;
+	/**
+	* 修改人
+	*/
+		@ApiModelProperty(value = "修改人")
+		private Long updateUser;
+	/**
+	* 是否已删除(0 否 1是)
+	*/
+		@ApiModelProperty(value = "是否已删除(0 否 1是)")
+		private Integer isDeleted;
+
+
+}

+ 36 - 0
blade-service-api/blade-client-api/src/main/java/org/springblade/client/vo/MessageVO.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.vo;
+
+import org.springblade.client.entity.Message;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+
+/**
+ * 视图实体类
+ *
+ * @author BladeX
+ * @since 2021-12-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "MessageVO对象", description = "MessageVO对象")
+public class MessageVO extends Message {
+	private static final long serialVersionUID = 1L;
+
+}

+ 126 - 0
blade-service/blade-client/src/main/java/org/springblade/client/message/controller/MessageController.java

@@ -0,0 +1,126 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.message.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.client.entity.Message;
+import org.springblade.client.message.service.IMessageService;
+import org.springblade.client.vo.MessageVO;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ *  控制器
+ *
+ * @author BladeX
+ * @since 2021-12-20
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/message")
+@Api(value = "", tags = "接口")
+public class MessageController extends BladeController {
+
+	private final IMessageService messageService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入message")
+	public R<Message> detail(Message message) {
+		Message detail = messageService.getOne(Condition.getQueryWrapper(message));
+		return R.data(detail);
+	}
+
+	/**
+	 * 分页
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入message")
+	public R<IPage<Message>> list(Message message, Query query) {
+		IPage<Message> pages = messageService.page(Condition.getPage(query), Condition.getQueryWrapper(message));
+		return R.data(pages);
+	}
+
+	/**
+	 * 自定义分页
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入message")
+	public R<IPage<MessageVO>> page(MessageVO message, Query query) {
+		IPage<MessageVO> pages = messageService.selectMessagePage(Condition.getPage(query), message);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入message")
+	public R save(@Valid @RequestBody Message message) {
+		return R.status(messageService.save(message));
+	}
+
+	/**
+	 * 修改
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入message")
+	public R update(@Valid @RequestBody Message message) {
+		return R.status(messageService.updateById(message));
+	}
+
+	/**
+	 * 新增或修改
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入message")
+	public R submit(@Valid @RequestBody Message message) {
+		return R.status(messageService.saveOrUpdate(message));
+	}
+
+
+	/**
+	 * 删除
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(messageService.removeByIds(Func.toLongList(ids)));
+	}
+
+
+}

+ 44 - 0
blade-service/blade-client/src/main/java/org/springblade/client/message/mapper/MessageMapper.java

@@ -0,0 +1,44 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.message.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.client.entity.Message;
+import org.springblade.client.vo.MessageVO;
+
+import java.util.List;
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2021-12-20
+ */
+public interface MessageMapper extends BaseMapper<Message> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param message
+	 * @return
+	 */
+	List<MessageVO> selectMessagePage(IPage page, MessageVO message);
+
+}

+ 27 - 0
blade-service/blade-client/src/main/java/org/springblade/client/message/mapper/MessageMapper.xml

@@ -0,0 +1,27 @@
+<?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="org.srpingblade.client.mapper.MessageMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="messageResultMap" type="org.srpingblade.client.entity.Message">
+        <id column="id" property="id"/>
+        <result column="user_id" property="userId"/>
+        <result column="user_name" property="userName"/>
+        <result column="to_user_id" property="toUserId"/>
+        <result column="to_user_name" property="toUserName"/>
+        <result column="message_type" property="messageType"/>
+        <result column="message_body" property="messageBody"/>
+        <result column="is_read" property="isRead"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="is_deleted" property="isDeleted"/>
+    </resultMap>
+
+
+    <select id="selectMessagePage" resultMap="messageResultMap">
+        select * from blade_message where is_deleted = 0
+    </select>
+
+</mapper>

+ 46 - 0
blade-service/blade-client/src/main/java/org/springblade/client/message/service/IMessageService.java

@@ -0,0 +1,46 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.message.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.client.entity.Message;
+import org.springblade.client.vo.MessageVO;
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2021-12-20
+ */
+public interface IMessageService extends IService<Message> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param message
+	 * @return
+	 */
+	IPage<MessageVO> selectMessagePage(IPage<MessageVO> page, MessageVO message);
+
+	//通过用户id推送
+	void pushByUserId(Long userId,String Message,Integer MessageType);
+	//通过用户角色推送
+	void pushByUserRole(String role,String Message,Integer MessageType);
+}

+ 53 - 0
blade-service/blade-client/src/main/java/org/springblade/client/message/service/impl/MessageServiceImpl.java

@@ -0,0 +1,53 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.client.message.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.client.entity.Message;
+import org.springblade.client.message.mapper.MessageMapper;
+import org.springblade.client.message.service.IMessageService;
+import org.springblade.client.vo.MessageVO;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务实现类
+ *
+ * @author BladeX
+ * @since 2021-12-20
+ */
+@Service
+public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements IMessageService
+{
+
+	@Override
+	public IPage<MessageVO> selectMessagePage(IPage<MessageVO> page, MessageVO message) {
+		return page.setRecords(baseMapper.selectMessagePage(page, message));
+	}
+
+	@Override
+	public void pushByUserId(Long userId, String Message, Integer MessageType) {
+
+	}
+
+	@Override
+	public void pushByUserRole(String role, String Message, Integer MessageType) {
+
+	}
+
+}

+ 16 - 0
blade-service/blade-client/src/main/java/org/springblade/client/message/socket/MessageSocket.java

@@ -0,0 +1,16 @@
+package org.springblade.client.message.socket;
+
+import io.swagger.annotations.Api;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("/socket/message")
+@Api(value = "消息socket接口", tags = "消息socket接口")
+public class MessageSocket
+{
+
+}

+ 22 - 0
blade-service/blade-client/src/main/java/org/springblade/client/message/until/MessageTool.java

@@ -0,0 +1,22 @@
+package org.springblade.client.message.until;
+
+import lombok.AllArgsConstructor;
+import org.springblade.client.message.service.IMessageService;
+import org.springframework.stereotype.Component;
+
+/**
+ * 消息工具类
+ * */
+@Component
+@AllArgsConstructor
+public class MessageTool
+{
+    private final IMessageService messageService;
+
+	//指定人推送消息
+
+	//推动角色推送消息
+
+
+
+}