新增站内信统计功能
This commit is contained in:
parent
7031bed2f4
commit
ae44782c75
@ -47,6 +47,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<artifactId>msg-center-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
@ -89,10 +90,12 @@
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.center.domain</groupId>
|
||||
<artifactId>msg-center-domain</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.center</groupId>
|
||||
<artifactId>msg-center-dal</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.retry</groupId>
|
||||
@ -107,6 +110,13 @@
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.notices.service.api</groupId>
|
||||
<artifactId>msg-notices-service-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.notices.service.api</groupId>
|
||||
<artifactId>msg-notices-service-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.dal.MessageRecordDao;
|
||||
import cn.axzo.msg.center.domain.dto.MsgBody4GuestDTO;
|
||||
import cn.axzo.msg.center.domain.entity.MessageRecord;
|
||||
import cn.axzo.msg.center.domain.enums.InsideMsgStateEnum;
|
||||
import cn.axzo.msg.center.inside.notices.event.SendMessageEvent;
|
||||
import cn.axzo.msg.center.inside.notices.service.NewImService;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
@ -48,10 +49,10 @@ public class SendMessageListener {
|
||||
messageRecord.setRetryCount(event.getRetryCounting().get());
|
||||
messageRecord.setFailCause(event.getErrMsg());
|
||||
if (event.getIsSend().get()) {
|
||||
messageRecord.setState(MsgStateEnum.HAS_BEEN_SENT);
|
||||
messageRecord.setState(InsideMsgStateEnum.getByCode(MsgStateEnum.HAS_BEEN_SENT.getCode()));
|
||||
messageRecord.setEventSource("");
|
||||
} else {
|
||||
messageRecord.setState(MsgStateEnum.UNSENT);
|
||||
messageRecord.setState(InsideMsgStateEnum.getByCode(MsgStateEnum.UNSENT.getCode()));
|
||||
messageRecord.setEventSource(JSON.toJSONString(event.getMessage()));
|
||||
}
|
||||
messageRecordDao.updateById(messageRecord);
|
||||
|
||||
@ -3,7 +3,11 @@ package cn.axzo.msg.center.inside.notices.service.impl;
|
||||
import cn.axzo.core.web.Result;
|
||||
import cn.axzo.core.web.Results;
|
||||
import cn.axzo.msg.center.api.MNSNoticesApi;
|
||||
import cn.axzo.msg.center.api.request.MnsCodeStatusReq;
|
||||
import cn.axzo.msg.center.api.request.MnsSendCodeV2Req;
|
||||
import cn.axzo.msg.center.api.request.SendMessageRequestDto;
|
||||
import cn.axzo.msg.center.api.response.MnsCodeStatusRes;
|
||||
import cn.axzo.msg.center.api.response.MnsSendCodeRes;
|
||||
import cn.axzo.msg.center.notices.manager.api.dto.request.MnsRequestDto;
|
||||
import cn.axzo.msg.center.notices.service.api.MessageService;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@ -30,4 +34,14 @@ public class MNSNoticesApiImpl implements MNSNoticesApi {
|
||||
messageService.sendMessage(mnsRequestDto);
|
||||
return Results.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MnsSendCodeRes> sendCodeV2(MnsSendCodeV2Req req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MnsCodeStatusRes> getPhoneCodeStatus(MnsCodeStatusReq req) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import cn.axzo.msg.center.domain.dto.MsgModuleDTO;
|
||||
import cn.axzo.msg.center.domain.dto.SearchModuleDTO;
|
||||
import cn.axzo.msg.center.domain.dto.UpdateModuleDTO;
|
||||
import cn.axzo.msg.center.domain.entity.MessageModule;
|
||||
import cn.axzo.msg.center.domain.enums.InsideReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.ModuleBizTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.UserTypeEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntity;
|
||||
@ -48,7 +49,7 @@ public class MessageModuleServiceImpl implements MessageModuleService {
|
||||
@Override
|
||||
public List<MessageModule> listMoudleByUserType(UserTypeEnum userTypeEnum) {
|
||||
ReceiveTypeEnum receiveTypeEnum = ReceiveTypeEnum.getByMessage(userTypeEnum.getName());
|
||||
List<MessageModule> messageModules = messageModuleDao.listMoudleByUserType(receiveTypeEnum);
|
||||
List<MessageModule> messageModules = messageModuleDao.listMoudleByUserType(InsideReceiveTypeEnum.valueOf(receiveTypeEnum.getCode()));
|
||||
return messageModules;
|
||||
}
|
||||
|
||||
|
||||
@ -18,10 +18,8 @@ import cn.axzo.msg.center.domain.dto.CmsMsgQueryReqDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MessageNewResDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MsgStatisticsDTO;
|
||||
import cn.axzo.msg.center.domain.entity.*;
|
||||
import cn.axzo.msg.center.domain.enums.ModuleBizTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.MsgRouteTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.NativeTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.UserTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.*;
|
||||
import cn.axzo.msg.center.domain.request.InsideCmsReadMsgReq;
|
||||
import cn.axzo.msg.center.inside.notices.event.SendMessageEvent;
|
||||
import cn.axzo.msg.center.inside.notices.service.MessageRecordService;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
@ -110,11 +108,11 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
basic.setModuleId(messageModule.getId());
|
||||
basic.setTitle(title);
|
||||
basic.setContent(content);
|
||||
basic.setReceiveType(message.getReceiveType());
|
||||
basic.setState(MsgStateEnum.UNSENT);
|
||||
basic.setReceiveType(InsideReceiveTypeEnum.valueOf(message.getReceiveType().getCode()));
|
||||
basic.setState(InsideMsgStateEnum.valueOf(MsgStateEnum.UNSENT.name()));
|
||||
|
||||
if (message.getTerminalType() == null) {
|
||||
basic.setTerminalType(MsgRecordTerminalTypeEnum.UNKNOWN);
|
||||
basic.setTerminalType(InsideMsgRecordTerminalTypeEnum.valueOf(MsgRecordTerminalTypeEnum.UNKNOWN.name()));
|
||||
}
|
||||
|
||||
List<MessageRecord> pushMessages = new ArrayList<>();
|
||||
@ -229,7 +227,7 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
});
|
||||
}
|
||||
|
||||
private String buildToId(Long itemToId, Long personId, ReceiveTypeEnum receiveType, Long bizId) {
|
||||
private String buildToId(Long itemToId, Long personId, InsideReceiveTypeEnum receiveType, Long bizId) {
|
||||
String toId = "";
|
||||
switch (receiveType) {
|
||||
case CM_LEADER:
|
||||
@ -317,7 +315,7 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
public Boolean changeMessageState(List<Long> msgId, MsgStateEnum state) {
|
||||
List<MessageRecord> messageRecords = messageRecordDao.listByIds(msgId);
|
||||
messageRecords = messageRecords.stream().map(item -> {
|
||||
item.setState(state);
|
||||
item.setState(InsideMsgStateEnum.valueOf(state.name()));
|
||||
return item;
|
||||
}).collect(Collectors.toList());
|
||||
return messageRecordDao.updateBatchById(messageRecords);
|
||||
@ -341,7 +339,7 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
log.info("消息主键为: {} 的状态被更新为: {}({})", record.getId(),
|
||||
record.getState().getMessage(),
|
||||
record.getState().getCode());
|
||||
record.setState(state);
|
||||
record.setState(InsideMsgStateEnum.valueOf(state.name()));
|
||||
return messageRecordDao.updateById(record);
|
||||
}
|
||||
|
||||
@ -359,7 +357,8 @@ public class MessageRecordServiceImpl implements MessageRecordService {
|
||||
}
|
||||
Long personId = ContextInfoHolder.get().getUserInfo().getPersonId();
|
||||
Long identityId = ContextInfoHolder.get().getUserInfo().getIdentityId();
|
||||
messageRecordDao.readMsg(req, personId, identityId);
|
||||
InsideCmsReadMsgReq request= BeanConvertUtils.copyBean(req,InsideCmsReadMsgReq.class);
|
||||
messageRecordDao.readMsg(request, personId, identityId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
package cn.axzo.msg.center.inside.notices.utils;
|
||||
|
||||
import cn.axzo.msg.center.inside.notices.redis.AxzoJedisManager;
|
||||
import cn.axzo.msg.center.common.redis.AxzoJedisManager;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.dingtalk.api.request.OapiGettokenRequest;
|
||||
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
|
||||
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request.Msg;
|
||||
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request.Text;
|
||||
import com.dingtalk.api.request.OapiV2UserGetbymobileRequest;
|
||||
import com.dingtalk.api.response.OapiGettokenResponse;
|
||||
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
|
||||
import com.dingtalk.api.response.OapiV2UserGetbymobileResponse;
|
||||
import com.taobao.api.ApiException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 钉钉消息推送工具类
|
||||
|
||||
@ -2,10 +2,16 @@ package cn.axzo.msg.center.api;
|
||||
|
||||
import cn.axzo.core.web.Result;
|
||||
import cn.axzo.msg.center.api.fallback.MNSNoticesApiFallBack;
|
||||
import cn.axzo.msg.center.api.request.MnsCodeStatusReq;
|
||||
import cn.axzo.msg.center.api.request.MnsSendCodeV2Req;
|
||||
import cn.axzo.msg.center.api.request.SendMessageRequestDto;
|
||||
import cn.axzo.msg.center.api.response.MnsCodeStatusRes;
|
||||
import cn.axzo.msg.center.api.response.MnsSendCodeRes;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* 短信消息相关接口
|
||||
@ -22,4 +28,17 @@ public interface MNSNoticesApi {
|
||||
@PostMapping("mns/send/sms")
|
||||
Result<Void> sendMessage(SendMessageRequestDto request);
|
||||
|
||||
/**
|
||||
* 发送验证码2.0(返回的是数字)
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
Result<MnsSendCodeRes> sendCodeV2(@Validated @RequestBody MnsSendCodeV2Req req);
|
||||
|
||||
/**
|
||||
* 获取验证码状态
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
Result<MnsCodeStatusRes> getPhoneCodeStatus(MnsCodeStatusReq req);
|
||||
}
|
||||
|
||||
@ -3,7 +3,12 @@ package cn.axzo.msg.center.api.fallback;
|
||||
import cn.axzo.core.web.Result;
|
||||
import cn.axzo.core.web.Results;
|
||||
import cn.axzo.msg.center.api.MNSNoticesApi;
|
||||
import cn.axzo.msg.center.api.request.MnsCodeStatusReq;
|
||||
import cn.axzo.msg.center.api.request.MnsSendCodeV2Req;
|
||||
import cn.axzo.msg.center.api.request.SendMessageRequestDto;
|
||||
import cn.axzo.msg.center.api.response.MnsCodeStatusRes;
|
||||
import cn.axzo.msg.center.api.response.MnsSendCodeRes;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -12,7 +17,19 @@ import org.springframework.stereotype.Service;
|
||||
public class MNSNoticesApiFallBack implements MNSNoticesApi {
|
||||
@Override
|
||||
public Result<Void> sendMessage(SendMessageRequestDto request) {
|
||||
log.info("推送短信消息超时, message: {}", request);
|
||||
log.warn("推送短信消息超时, message: {}", request);
|
||||
return Results.fail("调用推送短信消息超时");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MnsSendCodeRes> sendCodeV2(MnsSendCodeV2Req req) {
|
||||
log.warn("发送验证码失败,message:{}", JSON.toJSONString(req));
|
||||
return Results.fail("发送验证码失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MnsCodeStatusRes> getPhoneCodeStatus(MnsCodeStatusReq req) {
|
||||
log.warn("获取验证码状态失败,message:{}", JSON.toJSONString(req));
|
||||
return Results.fail("获取验证码状态失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.axzo.msg.center.api.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 16:53
|
||||
*/
|
||||
@Data
|
||||
public class MnsCodeStatusReq {
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 验证码类型
|
||||
* 1: 平台登录
|
||||
* 2:企业登录
|
||||
* 3:项目登录
|
||||
* 4:从业人员登录
|
||||
* 5:产业工人登录
|
||||
* 6:手机号验证
|
||||
* 7:修改手机号验证
|
||||
* 8:银行卡验证
|
||||
* 9:boss看板发送验证码
|
||||
* 10:监管机构
|
||||
* 11: 访客
|
||||
* 12:监管大屏
|
||||
*/
|
||||
@NotNull(message = "验证码类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String code;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.axzo.msg.center.api.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 类描述: mock
|
||||
*
|
||||
* @author zhangtianyu
|
||||
* @date 2022/2/17 5:12 PM
|
||||
**/
|
||||
@Data
|
||||
public class MnsMockReq {
|
||||
private boolean notMock = true;
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.axzo.msg.center.api.request;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/8/18 15:55
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MnsSendCodeV2Req extends MnsMockReq {
|
||||
|
||||
/** 手机号 */
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 验证码类型
|
||||
* 1: 平台登录
|
||||
* 2:企业登录
|
||||
* 3:项目登录
|
||||
* 4:从业人员登录
|
||||
* 5:产业工人登录
|
||||
* 6:手机号验证
|
||||
* 7:修改手机号验证
|
||||
* 8:银行卡验证
|
||||
* 9:boss看板发送验证码
|
||||
* 10:监管机构
|
||||
* 11: 访客
|
||||
* 12:监管大屏
|
||||
* 13:OMS-修改密码
|
||||
* 14: 招工找活H5登录注册
|
||||
* 14: H5登录注册
|
||||
* 15: cms登录
|
||||
* 16: 劳务招标平台
|
||||
* 17: CRM系统
|
||||
*/
|
||||
@NotNull(message = "验证码类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package cn.axzo.msg.center.api.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 16:55
|
||||
*/
|
||||
@Data
|
||||
public class MnsCodeStatusRes {
|
||||
|
||||
/**
|
||||
* 状态码:
|
||||
* 1:可用
|
||||
* 2:不可用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package cn.axzo.msg.center.api.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 11:36
|
||||
*/
|
||||
@Data
|
||||
public class MnsSendCodeRes {
|
||||
|
||||
/**
|
||||
* 发送的验证码 - 测试环境中使用 - 开发中不会返回
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
}
|
||||
@ -49,6 +49,10 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.axzo.msg.center.common.consts;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 15:17
|
||||
*/
|
||||
public interface RedisNameConstants {
|
||||
|
||||
String UNDERLINE = "_";
|
||||
String STAR = "*";
|
||||
String PERCENT = "%";
|
||||
String COLON = ":";
|
||||
int EXPIRE_ONE_DAY = 86400;
|
||||
int EXPIRE_ONE_HOUR = 3600;
|
||||
String BASIC = "basic";
|
||||
String AUTH = "auth";
|
||||
String CM_IDENTITY = "cm_identity:";
|
||||
String SMS_CODE = "smsCode:";
|
||||
String ENT_USER_PERMISSION = "entUserPermission:";
|
||||
String PROJ_USER_PERMISSION = "projUserPermission:";
|
||||
String PROFESSION_CODE = "profession:AllCode";
|
||||
String PROFESSION_HOT_CODE = "profession:HotCode";
|
||||
String REPEAT_SUBMISSION = "repeat:submission:";
|
||||
String PUSH = "push";
|
||||
// im 相关
|
||||
final String CM_LEADER = "im:cm_leader";
|
||||
final String CM_WORKER = "im:cm_worker";
|
||||
final String CMP = "im:cmp";
|
||||
// cms、cmp视角相关
|
||||
String CMS_PERSPECTIVE = "perspective:";
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.axzo.msg.center.common.enums;
|
||||
|
||||
/**
|
||||
* @author: zhangran
|
||||
* @date: 20210803 15:16
|
||||
* @description:
|
||||
**/
|
||||
public enum MnsTemplateEnum {
|
||||
|
||||
LOGIN("pudge", "pudge_100000031", "登录短信"),
|
||||
|
||||
JOIN_THE_DEPARTMENT("pudge", "pudge_100000030", "监理、甲方添加成功"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
public final String appCode;
|
||||
|
||||
public final String templateNo;
|
||||
|
||||
public final String desc;
|
||||
|
||||
MnsTemplateEnum(String appCode, String templateNo, String desc) {
|
||||
this.appCode = appCode;
|
||||
this.templateNo = templateNo;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.inside.notices.redis;
|
||||
package cn.axzo.msg.center.common.redis;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.inside.notices.redis;
|
||||
package cn.axzo.msg.center.common.redis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.inside.notices.redis;
|
||||
package cn.axzo.msg.center.common.redis;
|
||||
|
||||
/**
|
||||
* @author Smile
|
||||
@ -2,12 +2,12 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<!--<parent>
|
||||
<parent>
|
||||
<artifactId>msg-center</artifactId>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>-->
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>cn.axzo.msg.center</groupId>
|
||||
@ -58,6 +58,11 @@
|
||||
<artifactId>msg-center-domain</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.notices.common</groupId>
|
||||
<artifactId>msg-notices-common</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -1,10 +1,10 @@
|
||||
package cn.axzo.msg.center.dal;
|
||||
|
||||
import cn.axzo.msg.center.api.enums.ReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.dal.mapper.MessageModuleMapper;
|
||||
import cn.axzo.msg.center.domain.dto.MsgModuleDTO;
|
||||
import cn.axzo.msg.center.domain.dto.SyncModuleDataDTO;
|
||||
import cn.axzo.msg.center.domain.entity.MessageModule;
|
||||
import cn.axzo.msg.center.domain.enums.InsideReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntity;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -24,7 +24,7 @@ import java.util.Set;
|
||||
public class MessageModuleDao extends ServiceImpl<MessageModuleMapper, MessageModule>{
|
||||
|
||||
|
||||
public List<MessageModule> listMoudleByUserType(ReceiveTypeEnum receiveTypeEnum) {
|
||||
public List<MessageModule> listMoudleByUserType(InsideReceiveTypeEnum receiveTypeEnum) {
|
||||
return this.lambdaQuery().eq(MessageModule::getOwnedType,receiveTypeEnum)
|
||||
.eq(BaseEntity::getIsDelete,0).list();
|
||||
}
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
package cn.axzo.msg.center.dal;
|
||||
|
||||
|
||||
|
||||
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||
import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.api.enums.MsgTypeEnum;
|
||||
import cn.axzo.msg.center.api.enums.ReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.api.request.CmsReadMsgReq;
|
||||
import cn.axzo.msg.center.dal.mapper.MessageRecordMapper;
|
||||
import cn.axzo.msg.center.domain.dto.CmsMsgQueryReqDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MessageNewResDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MsgStatisticsDTO;
|
||||
import cn.axzo.msg.center.domain.entity.MessageRecord;
|
||||
import cn.axzo.msg.center.domain.enums.InsideMsgStateEnum;
|
||||
import cn.axzo.msg.center.domain.enums.InsideMsgTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.InsideReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.ModuleBizTypeEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntity;
|
||||
import cn.axzo.msg.center.domain.request.InsideCmsReadMsgReq;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -52,16 +51,16 @@ public class MessageRecordDao extends
|
||||
* @param personId message_record 表中的 person_id
|
||||
* @param identityId
|
||||
*/
|
||||
public void readMsg(CmsReadMsgReq req,
|
||||
public void readMsg(InsideCmsReadMsgReq req,
|
||||
Long personId, Long identityId) {
|
||||
lambdaUpdate().set(MessageRecord::getState, MsgStateEnum.HAVE_READ)
|
||||
lambdaUpdate().set(MessageRecord::getState, InsideMsgStateEnum.HAVE_READ)
|
||||
.and(i -> i.and(
|
||||
a -> a.eq(MessageRecord::getPersonId, personId).eq(MessageRecord::getReceiveType,
|
||||
ReceiveTypeEnum.NOT_IDENTITY)).or()
|
||||
InsideReceiveTypeEnum.NOT_IDENTITY)).or()
|
||||
.eq(MessageRecord::getToId, identityId))
|
||||
.eq(MessageRecord::getIsDelete, 0L)
|
||||
.eq(req.getMsgId() != -1L, MessageRecord::getId, req.getMsgId())
|
||||
.eq(MessageRecord::getType, MsgTypeEnum.GENERAL_MESSAGE)
|
||||
.eq(MessageRecord::getType, InsideMsgTypeEnum.GENERAL_MESSAGE)
|
||||
.update();
|
||||
}
|
||||
|
||||
@ -83,13 +82,13 @@ public class MessageRecordDao extends
|
||||
|
||||
public List<MsgStatisticsDTO> statisticsMsg4Trade(Long personId) {
|
||||
return baseMapper.statisticsMsg(ModuleBizTypeEnum.TRADE.getCode(), personId, null,
|
||||
ReceiveTypeEnum.NOT_IDENTITY.getCode());
|
||||
InsideReceiveTypeEnum.NOT_IDENTITY.getCode());
|
||||
}
|
||||
|
||||
public IPage<MessageNewResDTO> pageMsgInfo4WechatAndTrade(CmsMsgQueryReqDTO req,
|
||||
List<Long> moduleIds, Long personId, ArrayList<Integer> states) {
|
||||
return baseMapper.pageMsgInfo4WechatAndTrade(req, req.toPage(), moduleIds, personId,
|
||||
ReceiveTypeEnum.NOT_IDENTITY.getCode(), states);
|
||||
InsideReceiveTypeEnum.NOT_IDENTITY.getCode(), states);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package cn.axzo.msg.center.dal.mapper;
|
||||
|
||||
|
||||
import cn.axzo.msg.center.api.request.CmsMsgQueryReq;
|
||||
import cn.axzo.msg.center.api.request.MessageNewRes;
|
||||
import cn.axzo.msg.center.domain.dto.CmsMsgQueryReqDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MessageNewResDTO;
|
||||
import cn.axzo.msg.center.domain.dto.MsgStatisticsDTO;
|
||||
|
||||
@ -18,24 +18,20 @@
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<artifactId>msg-center-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.notices.common</groupId>
|
||||
<artifactId>msg-notices-common</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>cn.axzo.trade</groupId>
|
||||
<artifactId>trade-data-security-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>-->
|
||||
<version>2.14.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.trade</groupId>
|
||||
<artifactId>trade-data-security-sd-extension</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.basics</groupId>
|
||||
<artifactId>basics-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.domain.enums.YesNoEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseOwnEntity;
|
||||
import cn.axzo.msg.center.notices.common.enums.YesNoEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.domain.enums.YesNoEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseOwnEntity;
|
||||
import cn.axzo.msg.center.notices.common.enums.YesNoEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
|
||||
import cn.axzo.msg.center.api.enums.ReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.InsideReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.ModuleBizTypeEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
@ -34,7 +34,7 @@ public class MessageModule extends BaseEntity<MessageModule> {
|
||||
/**
|
||||
* 所属角色:cm_leader、cm_worker、cmp
|
||||
*/
|
||||
private ReceiveTypeEnum ownedType;
|
||||
private InsideReceiveTypeEnum ownedType;
|
||||
|
||||
/**
|
||||
* 业务分类 1 施工, 2 交易
|
||||
@ -42,7 +42,7 @@ public class MessageModule extends BaseEntity<MessageModule> {
|
||||
private ModuleBizTypeEnum bizType;
|
||||
|
||||
public void setOwnedType(Integer ownedType) {
|
||||
this.ownedType = ReceiveTypeEnum.valueOf(ownedType);
|
||||
this.ownedType = InsideReceiveTypeEnum.valueOf(ownedType);
|
||||
}
|
||||
|
||||
public void setBizType(Integer bizType) {
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
package cn.axzo.msg.center.domain.entity;
|
||||
|
||||
import cn.axzo.msg.center.api.enums.MsgRecordTerminalTypeEnum;
|
||||
import cn.axzo.msg.center.api.enums.MsgStateEnum;
|
||||
import cn.axzo.msg.center.api.enums.MsgTypeEnum;
|
||||
import cn.axzo.msg.center.api.enums.ReceiveTypeEnum;
|
||||
|
||||
import cn.axzo.msg.center.domain.enums.InsideMsgRecordTerminalTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.InsideMsgStateEnum;
|
||||
import cn.axzo.msg.center.domain.enums.InsideMsgTypeEnum;
|
||||
import cn.axzo.msg.center.domain.enums.InsideReceiveTypeEnum;
|
||||
import cn.axzo.msg.center.domain.persistence.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@ -33,7 +34,7 @@ public class MessageRecord extends BaseEntity<MessageRecord> {
|
||||
/**
|
||||
* 消息类型:1普通,2待办
|
||||
*/
|
||||
private MsgTypeEnum type;
|
||||
private InsideMsgTypeEnum type;
|
||||
/**
|
||||
* 模板与模块关系id
|
||||
*/
|
||||
@ -53,11 +54,11 @@ public class MessageRecord extends BaseEntity<MessageRecord> {
|
||||
/**
|
||||
* 接收者类型:1cm_leader,2cm_worker,3cmp_user,4not_identity
|
||||
*/
|
||||
private ReceiveTypeEnum receiveType;
|
||||
private InsideReceiveTypeEnum receiveType;
|
||||
/**
|
||||
* 消息所属标识类型 1:项目 2:企业
|
||||
*/
|
||||
private MsgRecordTerminalTypeEnum terminalType;
|
||||
private InsideMsgRecordTerminalTypeEnum terminalType;
|
||||
/**
|
||||
* 消息所属标识Id 用于跳转
|
||||
*/
|
||||
@ -69,7 +70,7 @@ public class MessageRecord extends BaseEntity<MessageRecord> {
|
||||
/**
|
||||
* 消息状态:1未发送,2已发送,3已接收,4已读,5已完成
|
||||
*/
|
||||
private MsgStateEnum state;
|
||||
private InsideMsgStateEnum state;
|
||||
/**
|
||||
* 关联业务主键
|
||||
*/
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
/**
|
||||
* 枚举抽象类
|
||||
@ -0,0 +1,22 @@
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author wangli
|
||||
* @date 2023/5/6 19:11
|
||||
*/
|
||||
@Getter
|
||||
public enum InsideBizTypeEnum {
|
||||
CONSTRUCTION(1, "施工业务"),
|
||||
TRADE(2, "交易业务");
|
||||
public final int value;
|
||||
public final String desc;
|
||||
|
||||
InsideBizTypeEnum(int value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Getter
|
||||
public enum InsideMsgRecordTerminalTypeEnum {
|
||||
ENT(2, "企业"),
|
||||
PROJECT(1, "项目"),
|
||||
UNKNOWN(0, "未知"),
|
||||
;
|
||||
|
||||
@EnumValue
|
||||
private final Integer code;
|
||||
private final String message;
|
||||
|
||||
InsideMsgRecordTerminalTypeEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public static InsideMsgRecordTerminalTypeEnum getValue(Integer code) {
|
||||
return Arrays.stream(values()).filter(it -> it.code.equals(code)).findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author: wangli
|
||||
* @date: 2022/3/21 15:40
|
||||
*/
|
||||
@Getter
|
||||
public enum InsideMsgStateEnum {
|
||||
|
||||
UNSENT(1, "未发送"),
|
||||
HAS_BEEN_SENT(2, "已发送"),
|
||||
RECEIVED(3, "已接收"),
|
||||
HAVE_READ(4, "已读"),
|
||||
COMPLETE(5, "已完成");
|
||||
|
||||
@EnumValue
|
||||
private final Integer code;
|
||||
private final String message;
|
||||
|
||||
InsideMsgStateEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public static InsideMsgStateEnum getByCode(Integer code) {
|
||||
return Arrays.stream(values()).filter(it -> it.code.equals(code)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.EnumValue;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author: wangli
|
||||
* @date: 2022/3/21 15:47
|
||||
*/
|
||||
@Getter
|
||||
public enum InsideMsgTypeEnum {
|
||||
GENERAL_MESSAGE(1, "普通消息"),
|
||||
PENDING_MESSAGE(2, "待办消息");
|
||||
|
||||
@EnumValue
|
||||
private final Integer code;
|
||||
private final String message;
|
||||
|
||||
InsideMsgTypeEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 17:07
|
||||
*/
|
||||
public enum InsideSmsCodeEnum {
|
||||
PLATFORM_TYPE(1, " 平台登录"),
|
||||
ENTERPRISE_TYPE(2, " 企业登录"),
|
||||
PROJECT_TYPE(3, " 项目登录"),
|
||||
PRACTITIONER_TYPE(4, " 从业人员登录"),
|
||||
PERSONNEL_TYPE(5, " 产业工人登录"),
|
||||
PHONEME_VERIFICATION_TYPE(6, " 手机号验证"),
|
||||
MODIFY_PHONEMES_TYPE(7, " 修改手机号验证"),
|
||||
BACK_CARD_VERIFICATION_TYPE(8, " 银行卡验证"),
|
||||
ENT_PAY_TYPE(9, " boss看板发送验证码"),
|
||||
REGULATORY_AUTHORITY(10, " 监管机构"),
|
||||
VISITOR(11, " 访客"),
|
||||
REGULATORY_AUTHORITY_SCREEN(12, " 监管机构大屏"),
|
||||
OMS_UPDATE_PWD_TYPE(13, " OMS-修改密码"),
|
||||
RECRUIT_H5_TYPE(14, " 招工找活h5平台"),
|
||||
;
|
||||
|
||||
public final int value;
|
||||
public final String desc;
|
||||
|
||||
InsideSmsCodeEnum(int value, String desc) {
|
||||
this.value = value;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
/**
|
||||
* @author: zhangran
|
||||
* @date: 20210803 15:16
|
||||
* @description:
|
||||
**/
|
||||
public enum MnsTemplateEnum {
|
||||
|
||||
LOGIN("pudge", "pudge_100000031", "登录短信"),
|
||||
|
||||
JOIN_THE_DEPARTMENT("pudge", "pudge_100000030", "监理、甲方添加成功"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
public final String appCode;
|
||||
|
||||
public final String templateNo;
|
||||
|
||||
public final String desc;
|
||||
|
||||
MnsTemplateEnum(String appCode, String templateNo, String desc) {
|
||||
this.appCode = appCode;
|
||||
this.templateNo = templateNo;
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
package cn.axzo.msg.center.domain.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.axzo.msg.center.domain.request;
|
||||
|
||||
import cn.axzo.msg.center.domain.enums.InsideBizTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author : liuchuntao
|
||||
* @date : 2022/3/21 16:01
|
||||
* @description : 读取消息请求
|
||||
*/
|
||||
@Data
|
||||
public class InsideCmsReadMsgReq {
|
||||
|
||||
|
||||
/**
|
||||
* 传-1 表示读取所有 其他表示单条读取
|
||||
*/
|
||||
@NotNull(message = "消息Id不能为空")
|
||||
private Long msgId;
|
||||
|
||||
/**
|
||||
* 业务类型,程序逻辑使用,前端不用传递
|
||||
*/
|
||||
private transient InsideBizTypeEnum bizTypeEnum = InsideBizTypeEnum.CONSTRUCTION;
|
||||
|
||||
}
|
||||
@ -35,10 +35,22 @@
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<artifactId>inside-notices</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.notices.service.api</groupId>
|
||||
<artifactId>msg-notices-service-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<artifactId>msg-center-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.center.domain</groupId>
|
||||
<artifactId>msg-center-domain</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.axzo.msg.center.notices.common.enums;
|
||||
|
||||
import cn.axzo.msg.center.notices.common.exception.BizException;
|
||||
import cn.azxo.framework.common.model.EnumBase;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package cn.axzo.msg.center.notices.common.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 15:32
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "spring.cloud.alicloud.sms")
|
||||
@Configuration
|
||||
public class SmsProperties {
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
private String regionId;
|
||||
|
||||
/**
|
||||
* 主账号AccessKey的ID
|
||||
*/
|
||||
private String accessKeyId;
|
||||
|
||||
/**
|
||||
* 主账号AccessSecret
|
||||
*/
|
||||
private String accessSecret;
|
||||
|
||||
/**
|
||||
* 短信签名名称
|
||||
*/
|
||||
private String signName;
|
||||
|
||||
/**
|
||||
* 短信验证码模板code
|
||||
*/
|
||||
private String captchaTemplate;
|
||||
|
||||
/**
|
||||
* 发薪成功模板code
|
||||
*/
|
||||
private String payrollSuccessTemplate;
|
||||
}
|
||||
@ -49,6 +49,20 @@
|
||||
<artifactId>msg-center-dal</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<artifactId>msg-center-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msg.notices.http.api</groupId>
|
||||
<artifactId>msg-notices-http-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.msgcenter</groupId>
|
||||
<artifactId>msg-center-api</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.axzo.msg.center.notices.service;
|
||||
|
||||
import cn.axzo.msg.center.notices.service.request.CodeStatusReq;
|
||||
import cn.axzo.msg.center.notices.service.request.SendCodeV2Req;
|
||||
import cn.axzo.msg.center.notices.service.response.CodeStatusRes;
|
||||
import cn.axzo.msg.center.notices.service.response.SendCodeRes;
|
||||
|
||||
public interface SmsService {
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
SendCodeRes sendPhoneCodeV2(SendCodeV2Req req);
|
||||
|
||||
/**
|
||||
* 获取验证码状态
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
CodeStatusRes getPhoneCodeStatus(CodeStatusReq req);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
package cn.axzo.msg.center.notices.service.gateway;
|
||||
|
||||
/**
|
||||
* @author cn
|
||||
* @version 1.0
|
||||
* @description
|
||||
* @date 2022/6/10 18:28
|
||||
*/
|
||||
public interface SmsGateway {
|
||||
|
||||
Integer getSmsCode(String phone, String smsCodeByTerminal);
|
||||
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
package cn.axzo.msg.center.notices.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.core.web.Result;
|
||||
import cn.axzo.core.web.Results;
|
||||
import cn.axzo.msg.center.api.MNSNoticesApi;
|
||||
import cn.axzo.msg.center.api.request.MnsCodeStatusReq;
|
||||
import cn.axzo.msg.center.api.request.MnsSendCodeV2Req;
|
||||
import cn.axzo.msg.center.api.request.SendMessageRequestDto;
|
||||
import cn.axzo.msg.center.api.response.MnsCodeStatusRes;
|
||||
import cn.axzo.msg.center.api.response.MnsSendCodeRes;
|
||||
import cn.axzo.msg.center.notices.service.SmsService;
|
||||
import cn.axzo.msg.center.notices.service.request.CodeStatusReq;
|
||||
import cn.axzo.msg.center.notices.service.request.SendCodeV2Req;
|
||||
import cn.axzo.msg.center.notices.service.response.SendCodeRes;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MNSNoticesApiImpl implements MNSNoticesApi {
|
||||
|
||||
@Resource
|
||||
private SmsService smsService;
|
||||
|
||||
/**
|
||||
* 手机正则
|
||||
*/
|
||||
private Pattern phonePattern = Pattern.compile("^[1]\\d{10}$");
|
||||
|
||||
@Override
|
||||
public Result<Void> sendMessage(SendMessageRequestDto request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MnsSendCodeRes> sendCodeV2(MnsSendCodeV2Req req) {
|
||||
if (!phonePattern.matcher(req.getPhone()).matches()) {
|
||||
throw new ServiceException("手机号格式不正确");
|
||||
}
|
||||
SendCodeV2Req request=new SendCodeV2Req();
|
||||
BeanUtils.copyProperties(req,request);
|
||||
SendCodeRes temp = smsService.sendPhoneCodeV2(request);
|
||||
MnsSendCodeRes result=new MnsSendCodeRes();
|
||||
BeanUtils.copyProperties(temp,result);
|
||||
return Results.ok(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<MnsCodeStatusRes> getPhoneCodeStatus(MnsCodeStatusReq req) {
|
||||
CodeStatusReq request=new CodeStatusReq();
|
||||
BeanUtils.copyProperties(req,request);
|
||||
smsService.getPhoneCodeStatus(request);
|
||||
return Results.ok();
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.notices.service;
|
||||
package cn.axzo.msg.center.notices.service.impl;
|
||||
|
||||
import cn.axzo.msg.center.dal.MNSBatchMessageDao;
|
||||
import cn.axzo.msg.center.dal.MNSMessageChannelLogDao;
|
||||
@ -1,7 +1,8 @@
|
||||
package cn.axzo.msg.center.notices.service;
|
||||
package cn.axzo.msg.center.notices.service.impl;
|
||||
|
||||
import cn.axzo.msg.center.dal.MNSMessageAppDao;
|
||||
import cn.axzo.msg.center.domain.entity.*;
|
||||
import cn.axzo.msg.center.domain.enums.YesNoEnum;
|
||||
import cn.axzo.msg.center.notices.common.annotation.ApiRequestLog;
|
||||
import cn.axzo.msg.center.notices.common.constans.CommonConstants;
|
||||
import cn.axzo.msg.center.notices.common.domain.BatchMessageSendContext;
|
||||
@ -12,8 +13,8 @@ import cn.axzo.msg.center.notices.common.utils.DateUtils;
|
||||
import cn.axzo.msg.center.notices.integration.client.DingDingClient;
|
||||
import cn.axzo.msg.center.notices.manager.api.*;
|
||||
import cn.axzo.msg.center.notices.manager.api.dto.request.MessageSendRequestDto;
|
||||
import cn.axzo.msg.center.notices.manager.api.dto.request.SendBatchMessageRequestDto;
|
||||
import cn.axzo.msg.center.notices.manager.api.dto.request.MnsRequestDto;
|
||||
import cn.axzo.msg.center.notices.manager.api.dto.request.SendBatchMessageRequestDto;
|
||||
import cn.axzo.msg.center.notices.manager.api.dto.request.SmsContentDto;
|
||||
import cn.axzo.msg.center.notices.manager.api.dto.response.SendSmsCommonResponseDto;
|
||||
import cn.axzo.msg.center.notices.manager.api.dto.response.TemplateParamDto;
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.notices.service;
|
||||
package cn.axzo.msg.center.notices.service.impl;
|
||||
|
||||
import cn.axzo.msg.center.dal.mapper.MNSChannelMessageTemplateMapper;
|
||||
import cn.axzo.msg.center.dal.mapper.MNSMessageAppMapper;
|
||||
@ -0,0 +1,94 @@
|
||||
package cn.axzo.msg.center.notices.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.basics.common.util.AssertUtil;
|
||||
import cn.axzo.framework.auth.domain.TerminalInfo;
|
||||
import cn.axzo.msg.center.domain.enums.InsideSmsCodeEnum;
|
||||
import cn.axzo.msg.center.notices.service.SmsService;
|
||||
import cn.axzo.msg.center.notices.service.manager.SmsManager;
|
||||
import cn.axzo.msg.center.notices.service.request.CodeStatusReq;
|
||||
import cn.axzo.msg.center.notices.service.request.SendCodeV2Req;
|
||||
import cn.axzo.msg.center.notices.service.response.CodeStatusRes;
|
||||
import cn.axzo.msg.center.notices.service.response.SendCodeRes;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SmsServiceImpl implements SmsService {
|
||||
|
||||
@Value("${phone.whites}")
|
||||
private List<String> phoneWrites;
|
||||
@Value("${phone.returnCode}")
|
||||
private Boolean returnCode;
|
||||
@Resource
|
||||
private SmsManager smsManager;
|
||||
@Override
|
||||
public SendCodeRes sendPhoneCodeV2(SendCodeV2Req req) {
|
||||
if (req.getType() == null) {
|
||||
AssertUtil.fail("未找到发短信的类型");
|
||||
}
|
||||
log.info("发送验证码: req = {}", req);
|
||||
String terminalType = "";
|
||||
if (InsideSmsCodeEnum.MODIFY_PHONEMES_TYPE.value == req.getType()) {
|
||||
terminalType = String.valueOf(InsideSmsCodeEnum.MODIFY_PHONEMES_TYPE.value);
|
||||
} else if (Objects.equals(InsideSmsCodeEnum.BACK_CARD_VERIFICATION_TYPE.value, req.getType())) {
|
||||
terminalType = req.getType().toString();
|
||||
} else {
|
||||
TerminalInfo terminalInfo = new TerminalInfo(req.getType().toString());
|
||||
terminalType = terminalInfo.NT();
|
||||
}
|
||||
Long codeSecond = smsManager.getSmsCodeSsl(req.getPhone(), terminalType);
|
||||
if (codeSecond != 0L && req.isNotMock()) {
|
||||
throw new ServiceException("发送频繁, 请" + codeSecond + "秒后再试");
|
||||
}
|
||||
log.info("发送验证码header terminal = {}", terminalType);
|
||||
SendCodeRes result = new SendCodeRes();
|
||||
// 生成验证码
|
||||
Integer code = RandomUtil.randomInt(100000, 999999);
|
||||
// 手机号再白名单中存在 则不发送验证码
|
||||
if (phoneWrites.contains(req.getPhone())) {
|
||||
//白名单返回个666
|
||||
result.setCode(666666);
|
||||
return result;
|
||||
}
|
||||
// // 验证boss看板用户是否存在
|
||||
// if (req.getType() == 9) {
|
||||
// verifyBossUser(req.getPhone());
|
||||
// }
|
||||
// 发送验证码
|
||||
code = smsManager.sendSmsCode(req.getPhone(), terminalType + "", code);
|
||||
if (returnCode) {
|
||||
result.setCode(code);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CodeStatusRes getPhoneCodeStatus(CodeStatusReq req) {
|
||||
CodeStatusRes res = new CodeStatusRes();
|
||||
// 手机号再白名单中存在 则不验证
|
||||
if (phoneWrites.contains(req.getPhoneNumber())) {
|
||||
return res;
|
||||
}
|
||||
Integer code = smsManager.getSmsCode(req.getPhoneNumber(), String.valueOf(req.getType()));
|
||||
Long second = smsManager.getSmsCodeSsl(req.getPhoneNumber(), String.valueOf(req.getType()));
|
||||
// 判断验证码
|
||||
if (!StringUtils.isEmpty(req.getCode())) {
|
||||
if (!(code + "").equals(req.getCode())) {
|
||||
throw new ServiceException("验证码不正确");
|
||||
}
|
||||
} else if (code != null && second != 0L) {
|
||||
throw new ServiceException("发送频繁, 请" + second + "秒后再试");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.axzo.msg.center.notices.service;
|
||||
package cn.axzo.msg.center.notices.service.impl;
|
||||
|
||||
import cn.axzo.msg.center.dal.MNSChannelMessageTemplateDao;
|
||||
import cn.axzo.msg.center.domain.entity.*;
|
||||
@ -0,0 +1,9 @@
|
||||
package cn.axzo.msg.center.notices.service.manager;
|
||||
|
||||
/**
|
||||
* 通用业务逻辑层, 低于 service 高于 dao
|
||||
* @author Smile
|
||||
* @date 2019/4/30 15:38
|
||||
*/
|
||||
public abstract class BaseManager {
|
||||
}
|
||||
@ -0,0 +1,214 @@
|
||||
package cn.axzo.msg.center.notices.service.manager;
|
||||
|
||||
|
||||
import cn.axzo.basics.common.constant.ConstStringPool;
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.core.constant.RedisNameConstants;
|
||||
import cn.axzo.msg.center.common.redis.IAxzoJedisManager;
|
||||
import cn.axzo.msg.center.domain.enums.MnsTemplateEnum;
|
||||
import cn.axzo.msg.center.domain.enums.InsideSmsCodeEnum;
|
||||
import cn.axzo.msg.center.notices.common.properties.SmsProperties;
|
||||
import cn.axzo.msg.center.notices.http.api.api.MessageNotifyApi;
|
||||
import cn.axzo.msg.center.notices.http.api.request.SendMobileMessageRequest;
|
||||
import cn.axzo.msg.center.notices.service.gateway.SmsGateway;
|
||||
import cn.axzo.msg.center.notices.service.request.CaptchaParam;
|
||||
import cn.axzo.msg.center.notices.service.response.SmsCodeInfoRes;
|
||||
import cn.azxo.framework.common.utils.LogUtil;
|
||||
import cn.azxo.framework.common.utils.LogUtil.ErrorLevel;
|
||||
import cn.azxo.framework.common.utils.LogUtil.ErrorType;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.CommonRequest;
|
||||
import com.aliyuncs.CommonResponse;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.http.MethodType;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 15:15
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
@RefreshScope
|
||||
public class SmsManager extends BaseManager implements SmsGateway {
|
||||
|
||||
@Resource
|
||||
private IAxzoJedisManager iAxzoJedisManager;
|
||||
|
||||
@Resource
|
||||
private SmsProperties smsProperties;
|
||||
@Resource
|
||||
private MessageNotifyApi messageNotifyApi;
|
||||
|
||||
@Value("${phone.isSendMnsCode}")
|
||||
private boolean isSendMnsCode;
|
||||
|
||||
private static final HashMap<String,String> messageErrMsg = new HashMap<>();
|
||||
static {
|
||||
messageErrMsg.put("isv.MOBILE_NUMBER_ILLEGAL", "非法手机号");
|
||||
messageErrMsg.put("isv.DOMESTIC_NUMBER_NOT_SUPPORTED", "国际/港澳台不支持发送境内号码");
|
||||
}
|
||||
|
||||
public static final Integer SUCCESS = 200;
|
||||
|
||||
/**
|
||||
* 发送验证码`
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @param code
|
||||
*/
|
||||
public int sendSmsCode(String phoneNumber, String type, int code) {
|
||||
Duration duration = Duration.ofSeconds(60 * 15L);
|
||||
String key = RedisNameConstants.SMS_CODE.concat(type + ":").concat(phoneNumber);
|
||||
// 在验证码有效期内(15分钟)重复发送验证码,返回同一验证码
|
||||
Integer realCode = iAxzoJedisManager.get(key);
|
||||
if (realCode == null || realCode == 0) {
|
||||
realCode = code;
|
||||
}
|
||||
if (String.valueOf(realCode).length() != String.valueOf(code).length()) {
|
||||
realCode = code;
|
||||
}
|
||||
iAxzoJedisManager.set(key, realCode, duration.getSeconds());
|
||||
|
||||
HashMap<String, Object> param = new HashMap<>();
|
||||
param.put("code", realCode);
|
||||
|
||||
sendMnsCode(phoneNumber, param, MnsTemplateEnum.LOGIN);
|
||||
log.info("发送验证码 手机号{} -- 验证码类型 {} -- 验证码 {}", phoneNumber, type, realCode);
|
||||
return realCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Integer getSmsCode(String phoneNumber, String type) {
|
||||
Integer code = iAxzoJedisManager.get(RedisNameConstants.SMS_CODE + type + ":" + phoneNumber);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取验证码过期时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Long getSmsCodeSsl(String phoneNumber, String type) {
|
||||
Long ssl = iAxzoJedisManager.ssl(RedisNameConstants.SMS_CODE + type + ":" + phoneNumber);
|
||||
if (null == ssl || ConstStringPool.PROFILES_EVN.contains(SpringUtil.getActiveProfile())) {
|
||||
return 0L;
|
||||
}
|
||||
return (ssl - (14 * 60L) +30) < 0L ? 0L : ssl - (14 * 60L)+30;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取各类验证码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<SmsCodeInfoRes> getAllSmsCode(String phoneNumber) {
|
||||
List<SmsCodeInfoRes> rets = new ArrayList<>();
|
||||
InsideSmsCodeEnum[] smsCodeEnums = InsideSmsCodeEnum.values();
|
||||
for (InsideSmsCodeEnum smsCodeEnum : smsCodeEnums) {
|
||||
Integer code = iAxzoJedisManager
|
||||
.get(RedisNameConstants.SMS_CODE + smsCodeEnum.value + ":" + phoneNumber);
|
||||
if (Objects.nonNull(code)) {
|
||||
SmsCodeInfoRes smsCodeInfoRes = new SmsCodeInfoRes();
|
||||
smsCodeInfoRes.setCode(code);
|
||||
smsCodeInfoRes.setType(smsCodeEnum.desc);
|
||||
rets.add(smsCodeInfoRes);
|
||||
}
|
||||
}
|
||||
return rets;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void sendCaptcha(CaptchaParam param) {
|
||||
log.info("调用发送验证码:{}", param);
|
||||
JSONObject templateParam = new JSONObject();
|
||||
templateParam.put("code", param.getCode());
|
||||
sendSms(param.getPhones(), smsProperties.getCaptchaTemplate(), templateParam.toJSONString());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void offlineAutoConfirm(String phoneNumber) {
|
||||
JSONObject templateParam = new JSONObject();
|
||||
sendSms(phoneNumber, "SMS_216279895", templateParam.toJSONString());
|
||||
}
|
||||
|
||||
//发送短信
|
||||
@Deprecated
|
||||
private void sendSms(String phones, String templateCode, String templateJson) {
|
||||
if(phones != ""){
|
||||
throw new ServiceException("参数异常");
|
||||
}
|
||||
DefaultProfile profile = DefaultProfile
|
||||
.getProfile(smsProperties.getRegionId(), smsProperties.getAccessKeyId(),
|
||||
smsProperties.getAccessSecret());
|
||||
IAcsClient client = new DefaultAcsClient(profile);
|
||||
|
||||
CommonRequest request = new CommonRequest();
|
||||
request.setSysMethod(MethodType.POST);
|
||||
request.setSysDomain("dysmsapi.aliyuncs.com");
|
||||
request.setSysVersion("2017-05-25");
|
||||
request.setSysAction("SendSms");
|
||||
request.putQueryParameter("RegionId", smsProperties.getRegionId());
|
||||
request.putQueryParameter("PhoneNumbers", phones);
|
||||
request.putQueryParameter("SignName", smsProperties.getSignName());
|
||||
request.putQueryParameter("TemplateCode", templateCode);
|
||||
request.putQueryParameter("TemplateParam", templateJson);
|
||||
|
||||
String resultJson;
|
||||
try {
|
||||
CommonResponse response = client.getCommonResponse(request);
|
||||
log.info("短信发送结果,httpStatus:{},data:{}", response.getHttpStatus(), response.getData());
|
||||
resultJson = response.getData();
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(ErrorLevel.P0, ErrorType.ERROR_THIRD_SERVICE,"短信服务异常, phones={}", phones, e);
|
||||
throw new ServiceException("短信发送失败");
|
||||
}
|
||||
// "Code":"OK","Message":"OK","RequestId":"2184201F-BFB3-446B-B1F2-C746B7BF0657","BizId":"197703245997295588^0"
|
||||
JSONObject result = JSON.parseObject(resultJson);
|
||||
if(!result.getString("Code").equalsIgnoreCase("OK")) {
|
||||
log.warn("短信发送失败, phones={}, resultJson={}",phones, resultJson);
|
||||
String message = messageErrMsg.get(result.getString("Code"));
|
||||
if(message != null && !message.equals("")){
|
||||
throw new ServiceException(message);
|
||||
}else {
|
||||
throw new ServiceException("短信发送失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMnsCode(String phoneNumber, Map<String, Object> param, MnsTemplateEnum mns) {
|
||||
if (!isSendMnsCode) {
|
||||
return;
|
||||
}
|
||||
SendMobileMessageRequest request = new SendMobileMessageRequest();
|
||||
request.setAppCode(mns.appCode);
|
||||
request.setPhoneNo(phoneNumber);
|
||||
request.setTemplateNo(mns.templateNo);
|
||||
request.setParams(param);
|
||||
request.setRequestNo(UUID.randomUUID().toString());
|
||||
cn.azxo.framework.common.model.CommonResponse commonResponse = messageNotifyApi
|
||||
.sendMobileMessage(request);
|
||||
if (!commonResponse.getCode().equals(SUCCESS)) {
|
||||
log.warn("发送验证码失败 request:{},commonResponse:{}",
|
||||
JSON.toJSONString(request), JSON.toJSONString(commonResponse));
|
||||
// throw new ServiceException(commonResponse.getMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.axzo.msg.center.notices.service.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 15:21
|
||||
*/
|
||||
@Data
|
||||
public class CaptchaParam {
|
||||
/**
|
||||
* 手机号:支持对多个手机号码发送短信,手机号码之间以英文逗号(,)分隔。上限为1000个手机号码
|
||||
*/
|
||||
private String phones;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String code;
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.axzo.msg.center.notices.service.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 16:53
|
||||
*/
|
||||
@Data
|
||||
public class CodeStatusReq {
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 验证码类型
|
||||
* 1: 平台登录
|
||||
* 2:企业登录
|
||||
* 3:项目登录
|
||||
* 4:从业人员登录
|
||||
* 5:产业工人登录
|
||||
* 6:手机号验证
|
||||
* 7:修改手机号验证
|
||||
* 8:银行卡验证
|
||||
* 9:boss看板发送验证码
|
||||
* 10:监管机构
|
||||
* 11: 访客
|
||||
* 12:监管大屏
|
||||
*/
|
||||
@NotNull(message = "验证码类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String code;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.axzo.msg.center.notices.service.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 类描述: mock
|
||||
*
|
||||
* @author zhangtianyu
|
||||
* @date 2022/2/17 5:12 PM
|
||||
**/
|
||||
@Data
|
||||
public class MockReq {
|
||||
private boolean notMock = true;
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.axzo.msg.center.notices.service.request;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/8/18 15:55
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SendCodeV2Req extends MockReq {
|
||||
|
||||
/** 手机号 */
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 验证码类型
|
||||
* 1: 平台登录
|
||||
* 2:企业登录
|
||||
* 3:项目登录
|
||||
* 4:从业人员登录
|
||||
* 5:产业工人登录
|
||||
* 6:手机号验证
|
||||
* 7:修改手机号验证
|
||||
* 8:银行卡验证
|
||||
* 9:boss看板发送验证码
|
||||
* 10:监管机构
|
||||
* 11: 访客
|
||||
* 12:监管大屏
|
||||
* 13:OMS-修改密码
|
||||
* 14: 招工找活H5登录注册
|
||||
* 14: H5登录注册
|
||||
* 15: cms登录
|
||||
* 16: 劳务招标平台
|
||||
* 17: CRM系统
|
||||
*/
|
||||
@NotNull(message = "验证码类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package cn.axzo.msg.center.notices.service.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 16:55
|
||||
*/
|
||||
@Data
|
||||
public class CodeStatusRes {
|
||||
|
||||
/**
|
||||
* 状态码:
|
||||
* 1:可用
|
||||
* 2:不可用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package cn.axzo.msg.center.notices.service.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 11:36
|
||||
*/
|
||||
@Data
|
||||
public class SendCodeRes {
|
||||
|
||||
/**
|
||||
* 发送的验证码 - 测试环境中使用 - 开发中不会返回
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.axzo.msg.center.notices.service.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author zhangPeng
|
||||
* @description
|
||||
* @date 2021/1/26 17:05
|
||||
*/
|
||||
@Data
|
||||
public class SmsCodeInfoRes {
|
||||
public int code;
|
||||
public String type;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user