guoshilong
2024-02-02 36b7f863fda32d53b5cdadd6ee1514de4aea3905
系统消息,我的消息
14 files modified
16 files added
1158 ■■■■■ changed files
src/main/java/org/springblade/common/utils/NodeTreeUtil.java 42 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/email/service/IEmailAccountService.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/email/service/impl/EmailAccountServiceImpl.java 51 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/controller/MessageRecordController.java 143 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/controller/MessageUserController.java 58 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/entity/MessageRecord.java 65 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/entity/MessageUser.java 56 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/mapper/MessageRecordMapper.java 44 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/mapper/MessageRecordMapper.xml 24 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/mapper/MessageUserMapper.java 55 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/mapper/MessageUserMapper.xml 106 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/service/IMessageRecordService.java 45 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/service/IMessageUserService.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/service/impl/MessageRecordServiceImpl.java 135 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/service/impl/MessageUserServiceImpl.java 52 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/vo/MessageRecordVO.java 36 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/messageRecord/vo/MessageUserVO.java 25 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/controller/DeptController.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java 20 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml 43 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/node/DeptUserTreeNode.java 24 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/node/TreeNode.java 48 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IDeptService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/IUserService.java 4 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java 14 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java 15 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/vo/DeptVO.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/wrapper/DeptWrapper.java 1 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/common/utils/NodeTreeUtil.java
@@ -6,8 +6,10 @@
import org.springblade.core.tool.node.TreeNode;
import org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree;
import org.springblade.modules.house.vo.HouseTree;
import org.springblade.modules.system.node.DeptUserTreeNode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -144,4 +146,44 @@
        }
        return parentList;
    }
    /**
     * map 转 tree 组织机构(父子id不会重复的情况,数据查询来自同一个表)
     * @param treeMap
     * @return
     */
    public  static List<DeptUserTreeNode> getDeptAndUserNodeTree(Map<String, DeptUserTreeNode> treeMap){
        List<DeptUserTreeNode> tree = new ArrayList<>();
        if (treeMap.size() > 1) {
            treeMap.forEach((id, treeNode) -> {
                if (!treeNode.getHasChildren()){
                    // 判断是否有绑定多个部门
                    List<String> asList = Arrays.asList(treeNode.getParentId().split(","));
                    if (asList.size()>1){
                        for (String parentId : asList) {
                            if (treeMap.containsKey(parentId)) {
                                treeMap.get(parentId).getChildren().add(treeNode);
                            } else {
                                tree.add(treeNode);
                            }
                        }
                    }else {
                        if (treeMap.containsKey(treeNode.getParentId())) {
                            DeptUserTreeNode deptUserTreeNode =treeMap.get(treeNode.getParentId());
                            deptUserTreeNode.getChildren().add(treeNode);
                        } else {
                            tree.add(treeNode);
                        }
                    }
                }else {
                    if (treeMap.containsKey(treeNode.getParentId())) {
                        treeMap.get(treeNode.getParentId()).getChildren().add(treeNode);
                    } else {
                        tree.add(treeNode);
                    }
                }
            });
        }
        return tree;
    }
}
src/main/java/org/springblade/modules/email/service/IEmailAccountService.java
@@ -1,9 +1,14 @@
package org.springblade.modules.email.service;
import org.springblade.modules.email.entity.EmailAccount;
import org.springblade.modules.messageRecord.entity.MessageUser;
import java.util.List;
public interface IEmailAccountService {
    /**用于注册成功后发送邮件 @param account 账号信息*/
    void senderEmail(EmailAccount account);
    void sendMessageUserEmail(String title, String content, List<MessageUser> messageUserList);
}
src/main/java/org/springblade/modules/email/service/impl/EmailAccountServiceImpl.java
@@ -1,10 +1,12 @@
package org.springblade.modules.email.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.email.config.MailProperties;
import org.springblade.modules.email.config.MailSenderConfig;
import org.springblade.modules.email.entity.EmailAccount;
import org.springblade.modules.email.service.IEmailAccountService;
import org.springblade.modules.messageRecord.entity.MessageUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
@@ -14,6 +16,8 @@
import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
@@ -29,27 +33,44 @@
    @Override
    public void senderEmail(EmailAccount account) {
        log.info(Thread.currentThread().getName());
        JavaMailSenderImpl javaMailSender = senderConfig.getSender();
        //一个复杂的邮件
        MimeMessage message = javaMailSender.createMimeMessage();
        try {
            //组装
            MimeMessageHelper helper = new MimeMessageHelper(message, true);
            //主题(标题)
            helper.setSubject(account.getSubject());
        if (account.getEmails().size()>0){
            log.info(Thread.currentThread().getName());
            JavaMailSenderImpl javaMailSender = senderConfig.getSender();
            //一个复杂的邮件
            MimeMessage message = javaMailSender.createMimeMessage();
            try {
                //组装
                MimeMessageHelper helper = new MimeMessageHelper(message, true);
            helper.setText(account.getContent(),true);
                //主题(标题)
                helper.setSubject(account.getSubject());
            helper.setTo(account.getEmails().toArray(new String[account.getEmails().size()]));
                helper.setText(account.getContent(),true);
            helper.setFrom(javaMailSender.getUsername());
                helper.setTo(account.getEmails().toArray(new String[account.getEmails().size()]));
            javaMailSender.send(message);
                helper.setFrom(javaMailSender.getUsername());
        } catch (MessagingException e) {
            e.printStackTrace();
                javaMailSender.send(message);
            } catch (MessagingException e) {
                e.printStackTrace();
            }
        }
    }
    @Override
    public void sendMessageUserEmail(String title, String content, List<MessageUser> messageUserList) {
        List<String> emails = messageUserList.stream().filter(e -> StringUtil.isNotBlank(e.getEmail())).map(MessageUser::getEmail).collect(Collectors.toList());
        EmailAccount emailAccount = new EmailAccount();
        emailAccount.setEmails(emails);
        emailAccount.setSubject(title);
        emailAccount.setContent(content);
        senderEmail(emailAccount);
    }
}
src/main/java/org/springblade/modules/messageRecord/controller/MessageRecordController.java
New file
@@ -0,0 +1,143 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.messageRecord.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.messageRecord.entity.MessageRecord;
import org.springblade.modules.messageRecord.vo.MessageRecordVO;
import org.springblade.modules.messageRecord.service.IMessageRecordService;
import org.springblade.core.boot.ctrl.BladeController;
/**
 * 消息记录表 控制器
 *
 * @author BladeX
 * @since 2024-01-18
 */
@RestController
@AllArgsConstructor
@RequestMapping("messageRecord/messageRecord")
@Api(value = "消息记录表", tags = "消息记录表接口")
public class MessageRecordController extends BladeController {
    private final IMessageRecordService messageRecordService;
    /**
     * 消息记录表 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入messageRecord")
    public R<MessageRecord> detail(MessageRecord messageRecord) {
        MessageRecord detail = messageRecordService.getOne(Condition.getQueryWrapper(messageRecord));
        return R.data(detail);
    }
    /**
     * 消息记录表 分页
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入messageRecord")
    public R<IPage<MessageRecord>> list(MessageRecord messageRecord, Query query) {
        IPage<MessageRecord> pages = messageRecordService.page(Condition.getPage(query), Condition.getQueryWrapper(messageRecord));
        return R.data(pages);
    }
    /**
     * 消息记录表 自定义分页
     */
    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入messageRecord")
    public R<IPage<MessageRecordVO>> page(MessageRecordVO messageRecord, Query query) {
        IPage<MessageRecordVO> pages = messageRecordService.selectMessageRecordPage(Condition.getPage(query), messageRecord);
        return R.data(pages);
    }
    /**
     * 消息记录表 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入messageRecord")
    public R save(@Valid @RequestBody MessageRecordVO messageRecord) {
        return R.status(messageRecordService.save(messageRecord));
    }
    /**
     * 消息记录表 自定义新增
     */
    @PostMapping("/customizeSave")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入messageRecord")
    public R customizeSave(@Valid @RequestBody MessageRecordVO messageRecord) {
        return R.status(messageRecordService.customizeSave(messageRecord));
    }
    /**
     * 消息记录表 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入messageRecord")
    public R update(@Valid @RequestBody MessageRecord messageRecord) {
        return R.status(messageRecordService.updateById(messageRecord));
    }
    /**
     * 消息记录表 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入messageRecord")
    public R submit(@Valid @RequestBody MessageRecord messageRecord) {
        return R.status(messageRecordService.saveOrUpdate(messageRecord));
    }
    /**
     * 消息记录表 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "逻辑删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(messageRecordService.deleteLogic(Func.toLongList(ids)));
    }
    /**
     * 发送消息
     */
    @PostMapping("/sendMessage")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "逻辑删除", notes = "传入ids")
    public R sendMessage(@RequestParam String id) {
        return R.status(messageRecordService.sendMessage(id));
    }
}
src/main/java/org/springblade/modules/messageRecord/controller/MessageUserController.java
New file
@@ -0,0 +1,58 @@
package org.springblade.modules.messageRecord.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.modules.messageRecord.entity.MessageRecord;
import org.springblade.modules.messageRecord.entity.MessageUser;
import org.springblade.modules.messageRecord.service.IMessageUserService;
import org.springblade.modules.messageRecord.vo.MessageRecordVO;
import org.springblade.modules.messageRecord.vo.MessageUserVO;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@RestController
@AllArgsConstructor
@RequestMapping("messageUser/messageUser")
public class MessageUserController extends BladeController {
    private final IMessageUserService messageUserService;
    @GetMapping("/getPage")
    public R<IPage<MessageUserVO>> page(MessageUserVO messageUserVO, Query query) {
        IPage<MessageUserVO> pages = messageUserService.getPage(Condition.getPage(query), messageUserVO);
        return R.data(pages);
    }
    /**
     * 消息记录表 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入messageRecord")
    public R update(@Valid @RequestBody MessageUser messageUser) {
        return R.status(messageUserService.updateById(messageUser));
    }
    @PostMapping("updateIsReadStatus")
    public R updateIsReadStatus(String ids,String isRead){
        Boolean res = messageUserService.updateIsReadStatus(ids,isRead);
        return R.status(res);
    }
    @GetMapping("/getMessage")
    public R<IPage<MessageUserVO>> getMessage(MessageUserVO messageUserVO, Query query) {
        IPage<MessageUserVO> pages = messageUserService.getMessagePage(Condition.getPage(query), messageUserVO);
        return R.data(pages);
    }
}
src/main/java/org/springblade/modules/messageRecord/entity/MessageRecord.java
New file
@@ -0,0 +1,65 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.messageRecord.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
/**
 * 消息记录表 实体类
 *
 * @author BladeX
 * @since 2024-01-18
 */
@Data
@TableName("blade_message_record")
@ApiModel(value = "MessageRecord对象", description = "消息记录表")
public class MessageRecord extends BaseEntity {
    private static final long serialVersionUID = 1L;
    //接收对象
    private String receiver;
    /**
     * 消息发送类型(1、站内信;2、邮件;3、短信)
     */
    @ApiModelProperty(value = "消息发送类型(1、站内信;2、邮件;3、短信)")
    private String type;
    /**
     * 消息来源(1、系统消息;2、用户消息)
     */
    @ApiModelProperty(value = "消息来源(1、系统消息;2、用户消息)")
    private String messageResource;
    /**
     * 标题
     */
    @ApiModelProperty(value = "标题")
    private String title;
    /**
     * 内容
     */
    @ApiModelProperty(value = "内容")
    private String content;
}
src/main/java/org/springblade/modules/messageRecord/entity/MessageUser.java
New file
@@ -0,0 +1,56 @@
package org.springblade.modules.messageRecord.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
 * 用户消息表
 */
@Data
@TableName("blade_message_user")
public class MessageUser  implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 用户ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;
    /**
     * 消息ID
     */
    private String messageRecordId;
    //用户id
    private String userId;
    //消息类型
    private String type;
    //邮箱
    private String email;
    //手机号
    private String phone;
    //是否已读(1、已读;2、未读)
    private String isRead;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("创建时间")
    private Date createTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("更新时间")
    private Date updateTime;
}
src/main/java/org/springblade/modules/messageRecord/mapper/MessageRecordMapper.java
New file
@@ -0,0 +1,44 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.messageRecord.mapper;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.messageRecord.entity.MessageRecord;
import org.springblade.modules.messageRecord.vo.MessageRecordVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
 * 消息记录表 Mapper 接口
 *
 * @author BladeX
 * @since 2024-01-18
 */
public interface MessageRecordMapper extends BaseMapper<MessageRecord> {
    /**
     * 自定义分页
     *
     * @param page
     * @param messageRecord
     * @return
     */
    List<MessageRecordVO> selectMessageRecordPage(IPage page,@Param("vo") MessageRecordVO messageRecord);
}
src/main/java/org/springblade/modules/messageRecord/mapper/MessageRecordMapper.xml
New file
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.messageRecord.mapper.MessageRecordMapper">
    <select id="selectMessageRecordPage" resultType="org.springblade.modules.messageRecord.vo.MessageRecordVO">
        select bmr.* from blade_message_record bmr
        where bmr.is_deleted = 0
        <if test="vo.type != null and vo.type !=''">
            and bmr.type  LIKE CONCAT('%',#{vo.type},'%')
        </if>
        <if test="vo.startTime!=null and vo.startTime!=''">
            and bmr.create_time&gt;=#{vo.startTime}
        </if>
        <if test="vo.endTime!=null and vo.endTime!=''">
            and bmr.create_time&lt;=#{vo.endTime}
        </if>
        <if test="vo.title != null and vo.title != ''">
            and bmr.title LIKE CONCAT('%',#{vo.title},'%')
        </if>
    </select>
</mapper>
src/main/java/org/springblade/modules/messageRecord/mapper/MessageUserMapper.java
New file
@@ -0,0 +1,55 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.messageRecord.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.messageRecord.entity.MessageRecord;
import org.springblade.modules.messageRecord.entity.MessageUser;
import org.springblade.modules.messageRecord.vo.MessageRecordVO;
import org.springblade.modules.messageRecord.vo.MessageUserVO;
import java.util.List;
/**
 * 消息记录表 Mapper 接口
 *
 * @author BladeX
 * @since 2024-01-18
 */
public interface MessageUserMapper extends BaseMapper<MessageUser> {
    List<MessageUserVO> getPage(IPage<MessageUserVO> page, @Param("vo") MessageUserVO messageUserVO);
    /**
     * 我发送的消息
     * @param page
     * @param messageUserVO
     * @return
     */
    List<MessageUserVO> getMySendMessage(IPage<MessageUserVO> page, @Param("vo") MessageUserVO messageUserVO);
    /**
     * 我收到的消息
     * @param page
     * @param messageUserVO
     * @return
     */
    List<MessageUserVO> getMyReceiveMessage(IPage<MessageUserVO> page, @Param("vo") MessageUserVO messageUserVO);
}
src/main/java/org/springblade/modules/messageRecord/mapper/MessageUserMapper.xml
New file
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.modules.messageRecord.mapper.MessageUserMapper">
    <select id="getPage" resultType="org.springblade.modules.messageRecord.vo.MessageUserVO">
        SELECT
            bmu.*,
            bmr.title,bmr.content,bmr.create_time as sendTime,bmr.create_user as sendUserId,
            bu.real_name as sendUserName,
            bu1.real_name as receiveUserName
        FROM blade_message_user bmu
        LEFT JOIN blade_message_record bmr ON bmr.id = bmu.message_record_id
        LEFT JOIN blade_user bu ON bu.id = bmr.create_user
        LEFT JOIN blade_user bu1 ON bu1.id = bmu.user_id
        where 1=1
            <if test="vo.userId != null and vo.userId !=''">
                and bmu.user_id = #{vo.userId}
            </if>
            <if test="vo.type != null and vo.type !=''">
                AND bmu.type LIKE CONCAT('%',#{vo.type},'%')
            </if>
            <if test="vo.sendUserId != null and vo.sendUserId !=''">
                AND bmr.create_user = #{vo.sendUserId}
            </if>
        ORDER BY bmu.create_time DESC
    </select>
    <select id="getMySendMessage" resultType="org.springblade.modules.messageRecord.vo.MessageUserVO">
        SELECT
        bmu.*,
        bmr.title,bmr.content,bmr.create_time as time,
        bu.real_name as userName,
        bd.dept_name as deptName,
        bd.id as deptId
        FROM blade_message_user bmu
        LEFT JOIN blade_message_record bmr ON bmr.id = bmu.message_record_id
        LEFT JOIN blade_user bu ON bu.id = bmu.user_id
        LEFT JOIN blade_dept bd ON bu.dept_id = bd.id
        where 1=1
        <if test="vo.userId != null and vo.userId !=''">
            and bmr.create_user = #{vo.userId}
        </if>
        <if test="vo.type != null and vo.type !=''">
            AND bmu.type LIKE CONCAT('%',#{vo.type},'%')
        </if>
        <if test="vo.title != null and vo.title !='' ">
            and bmr.title LIKE CONCAT('%',#{vo.title},'%')
        </if>
        <if test="vo.startTime!=null and vo.startTime!=''">
            AND date_format(bmr.create_time,'%Y-%m-%d')&gt;= #{vo.startTime}
        </if>
        <if test="vo.endTime!=null and vo.endTime!=''">
            AND date_format(bmr.create_time,'%Y-%m-%d')&lt;= #{vo.endTime}
        </if>
        ORDER BY bmu.create_time DESC
    </select>
    <select id="getMyReceiveMessage" resultType="org.springblade.modules.messageRecord.vo.MessageUserVO">
        SELECT
        bmu.id,
        bmu.message_record_id,
        bmu.is_read,
        bmu.type,
        bmu.email,
        bmu.phone,
        bmu.create_time,
        bmu.update_time,
        bmr.title,
        bmr.content,
        bmr.create_time as time,
        bmr.create_user as userId,
        bu.real_name as userName,
        bd.dept_name as deptName,
        bd.id as deptId
        FROM blade_message_user bmu
        LEFT JOIN blade_message_record bmr ON bmr.id = bmu.message_record_id
        LEFT JOIN blade_user bu ON bu.id = bmr.create_user
        LEFT JOIN blade_dept bd ON bu.dept_id = bd.id
        where 1=1
        <if test="vo.userId != null and vo.userId !=''">
            and bmu.user_id = #{vo.userId}
        </if>
        <if test="vo.type != null and vo.type !=''">
            AND bmu.type LIKE CONCAT('%',#{vo.type},'%')
        </if>
        <if test="vo.title != null and vo.title !='' ">
            and bmr.title LIKE CONCAT('%',#{vo.title},'%')
        </if>
        <if test="vo.startTime!=null and vo.startTime!=''">
            AND date_format(bmr.create_time,'%Y-%m-%d')&gt;= #{vo.startTime}
        </if>
        <if test="vo.endTime!=null and vo.endTime!=''">
            AND date_format(bmr.create_time,'%Y-%m-%d')&lt;= #{vo.endTime}
        </if>
        <if test="vo.isRead != null and vo.isRead !=''">
            AND is_read = #{vo.isRead}
        </if>
        ORDER BY bmu.create_time DESC
    </select>
</mapper>
src/main/java/org/springblade/modules/messageRecord/service/IMessageRecordService.java
New file
@@ -0,0 +1,45 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.messageRecord.service;
import org.springblade.modules.messageRecord.entity.MessageRecord;
import org.springblade.modules.messageRecord.vo.MessageRecordVO;
import org.springblade.core.mp.base.BaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
/**
 * 消息记录表 服务类
 *
 * @author BladeX
 * @since 2024-01-18
 */
public interface IMessageRecordService extends BaseService<MessageRecord> {
    /**
     * 自定义分页
     *
     * @param page
     * @param messageRecord
     * @return
     */
    IPage<MessageRecordVO> selectMessageRecordPage(IPage<MessageRecordVO> page, MessageRecordVO messageRecord);
    Boolean customizeSave(MessageRecordVO messageRecord);
    Boolean sendMessage(String id);
}
src/main/java/org/springblade/modules/messageRecord/service/IMessageUserService.java
New file
@@ -0,0 +1,14 @@
package org.springblade.modules.messageRecord.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.messageRecord.entity.MessageUser;
import org.springblade.modules.messageRecord.vo.MessageUserVO;
public interface IMessageUserService extends IService<MessageUser> {
    IPage<MessageUserVO> getPage(IPage<MessageUserVO> page, MessageUserVO messageUserVO);
    Boolean updateIsReadStatus(String ids, String isRead);
    IPage<MessageUserVO> getMessagePage(IPage<MessageUserVO> page, MessageUserVO messageUserVO);
}
src/main/java/org/springblade/modules/messageRecord/service/impl/MessageRecordServiceImpl.java
New file
@@ -0,0 +1,135 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.messageRecord.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.modules.email.service.IEmailAccountService;
import org.springblade.modules.email.service.IEmailService;
import org.springblade.modules.messageRecord.entity.MessageRecord;
import org.springblade.modules.messageRecord.entity.MessageUser;
import org.springblade.modules.messageRecord.service.IMessageUserService;
import org.springblade.modules.messageRecord.vo.MessageRecordVO;
import org.springblade.modules.messageRecord.mapper.MessageRecordMapper;
import org.springblade.modules.messageRecord.service.IMessageRecordService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
 * 消息记录表 服务实现类
 *
 * @author BladeX
 * @since 2024-01-18
 */
@Service
@AllArgsConstructor
public class MessageRecordServiceImpl extends BaseServiceImpl<MessageRecordMapper, MessageRecord> implements IMessageRecordService {
    private final IMessageUserService messageUserService;
    private final IUserService userService;
    private final IEmailAccountService emailAccountService;
    @Override
    public IPage<MessageRecordVO> selectMessageRecordPage(IPage<MessageRecordVO> page, MessageRecordVO messageRecord) {
        return page.setRecords(baseMapper.selectMessageRecordPage(page, messageRecord));
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean customizeSave(MessageRecordVO messageRecord) {
        List<User> userList = new ArrayList();
        if (messageRecord.getMessageResource().equals("1")) {
            //系统消息(receiveUser指定的是部门,所以要通过部门去查人)
            userList = userService.getUserListByDeptIds(messageRecord.getReceiver());
        } else if (messageRecord.getMessageResource().equals("2")) {
            //用户消息(receiveUser指定的是人)
            userList = userService.getUserListByIds(messageRecord.getReceiver());
        }
        //保存消息记录
        boolean saveRecord = save(messageRecord);
        List<MessageUser> messageUserList = new ArrayList<>();
        userList.forEach(user -> {
            MessageUser messageUser = new MessageUser();
            messageUser.setUserId(user.getId().toString());
            messageUser.setMessageRecordId(messageRecord.getId().toString());
            messageUser.setType(messageRecord.getType());
            messageUser.setCreateTime(DateUtil.now());
            messageUser.setUpdateTime(DateUtil.now());
            if (messageRecord.getType().indexOf("2") > -1) {
                messageUser.setEmail(user.getEmail());
            }
            if (messageRecord.getType().indexOf("3") > -1) {
                messageUser.setPhone(user.getPhone());
            }
            messageUserList.add(messageUser);
        });
        //在message_user表里存数据
        boolean saveBatch = messageUserService.saveBatch(messageUserList);
        if (saveBatch&&saveRecord){
            if (messageRecord.getType().indexOf("2") > -1) {
                emailAccountService.sendMessageUserEmail(messageRecord.getTitle(), messageRecord.getContent(), messageUserList);
                return true;
            }
            if (messageRecord.getType().indexOf("3") > -1) {
                return true;
            }
        }
        return saveBatch && saveRecord;
    }
    @Override
    public Boolean sendMessage(String id) {
        //查询MessageRecord表里的数据
        MessageRecord messageRecord = getById(id);
        //查询MessageUser表里的数据
        List<MessageUser> messageUserList = messageUserService.list(new QueryWrapper<MessageUser>().eq("message_record_id", id));
        if (messageRecord.getType().indexOf("2") > -1) {
            emailAccountService.sendMessageUserEmail(messageRecord.getTitle(), messageRecord.getContent(), messageUserList);
            return true;
        }
        if (messageRecord.getType().indexOf("3") > -1) {
            return true;
        }
        return true;
    }
}
src/main/java/org/springblade/modules/messageRecord/service/impl/MessageUserServiceImpl.java
New file
@@ -0,0 +1,52 @@
package org.springblade.modules.messageRecord.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.modules.messageRecord.entity.MessageUser;
import org.springblade.modules.messageRecord.mapper.MessageUserMapper;
import org.springblade.modules.messageRecord.service.IMessageUserService;
import org.springblade.modules.messageRecord.vo.MessageUserVO;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Service
public class MessageUserServiceImpl extends ServiceImpl<MessageUserMapper, MessageUser> implements IMessageUserService {
    @Override
    public IPage<MessageUserVO> getPage(IPage<MessageUserVO> page, MessageUserVO messageUserVO) {
        return page.setRecords(baseMapper.getPage(page, messageUserVO));
    }
    @Override
    public Boolean updateIsReadStatus(String ids, String isRead) {
        List<MessageUser> messageUserList = baseMapper.selectBatchIds(Arrays.asList(ids));
        messageUserList.forEach(messageUser ->{
            messageUser.setUpdateTime(DateUtil.now());
            messageUser.setIsRead(isRead);
        });
        boolean b = updateBatchById(messageUserList);
        return b;
    }
    @Override
    public IPage<MessageUserVO> getMessagePage(IPage<MessageUserVO> page, MessageUserVO messageUserVO) {
        List<MessageUserVO> list = new ArrayList<>();
        if (messageUserVO.getMessageType().equals("send")){
            //我发送的
            list = baseMapper.getMySendMessage(page,messageUserVO);
        }else if (messageUserVO.getMessageType().equals("receive")){
            //我收到的
            list = baseMapper.getMyReceiveMessage(page,messageUserVO);
        }
        page.setRecords(list);
        return page;
    }
}
src/main/java/org/springblade/modules/messageRecord/vo/MessageRecordVO.java
New file
@@ -0,0 +1,36 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.messageRecord.vo;
import org.springblade.modules.messageRecord.entity.MessageRecord;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
 * 消息记录表 视图实体类
 *
 * @author BladeX
 * @since 2024-01-18
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MessageRecordVO extends MessageRecord {
    private static final long serialVersionUID = 1L;
    private String startTime;
    private String endTime;
}
src/main/java/org/springblade/modules/messageRecord/vo/MessageUserVO.java
New file
@@ -0,0 +1,25 @@
package org.springblade.modules.messageRecord.vo;
import lombok.Data;
import org.springblade.modules.messageRecord.entity.MessageUser;
@Data
public class MessageUserVO extends MessageUser {
    private String title;
    private String content;
    private String messageType;
    //取的是记录表里的创建时间
    private String time;
    private String userName;
    private String deptId;
    private String deptName;
    private String startTime;
    private String endTime;
}
src/main/java/org/springblade/modules/system/controller/DeptController.java
@@ -39,6 +39,7 @@
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.node.DeptUserTreeNode;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.vo.DeptVO;
import org.springblade.modules.system.wrapper.DeptWrapper;
@@ -216,6 +217,20 @@
    }
    /**
     * 查询组织机构树数据(下级包含人员信息)(数据量太大,不建议使用)
     * @param treeNode
     * @return
     */
    @GetMapping("/getDeptAndUserTree")
    @ApiOperation(value = "查询组织机构树数据(下级包含人员信息)")
    public R getDeptAndUserTree(DeptUserTreeNode treeNode) {
        return R.data(deptService.getDeptAndUserTree(treeNode));
    }
}
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
@@ -17,8 +17,10 @@
package org.springblade.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.node.DeptUserTreeNode;
import org.springblade.modules.system.vo.DeptVO;
import java.util.List;
@@ -72,7 +74,23 @@
     * @param id
     * @return
     */
    DeptVO getDeptById(@Param("id") Long id);
    DeptVO getDeptById(@Param("id") Long id);
    /**
     * 查询组织机构树
     * @param treeNode
     * @return
     */
    @MapKey(value = "id")
    Map<String, DeptUserTreeNode> getDeptMap(@Param("treeNode") DeptUserTreeNode treeNode);
    /**
     * 查询用户树
     * @param treeNode
     * @return
     */
    @MapKey(value = "id")
    Map<String, DeptUserTreeNode> getUserMap(@Param("treeNode") DeptUserTreeNode treeNode);
    /**
     * 查询网格对应的机构信息(包含父级机构名称)
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -63,6 +63,9 @@
        <if test="param3.fullName!=null and param3.fullName!=''">
            and dept.full_name like concat(concat('%', #{param3.fullName}),'%')
        </if>
        <if test="param3.showWg != null and param3.showWg != ''">
            and dept.dept_name not LIKE '第%网格'
        </if>
        ORDER BY dept.sort
    </select>
@@ -144,6 +147,46 @@
        and c.id = #{id}
    </select>
    <select id="getDeptMap" resultType="org.springblade.modules.system.node.DeptUserTreeNode">
        SELECT
        cast(dept.id as char) as id,
        dept.parent_id parentId,
        dept.dept_name AS name,
        1 as isMan,
        0 AS phone,
        (
        SELECT
        CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
        FROM
        blade_dept
        WHERE
        parent_id = dept.id and is_deleted = 0
        ) AS hasChildren
        FROM
        blade_dept dept WHERE dept.is_deleted = 0
        <if test="treeNode.id!=null and treeNode.id!=''">
            and dept.id = #{treeNode.id}
        </if>
    </select>
    <!--查询组织机构树数据(下级包含人员信息)(排除组织机构对应不上的人员)-->
    <select id="getUserMap" resultType="org.springblade.modules.system.node.DeptUserTreeNode">
        select
        bu.id,
        bu.dept_id parentId,
        bu.real_name AS name,
        bu.phone,
        bu.email,
        2 as isMan,
        0 as hasChildren
        from blade_user bu join blade_dept bd on find_in_set(bu.dept_id,bd.id)
        where 1=1 and bu.is_deleted = 0 and bu.status = 1
        <if test="treeNode.id!=null and treeNode.id!=''">
            and bu.dept_id like concat(concat('%',#{treeNode.id}),'%')
        </if>
    </select>
    <!--查询网格对应的机构信息(包含父级机构名称)-->
    <select id="getGridDeptAndParentList" resultType="org.springblade.modules.system.vo.DeptVO">
        select bd.*,bd1.dept_name as parentName from blade_dept bd
src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -106,5 +106,7 @@
     */
    List<User> getNotBindUserDept();
    List<User> getUserListByDeptIds(@Param("deptIds") String receiveDept);
    List<User> getUserInfoByPropertyId(String deptId,String roleId);
}
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -201,6 +201,13 @@
        where bu.is_deleted = 0 and bud.id is null
        and bu.dept_id!=''
    </select>
    <select id="getUserListByDeptIds" resultType="org.springblade.modules.system.entity.User">
        SELECT * FROM blade_user bu where is_deleted = 0
        and dept_id in
        <foreach collection="deptIds.split(',')" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
    </select>
    <select id="getUserInfoByPropertyId" resultType="org.springblade.modules.system.entity.User"
            parameterType="java.lang.String">
src/main/java/org/springblade/modules/system/node/DeptUserTreeNode.java
New file
@@ -0,0 +1,24 @@
package org.springblade.modules.system.node;
import lombok.Data;
/**
 * 部门用户树node
 * @author zhongrj
 * @date 2023-04-23
 */
@Data
public class DeptUserTreeNode extends TreeNode {
    /**
     * 手机号
     */
    private String phone;
    private String email;
    /**
     * 是人还是部门  1:部门  2:人
     */
    private String isMan;
}
src/main/java/org/springblade/modules/system/node/TreeNode.java
New file
@@ -0,0 +1,48 @@
package org.springblade.modules.system.node;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
 * 树节点
 * @author zhongrj
 * @date 2023-03-30
 */
@Data
public class TreeNode implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    private String id;
    /**
     * 父id
     */
    private String parentId;
    /**
     * 名称
     */
    private String name;
    /**
     * 层级
     */
    private String level;
    /**
     * 子孙节点
     */
    private List<TreeNode> children = new ArrayList<>();
    /**
     * 是否有子孙节点
     */
    private Boolean hasChildren;
}
src/main/java/org/springblade/modules/system/service/IDeptService.java
@@ -18,6 +18,8 @@
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.node.DeptUserTreeNode;
import org.springblade.modules.system.node.TreeNode;
import org.springblade.modules.system.vo.DeptVO;
import java.util.List;
@@ -137,4 +139,6 @@
     * 数据处理(社区绑定)-- 处理社区
     */
    Object dataHandleCommunity();
    List<DeptUserTreeNode> getDeptAndUserTree(DeptUserTreeNode treeNode);
}
src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -254,6 +254,10 @@
     */
    Object handleUserDept();
    List<User> getUserListByIds(String receiveUser);
    List<User> getUserListByDeptIds(String receiveDept);
    List<User> getUserInfoByPropertyId(String propertyCompanyId,String roleId);
    Object handleUser();
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
@@ -23,6 +23,7 @@
import org.springblade.common.cache.SysCache;
import org.springblade.common.node.TreeStringNode;
import org.springblade.common.utils.SpringUtils;
import org.springblade.common.utils.NodeTreeUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.constant.BladeConstant;
@@ -40,6 +41,8 @@
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.entity.Region;
import org.springblade.modules.system.mapper.DeptMapper;
import org.springblade.modules.system.node.DeptUserTreeNode;
import org.springblade.modules.system.node.TreeNode;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.service.IRegionService;
import org.springblade.modules.system.vo.DeptDetailVO;
@@ -399,4 +402,15 @@
        }
        return null;
    }
    @Override
    public List<DeptUserTreeNode> getDeptAndUserTree(DeptUserTreeNode treeNode) {
        // 查询数据
        Map<String, DeptUserTreeNode> deptMap = baseMapper.getDeptMap(treeNode);
        Map<String, DeptUserTreeNode> userMap = baseMapper.getUserMap(treeNode);
        deptMap.putAll(userMap);
        List<DeptUserTreeNode> deptAndUserNodeTree = NodeTreeUtil.getDeptAndUserNodeTree(deptMap);
        // 处理并返回
        return deptAndUserNodeTree;
    }
}
src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -62,10 +62,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
import static org.springblade.common.constant.CommonConstant.DEFAULT_PARAM_PASSWORD;
@@ -634,4 +631,14 @@
            }
        }
    }
    @Override
    public List<User> getUserListByIds(String receiveUser) {
        return baseMapper.selectBatchIds(Arrays.asList(receiveUser.split(",")));
    }
    @Override
    public List<User> getUserListByDeptIds(String receiveDept) {
        return baseMapper.getUserListByDeptIds(receiveDept);
    }
}
src/main/java/org/springblade/modules/system/vo/DeptVO.java
@@ -86,4 +86,9 @@
    private Boolean disabled;
    /**
     * 保持树型结构统一
     */
    private String name;
}
src/main/java/org/springblade/modules/system/wrapper/DeptWrapper.java
@@ -70,6 +70,7 @@
        List<DeptVO> collect = list.stream().peek(dept -> {
            String category = DictCache.getValue(DictEnum.ORG_CATEGORY, dept.getDeptCategory());
            Objects.requireNonNull(dept).setDeptCategoryName(category);
            Objects.requireNonNull(dept).setName(dept.getDeptName());
        }).collect(Collectors.toList());
        return ForestNodeMerger.merge(collect);
    }