wang-hao-jie
2022-01-07 0f2202dfcea3309c1b0e7515f6db5fbdc83d51d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//package cn.exrick.xboot.core.common.sms;
//
//import cn.exrick.xboot.core.common.constant.SettingConstant;
//import cn.exrick.xboot.core.common.exception.XbootException;
//import cn.exrick.xboot.core.entity.Setting;
//import cn.exrick.xboot.core.service.SettingService;
//import cn.hutool.core.util.StrUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
///**
// * 工厂模式
// * @author Exrick
// */
//@Component
//public class SmsFactory {
//
//    @Autowired
//    private SettingService settingService;
//
//    @Autowired
//    private AliSms aliSms;
//
//    @Autowired
//    private TencentSms tencentSms;
//
//    public Sms getSms() {
//
//        Setting setting = settingService.get(SettingConstant.SMS_USED);
//        if (setting == null || StrUtil.isBlank(setting.getValue())) {
//            throw new XbootException("您还未配置OSS存储服务");
//        }
//        String type = setting.getValue();
//        if (type.equals(SettingConstant.ALI_SMS)) {
//            return aliSms;
//        } else if (type.equals(SettingConstant.TENCENT_SMS)) {
//            return tencentSms;
//        } else {
//            throw new XbootException("暂不支持该存储配置,请检查配置");
//        }
//    }
//}