|
|
@ -19,24 +19,33 @@ package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.EpmetRoleKeyConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.UserRoleDao; |
|
|
|
import com.epmet.dto.RoleDTO; |
|
|
|
import com.epmet.dto.UserResiInfoDTO; |
|
|
|
import com.epmet.dto.UserRoleDTO; |
|
|
|
import com.epmet.dto.form.UserRoleFormDTO; |
|
|
|
import com.epmet.dto.result.UserRoleResultDTO; |
|
|
|
import com.epmet.entity.UserRoleEntity; |
|
|
|
import com.epmet.redis.UserRoleRedis; |
|
|
|
import com.epmet.service.RoleService; |
|
|
|
import com.epmet.service.UserRoleService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -49,8 +58,13 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class UserRoleServiceImpl extends BaseServiceImpl<UserRoleDao, UserRoleEntity> implements UserRoleService { |
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(UserRoleServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private UserRoleRedis userRoleRedis; |
|
|
|
@Autowired |
|
|
|
private RoleService roleService; |
|
|
|
@Autowired |
|
|
|
private UserRoleDao userRoleDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<UserRoleDTO> page(Map<String, Object> params) { |
|
|
@ -105,9 +119,9 @@ public class UserRoleServiceImpl extends BaseServiceImpl<UserRoleDao, UserRoleEn |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return UserRoleResultDTO |
|
|
|
* @Description 根据用户Id、来源app、客户Id查询用户角色 |
|
|
|
* @Param userRoleFormDTO |
|
|
|
* @return UserRoleResultDTO |
|
|
|
* @Author wangc |
|
|
|
* @Date 2020.03.30 15:35 |
|
|
|
**/ |
|
|
@ -116,4 +130,33 @@ public class UserRoleServiceImpl extends BaseServiceImpl<UserRoleDao, UserRoleEn |
|
|
|
return new Result<List<UserRoleResultDTO>>().ok(baseDao.getUserRoleInfo(userRoleFormDTO)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 居民注册成功添加居民角色 |
|
|
|
* @Author sun |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public Result saveResiRole(UserResiInfoDTO userResiInfoDTO) { |
|
|
|
//1:查询角色Id
|
|
|
|
RoleDTO roleDTO = new RoleDTO(); |
|
|
|
roleDTO.setApp(userResiInfoDTO.getApp()); |
|
|
|
roleDTO.setRoleKey(EpmetRoleKeyConstant.REGISTERED_RESI); |
|
|
|
Result<RoleDTO> result = roleService.getRoleByKey(roleDTO); |
|
|
|
RoleDTO role = result.getData(); |
|
|
|
//2:新增角色数据
|
|
|
|
UserRoleDTO userRoleDTO = new UserRoleDTO(); |
|
|
|
userRoleDTO.setCustomerId(userResiInfoDTO.getCustomerId()); |
|
|
|
userRoleDTO.setUserId(userResiInfoDTO.getUserId()); |
|
|
|
userRoleDTO.setRoleId(role.getId()); |
|
|
|
Date date = new Date(); |
|
|
|
userRoleDTO.setId(IdWorker.get32UUID()); |
|
|
|
userRoleDTO.setDelFlag(NumConstant.ZERO); |
|
|
|
userRoleDTO.setRevision(NumConstant.ZERO); |
|
|
|
userRoleDTO.setCreatedBy(userResiInfoDTO.getUserId()); |
|
|
|
userRoleDTO.setCreatedTime(date); |
|
|
|
userRoleDTO.setUpdatedBy(userResiInfoDTO.getUserId()); |
|
|
|
userRoleDTO.setUpdatedTime(date); |
|
|
|
userRoleDao.saveResiRole(userRoleDTO); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
} |