Sfoglia il codice sorgente

更新短信验证相关

tags/v1.9.0
xiaoying 1 anno fa
parent
commit
3e692eebd7
2 ha cambiato i file con 51 aggiunte e 31 eliminazioni
  1. +26
    -16
      tuoheng-api/src/main/java/com/tuoheng/api/service/impl/WestreamActivityApplyServiceImpl.java
  2. +25
    -15
      tuoheng-api/src/main/java/com/tuoheng/api/service/impl/WestreamSuggestServiceImpl.java

+ 26
- 16
tuoheng-api/src/main/java/com/tuoheng/api/service/impl/WestreamActivityApplyServiceImpl.java Vedi File

@@ -1,19 +1,18 @@
package com.tuoheng.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.api.entity.domain.Tenant;
import com.tuoheng.api.entity.domain.User;
import com.tuoheng.api.entity.domain.WestreamActivityApply;
import com.tuoheng.api.constants.DictConstants;
import com.tuoheng.api.entity.domain.*;
import com.tuoheng.api.entity.request.WestreamActivityQuery;
import com.tuoheng.api.mapper.TenantMapper;
import com.tuoheng.api.mapper.UserMapper;
import com.tuoheng.api.mapper.WestreamActivityApplyMapper;
import com.tuoheng.api.mapper.*;
import com.tuoheng.api.service.IWestreamActivityApplyService;
import com.tuoheng.api.service.TextMessageService;
import com.tuoheng.common.common.BaseServiceImpl;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@@ -22,14 +21,15 @@ import java.util.List;
import java.util.stream.Collectors;

@Service
@Slf4j
public class WestreamActivityApplyServiceImpl extends BaseServiceImpl<WestreamActivityApplyMapper, WestreamActivityApply> implements IWestreamActivityApplyService {

@Autowired
private WestreamActivityApplyMapper westreamActivityApplyMapper;
@Autowired
private TenantMapper tenantMapper;
private ThDictMapper thDictMapper;
@Autowired
private UserMapper userMapper;
private ThDictDataMapper thDictDataMapper;
@Autowired
private TextMessageService textMessageService;

@@ -55,15 +55,25 @@ public class WestreamActivityApplyServiceImpl extends BaseServiceImpl<WestreamAc
}
super.add(entity);
//向对应的审批人发送短信,获取手机号
Tenant tenant = tenantMapper.selectById(entity.getTenantId());
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getUsername, tenant.getUsername()).eq(User::getMark, 1));
String mobile = user.getMobile();
if (StringUtils.isNotEmpty(mobile)) {
List<String> list = Arrays.stream(mobile.split(",")).collect(Collectors.toList());
//发送短信
textMessageService.sendMessage(list);
ThDict thDict = thDictMapper.selectOne(new LambdaQueryWrapper<ThDict>()
.eq(ThDict::getTenantId, entity.getTenantId())
.eq(ThDict::getMark, 1)
.eq(ThDict::getCode, DictConstants.MSG_RULE_CODE));
if (ObjectUtils.isNotNull(thDict)) {
Integer dictId = thDict.getId();
ThDictData phoneData = thDictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>()
.eq(ThDictData::getMark, 1)
.eq(ThDictData::getDictId, dictId)
.eq(ThDictData::getName, DictConstants.MSG_RULE_PHONE));
if (ObjectUtils.isNotNull(phoneData)) {
String phones = phoneData.getValue();
List<String> list = Arrays.stream(phones.split(",")).collect(Collectors.toList());
Integer success = textMessageService.sendMessage(list);
if (success.equals(list.size())) {
log.info("短信全部发送成功!");
}
}
}

return JsonResult.success();
}


+ 25
- 15
tuoheng-api/src/main/java/com/tuoheng/api/service/impl/WestreamSuggestServiceImpl.java Vedi File

@@ -1,12 +1,11 @@
package com.tuoheng.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.api.entity.domain.Tenant;
import com.tuoheng.api.entity.domain.User;
import com.tuoheng.api.entity.domain.WestreamSuggest;
import com.tuoheng.api.mapper.TenantMapper;
import com.tuoheng.api.mapper.UserMapper;
import com.tuoheng.api.mapper.WestreamSuggestMapper;
import com.tuoheng.api.constants.DictConstants;
import com.tuoheng.api.entity.domain.*;
import com.tuoheng.api.mapper.*;
import com.tuoheng.api.service.IWestreamSuggestService;
import com.tuoheng.api.service.TextMessageService;
import com.tuoheng.common.common.BaseServiceImpl;
@@ -32,9 +31,9 @@ public class WestreamSuggestServiceImpl extends BaseServiceImpl<WestreamSuggestM


@Autowired
private TenantMapper tenantMapper;
private ThDictMapper thDictMapper;
@Autowired
private UserMapper userMapper;
private ThDictDataMapper thDictDataMapper;
@Autowired
private TextMessageService textMessageService;

@@ -55,13 +54,24 @@ public class WestreamSuggestServiceImpl extends BaseServiceImpl<WestreamSuggestM
return JsonResult.error("openid为空!");
}
//向对应的审批人发送短信,获取手机号
Tenant tenant = tenantMapper.selectById(entity.getTenantId());
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getUsername, tenant.getUsername()).eq(User::getMark, 1));
String mobile = user.getMobile();
if (StringUtils.isNotEmpty(mobile)) {
List<String> list = Arrays.stream(mobile.split(",")).collect(Collectors.toList());
//发送短信
textMessageService.sendMessage(list);
ThDict thDict = thDictMapper.selectOne(new LambdaQueryWrapper<ThDict>()
.eq(ThDict::getTenantId, entity.getTenantId())
.eq(ThDict::getMark, 1)
.eq(ThDict::getCode, DictConstants.MSG_RULE_CODE));
if (ObjectUtils.isNotNull(thDict)) {
Integer dictId = thDict.getId();
ThDictData phoneData = thDictDataMapper.selectOne(new LambdaQueryWrapper<ThDictData>()
.eq(ThDictData::getMark, 1)
.eq(ThDictData::getDictId, dictId)
.eq(ThDictData::getName, DictConstants.MSG_RULE_PHONE));
if (ObjectUtils.isNotNull(phoneData)) {
String phones = phoneData.getValue();
List<String> list = Arrays.stream(phones.split(",")).collect(Collectors.toList());
Integer success = textMessageService.sendMessage(list);
if (success.equals(list.size())) {
log.info("短信全部发送成功!");
}
}
}
return super.add(entity);
}

Loading…
Annulla
Salva