|
@ -18,28 +18,37 @@ |
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; |
|
|
import com.epmet.commons.tools.redis.common.bean.ResiUserInfoCache; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.NameUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
|
|
import com.epmet.constant.UserConstant; |
|
|
import com.epmet.dao.*; |
|
|
import com.epmet.dao.*; |
|
|
import com.epmet.dto.RegisterRelationDTO; |
|
|
import com.epmet.dto.RegisterRelationDTO; |
|
|
import com.epmet.dto.UserBaseInfoDTO; |
|
|
import com.epmet.dto.UserBaseInfoDTO; |
|
|
import com.epmet.dto.UserResiInfoDTO; |
|
|
import com.epmet.dto.UserResiInfoDTO; |
|
|
import com.epmet.dto.UserWechatDTO; |
|
|
import com.epmet.dto.UserWechatDTO; |
|
|
import com.epmet.dto.form.CommonUserIdFormDTO; |
|
|
import com.epmet.dto.form.CommonUserIdFormDTO; |
|
|
|
|
|
import com.epmet.dto.form.DingLoginResiFormDTO; |
|
|
import com.epmet.dto.form.UserRoleFormDTO; |
|
|
import com.epmet.dto.form.UserRoleFormDTO; |
|
|
import com.epmet.dto.form.VolunteerRegResiFormDTO; |
|
|
import com.epmet.dto.form.VolunteerRegResiFormDTO; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.dto.result.*; |
|
|
|
|
|
import com.epmet.entity.RegisterRelationEntity; |
|
|
import com.epmet.entity.UserBaseInfoEntity; |
|
|
import com.epmet.entity.UserBaseInfoEntity; |
|
|
|
|
|
import com.epmet.entity.UserEntity; |
|
|
import com.epmet.entity.UserWechatEntity; |
|
|
import com.epmet.entity.UserWechatEntity; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.redis.UserBaseInfoRedis; |
|
|
import com.epmet.redis.UserBaseInfoRedis; |
|
@ -57,6 +66,7 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -90,6 +100,8 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl<UserBaseInfoDao, Us |
|
|
private UserResiInfoService userResiInfoService; |
|
|
private UserResiInfoService userResiInfoService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private RegisterRelationDao registerRelationDao; |
|
|
private RegisterRelationDao registerRelationDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private UserDao userDao; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<UserBaseInfoDTO> page(Map<String, Object> params) { |
|
|
public PageData<UserBaseInfoDTO> page(Map<String, Object> params) { |
|
@ -519,4 +531,63 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl<UserBaseInfoDao, Us |
|
|
public ResiUserInfoCache getUserInfo(String userId) { |
|
|
public ResiUserInfoCache getUserInfo(String userId) { |
|
|
return ConvertUtils.sourceToTarget(userBaseInfoRedis.getUserInfo(userId), ResiUserInfoCache.class); |
|
|
return ConvertUtils.sourceToTarget(userBaseInfoRedis.getUserInfo(userId), ResiUserInfoCache.class); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 钉钉用户注册 |
|
|
|
|
|
* |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @Param formDTO |
|
|
|
|
|
* @Return {@link DingLoginResiResDTO} |
|
|
|
|
|
* @Author zhaoqifeng |
|
|
|
|
|
* @Date 2022/9/15 11:17 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public DingLoginResiResDTO dingResiLogin(DingLoginResiFormDTO formDTO) { |
|
|
|
|
|
DingLoginResiResDTO result = new DingLoginResiResDTO(); |
|
|
|
|
|
result.setCustomerId(formDTO.getCustomerId()); |
|
|
|
|
|
//根据手机号从baseinfo查对应的信息,如果有则返回,没有则注册
|
|
|
|
|
|
LambdaQueryWrapper<UserBaseInfoEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
wrapper.eq(UserBaseInfoEntity::getCustomerId, formDTO.getCustomerId()); |
|
|
|
|
|
wrapper.eq(UserBaseInfoEntity::getMobile, formDTO.getMobile()); |
|
|
|
|
|
UserBaseInfoEntity baseInfo = baseDao.selectOne(wrapper); |
|
|
|
|
|
if (null == baseInfo) { |
|
|
|
|
|
//注册
|
|
|
|
|
|
UserEntity userEntity = new UserEntity(); |
|
|
|
|
|
userEntity.setFromApp(UserConstant.APP_RESI); |
|
|
|
|
|
userEntity.setFromClient(UserConstant.CLIENT_DING); |
|
|
|
|
|
userEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
|
|
userDao.insert(userEntity); |
|
|
|
|
|
//信息存入baseinfo
|
|
|
|
|
|
baseInfo = new UserBaseInfoEntity(); |
|
|
|
|
|
baseInfo.setCustomerId(formDTO.getCustomerId()); |
|
|
|
|
|
baseInfo.setUserId(userEntity.getId()); |
|
|
|
|
|
baseInfo.setMobile(formDTO.getMobile()); |
|
|
|
|
|
baseInfo.setRealName(formDTO.getNick()); |
|
|
|
|
|
baseInfo.setSurname(NameUtils.getSurNameComplex(formDTO.getNick())); |
|
|
|
|
|
baseInfo.setName(NameUtils.getNameComplex(formDTO.getNick())); |
|
|
|
|
|
baseInfo.setNickname(formDTO.getNick()); |
|
|
|
|
|
baseInfo.setHeadImgUrl(formDTO.getAvatarUrl()); |
|
|
|
|
|
baseDao.insert(baseInfo); |
|
|
|
|
|
|
|
|
|
|
|
result.setEpmetUserId(userEntity.getId()); |
|
|
|
|
|
} else { |
|
|
|
|
|
result.setEpmetUserId(baseInfo.getUserId()); |
|
|
|
|
|
LambdaQueryWrapper<RegisterRelationEntity> registerWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
registerWrapper.eq(RegisterRelationEntity::getCustomerId, formDTO.getCustomerId()); |
|
|
|
|
|
registerWrapper.eq(RegisterRelationEntity::getUserId, baseInfo.getUserId()); |
|
|
|
|
|
registerWrapper.eq(RegisterRelationEntity::getFirstRegister, NumConstant.ONE_STR); |
|
|
|
|
|
RegisterRelationEntity registerRelation = registerRelationDao.selectOne(registerWrapper); |
|
|
|
|
|
if (null != registerRelation) { |
|
|
|
|
|
result.setAgencyId(registerRelation.getAgencyId()); |
|
|
|
|
|
result.setGridId(registerRelation.getGridId()); |
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(registerRelation.getGridId()); |
|
|
|
|
|
if (null == gridInfo) { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取网格信息失败", "获取网格信息失败"); |
|
|
|
|
|
} |
|
|
|
|
|
result.setGridName(gridInfo.getGridNamePath()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|