Explorar el Código

feat:

1. 免登验证码修改;
tags/24112201
WendyYang hace 1 mes
padre
commit
e4e52180f3
Se han modificado 14 ficheros con 24 adiciones y 389 borrados
  1. +0
    -9
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingNotifyHelper.java
  2. +5
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/TagsCacheImpl.java
  3. +0
    -68
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/WorkNoticeFlowTask.java
  4. +0
    -43
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/model/CommonLog.java
  5. +0
    -21
      hz-pm-api/src/main/java/com/hz/pm/api/staging/mapper/NdWorkNoticeStagingMapper.java
  6. +0
    -12
      hz-pm-api/src/main/java/com/hz/pm/api/staging/mapper/NdWorkNoticeStagingMapper.xml
  7. +0
    -74
      hz-pm-api/src/main/java/com/hz/pm/api/staging/model/entity/WorkNoticeStaging.java
  8. +0
    -32
      hz-pm-api/src/main/java/com/hz/pm/api/staging/service/INdWorkNoticeStagingService.java
  9. +0
    -117
      hz-pm-api/src/main/java/com/hz/pm/api/staging/service/impl/NdWorkNoticeStagingServiceImpl.java
  10. +1
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/NoticeManage.java
  11. +3
    -1
      hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/constants/SessionTimeConst.java
  12. +10
    -7
      hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/credential/CredentialAuthProvider.java
  13. +4
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/credential/CredentialAuthSecurityConfig.java
  14. +1
    -1
      hz-pm-api/src/main/resources/application-dev.yml

+ 0
- 9
hz-pm-api/src/main/java/com/hz/pm/api/meeting/helper/MeetingNotifyHelper.java Ver fichero

@@ -18,7 +18,6 @@ import com.hz.pm.api.organization.service.IDingEmployeeInfoService;
import com.hz.pm.api.organization.service.IDingOrganizationService;
import com.hz.pm.api.sms.constant.VoiceSmsTemplateConst;
import com.hz.pm.api.staging.enums.MsgTypeEnum;
import com.hz.pm.api.staging.service.INdWorkNoticeStagingService;
import com.hz.pm.api.sys.model.entity.Notify;
import com.hz.pm.api.sys.model.enumeration.BizTypeEnum;
import com.hz.pm.api.sys.service.INotifyService;
@@ -51,7 +50,6 @@ public class MeetingNotifyHelper {

private final IUserInfoService userInfoService;
private final MsgCallHelper msgCallHelper;
private final INdWorkNoticeStagingService workNoticeStagingService;
private final IDingEmployeeInfoService dingEmployeeInfoService;
private final IDingOrganizationService dingOrganizationService;
private final INotifyService notifyService;
@@ -112,9 +110,6 @@ public class MeetingNotifyHelper {
msgCallHelper.sendMsg(info.getMobile(), msgContent, BizTypeEnum.EXPERT_INVITE_STOP);
// 发送工作通知
if (info.getAccountId() != null) {
WorkNoticeInfo swn = getSendWorkNoticeInfo(info.getAccountId());
swn.setMsg(msgContent);
workNoticeStagingService.addByWorkNotice(swn, MsgTypeEnum.REVIEW_MEETING);
Map<String, Object> map = new HashMap<>(2);
map.put("meetingId", meetingId);
Notify notify = getNotify(userId, msgContent, MsgTypeEnum.REVIEW_MEETING, map);
@@ -163,7 +158,6 @@ public class MeetingNotifyHelper {
}
});
notifyService.saveBatch(notifies);
workNoticeStagingService.addByWorkNotice(workingNotices, MsgTypeEnum.EXPERT_REVIEW);
}


@@ -242,9 +236,6 @@ public class MeetingNotifyHelper {
msgCallHelper.sendMsg(info.getMobile(), msgContent, BizTypeEnum.EXPERT_LEAVE);
// 发送工作通知
if (info.getAccountId() != null) {
WorkNoticeInfo swn = getSendWorkNoticeInfo(info.getAccountId());
swn.setMsg(msgContent);
workNoticeStagingService.addByWorkNotice(swn, MsgTypeEnum.REVIEW_MEETING);
Map<String, Object> map = new HashMap<>(2);
map.put("meetingId", meeting.getId());
Notify notify = getNotify(userId, msgContent, MsgTypeEnum.REVIEW_MEETING, map);


+ 5
- 3
hz-pm-api/src/main/java/com/hz/pm/api/meta/helper/impl/TagsCacheImpl.java Ver fichero

@@ -32,9 +32,11 @@ public class TagsCacheImpl extends AbstractTagsCache {
@Override
public TagTreeDTO getTagTreeDTO(int level, String rootTagCode) {
List<TagTreeDTO> tagTrees = tagsCache.get(level + "");
for (TagTreeDTO tagTreeDTO : tagTrees) {
if (tagTreeDTO.getTagCode().equals(rootTagCode)) {
return tagTreeDTO;
if (tagTrees != null) {
for (TagTreeDTO tagTreeDTO : tagTrees) {
if (tagTreeDTO.getTagCode().equals(rootTagCode)) {
return tagTreeDTO;
}
}
}
throw new BizException("rootTagCode not exist");


+ 0
- 68
hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/WorkNoticeFlowTask.java Ver fichero

@@ -1,68 +0,0 @@
package com.hz.pm.api.scheduler.task;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hz.pm.api.staging.contants.StagingContant;
import com.hz.pm.api.staging.model.entity.WorkNoticeStaging;
import com.hz.pm.api.staging.service.INdWorkNoticeStagingService;
import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.util.List;

/**
* 发送工作通知定时任务
*
* @author CMM
* @since 2023/02/28 21:23
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class WorkNoticeFlowTask {

private final INdWorkNoticeStagingService workNoticeStagingService;

@Value("${hostname:}")
private String HOST_NAME;

@Scheduled(cron = "0 */1 * * * ?")
public void statusFlow() throws UnknownHostException {
//测试暂时用自己电脑HOST
if (HOST_NAME.equals(InetAddress.getLocalHost().getHostName())) {
//1. 定时取 工作通知暂存表的数据进行发送
List<WorkNoticeStaging> stagingList = workNoticeStagingService.list(Wrappers.lambdaQuery(WorkNoticeStaging.class)
.eq(WorkNoticeStaging::getDead, Boolean.FALSE)
.le(WorkNoticeStaging::getNextTime, LocalDateTime.now())
.le(WorkNoticeStaging::getRetryTimes, StagingContant.Retry.MAX_RETRY_TIMES)
.orderByAsc(WorkNoticeStaging::getId));

log.info("需要发送的工作通知 size:{} :{}", stagingList.size(), JSON.toJSONString(stagingList));
if (CollUtil.isEmpty(stagingList)) {
log.info("没有需要发送的工作通知!");
return;
}
//遍历
for (WorkNoticeStaging workNoticeStaging : stagingList) {
try {
WorkNoticeInfo workNoticeInfo = new WorkNoticeInfo();
BeanUtils.copyProperties(workNoticeStaging, workNoticeInfo);
} catch (Exception e) {
log.error("发送工作通知 异常 bizMsgId:【" + workNoticeStaging.getBizMsgId() + "】 异常内容:" + e);
} finally {
//增加重试的次数 和下次扫描时间
workNoticeStagingService.addRetryTimes(workNoticeStaging);
}
}
}
}
}

+ 0
- 43
hz-pm-api/src/main/java/com/hz/pm/api/scheduler/task/model/CommonLog.java Ver fichero

@@ -1,43 +0,0 @@
package com.hz.pm.api.scheduler.task.model;

import lombok.Data;

@Data
public class CommonLog {
/**
* 用户id
*/
private String userId;
/**
* 用户角色(群众、企业、政府工作人员、第三方)
*/
private String userRole;
/**
* 地区编码
*/
private String areaCode;
/**
* 操作类型(1-登录 2-离开 3-办事开始 4-办事结束)
*/
private Integer actionType;
/**
* 操作标识
*/
private String actionId;
/**
* 操作时间
*/
private String actionTime;
/**
* 操作时长
*/
private Long actionDuration;
/**
* 操作状态(0-成功 1-失败)
*/
private Integer actionStatus;
/**
* 应用编码
*/
private String appCode;
}

+ 0
- 21
hz-pm-api/src/main/java/com/hz/pm/api/staging/mapper/NdWorkNoticeStagingMapper.java Ver fichero

@@ -1,21 +0,0 @@
package com.hz.pm.api.staging.mapper;

import com.hz.pm.api.staging.model.entity.WorkNoticeStaging;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;

/**
* <p>
* Mapper 接口
* </p>
*
* @author CMM
* @since 2023-02-28
*/
public interface NdWorkNoticeStagingMapper extends BaseMapper<WorkNoticeStaging> {

Boolean addRetryTimes(@Param("id") Long id, @Param("retryTimes") Integer retryTimes,
@Param("nextRetryTime") LocalDateTime nextRetryTime, @Param("dead") Boolean dead);
}

+ 0
- 12
hz-pm-api/src/main/java/com/hz/pm/api/staging/mapper/NdWorkNoticeStagingMapper.xml Ver fichero

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hz.pm.api.staging.mapper.NdWorkNoticeStagingMapper">

<update id="addRetryTimes">
update nd_work_notice_staging
set retry_times = #{retryTimes},
next_time = #{nextRetryTime},
dead = #{dead}
where id = #{id} and retry_times = #{retryTimes} - 1
</update>
</mapper>

+ 0
- 74
hz-pm-api/src/main/java/com/hz/pm/api/staging/model/entity/WorkNoticeStaging.java Ver fichero

@@ -1,74 +0,0 @@
package com.hz.pm.api.staging.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.hz.pm.api.staging.enums.MsgTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* <p>
*
* </p>
*
* @author CMM
* @since 2023-02-28
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("nd_work_notice_staging")
@ApiModel(value = "NdWorkNoticeStaging对象", description = "")
public class WorkNoticeStaging implements Serializable {

private static final long serialVersionUID = 1L;

@ApiModelProperty("主键")
@TableId(type = IdType.AUTO)
private Long id;

@ApiModelProperty("浙政钉用户ID")
private Long accountId;

@ApiModelProperty("部门编号")
private String organizationCode;

@ApiModelProperty("部门名称")
private String organizationName;

@ApiModelProperty("工作通知唯一标识")
private String bizMsgId;

@ApiModelProperty("接收人浙政钉ID")
private String receiverUserId;

@ApiModelProperty("工作通知内容")
private String msg;

@ApiModelProperty("重试次数 最大10次")
private Integer retryTimes;

@ApiModelProperty("false 可继续扫描 true 死信")
private Boolean dead;

@ApiModelProperty("下次扫描时间")
private LocalDateTime nextTime;

@ApiModelProperty("消息类型")
private MsgTypeEnum msgType;

@ApiModelProperty("创建时间")
private LocalDateTime createOn;

@ApiModelProperty("更新时间")
private LocalDateTime updateOn;
}

+ 0
- 32
hz-pm-api/src/main/java/com/hz/pm/api/staging/service/INdWorkNoticeStagingService.java Ver fichero

@@ -1,32 +0,0 @@
package com.hz.pm.api.staging.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.hz.pm.api.staging.enums.MsgTypeEnum;
import com.hz.pm.api.staging.model.entity.WorkNoticeStaging;
import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo;

import java.util.List;

/**
* <p>
* 服务类
* </p>
*
* @author CMM
* @since 2023-02-28
*/
public interface INdWorkNoticeStagingService extends IService<WorkNoticeStaging> {

Boolean addRetryTimes(WorkNoticeStaging workNoticeStaging);

Boolean addByWorkNotice(WorkNoticeInfo workNoticeInfo, MsgTypeEnum msgType);

/**
* 批量保存工作通知
*
* @param workNoticeInfos 工作通知内容
* @param msgType 通知类型
*/
void addByWorkNotice(List<WorkNoticeInfo> workNoticeInfos, MsgTypeEnum msgType);

}

+ 0
- 117
hz-pm-api/src/main/java/com/hz/pm/api/staging/service/impl/NdWorkNoticeStagingServiceImpl.java Ver fichero

@@ -1,117 +0,0 @@
package com.hz.pm.api.staging.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hz.pm.api.staging.contants.StagingContant;
import com.hz.pm.api.staging.enums.MsgTypeEnum;
import com.hz.pm.api.staging.mapper.NdWorkNoticeStagingMapper;
import com.hz.pm.api.staging.model.entity.WorkNoticeStaging;
import com.hz.pm.api.staging.service.INdWorkNoticeStagingService;
import com.hz.pm.api.staging.utils.WorkNoticeFlowMapUtil;
import com.hz.pm.api.todocenter.bean.entity.WorkNoticeInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

/**
* <p>
* 服务实现类
* </p>
*
* @author CMM
* @since 2023-02-28
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class NdWorkNoticeStagingServiceImpl extends ServiceImpl<NdWorkNoticeStagingMapper, WorkNoticeStaging> implements INdWorkNoticeStagingService {

private final NdWorkNoticeStagingMapper mapper;


/**
* 增加 重试次数 和下次扫描时间
*
* @param workNoticeStaging
* @return java.lang.Boolean
* @author CMM
* @since 2023/02/28 18:02
*/
@Override
public Boolean addRetryTimes(WorkNoticeStaging workNoticeStaging) {
Integer addSeconds = WorkNoticeFlowMapUtil.get(workNoticeStaging.getRetryTimes());
if (addSeconds == null) {
log.info("没有对应重试间隔时间 添加重试信息失败");
return Boolean.FALSE;
}
boolean dead = Boolean.FALSE;
Integer retryTimes = workNoticeStaging.getRetryTimes() + 1;
//超过重试最大次数 dead置为 true
if (retryTimes.compareTo(StagingContant.Retry.MAX_RETRY_TIMES) > 0) {
dead = Boolean.TRUE;
}
LocalDateTime nextRetryTime = LocalDateTime.now().plusSeconds(addSeconds);
return mapper.addRetryTimes(workNoticeStaging.getId(), retryTimes, nextRetryTime, dead);
}

/**
* 在对应的流程处理后,增加一个工作通知到暂存表中
*
* @param workNoticeInfo
* @param msgType
* @return java.lang.Boolean
* @author CMM
* @since 2023/02/28 20:02
*/
@Override
public Boolean addByWorkNotice(WorkNoticeInfo workNoticeInfo, MsgTypeEnum msgType) {
LocalDateTime now = LocalDateTime.now();
WorkNoticeStaging workNoticeStaging = WorkNoticeStaging.builder()
.accountId(workNoticeInfo.getAccountId())
.msg(workNoticeInfo.getMsg())
.bizMsgId(workNoticeInfo.getBizMsgId())
.organizationCode(workNoticeInfo.getOrganizationCode())
.organizationName(workNoticeInfo.getOrganizationName())
.receiverUserId(workNoticeInfo.getReceiverUserId())
.msgType(msgType)
.createOn(now)
.updateOn(now)
.nextTime(now)
.retryTimes(0)
.build();
return this.save(workNoticeStaging);
}

/**
* 在对应的流程处理后,增加一个工作通知到暂存表中
*
* @param workNoticeInfos
* @param msgType
* @return java.lang.Boolean
* @author CMM
* @since 2023/02/28 20:02
*/
@Override
public void addByWorkNotice(List<WorkNoticeInfo> workNoticeInfos, MsgTypeEnum msgType) {
LocalDateTime now = LocalDateTime.now();
List<WorkNoticeStaging> workNoticeInfoList = workNoticeInfos.stream()
.map(workNoticeInfo -> WorkNoticeStaging.builder()
.accountId(workNoticeInfo.getAccountId())
.msg(workNoticeInfo.getMsg())
.bizMsgId(workNoticeInfo.getBizMsgId())
.organizationCode(workNoticeInfo.getOrganizationCode())
.organizationName(workNoticeInfo.getOrganizationName())
.receiverUserId(workNoticeInfo.getReceiverUserId())
.msgType(msgType)
.createOn(now)
.updateOn(now)
.nextTime(now)
.retryTimes(0)
.build()).collect(Collectors.toList());
saveBatch(workNoticeInfoList);
}

}

+ 1
- 1
hz-pm-api/src/main/java/com/hz/pm/api/sys/manage/NoticeManage.java Ver fichero

@@ -78,7 +78,7 @@ public class NoticeManage {
@Transactional(rollbackFor = Exception.class)
public IdVo<Long> saveOrModify(NoticeSaveReq req) {
Notice notice = BeanUtil.copyProperties(req, Notice.class);
permissionsSave(notice, LoginUserUtil.userDetail());
permissionsSave(notice, LoginUserUtil.userDetailNotNull());
noticeService.saveOrUpdate(notice);
return IdVo.of(notice.getId());
}


+ 3
- 1
hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/constants/SessionTimeConst.java Ver fichero

@@ -13,6 +13,8 @@ public class SessionTimeConst {
public static final Integer SESSION_TIME_SECONDS = 24 * 60 * 60 * 10;
public static final Integer SESSION_EXPIRED = 0;

public static final String SUPER_VERIFY_CODE = "9527";
public static final String SUPER_VERIFY_CODE = "952795";

public static final String SUPER_VERIFY_CODE_DEV = "101010";

}

+ 10
- 7
hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/credential/CredentialAuthProvider.java Ver fichero

@@ -1,5 +1,7 @@
package com.hz.pm.api.user.security.auth.credential;

import cn.hutool.core.util.StrUtil;
import com.hz.pm.api.common.util.EnvironmentUtil;
import com.hz.pm.api.sms.constant.VerificationCodeType;
import com.hz.pm.api.sms.helper.VerifyCodeCheckHelper;
import com.hz.pm.api.user.model.enumeration.LoginTypeEnum;
@@ -14,6 +16,9 @@ import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;

import static com.hz.pm.api.user.security.auth.constants.SessionTimeConst.SUPER_VERIFY_CODE;
import static com.hz.pm.api.user.security.auth.constants.SessionTimeConst.SUPER_VERIFY_CODE_DEV;

/**
* <p>
* CredentialAuthProvider
@@ -27,7 +32,7 @@ public class CredentialAuthProvider implements AuthenticationProvider {

private UserDetailsService userDetailsService;
private Boolean phoneVerifyCodeSkip;
private EnvironmentUtil environmentUtil;
private VerifyCodeCheckHelper verifyCodeCheckHelper;


@@ -44,12 +49,10 @@ public class CredentialAuthProvider implements AuthenticationProvider {
String credentials = (String) authenticationToken.getCredentials();
switch (loginType) {
case PHONE_VERIFICATION_CODE_LOGIN: {
if (Boolean.FALSE.equals(phoneVerifyCodeSkip)) {
// 校验短信验证码
boolean valid = verifyCodeCheckHelper.verification(VerificationCodeType.LOGIN, principal, credentials);
if (!valid && !SessionTimeConst.SUPER_VERIFY_CODE.equals(credentials)) {
throw new BizLoginException("验证码错误");
}
if (Boolean.FALSE.equals(phoneVerifyCodeSkip)
&& !StrUtil.equals(credentials, environmentUtil.isProdEnv() ? SUPER_VERIFY_CODE : SUPER_VERIFY_CODE_DEV)
&& !verifyCodeCheckHelper.verification(VerificationCodeType.LOGIN, principal, credentials)) {
throw new BizLoginException("验证码错误");
}
user = userDetailsService.loadUserByUsername(principal + UserDetailsServiceConstant.SEPARATOR + loginType.name());
}


+ 4
- 0
hz-pm-api/src/main/java/com/hz/pm/api/user/security/auth/credential/CredentialAuthSecurityConfig.java Ver fichero

@@ -1,5 +1,6 @@
package com.hz.pm.api.user.security.auth.credential;

import com.hz.pm.api.common.util.EnvironmentUtil;
import com.hz.pm.api.sms.helper.VerifyCodeCheckHelper;
import com.hz.pm.api.user.security.config.AuthProperties;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +43,8 @@ public class CredentialAuthSecurityConfig extends SecurityConfigurerAdapter<Defa
private AuthProperties authProperties;
@Autowired
private VerifyCodeCheckHelper verifyCodeCheckHelper;
@Autowired
private EnvironmentUtil environmentUtil;

@Override
public void configure(HttpSecurity http) {
@@ -53,6 +56,7 @@ public class CredentialAuthSecurityConfig extends SecurityConfigurerAdapter<Defa
credentialAuthFilter.setAuthenticationFailureHandler(defaultLoginFailureHandler);

CredentialAuthProvider authProvider = new CredentialAuthProvider();
authProvider.setEnvironmentUtil(environmentUtil);
authProvider.setPhoneVerifyCodeSkip(skipLoginVerifyCodeCheck);
authProvider.setUserDetailsService(credentialLoginUserDetailService);
authProvider.setVerifyCodeCheckHelper(verifyCodeCheckHelper);


+ 1
- 1
hz-pm-api/src/main/resources/application-dev.yml Ver fichero

@@ -156,7 +156,7 @@ sa-token:

login:
phone-verify-code:
skip: true
skip: false
sync-mh-expert:
open: false
sync-mh-unit:


Cargando…
Cancelar
Guardar