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;
}
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);
}
}
Aggregations