refactor(消息模板): 重构微信小程序和公众号消息发送逻辑- 重新组织了消息模板代码,分离小程序和公众号消息发送功能
- 优化了消息发送API接口,增加了单独的公众号消息发送方法 - 调整了消息发送实现类,支持小程序和公众号分别发送消息 - 更新了消息发送调用逻辑,根据不同社交类型选择对应的消息发送方法 - 重构查询用户下属部门逻辑,根据用户所负责的部门递归获取所有子部门 - 重构获取用户列表信息方法,增加通过用户状态查询,根据菜单查询
This commit is contained in:
parent
3df040cbf3
commit
079bdaa6a4
@ -0,0 +1,146 @@
|
||||
package cn.iocoder.yudao.framework.common.template;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.CheckInReminderDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.CompanyAnnouncementNoticeDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.MessageUnreadReminderDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.MsgData;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
// -- 微信小程序模版转换器
|
||||
public class WxMaMsgTemplateUtils {
|
||||
|
||||
/**
|
||||
* 消息未读提醒
|
||||
*/
|
||||
public final static String MESSAGE_UNREAD_REMINDER = "fH29xjNb8pe-7onQ-wE3QrBAC-y8aaC_oosYZKNMtzM";
|
||||
/**
|
||||
* 公司公告通知
|
||||
*/
|
||||
public final static String COMPANY_ANNOUNCEMENT_NOTICE = "OF4-948Vz9rtE_VA55rmDxo4azOwmrjjk33jDpOiPiY";
|
||||
/**
|
||||
* 打卡提醒
|
||||
*/
|
||||
public final static String CHECK_IN_REMINDER = "5yHyXhrsyqXi8s4hYhvaeMtz9kT5OPvDCe3h6G1T-OE";
|
||||
|
||||
|
||||
/**
|
||||
* 消息未读提醒
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public SubscribeMessageReqDTO convertMessageUnreadReminder(MessageUnreadReminderDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(MESSAGE_UNREAD_REMINDER);
|
||||
|
||||
//消息类型
|
||||
MsgData noticeType = new MsgData();
|
||||
noticeType.setName("phrase8");
|
||||
noticeType.setValue(dto.getMsgType());
|
||||
|
||||
message.addData(noticeType);
|
||||
|
||||
//发送人
|
||||
MsgData publishMan = new MsgData();
|
||||
publishMan.setName("thing16");
|
||||
publishMan.setValue(dto.getSender());
|
||||
message.addData(publishMan);
|
||||
|
||||
//发送时间
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time3");
|
||||
createTime.setValue(dto.getSendingTime());
|
||||
message.addData(createTime);
|
||||
|
||||
//消息内容
|
||||
MsgData content = new MsgData();
|
||||
content.setName("thing2");
|
||||
String comment = dto.getComment();
|
||||
if (comment.length() > 10) {
|
||||
comment = comment.substring(0, 10) + ". . . . ";
|
||||
}
|
||||
content.setValue(comment);
|
||||
message.addData(content);
|
||||
|
||||
message.setMiniProgramState(dto.getPage());
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
public SubscribeMessageReqDTO convertCompanyAnnouncementNotice(CompanyAnnouncementNoticeDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(COMPANY_ANNOUNCEMENT_NOTICE);
|
||||
//通知类型
|
||||
MsgData noticeType = new MsgData();
|
||||
noticeType.setName("thing1");
|
||||
noticeType.setValue(dto.getNoticeType()); //这里根据业务需求填写具体的公告类型 如全员公告, xxx公告
|
||||
message.addData(noticeType);
|
||||
|
||||
//公告标题
|
||||
String value = dto.getTitle();
|
||||
if (value.length() > 10) {
|
||||
value = value.substring(0, 10) + ". . . . ";
|
||||
}
|
||||
|
||||
MsgData title = new MsgData();
|
||||
title.setName("thing6");
|
||||
title.setValue(value);
|
||||
message.addData(title);
|
||||
|
||||
//通知内容
|
||||
MsgData content = new MsgData();
|
||||
content.setName("thing2");
|
||||
content.setValue("具体内容请进入小程序查看");
|
||||
message.addData(content);
|
||||
|
||||
//发布人
|
||||
MsgData publishMan = new MsgData();
|
||||
publishMan.setName("thing9");
|
||||
publishMan.setValue(dto.getNickname());
|
||||
message.addData(publishMan);
|
||||
|
||||
//通知时间
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time3");
|
||||
createTime.setValue(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
|
||||
message.addData(createTime);
|
||||
|
||||
message.setMiniProgramState(dto.getMiniProgramState());
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打卡通知
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public SubscribeMessageReqDTO convertCheckInReminder(CheckInReminderDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(CHECK_IN_REMINDER);
|
||||
MsgData data = new MsgData();
|
||||
data.setName("thing9");
|
||||
data.setValue(dto.getCheckInType());
|
||||
message.addData(data);
|
||||
data = new MsgData();
|
||||
data.setName("thing6");
|
||||
data.setValue(dto.getComment());
|
||||
message.addData(data);
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,243 +0,0 @@
|
||||
package cn.iocoder.yudao.framework.common.template;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.*;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.MsgData;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
// -- 微信小程序模版转换器
|
||||
public interface WxMiNiMsgTemplate {
|
||||
|
||||
WxMiNiMsgTemplate INSTANCE = Mappers.getMapper(WxMiNiMsgTemplate.class);
|
||||
|
||||
/**
|
||||
* 审批结果通知
|
||||
*/
|
||||
String APPROVAL_RESULT_NOTIFICATION = "OnJjp5pdjG1PHMoELYaqp3Xq8jWZ5E6ndO0clEIQ4tk";
|
||||
|
||||
/**
|
||||
* 消息未读提醒
|
||||
*/
|
||||
String MESSAGE_UNREAD_REMINDER = "fH29xjNb8pe-7onQ-wE3QrBAC-y8aaC_oosYZKNMtzM";
|
||||
/**
|
||||
* 公司公告通知
|
||||
*/
|
||||
String COMPANY_ANNOUNCEMENT_NOTICE = "OF4-948Vz9rtE_VA55rmDxo4azOwmrjjk33jDpOiPiY";
|
||||
/**
|
||||
* 打卡提醒
|
||||
*/
|
||||
String CHECK_IN_REMINDER = "5yHyXhrsyqXi8s4hYhvaeMtz9kT5OPvDCe3h6G1T-OE";
|
||||
/**
|
||||
* OA流程待办提醒
|
||||
*/
|
||||
String OA_PROCESS_TO_DO_REMINDER = "3cP4btlFSSiZk65qVewN_WoT_bh0OfUkYzzTsADOrR4";
|
||||
|
||||
/**
|
||||
* 转换审批结果通知
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
default SubscribeMessageReqDTO convertApprovalResultNotification(ApprovalResultNotificationMessageDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(APPROVAL_RESULT_NOTIFICATION);
|
||||
//审批类型
|
||||
MsgData processType = new MsgData();
|
||||
processType.setName("thing1");
|
||||
processType.setValue(dto.getProcessInstanceName());
|
||||
message.addData(processType);
|
||||
|
||||
//发起时间
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time2");
|
||||
createTime.setValue(dto.getTime());
|
||||
message.addData(createTime);
|
||||
|
||||
//审批时间
|
||||
MsgData approvalTime = new MsgData();
|
||||
approvalTime.setName("time7");
|
||||
approvalTime.setValue(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
|
||||
message.addData(approvalTime);
|
||||
//审批结果
|
||||
MsgData approvalResult = new MsgData();
|
||||
approvalResult.setName("phrase3");
|
||||
approvalResult.setValue(dto.getResult());
|
||||
message.addData(approvalResult);
|
||||
String reason = dto.getReason();
|
||||
if (StrUtil.isNotEmpty(reason)) {
|
||||
MsgData approvalReason = new MsgData();
|
||||
if (reason.length() > 10) {
|
||||
reason = reason.substring(0, 10) + ". . . . ";
|
||||
}
|
||||
approvalReason.setName("thing12");
|
||||
approvalReason.setValue(reason);
|
||||
message.addData(approvalReason);
|
||||
}
|
||||
message.setMiniProgramState(dto.getMiniProgramState());
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息未读提醒
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
default SubscribeMessageReqDTO convertMessageUnreadReminder(MessageUnreadReminderDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(MESSAGE_UNREAD_REMINDER);
|
||||
|
||||
//消息类型
|
||||
MsgData noticeType = new MsgData();
|
||||
noticeType.setName("phrase8");
|
||||
noticeType.setValue(dto.getMsgType());
|
||||
|
||||
message.addData(noticeType);
|
||||
|
||||
//发送人
|
||||
MsgData publishMan = new MsgData();
|
||||
publishMan.setName("thing16");
|
||||
publishMan.setValue(dto.getSender());
|
||||
message.addData(publishMan);
|
||||
|
||||
//发送时间
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time3");
|
||||
createTime.setValue(dto.getSendingTime());
|
||||
message.addData(createTime);
|
||||
|
||||
//消息内容
|
||||
MsgData content = new MsgData();
|
||||
content.setName("thing2");
|
||||
String comment = dto.getComment();
|
||||
if (comment.length() > 10) {
|
||||
comment = comment.substring(0, 10) + ". . . . ";
|
||||
}
|
||||
content.setValue(comment);
|
||||
message.addData(content);
|
||||
|
||||
message.setMiniProgramState(dto.getPage());
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
default SubscribeMessageReqDTO convertCompanyAnnouncementNotice(CompanyAnnouncementNoticeDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(COMPANY_ANNOUNCEMENT_NOTICE);
|
||||
//通知类型
|
||||
MsgData noticeType = new MsgData();
|
||||
noticeType.setName("thing1");
|
||||
noticeType.setValue(dto.getNoticeType()); //这里根据业务需求填写具体的公告类型 如全员公告, xxx公告
|
||||
message.addData(noticeType);
|
||||
|
||||
//公告标题
|
||||
String value = dto.getTitle();
|
||||
if (value.length() > 10) {
|
||||
value = value.substring(0, 10) + ". . . . ";
|
||||
}
|
||||
|
||||
MsgData title = new MsgData();
|
||||
title.setName("thing6");
|
||||
title.setValue(value);
|
||||
message.addData(title);
|
||||
|
||||
//通知内容
|
||||
MsgData content = new MsgData();
|
||||
content.setName("thing2");
|
||||
content.setValue("具体内容请进入小程序查看");
|
||||
message.addData(content);
|
||||
|
||||
//发布人
|
||||
MsgData publishMan = new MsgData();
|
||||
publishMan.setName("thing9");
|
||||
publishMan.setValue(dto.getNickname());
|
||||
message.addData(publishMan);
|
||||
|
||||
//通知时间
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time3");
|
||||
createTime.setValue(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
|
||||
message.addData(createTime);
|
||||
|
||||
message.setMiniProgramState(dto.getMiniProgramState());
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打卡通知
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
default SubscribeMessageReqDTO convertCheckInReminder(CheckInReminderDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(CHECK_IN_REMINDER);
|
||||
MsgData data = new MsgData();
|
||||
data.setName("thing9");
|
||||
data.setValue(dto.getCheckInType());
|
||||
message.addData(data);
|
||||
data = new MsgData();
|
||||
data.setName("thing6");
|
||||
data.setValue(dto.getComment());
|
||||
message.addData(data);
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* OA流程待办提醒
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
default SubscribeMessageReqDTO convertProcessToDoReminder(ProcessToDoReminderDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(OA_PROCESS_TO_DO_REMINDER);
|
||||
//待办标题
|
||||
MsgData processType = new MsgData();
|
||||
processType.setName("thing1");
|
||||
processType.setValue(dto.getProcessType());
|
||||
message.addData(processType);
|
||||
|
||||
//申请人
|
||||
MsgData applicant = new MsgData();
|
||||
applicant.setName("thing4");
|
||||
applicant.setValue(dto.getStartUserNickname());
|
||||
message.addData(applicant);
|
||||
|
||||
//申请时间
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time5");
|
||||
createTime.setValue(dto.getTime());
|
||||
message.addData(createTime);
|
||||
|
||||
//当前进度
|
||||
MsgData currentSchedule = new MsgData();
|
||||
currentSchedule.setName("thing6");
|
||||
currentSchedule.setValue(dto.getSchedule());
|
||||
message.addData(currentSchedule);
|
||||
|
||||
message.setMiniProgramState(dto.getMiniProgramState());
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package cn.iocoder.yudao.framework.common.template;
|
||||
|
||||
// -- 微信公众号模版转换器
|
||||
public class WxMpMsgTemplate {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package cn.iocoder.yudao.framework.common.template;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.ApprovalResultNotificationMessageDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.ProcessToDoReminderDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.MsgData;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
// -- 微信公众号模版转换器
|
||||
public class WxMpMsgTemplateUtils {
|
||||
|
||||
/**
|
||||
* 审批结果通知
|
||||
*/
|
||||
String APPROVAL_RESULT_NOTIFICATION = "xeV5M36qHGIup512JnfmFjoJhLT4-gGY6uqz2cgfFlM";
|
||||
/**
|
||||
* OA流程待办提醒
|
||||
*/
|
||||
String OA_PROCESS_TO_DO_REMINDER = "rV94N8PbUOz4EQyjpJcucPQOTrBPx2icOZ5F2KNgD40";
|
||||
|
||||
|
||||
/**
|
||||
* 转换审批结果通知
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public SubscribeMessageReqDTO convertApprovalResultNotification(ApprovalResultNotificationMessageDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(APPROVAL_RESULT_NOTIFICATION);
|
||||
//审批类型
|
||||
MsgData processType = new MsgData();
|
||||
processType.setName("thing1");
|
||||
processType.setValue(dto.getProcessInstanceName());
|
||||
message.addData(processType);
|
||||
|
||||
//发起时间
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time7");
|
||||
createTime.setValue(dto.getTime());
|
||||
message.addData(createTime);
|
||||
|
||||
//审批时间
|
||||
MsgData approvalTime = new MsgData();
|
||||
approvalTime.setName("time4");
|
||||
approvalTime.setValue(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
|
||||
message.addData(approvalTime);
|
||||
//审批结果
|
||||
MsgData approvalResult = new MsgData();
|
||||
approvalResult.setName("const6");
|
||||
approvalResult.setValue(dto.getResult());
|
||||
message.addData(approvalResult);
|
||||
String reason = dto.getReason();
|
||||
if (StrUtil.isNotEmpty(reason)) {
|
||||
MsgData approvalReason = new MsgData();
|
||||
if (reason.length() > 10) {
|
||||
reason = reason.substring(0, 10) + ". . . . ";
|
||||
}
|
||||
approvalReason.setName("thing5");
|
||||
approvalReason.setValue(reason);
|
||||
message.addData(approvalReason);
|
||||
}
|
||||
message.setJumpWxMaFlag(true);
|
||||
message.setMiniProgramState(dto.getMiniProgramState());
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* OA流程待办提醒
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public SubscribeMessageReqDTO convertProcessToDoReminder(ProcessToDoReminderDTO dto) {
|
||||
SubscribeMessageReqDTO message = new SubscribeMessageReqDTO();
|
||||
message.setToUser(dto.getOpenId());
|
||||
message.setTemplateId(OA_PROCESS_TO_DO_REMINDER);
|
||||
//待办标题
|
||||
MsgData processType = new MsgData();
|
||||
processType.setName("thing2");
|
||||
processType.setValue(dto.getProcessType());
|
||||
message.addData(processType);
|
||||
|
||||
//申请人
|
||||
MsgData applicant = new MsgData();
|
||||
applicant.setName("phrase10");
|
||||
applicant.setValue(dto.getStartUserNickname());
|
||||
message.addData(applicant);
|
||||
|
||||
//申请时间
|
||||
MsgData createTime = new MsgData();
|
||||
createTime.setName("time15");
|
||||
createTime.setValue(dto.getTime());
|
||||
message.addData(createTime);
|
||||
|
||||
//当前进度
|
||||
MsgData currentSchedule = new MsgData();
|
||||
currentSchedule.setName("thing9");
|
||||
currentSchedule.setValue(dto.getSchedule());
|
||||
message.addData(currentSchedule);
|
||||
|
||||
message.setJumpWxMaFlag(true);
|
||||
message.setMiniProgramState(dto.getMiniProgramState());
|
||||
message.setPage(dto.getPage());
|
||||
message.setSocialType(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
@ -30,11 +30,15 @@ public class SubscribeMessageReqDTO {
|
||||
private List<MsgData> data = new ArrayList<>();
|
||||
|
||||
@Schema(description = "跳转小程序类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "developer为开发版;trial为体验版;formal为正式版;默认为正式版")
|
||||
@NotNull(message = "跳转小程序类型不能为空")
|
||||
private String miniProgramState = "formal";
|
||||
|
||||
@Schema(description = "小程序页面地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "pages/home/index")
|
||||
@NotNull(message = "小程序页面地址不能为空")
|
||||
@Schema(description = "是否跳转小程序 true 是 false 否 默认跳转", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Boolean jumpWxMaFlag;
|
||||
|
||||
@Schema(description = "公众号跳转小程序appId(公众号消息需要跳转小程序时候传)", requiredMode = Schema.RequiredMode.REQUIRED, example = "developer为开发版;trial为体验版;formal为正式版;默认为正式版")
|
||||
private String miniAppId;
|
||||
|
||||
@Schema(description = "小程序页面地址(公众号消息需要跳转小程序时候传)", requiredMode = Schema.RequiredMode.REQUIRED, example = "pages/home/index")
|
||||
private String page;
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMiNiMsgTemplate;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMpMsgTemplateUtils;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.ApprovalResultNotificationMessageDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
@ -131,7 +131,7 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
|
||||
"subPagesB/bpm/task/todo/examineApprove?id=" + financialPayment.getId() + "&isDetail=1";
|
||||
// --- 发消息通知发起人
|
||||
String time = financialPaymentItem.getCreateTime().format(Constants.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertApprovalResultNotification(new ApprovalResultNotificationMessageDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMpMsgTemplateUtils().convertApprovalResultNotification(new ApprovalResultNotificationMessageDTO()
|
||||
.setOpenId(item.getOpenId())
|
||||
.setProcessInstanceName(financialPayment.getProcessInstanceName())
|
||||
.setTime(time)
|
||||
@ -139,7 +139,7 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
|
||||
.setReason((StrUtil.isEmpty(financialPaymentItem.getNotes()) ? result : financialPaymentItem.getNotes()))
|
||||
.setMiniProgramState("formal")
|
||||
.setPage(page));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMpMsg(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("财务管理审批发送通知人失败:{}", financialPayment);
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.message;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMiNiMsgTemplate;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMaMsgTemplateUtils;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMpMsgTemplateUtils;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.ApprovalResultNotificationMessageDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.MessageUnreadReminderDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.ProcessToDoReminderDTO;
|
||||
@ -33,6 +35,7 @@ import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* BPM 消息 Service 实现类
|
||||
@ -95,35 +98,34 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams));
|
||||
}
|
||||
|
||||
//发送审批结果通知至微信
|
||||
List<AdminOauthUserOtherInfoApiVO> list = this.getUserOpenId(Collections.singletonList(reqDTO.getStartUserId()), SocialTypeEnum.WECHAT_MP.getType());
|
||||
for (AdminOauthUserOtherInfoApiVO item : list) {
|
||||
String openId = item.getOpenId();
|
||||
if (openId != null) {
|
||||
if (workTaskDO != null) {
|
||||
AdminUserRespDTO userRespDTO = userApi.getUser(workTaskDO.getReceiverUserId()).getCheckedData();
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(openId)
|
||||
.setMsgType(reqDTO.getProcessInstanceName())
|
||||
.setSender(nickName)
|
||||
.setComment("你分配的任务已完成!")
|
||||
.setSendingTime(reqDTO.getCreateTime())
|
||||
.setPage("subPages/task/taskAssignment?userId=" + workTaskDO.getReceiverUserId() + "&deptId=" + userRespDTO.getDeptId())
|
||||
.setMiniProgramState("formal"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
|
||||
} else {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertApprovalResultNotification(new ApprovalResultNotificationMessageDTO()
|
||||
.setOpenId(openId)
|
||||
.setProcessInstanceName(reqDTO.getProcessInstanceName())
|
||||
.setTime(reqDTO.getCreateTime())
|
||||
.setResult("通过")
|
||||
.setReason(reqDTO.getReason())
|
||||
.setMiniProgramState("formal")
|
||||
.setPage("subPagesB/bpm/task/todo/examineApprove?id=" + reqDTO.getProcessInstanceId() + "&isDetail=1"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
}
|
||||
}
|
||||
//发送审批结果通知至微信
|
||||
List<AdminOauthUserOtherInfoApiVO> list = this.getUserOpenId(Collections.singletonList(reqDTO.getStartUserId()));
|
||||
Map<Integer, String> openIdMap = list.stream().collect(Collectors.toMap(AdminOauthUserOtherInfoApiVO::getSocialType, AdminOauthUserOtherInfoApiVO::getOpenId));
|
||||
|
||||
if (workTaskDO != null && StrUtil.isNotEmpty(openIdMap.get(SocialTypeEnum.WECHAT_MINI_APP.getType()))) {
|
||||
AdminUserRespDTO userRespDTO = userApi.getUser(workTaskDO.getReceiverUserId()).getCheckedData();
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(openIdMap.get(SocialTypeEnum.WECHAT_MINI_APP.getType()))
|
||||
.setMsgType(reqDTO.getProcessInstanceName())
|
||||
.setSender(nickName)
|
||||
.setComment("你分配的任务已完成!")
|
||||
.setSendingTime(reqDTO.getCreateTime())
|
||||
.setPage("subPages/task/taskAssignment?userId=" + workTaskDO.getReceiverUserId() + "&deptId=" + userRespDTO.getDeptId())
|
||||
.setMiniProgramState("formal"));
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
}
|
||||
|
||||
if (workTaskDO == null && StrUtil.isNotEmpty(openIdMap.get(SocialTypeEnum.WECHAT_MP.getType()))) {
|
||||
SubscribeMessageReqDTO dto = new WxMpMsgTemplateUtils().convertApprovalResultNotification(new ApprovalResultNotificationMessageDTO()
|
||||
.setOpenId(openIdMap.get(SocialTypeEnum.WECHAT_MP.getType()))
|
||||
.setProcessInstanceName(reqDTO.getProcessInstanceName())
|
||||
.setTime(reqDTO.getCreateTime())
|
||||
.setResult("通过")
|
||||
.setReason(reqDTO.getReason())
|
||||
.setMiniProgramState("formal")
|
||||
.setPage("subPagesB/bpm/task/todo/examineApprove?id=" + reqDTO.getProcessInstanceId() + "&isDetail=1"));
|
||||
subscribeMessageSendApi.sendMpMsg(dto);
|
||||
}
|
||||
|
||||
//当流程全部审批通过
|
||||
@ -143,7 +145,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
List<AdminOauthUserOtherInfoApiVO> adminOauthUserOtherInfoApiVOS = this.getUserOpenId(userIds, SocialTypeEnum.WECHAT_MP.getType());
|
||||
for (AdminOauthUserOtherInfoApiVO adminOauthUserOtherInfoApiVO : adminOauthUserOtherInfoApiVOS) {
|
||||
if (adminOauthUserOtherInfoApiVO.getOpenId() != null) {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertApprovalResultNotification(new ApprovalResultNotificationMessageDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMpMsgTemplateUtils().convertApprovalResultNotification(new ApprovalResultNotificationMessageDTO()
|
||||
.setOpenId(adminOauthUserOtherInfoApiVO.getOpenId())
|
||||
.setProcessInstanceName(reqDTO.getProcessInstanceName())
|
||||
.setTime(reqDTO.getCreateTime())
|
||||
@ -151,7 +153,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
.setReason(reqDTO.getReason())
|
||||
.setMiniProgramState("formal")
|
||||
.setPage("subPagesB/bpm/task/todo/examineApprove?id=" + reqDTO.getProcessInstanceId() + "&isDetail=1"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMpMsg(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,18 +173,18 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
reqDTO.getStartUserId(), BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams));
|
||||
|
||||
// //发送审批结果通知
|
||||
List<AdminOauthUserOtherInfoApiVO> list = this.getUserOpenId(Collections.singletonList(reqDTO.getStartUserId()));
|
||||
List<AdminOauthUserOtherInfoApiVO> list = this.getUserOpenId(Collections.singletonList(reqDTO.getStartUserId()), SocialTypeEnum.WECHAT_MP.getType());
|
||||
for (AdminOauthUserOtherInfoApiVO item : list) {
|
||||
if (item.getOpenId() != null) {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertApprovalResultNotification(new ApprovalResultNotificationMessageDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMpMsgTemplateUtils().convertApprovalResultNotification(new ApprovalResultNotificationMessageDTO()
|
||||
.setOpenId(item.getOpenId())
|
||||
.setProcessInstanceName(reqDTO.getProcessInstanceName())
|
||||
.setTime(reqDTO.getCreateTime())
|
||||
.setResult("不通过")
|
||||
.setResult("拒绝")
|
||||
.setReason(reqDTO.getReason())
|
||||
.setMiniProgramState("formal")
|
||||
.setPage("subPagesB/bpm/task/todo/examineApprove?id=" + reqDTO.getProcessInstanceId() + "&isDetail=1"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMpMsg(dto);
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,31 +230,29 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
//微信小程序订阅消息
|
||||
//发送OA流程待办提醒
|
||||
List<AdminOauthUserOtherInfoApiVO> list = getUserOpenId(Collections.singletonList(assigneeUserId));//只有在微信小程序登陆过用户才会有openid
|
||||
Map<Integer, String> openIdMap = list.stream().collect(Collectors.toMap(AdminOauthUserOtherInfoApiVO::getSocialType, AdminOauthUserOtherInfoApiVO::getOpenId));
|
||||
try {
|
||||
for (AdminOauthUserOtherInfoApiVO item : list) {
|
||||
if (item.getOpenId() != null) {
|
||||
if (workTaskDO != null) {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(item.getOpenId())
|
||||
.setMsgType(reqDTO.getProcessInstanceName())
|
||||
.setSender(reqDTO.getStartUserNickname())
|
||||
.setComment("你收到了一个新的任务!")
|
||||
.setSendingTime(reqDTO.getCreateTime())
|
||||
.setPage("subPages/task/taskDispose?id=" + workTaskDO.getId())
|
||||
.setMiniProgramState("formal"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
} else {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertProcessToDoReminder(new ProcessToDoReminderDTO()
|
||||
.setOpenId(item.getOpenId())
|
||||
.setProcessType("您收到了一条新的待办任务:" + reqDTO.getProcessInstanceName())
|
||||
.setStartUserNickname(reqDTO.getStartUserNickname())
|
||||
.setTime(reqDTO.getCreateTime())
|
||||
.setSchedule(reqDTO.getSchedule())
|
||||
.setMiniProgramState("formal")
|
||||
.setPage("subPagesB/bpm/task/todo/examineApprove?id=" + reqDTO.getProcessInstanceId()));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
}
|
||||
}
|
||||
if (workTaskDO != null && StrUtil.isNotEmpty(openIdMap.get(SocialTypeEnum.WECHAT_MINI_APP.getType()))) {
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(openIdMap.get(SocialTypeEnum.WECHAT_MINI_APP.getType()))
|
||||
.setMsgType(reqDTO.getProcessInstanceName())
|
||||
.setSender(reqDTO.getStartUserNickname())
|
||||
.setComment("你收到了一个新的任务!")
|
||||
.setSendingTime(reqDTO.getCreateTime())
|
||||
.setPage("subPages/task/taskDispose?id=" + workTaskDO.getId())
|
||||
.setMiniProgramState("formal"));
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
}
|
||||
if (workTaskDO == null && StrUtil.isNotEmpty(openIdMap.get(SocialTypeEnum.WECHAT_MP.getType()))) {
|
||||
SubscribeMessageReqDTO dto = new WxMpMsgTemplateUtils().convertProcessToDoReminder(new ProcessToDoReminderDTO()
|
||||
.setOpenId(openIdMap.get(SocialTypeEnum.WECHAT_MP.getType()))
|
||||
.setProcessType("您收到了一条新的待办任务:" + reqDTO.getProcessInstanceName())
|
||||
.setStartUserNickname(reqDTO.getStartUserNickname())
|
||||
.setTime(reqDTO.getCreateTime())
|
||||
.setSchedule(reqDTO.getSchedule())
|
||||
.setMiniProgramState("formal")
|
||||
.setPage("subPagesB/bpm/task/todo/examineApprove?id=" + reqDTO.getProcessInstanceId()));
|
||||
subscribeMessageSendApi.sendMpMsg(dto);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("发送OA流程待办提醒失败:{}", e.getMessage());
|
||||
@ -272,6 +272,7 @@ public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
}
|
||||
|
||||
private List<AdminOauthUserOtherInfoApiVO> getUserOpenId(List<Long> userIds) {
|
||||
return this.getUserOpenId(userIds, SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
return adminOauthUserOtherInfoApi.getOpenIdByCondition(
|
||||
new AdminOauthUserOtherInfoApiDTO().setUserIds(userIds)).getCheckedData();
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,8 @@ package cn.iocoder.yudao.module.system.api.auth;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.system.api.auth.dto.AdminOauthUserOtherInfoApiDTO;
|
||||
import cn.iocoder.yudao.module.system.api.auth.vo.AdminOauthUserOtherInfoApiVO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import cn.iocoder.yudao.module.system.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -23,7 +21,8 @@ public interface AdminOauthUserOtherInfoApi {
|
||||
@PostMapping(PREFIX + "/getOpenIdByCondition")
|
||||
@Operation(summary = "根据条件查询用户三方账号信息")
|
||||
CommonResult<List<AdminOauthUserOtherInfoApiVO>> getOpenIdByCondition(@RequestBody AdminOauthUserOtherInfoApiDTO dto);
|
||||
@PostMapping(PREFIX + "/getByCondition")
|
||||
|
||||
@PostMapping(PREFIX + "/getByCondition")
|
||||
@Operation(summary = "根据条件查询用户三方账号信息")
|
||||
CommonResult<AdminOauthUserOtherInfoApiVO> getByCondition(@RequestBody AdminOauthUserOtherInfoApiDTO dto);
|
||||
|
||||
|
@ -15,7 +15,11 @@ public interface SubscribeMessageSendApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/subscribe/send";
|
||||
|
||||
@PostMapping(PREFIX + "/send-msg")
|
||||
@PostMapping(PREFIX + "/send-mi-ni-msg")
|
||||
@Operation(summary = "发送消息")
|
||||
CommonResult<Long> sendMsg(@RequestBody SubscribeMessageReqDTO reqDTO);
|
||||
CommonResult<Long> sendMaMsg(@RequestBody SubscribeMessageReqDTO reqDTO);
|
||||
|
||||
@PostMapping(PREFIX + "/send-mp-msg")
|
||||
@Operation(summary = "发送公众号消息")
|
||||
CommonResult<Long> sendMpMsg(@RequestBody SubscribeMessageReqDTO reqDTO);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class SocialClientApiImpl implements SocialClientApi {
|
||||
@SneakyThrows
|
||||
public CommonResult<File> getQRCode(String path, String scene) {
|
||||
|
||||
WxMaService wxService = socialClientService.getWxMaService();
|
||||
WxMaService wxService = socialClientService.getWxMaService(SocialTypeEnum.WECHAT_MINI_APP.getType());
|
||||
// File QRCode = wxService.getQrcodeService().createWxaCodeUnlimit(scene, path);
|
||||
File QRCode = wxService.getQrcodeService().createWxaCodeUnlimit(scene, path, false, "trial", 430, true, null, false);
|
||||
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.MsgData;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
|
||||
import cn.iocoder.yudao.module.system.service.social.SocialClientService;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -39,20 +40,20 @@ public class SubscribeMessageSendApiImpl implements SubscribeMessageSendApi {
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public CommonResult<Long> sendMsg(SubscribeMessageReqDTO reqDTO) {
|
||||
public CommonResult<Long> sendMaMsg(SubscribeMessageReqDTO reqDTO) {
|
||||
//发送审批结果通知
|
||||
Integer socialType = reqDTO.getSocialType();
|
||||
if (wechatMiniList.contains(socialType)) {
|
||||
socialClientService.getWxMaService().getMsgService().sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
|
||||
} else {
|
||||
// -- 公众号 点击 跳转 小程序 - 需要获取到小程序appId
|
||||
reqDTO.getSocialType();
|
||||
|
||||
socialClientService.getWxMpService().getTemplateMsgService().sendTemplateMsg(initWxMpSubscribeMessage(reqDTO));
|
||||
}
|
||||
socialClientService.getWxMaService(reqDTO.getSocialType()).getMsgService().sendSubscribeMsg(initWxMaSubscribeMessage(reqDTO));
|
||||
return success(1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public CommonResult<Long> sendMpMsg(SubscribeMessageReqDTO reqDTO) {
|
||||
// -- 公众号 点击 跳转 小程序 - 需要获取到小程序appId
|
||||
// 判断是否需要跳转小程序 - 通过
|
||||
socialClientService.getWxMpService().getTemplateMsgService().sendTemplateMsg(initWxMpSubscribeMessage(reqDTO));
|
||||
return success(1L);
|
||||
}
|
||||
|
||||
private WxMaSubscribeMessage initWxMaSubscribeMessage(SubscribeMessageReqDTO reqDTO) {
|
||||
WxMaSubscribeMessage message = WxMaSubscribeMessage.builder()
|
||||
@ -81,8 +82,17 @@ public class SubscribeMessageSendApiImpl implements SubscribeMessageSendApi {
|
||||
wxMpTemplateData.setValue(msgData.getValue());
|
||||
data.add(wxMpTemplateData);
|
||||
}
|
||||
// -- 公众号跳转小程序
|
||||
WxMpTemplateMessage.MiniProgram miniProgram = new WxMpTemplateMessage.MiniProgram();
|
||||
if (reqDTO.getJumpWxMaFlag()) {
|
||||
// -- 插入appId
|
||||
SocialClientDO social = socialClientService.getBySocialType(reqDTO.getSocialType());
|
||||
miniProgram.setAppid(social.getClientId());
|
||||
miniProgram.setPagePath(reqDTO.getPage());
|
||||
}
|
||||
WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
|
||||
.toUser(reqDTO.getToUser())
|
||||
.miniProgram(miniProgram)
|
||||
.templateId(reqDTO.getTemplateId())
|
||||
.data(data)
|
||||
.build();
|
||||
|
@ -85,10 +85,10 @@ public class WeiXinController {
|
||||
} else {
|
||||
//删除存贮的公众号openId - 这里不管他有没有存 - 先删再说
|
||||
adminWxMpInfoService.del(appId, unionId);
|
||||
if (adminUserDO != null) {
|
||||
// -- 删除 关联的 公众号openId
|
||||
adminOauthUserOtherInfoService.delByCondition(adminUserDO.getId(), appId, openId, SocialTypeEnum.WECHAT_MP.getType());
|
||||
}
|
||||
// if (adminUserDO != null) {
|
||||
// // -- 删除 关联的 公众号openId
|
||||
// adminOauthUserOtherInfoService.delByCondition(adminUserDO.getId(), appId, openId, SocialTypeEnum.WECHAT_MP.getType());
|
||||
// }
|
||||
}
|
||||
log.info("微信信息用户信息:{}", wxMpUser);
|
||||
} catch (WxErrorException e) {
|
||||
|
@ -161,8 +161,10 @@ public class UserController {
|
||||
@GetMapping({"/list-all-simple", "/simple-list"})
|
||||
@Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项")
|
||||
public CommonResult<List<UserSimpleRespVO>> getSimpleUserList(@RequestParam(required = false, defaultValue = "1") Integer userType,
|
||||
@RequestParam(required = false) Long deptId) {
|
||||
List<AdminUserDO> list = userService.getUserListByStatus(userType, deptId, CommonStatusEnum.ENABLE.getStatus());
|
||||
@RequestParam(required = false) Long deptId,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer status,
|
||||
@RequestParam(required = false) String menus) {
|
||||
List<AdminUserDO> list = userService.getUserListByStatus(userType, deptId, status, menus);
|
||||
// 拼接数据
|
||||
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
||||
convertList(list, AdminUserDO::getDeptId));
|
||||
@ -174,7 +176,7 @@ public class UserController {
|
||||
@DataPermission(enable = false)
|
||||
public CommonResult<List<UserSimpleRespVO>> getAllUserList(@RequestParam(required = false, defaultValue = "1") Integer userType,
|
||||
@RequestParam(required = false) Long deptId) {
|
||||
List<AdminUserDO> list = userService.getUserListByStatus(userType, deptId, CommonStatusEnum.ENABLE.getStatus());
|
||||
List<AdminUserDO> list = userService.getUserListByStatus(userType, deptId, CommonStatusEnum.ENABLE.getStatus(), null);
|
||||
// 拼接数据
|
||||
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
|
||||
convertList(list, AdminUserDO::getDeptId));
|
||||
|
@ -64,12 +64,7 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
||||
return selectList(new LambdaQueryWrapperX<AdminUserDO>().like(AdminUserDO::getNickname, nickname));
|
||||
}
|
||||
|
||||
default List<AdminUserDO> selectListByStatus(Integer userType, List<Long> deptIds, Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<AdminUserDO>()
|
||||
.eq(AdminUserDO::getStatus, status)
|
||||
.inIfPresent(AdminUserDO::getDeptId, deptIds)
|
||||
.eqIfPresent(AdminUserDO::getUserType, userType));
|
||||
}
|
||||
List<AdminUserDO> selectListByCondition(@Param("userType") Integer userType, @Param("deptIds") List<Long> deptIds, @Param("status") Integer status, @Param("menuList") List<String> menuList);
|
||||
|
||||
default List<AdminUserDO> selectListByDeptIds(Collection<Long> deptIds, Integer status) {
|
||||
|
||||
|
@ -7,7 +7,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.Constants;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMiNiMsgTemplate;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMaMsgTemplateUtils;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.CheckInReminderDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||
@ -95,7 +95,7 @@ public class RemindJob {
|
||||
List<SubscribeMessageReqDTO> dtos = new ArrayList<>();
|
||||
for (AdminOauthUserOtherInfoDO user : list) {
|
||||
AttendanceWorkDTO attendanceWorkDTO = map.get(user.getId());
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertCheckInReminder(new CheckInReminderDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertCheckInReminder(new CheckInReminderDTO()
|
||||
.setOpenId(user.getOpenId())
|
||||
.setCheckInType(attendanceWorkDTO.getWorkTypeStr())
|
||||
.setComment(attendanceWorkDTO.getData())
|
||||
@ -104,7 +104,7 @@ public class RemindJob {
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(dtos)) {
|
||||
for (SubscribeMessageReqDTO dto : dtos) {
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(editList)) {
|
||||
|
@ -5,7 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMiNiMsgTemplate;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMaMsgTemplateUtils;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.MessageUnreadReminderDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
@ -109,14 +109,14 @@ public class BirthdayJob {
|
||||
laborContractService.updateLaborContractList(convertList(laborContractDOS, LaborContractDO::getId), LaborContractDO.STATUS_EXPIRE);
|
||||
for (AdminOauthUserOtherInfoDO otherInfoDO : list) {
|
||||
if (otherInfoDO.getOpenId() != null && !otherInfoDO.getOpenId().isEmpty()) {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(otherInfoDO.getOpenId())
|
||||
.setMsgType("合同提醒")
|
||||
.setSender("系统")
|
||||
.setComment("有人合同已过期,请前往PC端查看!")
|
||||
.setSendingTime(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND))
|
||||
.setMiniProgramState("formal"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,14 +147,14 @@ public class BirthdayJob {
|
||||
}
|
||||
for (AdminOauthUserOtherInfoDO otherInfoDO : list) {
|
||||
if (StrUtil.isNotEmpty(otherInfoDO.getOpenId())) {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(otherInfoDO.getOpenId())
|
||||
.setMsgType("转正提醒")
|
||||
.setSender("系统")
|
||||
.setComment("恭喜快要转正了哦,记得走转正流程!")
|
||||
.setSendingTime(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND))
|
||||
.setMiniProgramState("formal"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -172,14 +172,14 @@ public class BirthdayJob {
|
||||
if (!list.isEmpty()) {
|
||||
for (AdminOauthUserOtherInfoDO otherInfoDO : userDOs) {
|
||||
if (otherInfoDO.getOpenId() != null && !otherInfoDO.getOpenId().isEmpty()) {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(otherInfoDO.getOpenId())
|
||||
.setMsgType("生日提醒")
|
||||
.setSender("系统")
|
||||
.setComment("今天有人过生日,请前往PC端查看!")
|
||||
.setSendingTime(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND))
|
||||
.setMiniProgramState("formal"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
}
|
||||
}
|
||||
log.info("生日提醒,生日为{},人员为{}", time, convertList(list, AdminUserDO::getNickname));
|
||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.system.job.holiday;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMiNiMsgTemplate;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMaMsgTemplateUtils;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.MessageUnreadReminderDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
@ -159,14 +159,14 @@ public class HolidayRemindJob {
|
||||
// 发送信息 -
|
||||
for (HolidayRemindDTO holidayRemindDTO : holidayRemindDTOS) {
|
||||
try {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(holidayRemindDTO.getOpenId())
|
||||
.setMsgType("假期提醒")
|
||||
.setSender("系统提醒")
|
||||
.setComment(holidayRemindDTO.getMsg())
|
||||
.setSendingTime(DateUtils.dateFormat(new Date(), DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND))
|
||||
.setMiniProgramState("formal"));
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("发送假期过期提醒失败:{}", holidayRemindDTO);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMiNiMsgTemplate;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMaMsgTemplateUtils;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.MessageUnreadReminderDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
@ -195,7 +195,7 @@ public class WorkLogCommentServiceImpl implements WorkLogCommentService {
|
||||
}
|
||||
if (openId != null) {
|
||||
try {
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertMessageUnreadReminder(new MessageUnreadReminderDTO()
|
||||
.setOpenId(openId)
|
||||
.setMsgType(workLogComment.getType() ? "评论回复" : "日志评论")
|
||||
.setSender(userMap.get(workLogComment.getUserId()).getNickname())
|
||||
@ -204,7 +204,7 @@ public class WorkLogCommentServiceImpl implements WorkLogCommentService {
|
||||
.setPage("/subPages/workLogDetail/workLogDetail?id=" + workLogComment.getWorkLogId())
|
||||
.setMiniProgramState("formal"));
|
||||
//发送消息通知
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("发送消息通知失败", e);
|
||||
}
|
||||
|
@ -172,8 +172,16 @@ public interface DeptService {
|
||||
|
||||
/**
|
||||
* 获取用户所在公司的信息
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 公司信息
|
||||
*/
|
||||
DeptDO getUserCompanyDept(Long userId);
|
||||
|
||||
/**
|
||||
* 获取所有可用部门列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DeptDO> getAllList();
|
||||
}
|
||||
|
@ -372,6 +372,12 @@ public class DeptServiceImpl implements DeptService {
|
||||
return companyDeptList.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptDO> getAllList() {
|
||||
return deptMapper.selectList(new LambdaQueryWrapper<DeptDO>()
|
||||
.eq(DeptDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptDO> getDeptList(DeptApiDTO dto) {
|
||||
List<DeptDO> list = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>()
|
||||
|
@ -4,7 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMiNiMsgTemplate;
|
||||
import cn.iocoder.yudao.framework.common.template.WxMaMsgTemplateUtils;
|
||||
import cn.iocoder.yudao.framework.common.template.dto.CompanyAnnouncementNoticeDTO;
|
||||
import cn.iocoder.yudao.framework.common.template.vo.SubscribeMessageReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
@ -161,7 +161,7 @@ public class NoticeServiceImpl implements NoticeService {
|
||||
for (AdminOauthUserOtherInfoDO otherInfoDO : finalList) {
|
||||
if (otherInfoDO.getOpenId() != null && !otherInfoDO.getOpenId().isEmpty()) {
|
||||
//获取openId有值的用户
|
||||
SubscribeMessageReqDTO dto = WxMiNiMsgTemplate.INSTANCE.convertCompanyAnnouncementNotice(new CompanyAnnouncementNoticeDTO()
|
||||
SubscribeMessageReqDTO dto = new WxMaMsgTemplateUtils().convertCompanyAnnouncementNotice(new CompanyAnnouncementNoticeDTO()
|
||||
.setOpenId(otherInfoDO.getOpenId())
|
||||
.setNoticeType(dictDataDO.getLabel())
|
||||
.setTitle(notice.getTitle())
|
||||
@ -170,7 +170,7 @@ public class NoticeServiceImpl implements NoticeService {
|
||||
.setMiniProgramState("formal")
|
||||
.setPage("/subPages/notice/detail?id=" + notice.getId())
|
||||
);
|
||||
subscribeMessageSendApi.sendMsg(dto);
|
||||
subscribeMessageSendApi.sendMaMsg(dto);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -3,11 +3,11 @@ package cn.iocoder.yudao.module.system.service.social;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientPageReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import com.xingyuv.jushauth.model.AuthUser;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
@ -83,7 +83,7 @@ public interface SocialClientService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WxMaService getWxMaService();
|
||||
WxMaService getWxMaService(Integer socialType);
|
||||
|
||||
// =================== 客户端管理 ===================
|
||||
|
||||
@ -125,4 +125,11 @@ public interface SocialClientService {
|
||||
*/
|
||||
PageResult<SocialClientDO> getSocialClientPage(SocialClientPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 通过社交类型获取社交客户端
|
||||
*
|
||||
* @param socialType
|
||||
* @return
|
||||
*/
|
||||
SocialClientDO getBySocialType(Integer socialType);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.cache.CacheUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
|
||||
@ -18,7 +19,6 @@ import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialCl
|
||||
import cn.iocoder.yudao.module.system.controller.admin.socail.vo.client.SocialClientSaveReqVO;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialClientDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper;
|
||||
import cn.iocoder.yudao.framework.common.enums.SocialTypeEnum;
|
||||
import com.binarywang.spring.starter.wxjava.miniapp.properties.WxMaProperties;
|
||||
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@ -98,8 +98,8 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
private WxMaProperties wxMaProperties;
|
||||
|
||||
@Override
|
||||
public WxMaService getWxMaService() {
|
||||
return getWxMaService(2);
|
||||
public WxMaService getWxMaService(Integer socialType) {
|
||||
return getWxMaService(socialType, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -238,24 +238,6 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得 clientId + clientSecret 对应的 WxMpService 对象
|
||||
*
|
||||
* @param userType 用户类型
|
||||
* @return WxMpService 对象
|
||||
*/
|
||||
@VisibleForTesting
|
||||
WxMaService getWxMaService(Integer userType) {
|
||||
// 第一步,查询 DB 的配置项,获得对应的 WxMaService 对象
|
||||
SocialClientDO client = socialClientMapper.selectBySocialTypeAndUserType(
|
||||
SocialTypeEnum.WECHAT_MINI_APP.getType(), userType);
|
||||
if (client != null && Objects.equals(client.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||
return wxMaServiceCache.getUnchecked(client.getClientId() + ":" + client.getClientSecret());
|
||||
}
|
||||
// 第二步,不存在 DB 配置项,则使用 application-*.yaml 对应的 WxMaService 对象
|
||||
return wxMaService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得 clientId + clientSecret 对应的 WxMpService 对象
|
||||
*
|
||||
@ -365,6 +347,11 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
return socialClientMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocialClientDO getBySocialType(Integer socialType) {
|
||||
return socialClientMapper.selectOne(SocialClientDO::getSocialType, socialType);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public WxMaJscode2SessionResult getWxMaJscode2SessionResult(Integer type, String jsCode) {
|
||||
|
@ -295,9 +295,10 @@ public interface AdminUserService {
|
||||
* @param userType 用户类型 1:公司用户 2:工厂用户
|
||||
* @param deptId
|
||||
* @param status
|
||||
* @param menus 菜单
|
||||
* @return 用户们
|
||||
*/
|
||||
List<AdminUserDO> getUserListByStatus(Integer userType, Long deptId, Integer status);
|
||||
List<AdminUserDO> getUserListByStatus(Integer userType, Long deptId, Integer status, String menus);
|
||||
|
||||
/**
|
||||
* 判断密码是否匹配
|
||||
@ -411,9 +412,10 @@ public interface AdminUserService {
|
||||
|
||||
/**
|
||||
* 获取指定部门下的用户信息
|
||||
*
|
||||
* @param userType 用户类型
|
||||
* @param deptIds 部门列表
|
||||
* @param status 用户状态
|
||||
* @param deptIds 部门列表
|
||||
* @param status 用户状态
|
||||
* @return 用户列表
|
||||
*/
|
||||
List<AdminUserDO> getUserListByDepts(Integer userType, List<Long> deptIds, Integer status);
|
||||
|
@ -686,12 +686,16 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminUserDO> getUserListByStatus(Integer userType, Long deptId, Integer status) {
|
||||
public List<AdminUserDO> getUserListByStatus(Integer userType, Long deptId, Integer status, String menus) {
|
||||
List<Long> deptIds = new ArrayList<>();
|
||||
if (deptId != null) {
|
||||
deptIds = convertList(deptService.getChildDept(deptId), DeptDO::getId);
|
||||
}
|
||||
return userMapper.selectListByStatus(userType, deptIds, status);
|
||||
List<String> menuList = new ArrayList<>();
|
||||
if (StringUtil.isNotEmpty(menus)) {
|
||||
menuList = Arrays.asList(menus.split(","));
|
||||
}
|
||||
return userMapper.selectListByCondition(userType, deptIds, status, menuList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -838,27 +842,41 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
if (user == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ArrayList<Long> deptIds = new ArrayList<>();
|
||||
DeptDO dept = deptService.getDept(user.getDeptId());
|
||||
if (dept == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (ObjUtil.notEqual(dept.getLeaderUserId(), id)) { // 校验为负责人
|
||||
return Collections.emptyList();
|
||||
}
|
||||
deptIds.add(dept.getId());
|
||||
// 1.2 获取所有子部门
|
||||
List<DeptDO> childDeptList = deptService.getChildDeptList(dept.getId());
|
||||
if (CollUtil.isNotEmpty(childDeptList)) {
|
||||
deptIds.addAll(convertSet(childDeptList, DeptDO::getId));
|
||||
}
|
||||
// -- 获取当前用户所有负责的部门列表
|
||||
List<DeptDO> deptByLeaderIdList = deptService.getDeptByLeaderId(id);
|
||||
List<Long> ids = deptByLeaderIdList.stream().map(DeptDO::getId).collect(Collectors.toList());
|
||||
List<Long> nextIds = new ArrayList<>();
|
||||
// 获取所有可用部门列表
|
||||
List<DeptDO> deptList = deptService.getAllList();
|
||||
Map<Long, List<DeptDO>> map = deptList.stream().collect(Collectors.groupingBy(DeptDO::getParentId));
|
||||
this.getSubordinateDeptIds(map, nextIds, ids);
|
||||
|
||||
nextIds = nextIds.stream().distinct().collect(Collectors.toList());
|
||||
// 2. 获取部门对应的用户信息
|
||||
List<AdminUserDO> users = this.getUserListByDeptIds(deptIds, null);
|
||||
List<AdminUserDO> users = this.getUserListByDeptIds(nextIds, null);
|
||||
users.removeIf(item -> ObjUtil.equal(item.getId(), id)); // 排除自己
|
||||
return BeanUtils.toBean(users, AdminUserRespDTO.class);
|
||||
}
|
||||
|
||||
private void getSubordinateDeptIds(Map<Long, List<DeptDO>> map, List<Long> deptIds, List<Long> nextIds) {
|
||||
if (CollUtil.isEmpty(nextIds)) {
|
||||
return;
|
||||
}
|
||||
List<DeptDO> deptDOS = map.get(nextIds.get(0));
|
||||
if (CollUtil.isNotEmpty(deptDOS)) {
|
||||
List<Long> ids = deptDOS.stream().map(DeptDO::getId).collect(Collectors.toList());
|
||||
deptIds.addAll(ids);
|
||||
nextIds.addAll(ids);
|
||||
}
|
||||
nextIds.remove(0);
|
||||
nextIds = nextIds.stream().distinct().collect(Collectors.toList());
|
||||
getSubordinateDeptIds(map, deptIds, nextIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUnionId(Long id, String unionId) {
|
||||
userMapper.updateById(new AdminUserDO().setId(id).setUnionId(unionId));
|
||||
|
@ -127,7 +127,7 @@ wx:
|
||||
mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
|
||||
# app-id: wx041349c6f39b268b
|
||||
# secret: 5abee519483bc9f8cb37ce280e814bd0
|
||||
app-id: wx9943f95048ba8472
|
||||
app-id: wx9943f95048ba8472 # 测试号
|
||||
secret: f1f5625f210142b6ae31a06c699826df
|
||||
token: aikaidevtest
|
||||
aesKey: RmC9DkIpsq6pK2PGxyI4HQaDHrv5W7de8PXeAO3lqM9
|
||||
|
@ -123,8 +123,8 @@ wx:
|
||||
mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
|
||||
# app-id: wx041349c6f39b268b
|
||||
# secret: 5abee519483bc9f8cb37ce280e814bd0
|
||||
app-id: wx5b23ba7a5589ecbb # 测试号
|
||||
secret: 2a7b3b20c537e52e74afd395eb85f61f
|
||||
app-id: wx9943f95048ba8472 # 测试号
|
||||
secret: f1f5625f210142b6ae31a06c699826df
|
||||
token: aikaidevtest
|
||||
aesKey: RmC9DkIpsq6pK2PGxyI4HQaDHrv5W7de8PXeAO3lqM9
|
||||
# 存储配置,解决 AccessToken 的跨节点的共享
|
||||
|
@ -167,4 +167,38 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectListByCondition"
|
||||
resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
|
||||
select
|
||||
a.*
|
||||
<if test="menuList != null and menuList.size() > 0">
|
||||
LEFT JOIN system_user_role AS b ON a.id = b.user_id
|
||||
AND b.deleted = 0
|
||||
LEFT JOIN system_role_menu AS c ON b.role_id = c.role_id
|
||||
AND c.deleted = 0
|
||||
LEFT JOIN system_menu AS d ON c.menu_id = d.id
|
||||
AND c.deleted = 0
|
||||
</if>
|
||||
<where>
|
||||
a.deleted = 0
|
||||
<if test="userType != null">
|
||||
and a.user_type = #{userType}
|
||||
</if>
|
||||
<if test="deptIds != null and deptIds.size()>0">
|
||||
and a.dept_id in
|
||||
<foreach collection="deptIds" item="deptId" open="(" close=")" separator=",">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and a.status = #{status}
|
||||
</if>
|
||||
<if test="menuList != null and menuList.size() > 0">
|
||||
and d.permission in
|
||||
<foreach collection="menuList" item="menu" open="(" close=")" separator=",">
|
||||
#{menu}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -697,22 +697,6 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest {
|
||||
assertEquals(user, result.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUserListByStatus() {
|
||||
// mock 数据
|
||||
AdminUserDO user = randomAdminUserDO(o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()));
|
||||
userMapper.insert(user);
|
||||
// 测试 status 不匹配
|
||||
userMapper.insert(randomAdminUserDO(o -> o.setStatus(CommonStatusEnum.ENABLE.getStatus())));
|
||||
// 准备参数
|
||||
Integer status = CommonStatusEnum.DISABLE.getStatus();
|
||||
|
||||
// 调用
|
||||
List<AdminUserDO> result = userService.getUserListByStatus(status, null, CommonStatusEnum.ENABLE.getStatus());
|
||||
// 断言
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(user, result.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateUserList_success() {
|
||||
|
@ -127,8 +127,10 @@ wx:
|
||||
mp: # 公众号配置(必填),参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档
|
||||
# app-id: wx041349c6f39b268b
|
||||
# secret: 5abee519483bc9f8cb37ce280e814bd0
|
||||
app-id: wx5b23ba7a5589ecbb # 测试号
|
||||
secret: 2a7b3b20c537e52e74afd395eb85f61f
|
||||
app-id: wx9943f95048ba8472 # 测试号
|
||||
secret: f1f5625f210142b6ae31a06c699826df
|
||||
token: aikaidevtest
|
||||
aesKey: RmC9DkIpsq6pK2PGxyI4HQaDHrv5W7de8PXeAO3lqM9
|
||||
# 存储配置,解决 AccessToken 的跨节点的共享
|
||||
config-storage:
|
||||
type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取
|
||||
|
Loading…
Reference in New Issue
Block a user