Search in sources :

Example 1 with QQConnectSetting

use of cn.lili.modules.system.entity.dto.connect.QQConnectSetting in project lilishop by lilishop.

the class ConnectUtil method getAuthRequest.

/**
 * 联合登录
 *
 * @param type 枚举
 * @return
 */
public AuthRequest getAuthRequest(String type) {
    ConnectAuthEnum authInterface = ConnectAuthEnum.valueOf(type);
    if (authInterface == null) {
        throw new ServiceException(ResultCode.CONNECT_NOT_EXIST);
    }
    AuthRequest authRequest = null;
    switch(authInterface) {
        case WECHAT:
            {
                // 寻找配置
                Setting setting = settingService.get(SettingEnum.WECHAT_CONNECT.name());
                WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
                for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
                    if (wechatConnectSettingItem.getClientType().equals(ClientTypeEnum.H5.name())) {
                        authRequest = new BaseAuthWeChatRequest(AuthConfig.builder().clientId(wechatConnectSettingItem.getAppId()).clientSecret(wechatConnectSettingItem.getAppSecret()).redirectUri(getRedirectUri(authInterface)).build(), cache);
                    }
                }
                break;
            }
        case WECHAT_PC:
            {
                // 寻找配置
                Setting setting = settingService.get(SettingEnum.WECHAT_CONNECT.name());
                WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
                for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
                    if (wechatConnectSettingItem.getClientType().equals(ClientTypeEnum.PC.name())) {
                        authRequest = new BaseAuthWeChatPCRequest(AuthConfig.builder().clientId(wechatConnectSettingItem.getAppId()).clientSecret(wechatConnectSettingItem.getAppSecret()).redirectUri(getRedirectUri(authInterface)).build(), cache);
                    }
                }
                break;
            }
        case QQ:
            // 寻找配置
            Setting setting = settingService.get(SettingEnum.QQ_CONNECT.name());
            QQConnectSetting qqConnectSetting = JSONUtil.toBean(setting.getSettingValue(), QQConnectSetting.class);
            for (QQConnectSettingItem qqConnectSettingItem : qqConnectSetting.getQqConnectSettingItemList()) {
                if (qqConnectSettingItem.getClientType().equals(ClientTypeEnum.PC.name())) {
                    authRequest = new BaseAuthQQRequest(AuthConfig.builder().clientId(qqConnectSettingItem.getAppId()).clientSecret(qqConnectSettingItem.getAppKey()).redirectUri(getRedirectUri(authInterface)).unionId(true).build(), cache);
                }
            }
            break;
        default:
            break;
    }
    if (null == authRequest) {
        throw new AuthException("暂不支持第三方登陆");
    }
    return authRequest;
}
Also used : WechatConnectSetting(cn.lili.modules.system.entity.dto.connect.WechatConnectSetting) AuthRequest(cn.lili.modules.connect.request.AuthRequest) BaseAuthWeChatPCRequest(cn.lili.modules.connect.request.BaseAuthWeChatPCRequest) ServiceException(cn.lili.common.exception.ServiceException) WechatConnectSettingItem(cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem) QQConnectSettingItem(cn.lili.modules.system.entity.dto.connect.dto.QQConnectSettingItem) WechatConnectSetting(cn.lili.modules.system.entity.dto.connect.WechatConnectSetting) Setting(cn.lili.modules.system.entity.dos.Setting) QQConnectSetting(cn.lili.modules.system.entity.dto.connect.QQConnectSetting) BaseAuthWeChatRequest(cn.lili.modules.connect.request.BaseAuthWeChatRequest) AuthException(cn.lili.modules.connect.exception.AuthException) ConnectAuthEnum(cn.lili.modules.connect.config.ConnectAuthEnum) BaseAuthQQRequest(cn.lili.modules.connect.request.BaseAuthQQRequest) QQConnectSetting(cn.lili.modules.system.entity.dto.connect.QQConnectSetting)

Example 2 with QQConnectSetting

use of cn.lili.modules.system.entity.dto.connect.QQConnectSetting in project lilishop by lilishop.

the class SettingManagerController method createSetting.

/**
 * 获取表单
 * 这里主要包含一个配置对象为空,导致转换异常问题的处理,解决配置项增加减少,带来的系统异常,无法直接配置
 *
 * @param key
 * @return
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
private ResultMessage createSetting(String key) {
    SettingEnum settingEnum = SettingEnum.valueOf(key);
    Setting setting = settingService.get(key);
    switch(settingEnum) {
        case BASE_SETTING:
            return setting == null ? ResultUtil.data(new BaseSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), BaseSetting.class));
        case WITHDRAWAL_SETTING:
            return setting == null ? ResultUtil.data(new WithdrawalSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WithdrawalSetting.class));
        case DISTRIBUTION_SETTING:
            return setting == null ? ResultUtil.data(new DistributionSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class));
        case EMAIL_SETTING:
            return setting == null ? ResultUtil.data(new EmailSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), EmailSetting.class));
        case GOODS_SETTING:
            return setting == null ? ResultUtil.data(new GoodsSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class));
        case KUAIDI_SETTING:
            return setting == null ? ResultUtil.data(new KuaidiSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), KuaidiSetting.class));
        case ORDER_SETTING:
            return setting == null ? ResultUtil.data(new OrderSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class));
        case OSS_SETTING:
            return setting == null ? ResultUtil.data(new OssSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), OssSetting.class));
        case SMS_SETTING:
            return setting == null ? ResultUtil.data(new SmsSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), SmsSetting.class));
        case POINT_SETTING:
            return setting == null ? ResultUtil.data(new PointSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), PointSetting.class));
        case QQ_CONNECT:
            return setting == null ? ResultUtil.data(new QQConnectSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), QQConnectSetting.class));
        case PAYMENT_SUPPORT:
            return setting == null ? ResultUtil.data(new PaymentSupportSetting(new PaymentSupportForm())) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), PaymentSupportSetting.class));
        case ALIPAY_PAYMENT:
            return setting == null ? ResultUtil.data(new AlipayPaymentSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), AlipayPaymentSetting.class));
        case WECHAT_CONNECT:
            return setting == null ? ResultUtil.data(new WechatConnectSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class));
        case WECHAT_PAYMENT:
            return setting == null ? ResultUtil.data(new WechatPaymentSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WechatPaymentSetting.class));
        case SECKILL_SETTING:
            return setting == null ? ResultUtil.data(new SeckillSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), SeckillSetting.class));
        case EXPERIENCE_SETTING:
            return setting == null ? ResultUtil.data(new ExperienceSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ExperienceSetting.class));
        case IM_SETTING:
            return setting == null ? ResultUtil.data(new ImSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ImSetting.class));
        case HOT_WORDS:
            return setting == null ? ResultUtil.data(new HotWordsSetting()) : ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), HotWordsSetting.class));
        default:
            throw new ServiceException(ResultCode.SETTING_NOT_TO_SET);
    }
}
Also used : PaymentSupportSetting(cn.lili.modules.system.entity.dto.payment.PaymentSupportSetting) PaymentSupportForm(cn.lili.modules.system.entity.dto.payment.dto.PaymentSupportForm) AlipayPaymentSetting(cn.lili.modules.system.entity.dto.payment.AlipayPaymentSetting) WechatPaymentSetting(cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting) PaymentSupportSetting(cn.lili.modules.system.entity.dto.payment.PaymentSupportSetting) WechatConnectSetting(cn.lili.modules.system.entity.dto.connect.WechatConnectSetting) Setting(cn.lili.modules.system.entity.dos.Setting) QQConnectSetting(cn.lili.modules.system.entity.dto.connect.QQConnectSetting) SettingEnum(cn.lili.modules.system.entity.enums.SettingEnum) WechatConnectSetting(cn.lili.modules.system.entity.dto.connect.WechatConnectSetting) AlipayPaymentSetting(cn.lili.modules.system.entity.dto.payment.AlipayPaymentSetting) WechatPaymentSetting(cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting) ServiceException(cn.lili.common.exception.ServiceException) QQConnectSetting(cn.lili.modules.system.entity.dto.connect.QQConnectSetting)

Aggregations

ServiceException (cn.lili.common.exception.ServiceException)2 Setting (cn.lili.modules.system.entity.dos.Setting)2 QQConnectSetting (cn.lili.modules.system.entity.dto.connect.QQConnectSetting)2 WechatConnectSetting (cn.lili.modules.system.entity.dto.connect.WechatConnectSetting)2 ConnectAuthEnum (cn.lili.modules.connect.config.ConnectAuthEnum)1 AuthException (cn.lili.modules.connect.exception.AuthException)1 AuthRequest (cn.lili.modules.connect.request.AuthRequest)1 BaseAuthQQRequest (cn.lili.modules.connect.request.BaseAuthQQRequest)1 BaseAuthWeChatPCRequest (cn.lili.modules.connect.request.BaseAuthWeChatPCRequest)1 BaseAuthWeChatRequest (cn.lili.modules.connect.request.BaseAuthWeChatRequest)1 QQConnectSettingItem (cn.lili.modules.system.entity.dto.connect.dto.QQConnectSettingItem)1 WechatConnectSettingItem (cn.lili.modules.system.entity.dto.connect.dto.WechatConnectSettingItem)1 AlipayPaymentSetting (cn.lili.modules.system.entity.dto.payment.AlipayPaymentSetting)1 PaymentSupportSetting (cn.lili.modules.system.entity.dto.payment.PaymentSupportSetting)1 WechatPaymentSetting (cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting)1 PaymentSupportForm (cn.lili.modules.system.entity.dto.payment.dto.PaymentSupportForm)1 SettingEnum (cn.lili.modules.system.entity.enums.SettingEnum)1