humuyu 3 years ago
parent
commit
2200a2b642

+ 42 - 35
eladmin-system/src/main/java/me/zhengjie/application/admin/service/DictDetailService.java

@@ -23,41 +23,48 @@ import java.util.List;
 import java.util.Map;
 
 /**
-* @author Zheng Jie
-* @date 2019-04-10
-*/
+ * @author Zheng Jie
+ * @date 2019-04-10
+ */
 public interface DictDetailService {
 
-    /**
-     * 创建
-     * @param resources /
-     */
-    void create(DictDetail resources);
-
-    /**
-     * 编辑
-     * @param resources /
-     */
-    void update(DictDetail resources);
-
-    /**
-     * 删除
-     * @param id /
-     */
-    void delete(Long id);
-
-    /**
-     * 分页查询
-     * @param criteria 条件
-     * @param pageable 分页参数
-     * @return /
-     */
-    Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable);
-
-    /**
-     * 根据字典名称获取字典详情
-     * @param name 字典名称
-     * @return /
-     */
-    List<DictDetailDto> getDictByName(String name);
+	/**
+	 * 创建
+	 * 
+	 * @param resources /
+	 */
+	void create(DictDetail resources);
+
+	/**
+	 * 编辑
+	 * 
+	 * @param resources /
+	 */
+	void update(DictDetail resources);
+
+	/**
+	 * 删除
+	 * 
+	 * @param id /
+	 */
+	void delete(Long id);
+
+	/**
+	 * 分页查询
+	 * 
+	 * @param criteria 条件
+	 * @param pageable 分页参数
+	 * @return /
+	 */
+	Map<String, Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable);
+
+	/**
+	 * 根据字典名称获取字典详情
+	 * 
+	 * @param name 字典名称
+	 * @return /
+	 */
+	List<DictDetailDto> getDictByName(String name);
+
+	public Map<String, String> getValueByName(String name);
 }

+ 58 - 46
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/DictDetailServiceImpl.java

@@ -30,65 +30,77 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 /**
-* @author Zheng Jie
-* @date 2019-04-10
-*/
+ * @author Zheng Jie
+ * @date 2019-04-10
+ */
 @Service
 @RequiredArgsConstructor
 @CacheConfig(cacheNames = "dict")
 public class DictDetailServiceImpl implements DictDetailService {
 
-    private final DictRepository dictRepository;
-    private final DictDetailRepository dictDetailRepository;
-    private final DictDetailMapper dictDetailMapper;
-    private final RedisUtils redisUtils;
+	private final DictRepository dictRepository;
+	private final DictDetailRepository dictDetailRepository;
+	private final DictDetailMapper dictDetailMapper;
+	private final RedisUtils redisUtils;
+
+	@Override
+	public Map<String, Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
+		Page<DictDetail> page = dictDetailRepository.findAll(
+				(root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder),
+				pageable);
+		return PageUtil.toPage(page.map(dictDetailMapper::toDto));
+	}
 
-    @Override
-    public Map<String,Object> queryAll(DictDetailQueryCriteria criteria, Pageable pageable) {
-        Page<DictDetail> page = dictDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
-        return PageUtil.toPage(page.map(dictDetailMapper::toDto));
-    }
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void create(DictDetail resources) {
+		dictDetailRepository.save(resources);
+		// 清理缓存
+		delCaches(resources);
+	}
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void create(DictDetail resources) {
-        dictDetailRepository.save(resources);
-        // 清理缓存
-        delCaches(resources);
-    }
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void update(DictDetail resources) {
+		DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
+		ValidationUtil.isNull(dictDetail.getId(), "DictDetail", "id", resources.getId());
+		resources.setId(dictDetail.getId());
+		dictDetailRepository.save(resources);
+		// 清理缓存
+		delCaches(resources);
+	}
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void update(DictDetail resources) {
-        DictDetail dictDetail = dictDetailRepository.findById(resources.getId()).orElseGet(DictDetail::new);
-        ValidationUtil.isNull( dictDetail.getId(),"DictDetail","id",resources.getId());
-        resources.setId(dictDetail.getId());
-        dictDetailRepository.save(resources);
-        // 清理缓存
-        delCaches(resources);
-    }
+	@Override
+	public List<DictDetailDto> getDictByName(String name) {
+		return dictDetailMapper.toDto(dictDetailRepository.findByDictName(name));
+	}
 
-    @Override
-    //@Cacheable(key = "'name:' + #p0")
-    public List<DictDetailDto> getDictByName(String name) {
-        return dictDetailMapper.toDto(dictDetailRepository.findByDictName(name));
-    }
+	public Map<String, String> getValueByName(String name) {
+		List<DictDetailDto> dicts = getDictByName(name);
+		Map<String, String> map = new HashMap<>();
+		for (DictDetailDto dict : dicts) {
+			map.put(dict.getLabel(), dict.getValue());
+		}
+		return map;
+	}
 
-    @Override
-    @Transactional(rollbackFor = Exception.class)
-    public void delete(Long id) {
-        DictDetail dictDetail = dictDetailRepository.findById(id).orElseGet(DictDetail::new);
-        // 清理缓存
-        delCaches(dictDetail);
-        dictDetailRepository.deleteById(id);
-    }
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void delete(Long id) {
+		DictDetail dictDetail = dictDetailRepository.findById(id).orElseGet(DictDetail::new);
+		// 清理缓存
+		delCaches(dictDetail);
+		dictDetailRepository.deleteById(id);
+	}
 
-    public void delCaches(DictDetail dictDetail){
-        Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
-        redisUtils.del(CacheKey.DICT_NAME + dict.getName());
-    }
+	public void delCaches(DictDetail dictDetail) {
+		Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
+		redisUtils.del(CacheKey.DICT_NAME + dict.getName());
+	}
 }

+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/application/bank/controller/BankOrderController.java

@@ -95,7 +95,7 @@ public class BankOrderController extends BaseController {
     }
 
     /**
-     * 提交订单
+         * 提交订单
      *
      * @param json
      * @return

+ 3 - 3
eladmin-system/src/main/java/me/zhengjie/application/user/app/controller/AppUserController.java

@@ -172,9 +172,9 @@ public class AppUserController {
 			return ResponseDTO.error(ResultCode.PARAM_IS_BLANK);
 		}
 		BankOrderVO order = bankOrderService.getContractOrderWithBizNo(businessNo);
-		JSONObject str = SdkTest.getFaceId(faceVerify.getClientWebankAppId(), faceVerify.getClientSecret(),
-				faceVerify.getClientKeyLicence(), order.getName(), order.getIdCard(), String.valueOf(order.getId()));
-		return ResponseDTO.success(str);
+//		JSONObject str = SdkTest.getFaceId(faceVerify.getClientWebankAppId(), faceVerify.getClientSecret(),
+//				faceVerify.getClientKeyLicence(), order.getName(), order.getIdCard(), String.valueOf(order.getId()));
+		return ResponseDTO.success();
 	}
 
 	@RequestMapping("/order/updateStatus")

+ 9 - 9
eladmin-system/src/main/java/me/zhengjie/base/config/TencentHumanFaceVerify.java

@@ -20,15 +20,15 @@ import lombok.Setter;
 @Getter
 @Setter
 public class TencentHumanFaceVerify {
-	// 当事人appId
-	@Value("${tencent.client.webankAppId}")
-	private String clientWebankAppId;
-	//当事人secret
-	@Value("${tencent.client.secret}")
-	private String clientSecret;
-	//当事人keyLicence
-	@Value("${tencent.client.keyLicence}")
-	private String clientKeyLicence;
+//	// 当事人appId
+//	@Value("${tencent.client.webankAppId}")
+//	private String clientWebankAppId;
+//	//当事人secret
+//	@Value("${tencent.client.secret}")
+//	private String clientSecret;
+//	//当事人keyLicence
+//	@Value("${tencent.client.keyLicence}")
+//	private String clientKeyLicence;
 
 	//银行端appId
 	@Value("${tencent.bank.webankAppId}")

+ 13 - 0
eladmin-system/src/main/java/me/zhengjie/base/sms/SmsSendVo.java

@@ -0,0 +1,13 @@
+package me.zhengjie.base.sms;
+
+import java.util.List;
+
+import lombok.Data;
+@Data
+public class SmsSendVo {
+	//模板id
+	private String templateId;
+	//模板参数
+	private List<String> templateParam;
+
+}

+ 38 - 113
eladmin-system/src/main/java/me/zhengjie/base/sms/TxSmsRequest.java

@@ -14,7 +14,6 @@ import com.tencentcloudapi.common.profile.HttpProfile;
 import com.tencentcloudapi.sms.v20210111.SmsClient;
 import com.tencentcloudapi.sms.v20210111.models.*;
 import me.zhengjie.application.admin.service.DictDetailService;
-import me.zhengjie.application.admin.service.dto.DictDetailDto;
 import me.zhengjie.dao.mybatis.entity.SmsTemplateEntity;
 
 @Component
@@ -115,11 +114,7 @@ public class TxSmsRequest implements SmsRequest {
 	 * @return
 	 */
 	private SmsClient getClient() {
-		List<DictDetailDto> dicts = dictDetailService.getDictByName("sms_msg");
-		Map<String, String> map = new HashMap<>();
-		for (DictDetailDto dict : dicts) {
-			map.put(dict.getLabel(), dict.getValue());
-		}
+		Map<String, String> map = dictDetailService.getValueByName("sms_msg");
 		String secretId = map.get("secretId");
 		String secretKey = map.get("secretKey");
 		String endpoint = map.get("endpoint");
@@ -137,111 +132,41 @@ public class TxSmsRequest implements SmsRequest {
 		SmsClient client = new SmsClient(cred, region, clientProfile);
 		return client;
 	}
-	 /**
-     * 发送短信
-     * @param phone
-     * @param code
-     * @param time
-     * @return
-     */
-    public static String sendMsg(String phone, String code, String time) {
-        try {
-            /*
-             * 必要步骤: 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
-             * 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。 你也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人,
-             * 以免泄露密钥对危及你的财产安全。 CAM密匙查询: https://console.cloud.tencent.com/cam/capi
-             */
-            Credential cred = new Credential("", "");
-            // 实例化一个http选项,可选,没有特殊需求可以跳过
-            HttpProfile httpProfile = new HttpProfile();
-            // 设置代理
-            // httpProfile.setProxyHost("真实代理ip");
-            // httpProfile.setProxyPort(真实代理端口);
-            /*
-             * SDK默认使用POST方法。 如果你一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求
-             */
-            httpProfile.setReqMethod("POST");
-            /*
-             * SDK有默认的超时时间,非必要请不要进行调整 如有需要请在代码中查阅以获取最新的默认值
-             */
-            httpProfile.setConnTimeout(60);
-            /*
-             * SDK会自动指定域名。通常是不需要特地指定域名的,但是如果你访问的是金融区的服务 则必须手动指定域名,例如sms的上海金融区域名:
-             * sms.ap-shanghai-fsi.tencentcloudapi.com
-             */
-            httpProfile.setEndpoint("sms.tencentcloudapi.com");
-
-            /*
-             * 非必要步骤: 实例化一个客户端配置对象,可以指定超时时间等配置
-             */
-            ClientProfile clientProfile = new ClientProfile();
-            /*
-             * SDK默认用TC3-HMAC-SHA256进行签名 非必要请不要修改这个字段
-             */
-            clientProfile.setSignMethod("HmacSHA256");
-            clientProfile.setHttpProfile(httpProfile);
-            /*
-             * 实例化要请求产品(以sms为例)的client对象 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,或者引用预设的常量
-             */
-            SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
-            /*
-             * 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数 你可以直接查询SDK源码确定接口有哪些属性可以设置
-             * 属性可能是基本类型,也可能引用了另一个数据结构 推荐使用IDE进行开发,可以方便的跳转查阅各个接口和数据结构的文档说明
-             */
-            SendSmsRequest req = new SendSmsRequest();
-            /*
-             * 填充请求参数,这里request对象的成员变量即对应接口的入参 你可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
-             * 基本类型的设置: 帮助链接: 短信控制台: https://console.cloud.tencent.com/smsv2 sms helper:
-             * https://cloud.tencent.com/document/product/382/3773
-             */
-            /* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */
-            String sdkAppId = "1400625259";
-            req.setSmsSdkAppId(sdkAppId);
-
-            /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名,签名信息可登录 [短信控制台] 查看 */
-            String signName = "苏州展翼天创数字科技有限";
-            req.setSignName(signName);
-
-            /* 国际/港澳台短信 SenderId: 国内短信填空,默认未开通,如需开通请联系 [sms helper] */
-            String senderid = "";
-            req.setSenderId(senderid);
-
-            /* 用户的 session 内容: 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
-            String sessionContext = "xxx";
-            req.setSessionContext(sessionContext);
-
-            /* 短信号码扩展号: 默认未开通,如需开通请联系 [sms helper] */
-            String extendCode = "";
-            req.setExtendCode(extendCode);
-
-            /* 模板 ID: 必须填写已审核通过的模板 ID。模板ID可登录 [短信控制台] 查看 */
-            String templateId = "1281636";
-            req.setTemplateId(templateId);
-
-            /*
-             * 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号] 示例如:+8613711112222, 其中前面有一个+号
-             * ,86为国家码,13711112222为手机号,最多不要超过200个手机号
-             */
-            String[] phoneNumberSet = { phone };
-            req.setPhoneNumberSet(phoneNumberSet);
-
-            /* 模板参数: 若无模板参数,则设置为空 */
-            String[] templateParamSet = { code, time };
-            req.setTemplateParamSet(templateParamSet);
-
-            /*
-             * 通过 client 对象调用 SendSms 方法发起请求。注意请求方法名与请求对象是对应的 返回的 res 是一个 SendSmsResponse
-             * 类的实例,与请求对象对应
-             */
-            SendSmsResponse res = client.SendSms(req);
-            return SendSmsResponse.toJsonString(res);
-            // 输出json格式的字符串回包
-            // System.out.println();
-            // 也可以取出单个值,你可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
-            // System.out.println(res.getRequestId());
-        } catch (TencentCloudSDKException e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
+
+	/**
+	 * 发送短信
+	 * 
+	 * @param phone
+	 * @param code
+	 * @param time
+	 * @return
+	 * @throws TencentCloudSDKException
+	 */
+	public String sendMsg(SmsSendVo smsSend) throws Exception {
+		// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
+		// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
+		// 实例化一个http选项,可选的,没有特殊需求可以跳过
+		HttpProfile httpProfile = new HttpProfile();
+		httpProfile.setEndpoint("sms.tencentcloudapi.com");
+		// 实例化一个client选项,可选的,没有特殊需求可以跳过
+		ClientProfile clientProfile = new ClientProfile();
+		clientProfile.setHttpProfile(httpProfile);
+		// 实例化要请求产品的client对象,clientProfile是可选的
+		SmsClient client = getClient();
+		// 实例化一个请求对象,每个接口都会对应一个request对象
+		SendSmsRequest req = new SendSmsRequest();
+		Map<String, String> map = dictDetailService.getValueByName("sms_msg");
+		String sdkAppID = map.get("SDKAppID");
+		String signName = map.get("signName");
+		req.setSmsSdkAppId(sdkAppID);
+		req.setSignName(signName);
+		req.setTemplateId(smsSend.getTemplateId());
+		List<String> templateParamSet = smsSend.getTemplateParam();
+		//设置模板参数
+		req.setTemplateParamSet(templateParamSet.toArray(new String[templateParamSet.size()]));
+		// 返回的resp是一个SendSmsResponse的实例,与请求对象对应
+		SendSmsResponse resp = client.SendSms(req);
+		// 输出json格式的字符串回包
+		return SendSmsResponse.toJsonString(resp);
+	}
 }