Merge branch 'master' of https://gitee.com/geek-xd/ruoyi-geek-springboot3
This commit is contained in:
commit
49b9f7a55e
@ -44,6 +44,27 @@
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 消息模块-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-message</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 手机号认证-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-tfa-phone</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 邮箱认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-tfa-email</artifactId>
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
@ -54,6 +75,7 @@
|
||||
<module>ruoyi-generator</module>
|
||||
<module>ruoyi-quartz</module>
|
||||
<module>ruoyi-online</module>
|
||||
<module>ruoyi-message</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
</project>
|
45
ruoyi-models/ruoyi-message/pom.xml
Normal file
45
ruoyi-models/ruoyi-message/pom.xml
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>ruoyi-models</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>3.8.8.3.1</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-message</artifactId>
|
||||
|
||||
<description>
|
||||
message消息模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统框架 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 手机号认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-tfa-phone</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 邮箱认证 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-tfa-email</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,36 @@
|
||||
package com.ruoyi.modelMessage.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.ruoyi.modelMessage.enums.MessageType;
|
||||
|
||||
|
||||
//自定义消息系统注解
|
||||
@Target({ ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface MessageLog {
|
||||
/**
|
||||
* 消息操作的描述
|
||||
*/
|
||||
String description() default "";
|
||||
|
||||
/**
|
||||
* 消息标题
|
||||
*/
|
||||
String title() default "";
|
||||
|
||||
/**
|
||||
* 是否立即记录消息,默认为 true
|
||||
*/
|
||||
boolean immediateLog() default true;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
MessageType messageType() default MessageType.INFO;
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
package com.ruoyi.modelMessage.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.modelMessage.domain.MessageSystem;
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysUserVo;
|
||||
import com.ruoyi.modelMessage.service.IMessageSystemService;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 消息管理Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-21
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/modelMessage/messageSystem")
|
||||
@Tag(name = "【消息管理】管理")
|
||||
public class MessageSystemController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IMessageSystemService messageSystemService;
|
||||
|
||||
/**
|
||||
* 查询消息管理列表
|
||||
*/
|
||||
@Operation(summary = "查询消息管理列表")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:messageSystem:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(MessageSystem messageSystem)
|
||||
{
|
||||
startPage();
|
||||
messageSystem.setCreateBy(getUsername());
|
||||
messageSystem.setMessageRecipient(getUsername());
|
||||
List<MessageSystem> list = messageSystemService.selectMessageSystemList(messageSystem);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出消息管理列表
|
||||
*/
|
||||
@Operation(summary = "导出消息管理列表")
|
||||
@PreAuthorize("@ss.hasPermi('modelMessage:messageSystem:export')")
|
||||
@Log(title = "消息管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, MessageSystem messageSystem)
|
||||
{
|
||||
List<MessageSystem> list = messageSystemService.selectMessageSystemList(messageSystem);
|
||||
ExcelUtil<MessageSystem> util = new ExcelUtil<MessageSystem>(MessageSystem.class);
|
||||
util.exportExcel(response, list, "消息管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息管理详细信息
|
||||
*/
|
||||
@Operation(summary = "获取消息管理详细信息")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:messageSystem:query')")
|
||||
@GetMapping(value = "/{messageId}")
|
||||
public AjaxResult getInfo(@PathVariable("messageId") Long messageId)
|
||||
{
|
||||
return success(messageSystemService.selectMessageSystemByMessageId(messageId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改消息管理
|
||||
*/
|
||||
@Operation(summary = "修改消息管理")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:messageSystem:edit')")
|
||||
@Log(title = "消息管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody MessageSystem messageSystem)
|
||||
{
|
||||
messageSystem.setUpdateBy(getUsername());
|
||||
return toAjax(messageSystemService.updateMessageSystem(messageSystem));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除消息管理
|
||||
*/
|
||||
@Operation(summary = "删除消息管理")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:messageSystem:remove')")
|
||||
@Log(title = "消息管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{messageIds}")
|
||||
public AjaxResult remove(@PathVariable( name = "messageIds" ) Long[] messageIds)
|
||||
{
|
||||
return toAjax(messageSystemService.deleteMessageSystemByMessageIds(messageIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发送消息
|
||||
*/
|
||||
@Operation(summary = "发送消息")
|
||||
@Log(title = "发送消息", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@Transactional
|
||||
public AjaxResult batchAdd(@RequestBody List<MessageSystem> messageSystemList) {
|
||||
try {
|
||||
for (MessageSystem message : messageSystemList) {
|
||||
messageSystemService.processMessageSystem(message);
|
||||
}
|
||||
if (messageSystemService.batchInsertMessageSystem(messageSystemList) <= 0) {
|
||||
throw new ServiceException("消息发送失败!");
|
||||
}
|
||||
return AjaxResult.success("消息发送成功!");
|
||||
} catch (Exception e) {
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
return AjaxResult.error("消息发送失败!", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户点击标题之后已读信息
|
||||
*/
|
||||
@Operation(summary = "用户点击标题调整信息状态")
|
||||
@PostMapping("/{messageId}")
|
||||
public AjaxResult update(@PathVariable Long messageId){
|
||||
try{
|
||||
int state= messageSystemService.updateState(messageId);
|
||||
return success(state);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询平台用户 sendMode 进行过滤。
|
||||
*/
|
||||
@Operation(summary = "查询平台用户")
|
||||
@GetMapping("/selectUser")
|
||||
public AjaxResult selectUser(@RequestParam(required = false) String sendMode) {
|
||||
try {
|
||||
List<SysUserVo> list;
|
||||
if ("1".equals(sendMode)) { // 手机号
|
||||
list = messageSystemService.getUsersFilteredBySendMode("phone");
|
||||
} else if ("2".equals(sendMode)) { // 邮箱
|
||||
list = messageSystemService.getUsersFilteredBySendMode("email");
|
||||
} else {
|
||||
list = messageSystemService.selectUser();
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
} catch (ServiceException e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色信息
|
||||
*/
|
||||
@Operation(summary = "查询角色")
|
||||
@GetMapping("/selectRole")
|
||||
public AjaxResult selectRole() {
|
||||
return success(messageSystemService.selectRole());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有部门信息
|
||||
*/
|
||||
@Operation(summary = "查询部门")
|
||||
@GetMapping("/selectDept")
|
||||
public AjaxResult selectDept() {
|
||||
return success(messageSystemService.selectDept());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID获取所有符合条件的用户信息。
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 用户信息列表
|
||||
*/
|
||||
@Operation(summary = "根据角色ID获取所有符合条件的用户信息")
|
||||
@GetMapping("/getUsersByRole/{roleId}")
|
||||
public R<List<SysUserVo>> selectUsersByRoleId(@PathVariable Long roleId) {
|
||||
List<SysUserVo> users = messageSystemService.selectUsersByRoleId(roleId);
|
||||
return R.ok(users);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门ID获取所有符合条件的用户信息。
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 用户信息列表
|
||||
*/
|
||||
@Operation(summary = "根据部门ID获取所有符合条件的用户信息")
|
||||
@GetMapping("/getUserNameByDeptId/{deptId}")
|
||||
public R<List<SysUserVo>> getUserNameByDeptId(@PathVariable Long deptId) {
|
||||
List<SysUserVo> depts= messageSystemService.getUserNameByDeptId(deptId);
|
||||
return R.ok(depts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模版签名
|
||||
* @return 模版信息列表
|
||||
*/
|
||||
@Operation(summary = "查询模版签名")
|
||||
@GetMapping("/selecTemplates")
|
||||
public R selecTemplates() {
|
||||
List<MessageTemplate> templates= messageSystemService.selecTemplates();
|
||||
return R.ok(templates);
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package com.ruoyi.modelMessage.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
import com.ruoyi.modelMessage.service.IMessageTemplateService;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 模版管理Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/modelMessage/template")
|
||||
@Tag(name = "【模版管理】管理")
|
||||
public class MessageTemplateController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IMessageTemplateService messageTemplateService;
|
||||
|
||||
/**
|
||||
* 查询模版管理列表
|
||||
*/
|
||||
@Operation(summary = "查询模版管理列表")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:template:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(MessageTemplate messageTemplate)
|
||||
{
|
||||
startPage();
|
||||
List<MessageTemplate> list = messageTemplateService.selectMessageTemplateList(messageTemplate);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出模版管理列表
|
||||
*/
|
||||
@Operation(summary = "导出模版管理列表")
|
||||
@PreAuthorize("@ss.hasPermi('modelMessage:template:export')")
|
||||
@Log(title = "模版管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, MessageTemplate messageTemplate)
|
||||
{
|
||||
List<MessageTemplate> list = messageTemplateService.selectMessageTemplateList(messageTemplate);
|
||||
ExcelUtil<MessageTemplate> util = new ExcelUtil<MessageTemplate>(MessageTemplate.class);
|
||||
util.exportExcel(response, list, "模版管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模版管理详细信息
|
||||
*/
|
||||
@Operation(summary = "获取模版管理详细信息")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:template:query')")
|
||||
@GetMapping(value = "/{templateId}")
|
||||
public AjaxResult getInfo(@PathVariable("templateId") Long templateId)
|
||||
{
|
||||
return success(messageTemplateService.selectMessageTemplateByTemplateId(templateId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模版管理
|
||||
*/
|
||||
@Operation(summary = "新增模版管理")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:template:add')")
|
||||
@Log(title = "模版管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody MessageTemplate messageTemplate)
|
||||
{
|
||||
return toAjax(messageTemplateService.insertMessageTemplate(messageTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改模版管理
|
||||
*/
|
||||
@Operation(summary = "修改模版管理")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:template:edit')")
|
||||
@Log(title = "模版管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody MessageTemplate messageTemplate)
|
||||
{
|
||||
return toAjax(messageTemplateService.updateMessageTemplate(messageTemplate));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模版管理
|
||||
*/
|
||||
@Operation(summary = "删除模版管理")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:template:remove')")
|
||||
@Log(title = "模版管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{templateIds}")
|
||||
public AjaxResult remove(@PathVariable( name = "templateIds" ) Long[] templateIds)
|
||||
{
|
||||
return toAjax(messageTemplateService.deleteMessageTemplateByTemplateIds(templateIds));
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package com.ruoyi.modelMessage.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.modelMessage.domain.MessageVariable;
|
||||
import com.ruoyi.modelMessage.service.IMessageVariableService;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 变量管理Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/modelMessage/variable")
|
||||
@Tag(name = "【变量管理】管理")
|
||||
public class MessageVariableController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IMessageVariableService messageVariableService;
|
||||
|
||||
/**
|
||||
* 查询变量管理列表
|
||||
*/
|
||||
@Operation(summary = "查询变量管理列表")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:variable:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(MessageVariable messageVariable)
|
||||
{
|
||||
startPage();
|
||||
List<MessageVariable> list = messageVariableService.selectMessageVariableList(messageVariable);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出变量管理列表
|
||||
*/
|
||||
@Operation(summary = "导出变量管理列表")
|
||||
@PreAuthorize("@ss.hasPermi('modelMessage:variable:export')")
|
||||
@Log(title = "变量管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, MessageVariable messageVariable)
|
||||
{
|
||||
List<MessageVariable> list = messageVariableService.selectMessageVariableList(messageVariable);
|
||||
ExcelUtil<MessageVariable> util = new ExcelUtil<MessageVariable>(MessageVariable.class);
|
||||
util.exportExcel(response, list, "变量管理数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取变量管理详细信息
|
||||
*/
|
||||
@Operation(summary = "获取变量管理详细信息")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:variable:query')")
|
||||
@GetMapping(value = "/{variableId}")
|
||||
public AjaxResult getInfo(@PathVariable("variableId") Long variableId)
|
||||
{
|
||||
return success(messageVariableService.selectMessageVariableByVariableId(variableId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增变量管理
|
||||
*/
|
||||
@Operation(summary = "新增变量管理")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:variable:add')")
|
||||
@Log(title = "变量管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody MessageVariable messageVariable)
|
||||
{
|
||||
return toAjax(messageVariableService.insertMessageVariable(messageVariable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改变量管理
|
||||
*/
|
||||
@Operation(summary = "修改变量管理")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:variable:edit')")
|
||||
@Log(title = "变量管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody MessageVariable messageVariable)
|
||||
{
|
||||
return toAjax(messageVariableService.updateMessageVariable(messageVariable));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除变量管理
|
||||
*/
|
||||
@Operation(summary = "删除变量管理")
|
||||
//@PreAuthorize("@ss.hasPermi('modelMessage:variable:remove')")
|
||||
@Log(title = "变量管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{variableIds}")
|
||||
public AjaxResult remove(@PathVariable( name = "variableIds" ) Long[] variableIds)
|
||||
{
|
||||
for (Long variableId : variableIds) {
|
||||
// 获取变量信息
|
||||
MessageVariable variable = messageVariableService.selectMessageVariableByVariableId(variableId);
|
||||
if (variable == null) {
|
||||
throw new ServiceException("变量不存在!");
|
||||
}
|
||||
// 检查变量是否被模板使用
|
||||
if (messageVariableService.selectTemplateByVariableId(variable.getVariableName())) {
|
||||
throw new ServiceException("该变量已被模版使用,不能删除!");
|
||||
}
|
||||
}
|
||||
return toAjax(messageVariableService.deleteMessageVariableByVariableIds(variableIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色信息
|
||||
*/
|
||||
@Operation(summary = "查询变量")
|
||||
@GetMapping("/selectMessageVariable")
|
||||
@Anonymous
|
||||
public AjaxResult selectMessageVariable() {
|
||||
return success(messageVariableService.selectMessageVariable());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据变量类型生成不同的变量内容
|
||||
*/
|
||||
@Operation(summary = "根据变量类型生成不同变量内容")
|
||||
@GetMapping("/generate")
|
||||
public AjaxResult generateVariableContent(@RequestParam String variableType) {
|
||||
try {
|
||||
Object content = messageVariableService.generateVariableContent(variableType);
|
||||
return AjaxResult.success(content);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("生成变量内容失败!");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,159 @@
|
||||
package com.ruoyi.modelMessage.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 消息管理对象 message_system
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-21
|
||||
*/
|
||||
@Schema(description = "消息管理对象")
|
||||
public class MessageSystem extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@Schema(title = "主键")
|
||||
private Long messageId;
|
||||
|
||||
/** 标题 */
|
||||
@Schema(title = "标题")
|
||||
@Excel(name = "标题")
|
||||
private String messageTitle;
|
||||
|
||||
/** 消息内容 */
|
||||
@Schema(title = "消息内容")
|
||||
@Excel(name = "消息内容")
|
||||
private String messageContent;
|
||||
|
||||
/** 消息状态(0未读 1已读) */
|
||||
@Schema(title = "消息状态(0未读 1已读)")
|
||||
@Excel(name = "消息状态(0未读 1已读)")
|
||||
private String messageStatus;
|
||||
|
||||
/** 消息类型 */
|
||||
@Schema(title = "消息类型")
|
||||
@Excel(name = "消息类型")
|
||||
private String messageType;
|
||||
|
||||
/** 消息类型 */
|
||||
@Schema(title = "接收人")
|
||||
@Excel(name = "接收人")
|
||||
private String messageRecipient;
|
||||
|
||||
/** 发送方式(0平台 1手机号 2 邮箱) */
|
||||
@Schema(title = "发送方式(0平台 1手机号 2 邮箱)")
|
||||
@Excel(name = "发送方式(0平台 1手机号 2 邮箱)")
|
||||
private String sendMode;
|
||||
|
||||
/** 号码 */
|
||||
@Schema(title = "号码")
|
||||
@Excel(name = "号码")
|
||||
private String code;
|
||||
|
||||
public String getSendMode() {
|
||||
return sendMode;
|
||||
}
|
||||
|
||||
public void setSendMode(String sendMode) {
|
||||
this.sendMode = sendMode;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public void setMessageId(Long messageId)
|
||||
{
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public Long getMessageId()
|
||||
{
|
||||
return messageId;
|
||||
}
|
||||
|
||||
|
||||
public void setMessageTitle(String messageTitle)
|
||||
{
|
||||
this.messageTitle = messageTitle;
|
||||
}
|
||||
|
||||
public String getMessageTitle()
|
||||
{
|
||||
return messageTitle;
|
||||
}
|
||||
|
||||
|
||||
public void setMessageContent(String messageContent)
|
||||
{
|
||||
this.messageContent = messageContent;
|
||||
}
|
||||
|
||||
public String getMessageContent()
|
||||
{
|
||||
return messageContent;
|
||||
}
|
||||
|
||||
|
||||
public void setMessageStatus(String messageStatus)
|
||||
{
|
||||
this.messageStatus = messageStatus;
|
||||
}
|
||||
|
||||
public String getMessageStatus()
|
||||
{
|
||||
return messageStatus;
|
||||
}
|
||||
|
||||
|
||||
public void setMessageType(String messageType)
|
||||
{
|
||||
this.messageType = messageType;
|
||||
}
|
||||
|
||||
public String getMessageType()
|
||||
{
|
||||
return messageType;
|
||||
}
|
||||
|
||||
public String getMessageRecipient() {
|
||||
return messageRecipient;
|
||||
}
|
||||
|
||||
public void setMessageRecipient(String messageRecipient) {
|
||||
this.messageRecipient = messageRecipient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("messageId", getMessageId())
|
||||
.append("messageTitle", getMessageTitle())
|
||||
.append("messageContent", getMessageContent())
|
||||
.append("messageStatus", getMessageStatus())
|
||||
.append("messageType", getMessageType())
|
||||
.append("messageRecipient", getMessageRecipient())
|
||||
.append("sendMode", getSendMode())
|
||||
.append("code", getCode())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package com.ruoyi.modelMessage.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 模版管理对象 message_template
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
@Schema(description = "模版管理对象")
|
||||
public class MessageTemplate extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@Schema(title = "主键")
|
||||
private Long templateId;
|
||||
|
||||
/** 模版名称 */
|
||||
@Schema(title = "模版名称")
|
||||
@Excel(name = "模版名称")
|
||||
private String templateName;
|
||||
|
||||
/** 模版CODE */
|
||||
@Schema(title = "模版CODE")
|
||||
@Excel(name = "模版CODE")
|
||||
private String templateCode;
|
||||
|
||||
/** 模版类型 */
|
||||
@Schema(title = "模版类型")
|
||||
@Excel(name = "模版类型")
|
||||
private String templateType;
|
||||
|
||||
/** 模版内容 */
|
||||
@Schema(title = "模版内容")
|
||||
@Excel(name = "模版内容")
|
||||
private String templateContent;
|
||||
|
||||
/** 变量属性 */
|
||||
@Schema(title = "变量属性")
|
||||
@Excel(name = "变量属性")
|
||||
private String templateVariable;
|
||||
public void setTemplateId(Long templateId)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public Long getTemplateId()
|
||||
{
|
||||
return templateId;
|
||||
}
|
||||
|
||||
|
||||
public void setTemplateName(String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
|
||||
public String getTemplateName()
|
||||
{
|
||||
return templateName;
|
||||
}
|
||||
|
||||
|
||||
public void setTemplateCode(String templateCode)
|
||||
{
|
||||
this.templateCode = templateCode;
|
||||
}
|
||||
|
||||
public String getTemplateCode()
|
||||
{
|
||||
return templateCode;
|
||||
}
|
||||
|
||||
|
||||
public void setTemplateType(String templateType)
|
||||
{
|
||||
this.templateType = templateType;
|
||||
}
|
||||
|
||||
public String getTemplateType()
|
||||
{
|
||||
return templateType;
|
||||
}
|
||||
|
||||
|
||||
public void setTemplateContent(String templateContent)
|
||||
{
|
||||
this.templateContent = templateContent;
|
||||
}
|
||||
|
||||
public String getTemplateContent()
|
||||
{
|
||||
return templateContent;
|
||||
}
|
||||
|
||||
|
||||
public void setTemplateVariable(String templateVariable)
|
||||
{
|
||||
this.templateVariable = templateVariable;
|
||||
}
|
||||
|
||||
public String getTemplateVariable()
|
||||
{
|
||||
return templateVariable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("templateId", getTemplateId())
|
||||
.append("templateName", getTemplateName())
|
||||
.append("templateCode", getTemplateCode())
|
||||
.append("templateType", getTemplateType())
|
||||
.append("templateContent", getTemplateContent())
|
||||
.append("templateVariable", getTemplateVariable())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.ruoyi.modelMessage.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 变量管理对象 message_variable
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
@Schema(description = "变量管理对象")
|
||||
public class MessageVariable extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/** 主键 */
|
||||
@Schema(title = "主键")
|
||||
private Long variableId;
|
||||
|
||||
/** 变量名称 */
|
||||
@Schema(title = "变量名称")
|
||||
@Excel(name = "变量名称")
|
||||
private String variableName;
|
||||
|
||||
/** 变量类型 */
|
||||
@Schema(title = "变量类型")
|
||||
@Excel(name = "变量类型")
|
||||
private String variableType;
|
||||
|
||||
/** 变量内容 */
|
||||
@Schema(title = "变量内容")
|
||||
@Excel(name = "变量内容")
|
||||
private String variableContent;
|
||||
public void setVariableId(Long variableId)
|
||||
{
|
||||
this.variableId = variableId;
|
||||
}
|
||||
|
||||
public MessageVariable(Long variableId, String variableName, String variableType, String variableContent) {
|
||||
this.variableId = variableId;
|
||||
this.variableName = variableName;
|
||||
this.variableType = variableType;
|
||||
this.variableContent = variableContent;
|
||||
}
|
||||
|
||||
public Long getVariableId()
|
||||
{
|
||||
return variableId;
|
||||
}
|
||||
|
||||
|
||||
public void setVariableName(String variableName)
|
||||
{
|
||||
this.variableName = variableName;
|
||||
}
|
||||
|
||||
public String getVariableName()
|
||||
{
|
||||
return variableName;
|
||||
}
|
||||
|
||||
|
||||
public void setVariableType(String variableLength)
|
||||
{
|
||||
this.variableType = variableLength;
|
||||
}
|
||||
|
||||
public String getVariableType()
|
||||
{
|
||||
return variableType;
|
||||
}
|
||||
|
||||
|
||||
public void setVariableContent(String variableContent)
|
||||
{
|
||||
this.variableContent = variableContent;
|
||||
}
|
||||
|
||||
public String getVariableContent()
|
||||
{
|
||||
return variableContent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("variableId", getVariableId())
|
||||
.append("variableName", getVariableName())
|
||||
.append("variableType", getVariableType())
|
||||
.append("variableContent", getVariableContent())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
package com.ruoyi.modelMessage.domain.vo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 部门表 sys_dept
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Schema(title = "部门")
|
||||
public class SysDeptVo extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 部门ID */
|
||||
@Schema(title = "部门ID")
|
||||
private Long deptId;
|
||||
|
||||
/** 父部门ID */
|
||||
@Schema(title = "父部门ID")
|
||||
private Long parentId;
|
||||
|
||||
/** 祖级列表 */
|
||||
@Schema(title = "祖级列表")
|
||||
private String ancestors;
|
||||
|
||||
/** 部门名称 */
|
||||
@Schema(title = "部门名称")
|
||||
private String deptName;
|
||||
|
||||
/** 显示顺序 */
|
||||
@Schema(title = "显示顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
/** 负责人 */
|
||||
@Schema(title = "负责人")
|
||||
private String leader;
|
||||
|
||||
/** 联系电话 */
|
||||
@Schema(title = "联系电话")
|
||||
private String phone;
|
||||
|
||||
/** 邮箱 */
|
||||
@Schema(title = "邮箱")
|
||||
private String email;
|
||||
|
||||
/** 部门状态:0正常,1停用 */
|
||||
@Schema(title = "部门表",description = "0正常,1停用")
|
||||
private String status;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
@Schema(title = "删除标志",description = "0代表存在 2代表删除")
|
||||
private String delFlag;
|
||||
|
||||
/** 父部门名称 */
|
||||
@Schema(title = "父部门名称")
|
||||
private String parentName;
|
||||
|
||||
/** 子部门 */
|
||||
@Schema(title = "子部门")
|
||||
private List<SysDeptVo> children = new ArrayList<SysDeptVo>();
|
||||
|
||||
public Long getDeptId()
|
||||
{
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId)
|
||||
{
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getAncestors()
|
||||
{
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
public void setAncestors(String ancestors)
|
||||
{
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
@NotBlank(message = "部门名称不能为空")
|
||||
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
|
||||
public String getDeptName()
|
||||
{
|
||||
return deptName;
|
||||
}
|
||||
|
||||
public void setDeptName(String deptName)
|
||||
{
|
||||
this.deptName = deptName;
|
||||
}
|
||||
|
||||
@NotNull(message = "显示顺序不能为空")
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
|
||||
public void setOrderNum(Integer orderNum)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public String getLeader()
|
||||
{
|
||||
return leader;
|
||||
}
|
||||
|
||||
public void setLeader(String leader)
|
||||
{
|
||||
this.leader = leader;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
|
||||
public String getPhone()
|
||||
{
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone)
|
||||
{
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
@Email(message = "邮箱格式不正确")
|
||||
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getDelFlag()
|
||||
{
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag)
|
||||
{
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getParentName()
|
||||
{
|
||||
return parentName;
|
||||
}
|
||||
|
||||
public void setParentName(String parentName)
|
||||
{
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public List<SysDeptVo> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<SysDeptVo> children)
|
||||
{
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("deptId", getDeptId())
|
||||
.append("parentId", getParentId())
|
||||
.append("ancestors", getAncestors())
|
||||
.append("deptName", getDeptName())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("leader", getLeader())
|
||||
.append("phone", getPhone())
|
||||
.append("email", getEmail())
|
||||
.append("status", getStatus())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.ruoyi.modelMessage.domain.vo;
|
||||
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.annotation.Excel.ColumnType;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
/**
|
||||
* 角色表 sys_role
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Schema(title = "角色表")
|
||||
public class SysRoleVo
|
||||
{
|
||||
|
||||
/** 角色ID */
|
||||
@Schema(title = "角色ID")
|
||||
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
|
||||
private Long roleId;
|
||||
|
||||
/** 角色名称 */
|
||||
@Schema(title = "角色名称")
|
||||
@Excel(name = "角色名称")
|
||||
private String roleName;
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("roleId", getRoleId())
|
||||
.append("roleName", getRoleName())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.ruoyi.modelMessage.domain.vo;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.annotation.Excel.Type;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
/**
|
||||
* 用户对象 sys_user
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Schema(title = "用户")
|
||||
public class SysUserVo
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 用户ID */
|
||||
@Schema(title = "用户编号")
|
||||
@Excel(name = "用户编号")
|
||||
private Long userId;
|
||||
|
||||
/** 部门ID */
|
||||
@Schema(title = "部门编号")
|
||||
@Excel(name = "部门编号", type = Type.IMPORT)
|
||||
private Long deptId;
|
||||
|
||||
/** 用户账号 */
|
||||
@Schema(title = "登录名称")
|
||||
@Excel(name = "登录名称")
|
||||
private String userName;
|
||||
|
||||
/** 用户邮箱 */
|
||||
@Schema(title = "用户邮箱")
|
||||
@Excel(name = "用户邮箱")
|
||||
private String email;
|
||||
|
||||
/** 手机号码 */
|
||||
@Schema(title = "手机号码")
|
||||
@Excel(name = "手机号码")
|
||||
private String phonenumber;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPhonenumber() {
|
||||
return phonenumber;
|
||||
}
|
||||
|
||||
public void setPhonenumber(String phonenumber) {
|
||||
this.phonenumber = phonenumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("userId", getUserId())
|
||||
.append("deptId", getDeptId())
|
||||
.append("userName", getUserName())
|
||||
.append("email", getEmail())
|
||||
.append("phonenumber", getPhonenumber())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.ruoyi.modelMessage.enums;
|
||||
|
||||
public enum MessageType {
|
||||
INFO("信息", "普通信息记录"),
|
||||
WARN("警告", "非致命问题警告"),
|
||||
ERROR("错误", "严重错误信息"),
|
||||
DEBUG("调试", "调试信息,仅用于开发环境"),
|
||||
SUCCESS("成功", "操作成功的提示信息");
|
||||
|
||||
private final String code;
|
||||
private final String description;
|
||||
|
||||
MessageType(String code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.ruoyi.modelMessage.enums;
|
||||
|
||||
public enum SendMode {
|
||||
PLATFORM("0", "平台"),
|
||||
PHONE("1", "手机号"),
|
||||
EMAIL("2", "邮箱");
|
||||
|
||||
private final String code;
|
||||
private final String description;
|
||||
|
||||
SendMode(String code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public static SendMode fromCode(String code) {
|
||||
for (SendMode mode : SendMode.values()) {
|
||||
if (mode.getCode().equals(code)) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("未知的发送方式: " + code);
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package com.ruoyi.modelMessage.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import com.ruoyi.modelMessage.domain.MessageSystem;
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysDeptVo;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysRoleVo;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysUserVo;
|
||||
|
||||
/**
|
||||
* 消息管理Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-21
|
||||
*/
|
||||
public interface MessageSystemMapper
|
||||
{
|
||||
/**
|
||||
* 查询消息管理
|
||||
*
|
||||
* @param messageId 消息管理主键
|
||||
* @return 消息管理
|
||||
*/
|
||||
public MessageSystem selectMessageSystemByMessageId(Long messageId);
|
||||
|
||||
/**
|
||||
* 查询消息管理列表
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 消息管理集合
|
||||
*/
|
||||
public List<MessageSystem> selectMessageSystemList(MessageSystem messageSystem);
|
||||
|
||||
/**
|
||||
* 新增消息管理
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMessageSystem(MessageSystem messageSystem);
|
||||
|
||||
/**
|
||||
* 修改消息管理
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMessageSystem(MessageSystem messageSystem);
|
||||
|
||||
/**
|
||||
* 删除消息管理
|
||||
*
|
||||
* @param messageId 消息管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageSystemByMessageId(Long messageId);
|
||||
|
||||
/**
|
||||
* 批量删除消息管理
|
||||
*
|
||||
* @param messageIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageSystemByMessageIds(Long[] messageIds);
|
||||
|
||||
//查询平台系统资源收件人用户信息
|
||||
@Select("SELECT * FROM `sys_user`")
|
||||
public List<SysUserVo> selectUser();
|
||||
|
||||
//查询角色信息 然后根据角色把消息发给某角色
|
||||
@Select("SELECT * FROM `sys_role`")
|
||||
public List<SysRoleVo> selectRole();
|
||||
|
||||
//查询部门信息 然后根据部门把消息发给某部门
|
||||
@Select("SELECT * FROM `sys_dept`")
|
||||
public List<SysDeptVo> selectDept();
|
||||
|
||||
// 根据发送方式过滤用户 (短信或邮箱)
|
||||
@Select("<script>" +
|
||||
"SELECT * FROM `sys_user`" +
|
||||
"<where>" +
|
||||
"<if test='filterType == \"phone\"'>AND phonenumber IS NOT NULL AND phonenumber != ''</if>" +
|
||||
"<if test='filterType == \"email\"'>AND email IS NOT NULL AND email != ''</if>" +
|
||||
"</where>" +
|
||||
"</script>")
|
||||
List<SysUserVo> selectUserBySendMode(String filterType);
|
||||
|
||||
//将信息状态未读信息变为已读
|
||||
@Update("update message_system set message_status = 1 where message_id = #{messageId} and message_recipient = #{userName}")
|
||||
public int updateState(Long messageId, String userName);
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门ID获取所有符合条件的用户信息。
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 用户信息列表
|
||||
*/
|
||||
@Select("SELECT u.* FROM sys_user u JOIN sys_dept d ON u.dept_id = d.dept_id WHERE d.dept_id = #{deptId}")
|
||||
public List<SysUserVo> getUserNameByDeptId(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询用户列表。
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 用户列表
|
||||
*/
|
||||
@Select("SELECT u.* FROM sys_user u JOIN sys_user_role ur ON u.user_id = ur.user_id WHERE ur.role_id = #{roleId}")
|
||||
public List<SysUserVo> selectUsersByRoleId(Long roleId);
|
||||
|
||||
//查询模版签名
|
||||
@Select("SELECT template_id,template_code,template_variable FROM `message_template`")
|
||||
public List<MessageTemplate> selecTemplates();
|
||||
|
||||
//批量发送信息
|
||||
public int batchInsertMessageSystem(List<MessageSystem> messageSystemList);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.ruoyi.modelMessage.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
|
||||
/**
|
||||
* 模版管理Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
public interface MessageTemplateMapper
|
||||
{
|
||||
/**
|
||||
* 查询模版管理
|
||||
*
|
||||
* @param templateId 模版管理主键
|
||||
* @return 模版管理
|
||||
*/
|
||||
public MessageTemplate selectMessageTemplateByTemplateId(Long templateId);
|
||||
|
||||
/**
|
||||
* 查询模版管理列表
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 模版管理集合
|
||||
*/
|
||||
public List<MessageTemplate> selectMessageTemplateList(MessageTemplate messageTemplate);
|
||||
|
||||
/**
|
||||
* 新增模版管理
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMessageTemplate(MessageTemplate messageTemplate);
|
||||
|
||||
/**
|
||||
* 修改模版管理
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMessageTemplate(MessageTemplate messageTemplate);
|
||||
|
||||
/**
|
||||
* 删除模版管理
|
||||
*
|
||||
* @param templateId 模版管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageTemplateByTemplateId(Long templateId);
|
||||
|
||||
/**
|
||||
* 批量删除模版管理
|
||||
*
|
||||
* @param templateIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageTemplateByTemplateIds(Long[] templateIds);
|
||||
|
||||
/**
|
||||
* 根据模板templateCode查询模板信息
|
||||
*
|
||||
* @param templateCode 模版编码
|
||||
* @return 模版对象
|
||||
*/
|
||||
@Select("SELECT * FROM message_template WHERE template_code = #{templateCode}")
|
||||
public MessageTemplate selectMessageTemplateByTemplateCode(String templateCode);
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.ruoyi.modelMessage.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import com.ruoyi.modelMessage.domain.MessageVariable;
|
||||
|
||||
/**
|
||||
* 变量管理Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
public interface MessageVariableMapper
|
||||
{
|
||||
/**
|
||||
* 查询变量管理
|
||||
*
|
||||
* @param variableId 变量管理主键
|
||||
* @return 变量管理
|
||||
*/
|
||||
public MessageVariable selectMessageVariableByVariableId(Long variableId);
|
||||
|
||||
/**
|
||||
* 查询变量管理列表
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 变量管理集合
|
||||
*/
|
||||
public List<MessageVariable> selectMessageVariableList(MessageVariable messageVariable);
|
||||
|
||||
/**
|
||||
* 新增变量管理
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMessageVariable(MessageVariable messageVariable);
|
||||
|
||||
/**
|
||||
* 修改变量管理
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMessageVariable(MessageVariable messageVariable);
|
||||
|
||||
/**
|
||||
* 删除变量管理
|
||||
*
|
||||
* @param variableId 变量管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageVariableByVariableId(Long variableId);
|
||||
|
||||
/**
|
||||
* 批量删除变量管理
|
||||
*
|
||||
* @param variableIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageVariableByVariableIds(Long[] variableIds);
|
||||
|
||||
//删除变量之前检查一下有没有模版使用
|
||||
@Select("SELECT COUNT(*) > 0 FROM message_template WHERE template_variable = #{templateVariable}")
|
||||
public boolean selectTemplateByVariableId(String templateVariable);
|
||||
|
||||
//查询变量
|
||||
@Select("SELECT * FROM message_variable")
|
||||
public List<MessageVariable> selectMessageVariable();
|
||||
|
||||
//查询在使用模版签名时用到了那些变量一一赋值
|
||||
public List<MessageVariable> selectMessageVariables(List<String> variableNames);
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package com.ruoyi.modelMessage.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.modelMessage.domain.MessageSystem;
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysDeptVo;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysRoleVo;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysUserVo;
|
||||
|
||||
/**
|
||||
* 消息管理Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-21
|
||||
*/
|
||||
public interface IMessageSystemService
|
||||
{
|
||||
/**
|
||||
* 查询消息管理
|
||||
*
|
||||
* @param messageId 消息管理主键
|
||||
* @return 消息管理
|
||||
*/
|
||||
public MessageSystem selectMessageSystemByMessageId(Long messageId);
|
||||
|
||||
/**
|
||||
* 查询消息管理列表
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 消息管理集合
|
||||
*/
|
||||
public List<MessageSystem> selectMessageSystemList(MessageSystem messageSystem);
|
||||
|
||||
/**
|
||||
* 新增消息管理
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMessageSystem(MessageSystem messageSystem);
|
||||
|
||||
/**
|
||||
* 修改消息管理
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMessageSystem(MessageSystem messageSystem);
|
||||
|
||||
/**
|
||||
* 批量删除消息管理
|
||||
*
|
||||
* @param messageIds 需要删除的消息管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageSystemByMessageIds(Long[] messageIds);
|
||||
|
||||
/**
|
||||
* 删除消息管理信息
|
||||
*
|
||||
* @param messageId 消息管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageSystemByMessageId(Long messageId);
|
||||
|
||||
//查询系统资源用户信息
|
||||
public List<SysUserVo> selectUser();
|
||||
|
||||
//将信息状态未读信息变为已读
|
||||
public int updateState(Long messageId);
|
||||
|
||||
//根据发送方式 执行不同操作
|
||||
public void processMessageSystem(MessageSystem messageSystem);
|
||||
|
||||
// 根据发送方式过滤用户 (短信或邮箱)
|
||||
public List<SysUserVo> getUsersFilteredBySendMode(String filterType);
|
||||
|
||||
//查询角色信息 然后根据角色把消息发给某角色
|
||||
public List<SysRoleVo> selectRole();
|
||||
|
||||
//查询部门信息 然后根据部门把消息发给某部门
|
||||
public List<SysDeptVo> selectDept();
|
||||
|
||||
/**
|
||||
* 根据角色ID获取用户列表。
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return
|
||||
*
|
||||
* */
|
||||
public List<SysUserVo> selectUsersByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据部门ID获取用户列表。
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return
|
||||
*
|
||||
* */
|
||||
public List<SysUserVo> getUserNameByDeptId(Long deptId);
|
||||
|
||||
// 查询模版签名
|
||||
public List<MessageTemplate> selecTemplates();
|
||||
|
||||
// 批量发送信息
|
||||
public int batchInsertMessageSystem(List<MessageSystem> messageSystemList);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.ruoyi.modelMessage.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
|
||||
/**
|
||||
* 模版管理Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
public interface IMessageTemplateService
|
||||
{
|
||||
/**
|
||||
* 查询模版管理
|
||||
*
|
||||
* @param templateId 模版管理主键
|
||||
* @return 模版管理
|
||||
*/
|
||||
public MessageTemplate selectMessageTemplateByTemplateId(Long templateId);
|
||||
|
||||
/**
|
||||
* 查询模版管理列表
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 模版管理集合
|
||||
*/
|
||||
public List<MessageTemplate> selectMessageTemplateList(MessageTemplate messageTemplate);
|
||||
|
||||
/**
|
||||
* 新增模版管理
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMessageTemplate(MessageTemplate messageTemplate);
|
||||
|
||||
/**
|
||||
* 修改模版管理
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMessageTemplate(MessageTemplate messageTemplate);
|
||||
|
||||
/**
|
||||
* 批量删除模版管理
|
||||
*
|
||||
* @param templateIds 需要删除的模版管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageTemplateByTemplateIds(Long[] templateIds);
|
||||
|
||||
/**
|
||||
* 删除模版管理信息
|
||||
*
|
||||
* @param templateId 模版管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageTemplateByTemplateId(Long templateId);
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.ruoyi.modelMessage.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.modelMessage.domain.MessageVariable;
|
||||
|
||||
/**
|
||||
* 变量管理Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
public interface IMessageVariableService
|
||||
{
|
||||
/**
|
||||
* 查询变量管理
|
||||
*
|
||||
* @param variableId 变量管理主键
|
||||
* @return 变量管理
|
||||
*/
|
||||
public MessageVariable selectMessageVariableByVariableId(Long variableId);
|
||||
|
||||
/**
|
||||
* 查询变量管理列表
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 变量管理集合
|
||||
*/
|
||||
public List<MessageVariable> selectMessageVariableList(MessageVariable messageVariable);
|
||||
|
||||
/**
|
||||
* 新增变量管理
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertMessageVariable(MessageVariable messageVariable);
|
||||
|
||||
/**
|
||||
* 修改变量管理
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateMessageVariable(MessageVariable messageVariable);
|
||||
|
||||
/**
|
||||
* 批量删除变量管理
|
||||
*
|
||||
* @param variableIds 需要删除的变量管理主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageVariableByVariableIds(Long[] variableIds);
|
||||
|
||||
/**
|
||||
* 删除变量管理信息
|
||||
*
|
||||
* @param variableId 变量管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMessageVariableByVariableId(Long variableId);
|
||||
|
||||
// 查询全部变量
|
||||
public List<MessageVariable> selectMessageVariable();
|
||||
|
||||
// 删除变量之前检查一下有没有模版使用
|
||||
public boolean selectTemplateByVariableId(String templateVariable);
|
||||
|
||||
// 根据类型生成不同的变量内容
|
||||
public String generateVariableContent(String variableType);
|
||||
}
|
@ -0,0 +1,291 @@
|
||||
package com.ruoyi.modelMessage.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.modelMessage.domain.MessageSystem;
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysDeptVo;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysRoleVo;
|
||||
import com.ruoyi.modelMessage.domain.vo.SysUserVo;
|
||||
import com.ruoyi.modelMessage.enums.SendMode;
|
||||
import com.ruoyi.modelMessage.mapper.MessageSystemMapper;
|
||||
import com.ruoyi.modelMessage.service.IMessageSystemService;
|
||||
import com.ruoyi.modelMessage.utils.MessageSystemUtils;
|
||||
import com.ruoyi.tfa.email.utils.EmailUtil;
|
||||
import com.ruoyi.tfa.phone.enums.DySmsTemplate;
|
||||
import com.ruoyi.tfa.phone.utils.DySmsUtil;
|
||||
|
||||
/**
|
||||
* 消息管理Service业务层处理
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class MessageSystemServiceImpl implements IMessageSystemService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MessageSystemServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private MessageSystemMapper messageSystemMapper;
|
||||
|
||||
@Autowired
|
||||
private MessageSystemUtils messageSystemUtils;
|
||||
|
||||
/**
|
||||
* 查询消息管理
|
||||
*
|
||||
* @param messageId 消息管理主键
|
||||
* @return 消息管理
|
||||
*/
|
||||
@Override
|
||||
public MessageSystem selectMessageSystemByMessageId(Long messageId) {
|
||||
return messageSystemMapper.selectMessageSystemByMessageId(messageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询消息管理列表
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 消息管理列表
|
||||
*/
|
||||
@Override
|
||||
public List<MessageSystem> selectMessageSystemList(MessageSystem messageSystem) {
|
||||
return messageSystemMapper.selectMessageSystemList(messageSystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增消息管理
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMessageSystem(MessageSystem messageSystem) {
|
||||
messageSystem.setMessageStatus("0"); // 默认发送信息为未读状态
|
||||
messageSystem.setCreateBy(SecurityUtils.getUsername());
|
||||
messageSystem.setUpdateBy(SecurityUtils.getUsername());
|
||||
messageSystem.setCreateTime(DateUtils.getNowDate());
|
||||
messageSystem.setUpdateTime(DateUtils.getNowDate());
|
||||
return messageSystemMapper.insertMessageSystem(messageSystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改消息管理
|
||||
*
|
||||
* @param messageSystem 消息管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMessageSystem(MessageSystem messageSystem) {
|
||||
messageSystem.setUpdateTime(DateUtils.getNowDate());
|
||||
return messageSystemMapper.updateMessageSystem(messageSystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除消息管理
|
||||
*
|
||||
* @param messageIds 需要删除的消息管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMessageSystemByMessageIds(Long[] messageIds) {
|
||||
return messageSystemMapper.deleteMessageSystemByMessageIds(messageIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除消息管理信息
|
||||
*
|
||||
* @param messageId 消息管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMessageSystemByMessageId(Long messageId) {
|
||||
return messageSystemMapper.deleteMessageSystemByMessageId(messageId);
|
||||
}
|
||||
|
||||
// 查询系统资源用户信息
|
||||
@Override
|
||||
public List<SysUserVo> selectUser() {
|
||||
return messageSystemMapper.selectUser();
|
||||
}
|
||||
|
||||
// 收件人为本人的话点击信息详情的时候然后把状态未读信息修改为已读
|
||||
@Override
|
||||
public int updateState(Long messageId) {
|
||||
return messageSystemMapper.updateState(messageId, SecurityUtils.getUsername());
|
||||
}
|
||||
|
||||
// 根据发送方式过滤用户 (短信或邮箱)
|
||||
@Override
|
||||
public List<SysUserVo> getUsersFilteredBySendMode(String filterType) {
|
||||
return messageSystemMapper.selectUserBySendMode(filterType);
|
||||
}
|
||||
|
||||
// 查询角色信息 然后根据角色把消息发给某角色
|
||||
@Override
|
||||
public List<SysRoleVo> selectRole() {
|
||||
return messageSystemMapper.selectRole();
|
||||
}
|
||||
|
||||
// 查询部门信息 然后根据部门把消息发给某部门
|
||||
@Override
|
||||
public List<SysDeptVo> selectDept() {
|
||||
return messageSystemMapper.selectDept();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID获取对应用户信息。
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 符合条件的用户列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserVo> selectUsersByRoleId(Long roleId) {
|
||||
return messageSystemMapper.selectUsersByRoleId(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角色ID获取用户ID列表。
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 用户ID列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserVo> getUserNameByDeptId(Long deptId) {
|
||||
return messageSystemMapper.getUserNameByDeptId(deptId);
|
||||
}
|
||||
|
||||
// 查询模版签名
|
||||
@Override
|
||||
public List<MessageTemplate> selecTemplates() {
|
||||
return messageSystemMapper.selecTemplates();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发送信息
|
||||
*/
|
||||
@Override
|
||||
public int batchInsertMessageSystem(List<MessageSystem> messageSystemList) {
|
||||
String username = SecurityUtils.getUsername();
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
for (MessageSystem messageSystem : messageSystemList) {
|
||||
messageSystem.setMessageStatus("0"); // 默认发送信息为未读状态
|
||||
messageSystem.setCreateBy(username);
|
||||
messageSystem.setUpdateBy(username);
|
||||
messageSystem.setCreateTime(nowDate);
|
||||
messageSystem.setUpdateTime(nowDate);
|
||||
}
|
||||
return messageSystemMapper.batchInsertMessageSystem(messageSystemList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 MessageSystem 对象的 sendMode 属性处理消息的发送方式
|
||||
*/
|
||||
@Override
|
||||
public void processMessageSystem(MessageSystem messageSystem) {
|
||||
if (messageSystem == null || messageSystem.getSendMode() == null) {
|
||||
throw new ServiceException("无效的消息系统对象或发送方式!");
|
||||
}
|
||||
String sendModeStr = messageSystem.getSendMode();
|
||||
SendMode sendMode;
|
||||
try {
|
||||
sendMode = SendMode.fromCode(sendModeStr);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ServiceException("类型转换失败: " + sendModeStr);
|
||||
}
|
||||
switch (sendMode) {
|
||||
case PHONE:
|
||||
sendNotificationMessage(messageSystem);
|
||||
break;
|
||||
case EMAIL:
|
||||
handleEmailNotification(messageSystem);
|
||||
break;
|
||||
case PLATFORM:
|
||||
sendPlatformMessage(messageSystem);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("未知的发送方式!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送平台消息
|
||||
*/
|
||||
public void sendPlatformMessage(MessageSystem messageSystem) {
|
||||
String notificationContent = messageSystem.getMessageContent();
|
||||
try {
|
||||
String filledMessage = notificationContent.startsWith("SMS_") ?
|
||||
messageSystemUtils.processTemplateMessage(messageSystem, notificationContent) :
|
||||
notificationContent; // 如果是自定义输入,使用用户输入的内容
|
||||
log.info("平台内容: {}", filledMessage);
|
||||
messageSystem.setMessageContent(filledMessage);
|
||||
} catch (Exception e) {
|
||||
log.error("发送平台消息时发生异常: ", e);
|
||||
throw new ServiceException("发送平台消息异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件通知
|
||||
*/
|
||||
public void handleEmailNotification(MessageSystem messageSystem) {
|
||||
String email = messageSystem.getCode();
|
||||
if (StringUtils.isEmpty(email)) {
|
||||
throw new ServiceException("邮箱地址不能为空!");
|
||||
}
|
||||
try {
|
||||
String filledMessage = messageSystem.getMessageContent().startsWith("SMS_") ?
|
||||
messageSystemUtils.processTemplateMessage(messageSystem, messageSystem.getMessageContent()) :
|
||||
messageSystem.getMessageContent(); // 如果是自定义输入,则直接使用用户提供的内容
|
||||
log.info("邮件内容: {}", filledMessage);
|
||||
messageSystem.setMessageContent(filledMessage);
|
||||
EmailUtil.sendMessage(email, "通知", filledMessage);
|
||||
} catch (Exception e) {
|
||||
log.error("发送邮件时发生异常: ", e);
|
||||
throw new ServiceException("发送通知信息异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信通知
|
||||
*/
|
||||
public void sendNotificationMessage(MessageSystem messageSystem) {
|
||||
String phone = messageSystem.getCode();
|
||||
if (StringUtils.isEmpty(phone)) {
|
||||
throw new ServiceException("手机号码为空!");
|
||||
}
|
||||
try {
|
||||
// 解析并处理模板消息
|
||||
Map<String, Object> parsedParams = messageSystemUtils.parseInput(messageSystem.getMessageContent());
|
||||
String templateCode = (String) parsedParams.get("templateCode");
|
||||
DySmsTemplate dySmsTemplate = null;
|
||||
|
||||
if (templateCode != null) {
|
||||
dySmsTemplate = DySmsTemplate.toEnum(templateCode);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> params = (Map<String, String>) parsedParams.get("params");
|
||||
String filledMessage = messageSystemUtils.fillTemplate((String) parsedParams.get("templateContent"), params);
|
||||
messageSystem.setMessageContent(filledMessage);
|
||||
JSONObject templateParamJson = new JSONObject(params);
|
||||
DySmsUtil.sendSms(dySmsTemplate, templateParamJson, phone);
|
||||
} else {
|
||||
DySmsUtil.sendSms(null, null, phone);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("发送短信时发生异常: ", e);
|
||||
throw new ServiceException("发送短信异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.ruoyi.modelMessage.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
import com.ruoyi.modelMessage.mapper.MessageTemplateMapper;
|
||||
import com.ruoyi.modelMessage.service.IMessageTemplateService;
|
||||
|
||||
|
||||
/**
|
||||
* 模版管理Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
@Service
|
||||
public class MessageTemplateServiceImpl implements IMessageTemplateService
|
||||
{
|
||||
@Autowired
|
||||
private MessageTemplateMapper messageTemplateMapper;
|
||||
|
||||
/**
|
||||
* 查询模版管理
|
||||
*
|
||||
* @param templateId 模版管理主键
|
||||
* @return 模版管理
|
||||
*/
|
||||
@Override
|
||||
public MessageTemplate selectMessageTemplateByTemplateId(Long templateId)
|
||||
{
|
||||
return messageTemplateMapper.selectMessageTemplateByTemplateId(templateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模版管理列表
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 模版管理
|
||||
*/
|
||||
@Override
|
||||
public List<MessageTemplate> selectMessageTemplateList(MessageTemplate messageTemplate)
|
||||
{
|
||||
return messageTemplateMapper.selectMessageTemplateList(messageTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模版管理
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMessageTemplate(MessageTemplate messageTemplate)
|
||||
{
|
||||
messageTemplate.setCreateBy(SecurityUtils.getUsername());
|
||||
messageTemplate.setCreateTime(DateUtils.getNowDate());
|
||||
messageTemplate.setUpdateBy(SecurityUtils.getUsername());
|
||||
messageTemplate.setUpdateTime(DateUtils.getNowDate());
|
||||
return messageTemplateMapper.insertMessageTemplate(messageTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改模版管理
|
||||
*
|
||||
* @param messageTemplate 模版管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMessageTemplate(MessageTemplate messageTemplate)
|
||||
{
|
||||
messageTemplate.setUpdateBy(SecurityUtils.getUsername());
|
||||
messageTemplate.setUpdateTime(DateUtils.getNowDate());
|
||||
return messageTemplateMapper.updateMessageTemplate(messageTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除模版管理
|
||||
*
|
||||
* @param templateIds 需要删除的模版管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMessageTemplateByTemplateIds(Long[] templateIds)
|
||||
{
|
||||
return messageTemplateMapper.deleteMessageTemplateByTemplateIds(templateIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模版管理信息
|
||||
*
|
||||
* @param templateId 模版管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMessageTemplateByTemplateId(Long templateId)
|
||||
{
|
||||
return messageTemplateMapper.deleteMessageTemplateByTemplateId(templateId);
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
package com.ruoyi.modelMessage.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.aliyun.oss.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.modelMessage.domain.MessageVariable;
|
||||
import com.ruoyi.modelMessage.mapper.MessageVariableMapper;
|
||||
import com.ruoyi.modelMessage.service.IMessageVariableService;
|
||||
|
||||
/**
|
||||
* 变量管理Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-12-31
|
||||
*/
|
||||
@Service
|
||||
public class MessageVariableServiceImpl implements IMessageVariableService
|
||||
{
|
||||
private static final int CODE_LENGTH = 6;
|
||||
|
||||
@Autowired
|
||||
private MessageVariableMapper messageVariableMapper;
|
||||
|
||||
/**
|
||||
* 查询变量管理
|
||||
*
|
||||
* @param variableId 变量管理主键
|
||||
* @return 变量管理
|
||||
*/
|
||||
@Override
|
||||
public MessageVariable selectMessageVariableByVariableId(Long variableId)
|
||||
{
|
||||
return messageVariableMapper.selectMessageVariableByVariableId(variableId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询变量管理列表
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 变量管理
|
||||
*/
|
||||
@Override
|
||||
public List<MessageVariable> selectMessageVariableList(MessageVariable messageVariable)
|
||||
{
|
||||
return messageVariableMapper.selectMessageVariableList(messageVariable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增变量管理
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMessageVariable(MessageVariable messageVariable)
|
||||
{
|
||||
messageVariable.setCreateBy(SecurityUtils.getUsername());
|
||||
messageVariable.setCreateTime(DateUtils.getNowDate());
|
||||
messageVariable.setUpdateBy(SecurityUtils.getUsername());
|
||||
messageVariable.setUpdateTime(DateUtils.getNowDate());
|
||||
return messageVariableMapper.insertMessageVariable(messageVariable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改变量管理
|
||||
*
|
||||
* @param messageVariable 变量管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMessageVariable(MessageVariable messageVariable)
|
||||
{
|
||||
messageVariable.setUpdateBy(SecurityUtils.getUsername());
|
||||
messageVariable.setUpdateTime(DateUtils.getNowDate());
|
||||
return messageVariableMapper.updateMessageVariable(messageVariable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除变量管理
|
||||
*
|
||||
* @param variableIds 需要删除的变量管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMessageVariableByVariableIds(Long[] variableIds)
|
||||
{
|
||||
return messageVariableMapper.deleteMessageVariableByVariableIds(variableIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除变量管理信息
|
||||
*
|
||||
* @param variableId 变量管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMessageVariableByVariableId(Long variableId)
|
||||
{
|
||||
return messageVariableMapper.deleteMessageVariableByVariableId(variableId);
|
||||
}
|
||||
|
||||
//查询变量
|
||||
@Override
|
||||
public List<MessageVariable> selectMessageVariable() {
|
||||
return messageVariableMapper.selectMessageVariable();
|
||||
}
|
||||
|
||||
//删除变量之前检查一下有没有模版使用
|
||||
@Override
|
||||
public boolean selectTemplateByVariableId(String templateVariable) {
|
||||
return messageVariableMapper.selectTemplateByVariableId(templateVariable);
|
||||
}
|
||||
|
||||
//根据类型生成不同的变量内容
|
||||
@Override
|
||||
public String generateVariableContent(String variableType) {
|
||||
switch (variableType) {
|
||||
case "time":
|
||||
return DateUtils.dateTimeNow("HH:mm:ss");
|
||||
case "date":
|
||||
return DateUtils.dateTimeNow("yyyy-MM-dd");
|
||||
case "datetime":
|
||||
return DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss");
|
||||
case "addresser":
|
||||
return SecurityUtils.getUsername();
|
||||
case "recipients":
|
||||
return SecurityUtils.getUsername();
|
||||
case "RandomnDigits":
|
||||
return RandomStringUtils.randomNumeric(CODE_LENGTH);
|
||||
case "RandomnCharacters":
|
||||
return RandomStringUtils.randomAlphabetic(CODE_LENGTH);
|
||||
case "RandomN-digitLetters":
|
||||
return RandomStringUtils.randomAlphanumeric(CODE_LENGTH);
|
||||
default:
|
||||
throw new ServiceException("不明确的类型 " + variableType);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.ruoyi.modelMessage.utils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.modelMessage.annotation.MessageLog;
|
||||
import com.ruoyi.modelMessage.domain.MessageSystem;
|
||||
import com.ruoyi.modelMessage.enums.MessageType;
|
||||
import com.ruoyi.modelMessage.service.IMessageSystemService;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Order(1) //Aspect 的优先级
|
||||
public class MessageLogAspect {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MessageLogAspect.class);
|
||||
|
||||
@Autowired
|
||||
private IMessageSystemService messageSystemService;
|
||||
|
||||
@Around("@annotation(messageLog)")
|
||||
public Object handleMessageLog(ProceedingJoinPoint joinPoint, MessageLog messageLog) throws Throwable {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
// 获取注解信息
|
||||
String description = messageLog.description();
|
||||
String title = messageLog.title();
|
||||
MessageType messageType = messageLog.messageType();
|
||||
boolean immediateLog = messageLog.immediateLog();
|
||||
try {
|
||||
Object result = joinPoint.proceed();
|
||||
// 如果设置了true立即执行
|
||||
if (immediateLog) {
|
||||
logMessage(title, description, messageType);
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
logger.error("消息记录失败,方法: {}, 描述: {}", method.getName(), description, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void logMessage(String title, String description, MessageType messageType) {
|
||||
MessageSystem messageSystem = new MessageSystem();
|
||||
messageSystem.setMessageTitle(title); // 标题
|
||||
messageSystem.setCreateBy(SecurityUtils.getUsername()); // 发送人
|
||||
messageSystem.setCreateTime(DateUtils.getNowDate()); // 发送时间
|
||||
messageSystem.setMessageContent(description); // 信息内容
|
||||
messageSystem.setMessageStatus("0"); // 默认为未读 0未读 1 已读
|
||||
messageSystem.setMessageType(messageType.getCode());
|
||||
messageSystem.setUpdateBy(SecurityUtils.getUsername()); // 修改人
|
||||
messageSystem.setUpdateTime(DateUtils.getNowDate()); // 修改时间
|
||||
messageSystem.setSendMode("0"); // 默认发送方式为平台
|
||||
messageSystemService.insertMessageSystem(messageSystem);
|
||||
logger.info("消息记录成功,标题: {}, 描述: {}, 类型: {}", title, description, messageType);
|
||||
}
|
||||
}
|
@ -0,0 +1,229 @@
|
||||
package com.ruoyi.modelMessage.utils;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.modelMessage.domain.MessageSystem;
|
||||
import com.ruoyi.modelMessage.domain.MessageTemplate;
|
||||
import com.ruoyi.modelMessage.domain.MessageVariable;
|
||||
import com.ruoyi.modelMessage.mapper.MessageTemplateMapper;
|
||||
import com.ruoyi.modelMessage.mapper.MessageVariableMapper;
|
||||
|
||||
@Component
|
||||
public class MessageSystemUtils {
|
||||
|
||||
private static final String NUMERIC_CHARACTERS = "0123456789";
|
||||
private static final int CODE_LENGTH = 6;
|
||||
|
||||
@Autowired
|
||||
private MessageTemplateMapper messageTemplateMapper;
|
||||
|
||||
@Autowired
|
||||
private MessageVariableMapper messageVariableMapper;
|
||||
|
||||
/**
|
||||
* 解析输入字符串,提取模板代码和参数
|
||||
*
|
||||
* @param input 输入字符串
|
||||
* @return 解析结果
|
||||
*/
|
||||
public Map<String, Object> parseInput(String input) {
|
||||
if (input == null) {
|
||||
throw new ServiceException("输入内容不能为空!");
|
||||
}
|
||||
String templateCode = null;
|
||||
String queryParams = "";
|
||||
if (input.startsWith("SMS_")) {
|
||||
int templateCodeEndIndex = input.indexOf('?');
|
||||
if (templateCodeEndIndex != -1) {
|
||||
templateCode = input.substring(0, templateCodeEndIndex);
|
||||
queryParams = input.substring(templateCodeEndIndex + 1);
|
||||
} else {
|
||||
templateCode = input;
|
||||
}
|
||||
}
|
||||
MessageTemplate templateContent = null;
|
||||
List<String> variableNames = new ArrayList<>();
|
||||
if (templateCode != null) {
|
||||
templateContent = messageTemplateMapper.selectMessageTemplateByTemplateCode(templateCode);
|
||||
if (templateContent == null) {
|
||||
throw new ServiceException("未找到该模版签名! " + templateCode);
|
||||
}
|
||||
variableNames = extractVariableNamesFromTemplate(templateContent);
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
if (!queryParams.isEmpty()) {
|
||||
for (String param : queryParams.split("&")) {
|
||||
String[] keyValue = param.split("=", 2);
|
||||
if (keyValue.length != 2) {
|
||||
throw new ServiceException("无效的参数格式:" + param);
|
||||
}
|
||||
params.put(keyValue[0], URLDecoder.decode(keyValue[1], StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
if (templateContent != null) {
|
||||
for (String varName : variableNames) {
|
||||
if (!params.containsKey(varName)) {
|
||||
params.put(varName, generateRandomCode(CODE_LENGTH));
|
||||
}
|
||||
}
|
||||
}
|
||||
return Map.of("templateCode", templateCode, "params", params,
|
||||
"templateContent", templateContent != null ? templateContent.getTemplateContent() : input,
|
||||
"variableNames", variableNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成指定长度的随机数字字符串
|
||||
*
|
||||
* @param length 长度
|
||||
* @return 随机数字字符串
|
||||
*/
|
||||
public String generateRandomCode(int length) {
|
||||
Random random = new Random();
|
||||
StringBuilder codeBuilder = new StringBuilder(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int index = random.nextInt(NUMERIC_CHARACTERS.length());
|
||||
char randomChar = NUMERIC_CHARACTERS.charAt(index);
|
||||
codeBuilder.append(randomChar);
|
||||
}
|
||||
return codeBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取模板中的变量名
|
||||
*
|
||||
* @param templateContent 模板内容
|
||||
* @return 变量名列表
|
||||
*/
|
||||
public List<String> extractVariableNamesFromTemplate(MessageTemplate templateContent) {
|
||||
List<String> variableNames = new ArrayList<>();
|
||||
Pattern pattern = Pattern.compile("\\$\\{(.*?)\\}");
|
||||
Matcher matcher = pattern.matcher(templateContent.getTemplateContent());
|
||||
while (matcher.find()) {
|
||||
variableNames.add(matcher.group(1));
|
||||
}
|
||||
return variableNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充模板
|
||||
*
|
||||
* @param template 模板
|
||||
* @param params 参数
|
||||
* @return 填充后的模板
|
||||
*/
|
||||
public String fillTemplate(String template, Map<String, String> params) {
|
||||
String filledTemplate = template;
|
||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||
filledTemplate = filledTemplate.replace("${" + entry.getKey() + "}", entry.getValue());
|
||||
}
|
||||
return filledTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除内置变量的随机数字
|
||||
*
|
||||
* @param params 参数
|
||||
*/
|
||||
public void clearBuiltInVariables(Map<String, String> params) {
|
||||
List<MessageVariable> builtInVariables = messageVariableMapper.selectMessageVariable();
|
||||
for (MessageVariable variable : builtInVariables) {
|
||||
String variableContent = variable.getVariableContent();
|
||||
params.remove(variableContent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理模板消息并填充内置变量
|
||||
*/
|
||||
public String processTemplateMessage(MessageSystem messageSystem, String notificationContent) throws Exception {
|
||||
Map<String, Object> parsedParams = parseInput(notificationContent);
|
||||
String templateCode = (String) parsedParams.get("templateCode");
|
||||
MessageTemplate templateContent = null;
|
||||
|
||||
if (templateCode != null) {
|
||||
templateContent = messageTemplateMapper.selectMessageTemplateByTemplateCode(templateCode); //查询获取模版内容
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> params = (Map<String, String>) parsedParams.get("params");
|
||||
|
||||
// 检查参数
|
||||
List<String> variableNames = new ArrayList<>();
|
||||
if (templateContent != null) {
|
||||
variableNames = extractVariableNamesFromTemplate(templateContent);
|
||||
for (String varName : variableNames) {
|
||||
if (!params.containsKey(varName)) {
|
||||
throw new ServiceException("缺少参数: " + varName);
|
||||
}
|
||||
}
|
||||
}
|
||||
clearBuiltInVariables(params); // 清除内置变量
|
||||
fillBuiltInVariables(params, messageSystem, variableNames);
|
||||
// 如果未找到模板,使用原始内容作为模板
|
||||
String templateContentStr = templateContent != null ? templateContent.getTemplateContent() : notificationContent;
|
||||
return fillTemplate(templateContentStr, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充内置变量
|
||||
*
|
||||
* @param params 参数
|
||||
* @param message 消息
|
||||
* @param variableNames 变量名列表
|
||||
*/
|
||||
public void fillBuiltInVariables(Map<String, String> params, MessageSystem message, List<String> variableNames) {
|
||||
List<MessageVariable> builtInVariables = messageVariableMapper.selectMessageVariables(variableNames);
|
||||
for (MessageVariable variable : builtInVariables) {
|
||||
String variableContent = variable.getVariableContent();
|
||||
String variableValue = "recipients".equals(variableContent) ? message.getMessageRecipient() : generateVariableContent(variableContent);
|
||||
params.putIfAbsent(variableContent, variableValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成变量内容
|
||||
*
|
||||
* @param variableContent 变量内容
|
||||
* @return 生成的变量内容
|
||||
*/
|
||||
public String generateVariableContent(String variableContent) {
|
||||
switch (variableContent) {
|
||||
case "time":
|
||||
return DateUtils.dateTimeNow("HH:mm:ss");
|
||||
case "date":
|
||||
return DateUtils.dateTimeNow("yyyy-MM-dd");
|
||||
case "datetime":
|
||||
return DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss");
|
||||
case "addresser":
|
||||
case "recipients":
|
||||
return SecurityUtils.getUsername();
|
||||
case "code":
|
||||
return generateRandomCode(CODE_LENGTH); // 确保这里生成随机验证码
|
||||
case "RandomnDigits":
|
||||
return RandomStringUtils.randomNumeric(CODE_LENGTH);
|
||||
case "RandomnCharacters":
|
||||
return RandomStringUtils.randomAlphabetic(CODE_LENGTH);
|
||||
case "RandomN-digitLetters":
|
||||
return RandomStringUtils.randomAlphanumeric(CODE_LENGTH);
|
||||
default:
|
||||
throw new ServiceException("不明确的类型 " + variableContent);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
<?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.modelMessage.mapper.MessageSystemMapper">
|
||||
|
||||
<resultMap type="MessageSystem" id="MessageSystemResult">
|
||||
<result property="messageId" column="message_id" />
|
||||
<result property="messageTitle" column="message_title" />
|
||||
<result property="messageContent" column="message_content" />
|
||||
<result property="messageStatus" column="message_status" />
|
||||
<result property="messageType" column="message_type" />
|
||||
<result property="messageRecipient" column="message_recipient" />
|
||||
<result property="sendMode" column="send_mode" />
|
||||
<result property="code" column="code" />
|
||||
<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>
|
||||
|
||||
<sql id="selectMessageSystemVo">
|
||||
select message_id, message_title, message_content, message_status, message_type, create_by, create_time, update_by, update_time, remark, message_recipient, send_mode, `code` from message_system
|
||||
</sql>
|
||||
|
||||
<select id="selectMessageSystemList" parameterType="MessageSystem" resultMap="MessageSystemResult">
|
||||
<include refid="selectMessageSystemVo"/>
|
||||
<where>
|
||||
<if test="messageTitle != null and messageTitle != ''"> and message_title = #{messageTitle}</if>
|
||||
<if test="messageStatus != null and messageStatus != ''"> and message_status = #{messageStatus}</if>
|
||||
<if test="messageType != null and messageType != ''"> and message_type = #{messageType}</if>
|
||||
<if test="createBy != null and createBy != '' or messageRecipient != null and messageRecipient != ''">
|
||||
and (create_by = #{createBy} or message_recipient = #{messageRecipient})
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectMessageSystemByMessageId" parameterType="Long" resultMap="MessageSystemResult">
|
||||
<include refid="selectMessageSystemVo"/>
|
||||
where message_system.message_id = #{messageId}
|
||||
</select>
|
||||
|
||||
<insert id="insertMessageSystem" parameterType="MessageSystem" useGeneratedKeys="true" keyProperty="messageId">
|
||||
insert into message_system
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="messageTitle != null">message_title,</if>
|
||||
<if test="messageContent != null">message_content,</if>
|
||||
<if test="messageStatus != null">message_status,</if>
|
||||
<if test="messageType != null">message_type,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="messageRecipient != null">message_recipient,</if>
|
||||
<if test="sendMode != null">send_mode,</if>
|
||||
<if test="code != null">code,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="messageTitle != null">#{messageTitle},</if>
|
||||
<if test="messageContent != null">#{messageContent},</if>
|
||||
<if test="messageStatus != null">#{messageStatus},</if>
|
||||
<if test="messageType != null">#{messageType},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="messageRecipient != null">#{messageRecipient},</if>
|
||||
<if test="sendMode != null">#{sendMode},</if>
|
||||
<if test="code != null">#{code},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateMessageSystem" parameterType="MessageSystem">
|
||||
update message_system
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="messageTitle != null">message_title = #{messageTitle},</if>
|
||||
<if test="messageContent != null">message_content = #{messageContent},</if>
|
||||
<if test="messageStatus != null">message_status = #{messageStatus},</if>
|
||||
<if test="messageType != null">message_type = #{messageType},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="messageRecipient != null">message_recipient = #{messageRecipient},</if>
|
||||
<if test="sendMode != null">send_mode = #{sendMode},</if>
|
||||
<if test="code != null">code = #{code},</if>
|
||||
</trim>
|
||||
where message_system.message_id = #{messageId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteMessageSystemByMessageId" parameterType="Long">
|
||||
delete from message_system where message_id = #{messageId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMessageSystemByMessageIds" parameterType="String">
|
||||
delete from message_system where message_id in
|
||||
<foreach item="messageId" collection="array" open="(" separator="," close=")">
|
||||
#{messageId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 批量发送信息 -->
|
||||
<insert id="batchInsertMessageSystem" parameterType="java.util.List">
|
||||
INSERT INTO message_system (message_title, message_content, message_status, message_type, message_recipient,
|
||||
send_mode, `code`, create_by, create_time, update_by, update_time, remark) VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
( #{item.messageTitle}, #{item.messageContent}, #{item.messageStatus}, #{item.messageType},
|
||||
#{item.messageRecipient}, #{item.sendMode}, #{item.code}, #{item.createBy}, NOW(), #{item.updateBy},
|
||||
NOW(), #{item.remark} )
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,93 @@
|
||||
<?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.modelMessage.mapper.MessageTemplateMapper">
|
||||
|
||||
<resultMap type="MessageTemplate" id="MessageTemplateResult">
|
||||
<result property="templateId" column="template_id" />
|
||||
<result property="templateName" column="template_name" />
|
||||
<result property="templateCode" column="template_code" />
|
||||
<result property="templateType" column="template_type" />
|
||||
<result property="templateContent" column="template_content" />
|
||||
<result property="templateVariable" column="template_variable" />
|
||||
<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>
|
||||
|
||||
<sql id="selectMessageTemplateVo">
|
||||
select template_id, template_name, template_code, template_type, template_content, template_variable, create_by, create_time, update_by, update_time, remark from message_template
|
||||
</sql>
|
||||
|
||||
<select id="selectMessageTemplateList" parameterType="MessageTemplate" resultMap="MessageTemplateResult">
|
||||
<include refid="selectMessageTemplateVo"/>
|
||||
<where>
|
||||
<if test="templateName != null and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
|
||||
<if test="templateType != null and templateType != ''"> and template_type = #{templateType}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMessageTemplateByTemplateId" parameterType="Long" resultMap="MessageTemplateResult">
|
||||
<include refid="selectMessageTemplateVo"/>
|
||||
where message_template.template_id = #{templateId}
|
||||
</select>
|
||||
|
||||
<insert id="insertMessageTemplate" parameterType="MessageTemplate" useGeneratedKeys="true" keyProperty="templateId">
|
||||
insert into message_template
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="templateName != null">template_name,</if>
|
||||
<if test="templateCode != null">template_code,</if>
|
||||
<if test="templateType != null">template_type,</if>
|
||||
<if test="templateContent != null">template_content,</if>
|
||||
<if test="templateVariable != null">template_variable,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="templateName != null">#{templateName},</if>
|
||||
<if test="templateCode != null">#{templateCode},</if>
|
||||
<if test="templateType != null">#{templateType},</if>
|
||||
<if test="templateContent != null">#{templateContent},</if>
|
||||
<if test="templateVariable != null">#{templateVariable},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateMessageTemplate" parameterType="MessageTemplate">
|
||||
update message_template
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="templateName != null">template_name = #{templateName},</if>
|
||||
<if test="templateCode != null">template_code = #{templateCode},</if>
|
||||
<if test="templateType != null">template_type = #{templateType},</if>
|
||||
<if test="templateContent != null">template_content = #{templateContent},</if>
|
||||
<if test="templateVariable != null">template_variable = #{templateVariable},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where message_template.template_id = #{templateId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteMessageTemplateByTemplateId" parameterType="Long">
|
||||
delete from message_template where template_id = #{templateId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMessageTemplateByTemplateIds" parameterType="String">
|
||||
delete from message_template where template_id in
|
||||
<foreach item="templateId" collection="array" open="(" separator="," close=")">
|
||||
#{templateId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,92 @@
|
||||
<?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.modelMessage.mapper.MessageVariableMapper">
|
||||
|
||||
<resultMap type="MessageVariable" id="MessageVariableResult">
|
||||
<result property="variableId" column="variable_id" />
|
||||
<result property="variableName" column="variable_name" />
|
||||
<result property="variableType" column="variable_type" />
|
||||
<result property="variableContent" column="variable_content" />
|
||||
<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>
|
||||
|
||||
<sql id="selectMessageVariableVo">
|
||||
select variable_id, variable_name, variable_type, variable_content, create_by, create_time, update_by, update_time, remark from message_variable
|
||||
</sql>
|
||||
|
||||
<select id="selectMessageVariableList" parameterType="MessageVariable" resultMap="MessageVariableResult">
|
||||
<include refid="selectMessageVariableVo"/>
|
||||
<where>
|
||||
<if test="variableName != null and variableName != ''"> and variable_name like concat('%', #{variableName}, '%')</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectMessageVariableByVariableId" parameterType="Long" resultMap="MessageVariableResult">
|
||||
<include refid="selectMessageVariableVo"/>
|
||||
where message_variable.variable_id = #{variableId}
|
||||
</select>
|
||||
|
||||
<insert id="insertMessageVariable" parameterType="MessageVariable" useGeneratedKeys="true" keyProperty="variableId">
|
||||
insert into message_variable
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="variableName != null">variable_name,</if>
|
||||
<if test="variableType != null">variable_type,</if>
|
||||
<if test="variableContent != null">variable_content,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="variableName != null">#{variableName},</if>
|
||||
<if test="variableType != null">#{variableType},</if>
|
||||
<if test="variableContent != null">#{variableContent},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateMessageVariable" parameterType="MessageVariable">
|
||||
update message_variable
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="variableName != null">variable_name = #{variableName},</if>
|
||||
<if test="variableType != null">variable_type = #{variableType},</if>
|
||||
<if test="variableContent != null">variable_content = #{variableContent},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where message_variable.variable_id = #{variableId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteMessageVariableByVariableId" parameterType="Long">
|
||||
delete from message_variable where variable_id = #{variableId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMessageVariableByVariableIds" parameterType="String">
|
||||
delete from message_variable where variable_id in
|
||||
<foreach item="variableId" collection="array" open="(" separator="," close=")">
|
||||
#{variableId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 查询在使用模版签名时用到了那些变量一一赋值 -->
|
||||
<select id="selectMessageVariables" parameterType="java.util.List" resultType="MessageVariable">
|
||||
SELECT * FROM message_variable WHERE variable_content IN
|
||||
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
86
sql/mysql/message.sql
Normal file
86
sql/mysql/message.sql
Normal file
@ -0,0 +1,86 @@
|
||||
-- ----------------------------
|
||||
-- 消息系统
|
||||
-- ----------------------------
|
||||
-- 消息表
|
||||
DROP TABLE IF EXISTS `message_system`;
|
||||
CREATE TABLE `message_system` (
|
||||
`message_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`message_title` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '标题',
|
||||
`create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`send_mode` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '发送方式(0平台 1手机号 2 邮箱)',
|
||||
`code` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '号码',
|
||||
`message_content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '消息内容',
|
||||
`message_recipient` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '接收人',
|
||||
`message_status` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '消息状态(0未读 1已读)',
|
||||
`message_type` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '消息类型',
|
||||
`update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新者',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`message_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 893 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '消息表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- 模版表
|
||||
DROP TABLE IF EXISTS `message_template`;
|
||||
CREATE TABLE `message_template` (
|
||||
`template_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`template_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模版名称',
|
||||
`template_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模版CODE',
|
||||
`template_type` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '模版类型',
|
||||
`template_content` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '模版内容',
|
||||
`template_variable` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '变量属性',
|
||||
`create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新者',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`template_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 113 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '模版表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- 变量表
|
||||
DROP TABLE IF EXISTS `message_variable`;
|
||||
CREATE TABLE `message_variable` (
|
||||
`variable_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`variable_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '变量名称',
|
||||
`variable_type` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '变量类型',
|
||||
`variable_content` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '变量内容',
|
||||
`create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新者',
|
||||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||
`remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||
PRIMARY KEY (`variable_id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 132 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '变量表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- 消息系统菜单
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2257, '消息管理', 2264, 0, 'messageSystem', 'modelMessage/messageSystem/index', NULL, '', 1, 0, 'C', '0', '0', 'modelMessage:messageSystem:list', '#', 'admin', '2024-12-21 15:00:31', 'admin', '2024-12-31 15:04:49', '消息管理菜单');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2258, '消息管理查询', 2257, 1, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:messageSystem:query', '#', 'admin', '2024-12-21 15:00:31', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2259, '消息管理新增', 2257, 2, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:messageSystem:add', '#', 'admin', '2024-12-21 15:00:31', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2260, '消息管理修改', 2257, 3, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:messageSystem:edit', '#', 'admin', '2024-12-21 15:00:31', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2261, '消息管理删除', 2257, 4, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:messageSystem:remove', '#', 'admin', '2024-12-21 15:00:31', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2262, '消息管理导出', 2257, 5, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:messageSystem:export', '#', 'admin', '2024-12-21 15:00:31', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2264, '消息系统', 0, 0, 'modelMessage', NULL, NULL, '', 1, 0, 'M', '0', '0', '', 'message', 'admin', '2024-12-31 11:57:29', 'xl', '2025-01-03 15:48:44', '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2265, '模版管理', 2264, 1, 'template', 'modelMessage/template/index', NULL, '', 1, 0, 'C', '0', '0', 'modelMessage:template:list', '#', 'admin', '2024-12-31 14:59:52', '', NULL, '模版管理菜单');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2266, '模版管理查询', 2265, 1, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:template:query', '#', 'admin', '2024-12-31 14:59:52', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2267, '模版管理新增', 2265, 2, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:template:add', '#', 'admin', '2024-12-31 14:59:52', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2268, '模版管理修改', 2265, 3, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:template:edit', '#', 'admin', '2024-12-31 14:59:52', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2269, '模版管理删除', 2265, 4, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:template:remove', '#', 'admin', '2024-12-31 14:59:52', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2270, '模版管理导出', 2265, 5, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:template:export', '#', 'admin', '2024-12-31 14:59:52', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2271, '变量管理', 2264, 2, 'variable', 'modelMessage/variable/index', NULL, '', 1, 0, 'C', '0', '0', 'modelMessage:variable:list', '#', 'admin', '2024-12-31 15:01:50', 'admin', '2024-12-31 15:04:56', '变量管理菜单');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2272, '变量管理查询', 2271, 1, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:variable:query', '#', 'admin', '2024-12-31 15:01:50', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2273, '变量管理新增', 2271, 2, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:variable:add', '#', 'admin', '2024-12-31 15:01:50', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2274, '变量管理修改', 2271, 3, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:variable:edit', '#', 'admin', '2024-12-31 15:01:50', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2275, '变量管理删除', 2271, 4, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:variable:remove', '#', 'admin', '2024-12-31 15:01:50', '', NULL, '');
|
||||
INSERT INTO `platform`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2276, '变量管理导出', 2271, 5, '#', '', NULL, '', 1, 0, 'F', '0', '0', 'modelMessage:variable:export', '#', 'admin', '2024-12-31 15:01:50', '', NULL, '');
|
||||
|
||||
-- 消息系统字典
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (142, 0, '未读', '0', 'message_status', NULL, 'primary', 'N', '0', 'xl', '2024-12-21 15:13:02', '', NULL, NULL);
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (143, 1, '已读', '1', 'message_status', NULL, 'success', 'N', '0', 'xl', '2024-12-21 15:13:15', 'xl', '2024-12-21 15:13:22', NULL);
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (144, 0, '平台', '0', 'send_mode', NULL, 'primary', 'N', '0', 'xl', '2024-12-25 09:40:01', '', NULL, NULL);
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (145, 1, '短信', '1', 'send_mode', NULL, 'success', 'N', '0', 'xl', '2024-12-25 09:40:16', 'xl', '2025-01-01 10:12:07', NULL);
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (146, 2, '邮件', '2', 'send_mode', NULL, 'warning', 'N', '0', 'xl', '2024-12-25 09:40:28', 'xl', '2025-01-01 10:12:14', NULL);
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (147, 0, '验证码', '0', 'template_type', NULL, 'primary', 'N', '0', 'xl', '2025-01-03 09:22:52', '', NULL, NULL);
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (148, 0, '通知', '0', 'message_type', NULL, 'primary', 'N', '0', 'xl', '2025-01-03 15:12:29', '', NULL, NULL);
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (149, 0, '提示', '1', 'message_type', NULL, 'success', 'N', '0', 'xl', '2025-01-03 15:12:41', 'xl', '2025-01-03 15:12:45', NULL);
|
||||
INSERT INTO `platform`.`sys_dict_data` (`dict_code`, `dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (150, 1, '推广', '1', 'template_type', NULL, 'success', 'N', '0', 'xl', '2025-01-03 15:13:15', '', NULL, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user