|
@ -24,12 +24,15 @@ import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
|
|
import com.epmet.constant.UserConstant; |
|
|
import com.epmet.dao.UserRoleDao; |
|
|
import com.epmet.dao.UserRoleDao; |
|
|
|
|
|
import com.epmet.dto.RoleDTO; |
|
|
import com.epmet.dto.UserRoleDTO; |
|
|
import com.epmet.dto.UserRoleDTO; |
|
|
import com.epmet.dto.form.UserRoleFormDTO; |
|
|
import com.epmet.dto.form.UserRoleFormDTO; |
|
|
import com.epmet.dto.result.UserRoleResultDTO; |
|
|
import com.epmet.dto.result.UserRoleResultDTO; |
|
|
import com.epmet.entity.UserRoleEntity; |
|
|
import com.epmet.entity.UserRoleEntity; |
|
|
import com.epmet.redis.UserRoleRedis; |
|
|
import com.epmet.redis.UserRoleRedis; |
|
|
|
|
|
import com.epmet.service.RoleService; |
|
|
import com.epmet.service.UserRoleService; |
|
|
import com.epmet.service.UserRoleService; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
@ -41,7 +44,7 @@ import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用户角色关系表 |
|
|
* 用户角色关系表 |
|
|
* |
|
|
* |
|
|
* @author generator generator@elink-cn.com |
|
|
* @author generator generator@elink-cn.com |
|
|
* @since v1.0.0 2020-03-30 |
|
|
* @since v1.0.0 2020-03-30 |
|
@ -49,71 +52,85 @@ import java.util.Map; |
|
|
@Service |
|
|
@Service |
|
|
public class UserRoleServiceImpl extends BaseServiceImpl<UserRoleDao, UserRoleEntity> implements UserRoleService { |
|
|
public class UserRoleServiceImpl extends BaseServiceImpl<UserRoleDao, UserRoleEntity> implements UserRoleService { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private UserRoleRedis userRoleRedis; |
|
|
private UserRoleRedis userRoleRedis; |
|
|
|
|
|
@Autowired |
|
|
@Override |
|
|
private RoleService roleService; |
|
|
public PageData<UserRoleDTO> page(Map<String, Object> params) { |
|
|
|
|
|
IPage<UserRoleEntity> page = baseDao.selectPage( |
|
|
@Override |
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
public PageData<UserRoleDTO> page(Map<String, Object> params) { |
|
|
getWrapper(params) |
|
|
IPage<UserRoleEntity> page = baseDao.selectPage( |
|
|
); |
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
return getPageData(page, UserRoleDTO.class); |
|
|
getWrapper(params) |
|
|
} |
|
|
); |
|
|
|
|
|
return getPageData(page, UserRoleDTO.class); |
|
|
@Override |
|
|
} |
|
|
public List<UserRoleDTO> list(Map<String, Object> params) { |
|
|
|
|
|
List<UserRoleEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
@Override |
|
|
|
|
|
public List<UserRoleDTO> list(Map<String, Object> params) { |
|
|
return ConvertUtils.sourceToTarget(entityList, UserRoleDTO.class); |
|
|
List<UserRoleEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
} |
|
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, UserRoleDTO.class); |
|
|
private QueryWrapper<UserRoleEntity> getWrapper(Map<String, Object> params){ |
|
|
} |
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
|
private QueryWrapper<UserRoleEntity> getWrapper(Map<String, Object> params) { |
|
|
QueryWrapper<UserRoleEntity> wrapper = new QueryWrapper<>(); |
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
|
QueryWrapper<UserRoleEntity> wrapper = new QueryWrapper<>(); |
|
|
return wrapper; |
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
} |
|
|
|
|
|
|
|
|
return wrapper; |
|
|
@Override |
|
|
} |
|
|
public UserRoleDTO get(String id) { |
|
|
|
|
|
UserRoleEntity entity = baseDao.selectById(id); |
|
|
@Override |
|
|
return ConvertUtils.sourceToTarget(entity, UserRoleDTO.class); |
|
|
public UserRoleDTO get(String id) { |
|
|
} |
|
|
UserRoleEntity entity = baseDao.selectById(id); |
|
|
|
|
|
return ConvertUtils.sourceToTarget(entity, UserRoleDTO.class); |
|
|
@Override |
|
|
} |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void save(UserRoleDTO dto) { |
|
|
@Override |
|
|
UserRoleEntity entity = ConvertUtils.sourceToTarget(dto, UserRoleEntity.class); |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
insert(entity); |
|
|
public void save(UserRoleDTO dto) { |
|
|
} |
|
|
UserRoleEntity entity = ConvertUtils.sourceToTarget(dto, UserRoleEntity.class); |
|
|
|
|
|
insert(entity); |
|
|
@Override |
|
|
} |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void update(UserRoleDTO dto) { |
|
|
@Override |
|
|
UserRoleEntity entity = ConvertUtils.sourceToTarget(dto, UserRoleEntity.class); |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
updateById(entity); |
|
|
public void update(UserRoleDTO dto) { |
|
|
} |
|
|
UserRoleEntity entity = ConvertUtils.sourceToTarget(dto, UserRoleEntity.class); |
|
|
|
|
|
updateById(entity); |
|
|
@Override |
|
|
} |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void delete(String[] ids) { |
|
|
@Override |
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
public void delete(String[] ids) { |
|
|
} |
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
/** |
|
|
} |
|
|
* @Description 根据用户Id、来源app、客户Id查询用户角色 |
|
|
|
|
|
* @Param userRoleFormDTO |
|
|
/** |
|
|
* @return UserRoleResultDTO |
|
|
* @return UserRoleResultDTO |
|
|
* @Author wangc |
|
|
* @Description 根据用户Id、来源app、客户Id查询用户角色 |
|
|
* @Date 2020.03.30 15:35 |
|
|
* @Param userRoleFormDTO |
|
|
**/ |
|
|
* @Author wangc |
|
|
@Override |
|
|
* @Date 2020.03.30 15:35 |
|
|
public Result<List<UserRoleResultDTO>> getUserRoleInfo(UserRoleFormDTO userRoleFormDTO) { |
|
|
**/ |
|
|
return new Result<List<UserRoleResultDTO>>().ok(baseDao.getUserRoleInfo(userRoleFormDTO)); |
|
|
@Override |
|
|
} |
|
|
public Result<List<UserRoleResultDTO>> getUserRoleInfo(UserRoleFormDTO userRoleFormDTO) { |
|
|
|
|
|
return new Result<List<UserRoleResultDTO>>().ok(baseDao.getUserRoleInfo(userRoleFormDTO)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Result saveUserRole(UserRoleDTO userRoleDTO) { |
|
|
|
|
|
//获取角色ID
|
|
|
|
|
|
RoleDTO roleDTO = new RoleDTO(); |
|
|
|
|
|
roleDTO.setApp(UserConstant.APP_RESI); |
|
|
|
|
|
roleDTO.setRoleKey(userRoleDTO.getRoleKey()); |
|
|
|
|
|
RoleDTO role = roleService.getRoleByKey(roleDTO); |
|
|
|
|
|
userRoleDTO.setRoleId(role.getId()); |
|
|
|
|
|
baseDao.insert(ConvertUtils.sourceToTarget(userRoleDTO, UserRoleEntity.class)); |
|
|
|
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |