|
|
|
@ -7,8 +7,10 @@ import com.bnyer.common.core.constant.TiktokConstant; |
|
|
|
import com.bnyer.common.core.domain.FhUser; |
|
|
|
import com.bnyer.common.core.domain.R; |
|
|
|
import com.bnyer.common.core.dto.FhLoginDto; |
|
|
|
import com.bnyer.common.core.enums.EnumAppType; |
|
|
|
import com.bnyer.common.core.exception.ServiceException; |
|
|
|
import com.bnyer.common.core.utils.Sm4Util; |
|
|
|
import com.bnyer.common.core.utils.StringUtils; |
|
|
|
import com.bnyer.common.core.vo.FhUserLoginVo; |
|
|
|
import com.bnyer.common.redis.service.RedisService; |
|
|
|
import com.bnyer.img.api.model.LoginFhUser; |
|
|
|
@ -54,14 +56,20 @@ public class FhUserServiceImpl implements FhUserService { |
|
|
|
/** |
|
|
|
* 获取用户openId及sessionKey |
|
|
|
* @param code 登录凭证code |
|
|
|
* @param appType 应用类型(0->次元意境;1->妙鸭壁纸) |
|
|
|
* @return - |
|
|
|
*/ |
|
|
|
private FhSessionInfoVo getSessionInfo(String code) { |
|
|
|
private FhSessionInfoVo getSessionInfo(String code,String appType) { |
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
headers.add("Content-Type", "application/x-www-form-urlencoded"); |
|
|
|
MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>(); |
|
|
|
postParameters.add("app_id", fhConfig.getAppId()); |
|
|
|
postParameters.add("app_secret", fhConfig.getSecret()); |
|
|
|
if(appType.equals(EnumAppType.YJ_APP.getCode())){ |
|
|
|
postParameters.add("app_id", fhConfig.getYjAppId()); |
|
|
|
postParameters.add("app_secret", fhConfig.getYjSecret()); |
|
|
|
}else if (appType.equals(EnumAppType.MY_APP.getCode())){ |
|
|
|
postParameters.add("app_id", fhConfig.getMyAppId()); |
|
|
|
postParameters.add("app_secret", fhConfig.getMySecret()); |
|
|
|
} |
|
|
|
postParameters.add("js_code", code); |
|
|
|
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(postParameters, headers); |
|
|
|
JSONObject sessionInfo = restTemplate.postForObject(fhConfig.getSessionInfoUrl(), httpEntity, JSONObject.class); |
|
|
|
@ -108,7 +116,7 @@ public class FhUserServiceImpl implements FhUserService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存用户 |
|
|
|
* @param openId 微信id |
|
|
|
* @param openId 快手id |
|
|
|
* @param sessionKey - |
|
|
|
* @param encryptedData 敏感信息数据 |
|
|
|
* @param iv 加密向量 |
|
|
|
@ -187,10 +195,11 @@ public class FhUserServiceImpl implements FhUserService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public R<LoginFhUser> getFhLoginUserByLoginParam(FhLoginDto dto) { |
|
|
|
FhSessionInfoVo sessionInfo = this.getSessionInfo(dto.getCode()); |
|
|
|
FhSessionInfoVo sessionInfo = this.getSessionInfo(dto.getCode(),dto.getAppType()); |
|
|
|
//检查数据库中是否存在该openId,存在则直接返回结果;不存在则新增
|
|
|
|
LambdaQueryWrapper<FhUser> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(sessionInfo.getOpenId() != null,FhUser::getFhCode,Sm4Util.sm4Encryption(sessionInfo.getOpenId())); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(dto.getAppType()), FhUser::getAppType, dto.getAppType()); |
|
|
|
FhUser fhUser = fhUserMapper.selectOne(wrapper); |
|
|
|
if(fhUser == null){ |
|
|
|
//新用户,新增
|
|
|
|
|