You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.1 KiB
82 lines
3.1 KiB
package com.ccsens.carbasics.service;
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.ccsens.carbasics.bean.dto.RoleDto;
|
|
import com.ccsens.carbasics.bean.vo.RoleVo;
|
|
import com.ccsens.carbasics.persist.dao.RoleCarDao;
|
|
import com.ccsens.carbasics.util.Constant;
|
|
import com.ccsens.common.bean.dto.CRoleDto;
|
|
import com.ccsens.common.bean.po.ProRole;
|
|
import com.ccsens.common.bean.vo.CRoleVo;
|
|
import com.ccsens.common.persist.dao.ProRoleDao;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author AUSU
|
|
*/
|
|
@Slf4j
|
|
@Service
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public class RoleCarService implements IRoleCarService {
|
|
|
|
@Resource
|
|
private ProRoleDao proRoleDao;
|
|
@Resource
|
|
private RoleCarDao roleCarDao;
|
|
|
|
@Override
|
|
public CRoleVo.QueryRole queryShowRoleCar(CRoleDto.QueryRoleById param, Long userId) {
|
|
//返回的对象
|
|
CRoleVo.QueryRole queryRole = new CRoleVo.QueryRole();
|
|
List<CRoleVo.RoleInfo> visibleList = new ArrayList<>();
|
|
List<CRoleVo.RoleInfo> invisibleList = new ArrayList<>();
|
|
//查询当前用户在项目下的角色,没有则算作关注者
|
|
List<ProRole> userRoleList = proRoleDao.queryRoleByUserId(param.getProjectId(),userId);
|
|
//查询平车角色
|
|
CRoleVo.RoleInfo carRole = proRoleDao.queryByName(Constant.CAR_ROLE_NAME, param.getProjectId());
|
|
if (CollectionUtil.isNotEmpty(userRoleList)) {
|
|
if (1 < userRoleList.size()) {
|
|
userRoleList.forEach(userRole -> {
|
|
if ("创建者".equals(userRole.getName())) {
|
|
return;
|
|
}
|
|
if (CollectionUtil.isEmpty(visibleList)) {
|
|
CRoleVo.RoleInfo userRoleInfo = new CRoleVo.RoleInfo();
|
|
BeanUtil.copyProperties(userRole,userRoleInfo);
|
|
visibleList.add(userRoleInfo);
|
|
}else {
|
|
CRoleVo.RoleInfo userRoleInfo = new CRoleVo.RoleInfo();
|
|
BeanUtil.copyProperties(userRole,userRoleInfo);
|
|
invisibleList.add(userRoleInfo);
|
|
}
|
|
});
|
|
}else {
|
|
CRoleVo.RoleInfo userRoleInfo = new CRoleVo.RoleInfo();
|
|
BeanUtil.copyProperties(userRoleList.get(0),userRoleInfo);
|
|
visibleList.add(userRoleInfo);
|
|
}
|
|
}
|
|
if (ObjectUtil.isNotNull(carRole)) {
|
|
visibleList.add(carRole);
|
|
}
|
|
queryRole.setVisibleList(visibleList);
|
|
queryRole.setInvisibleList(invisibleList);
|
|
//查询平车角色
|
|
return queryRole;
|
|
}
|
|
|
|
@Override
|
|
public List<RoleVo.RoleInfo> queryMustShow(RoleDto.QueryMustShow param, Long userId) {
|
|
return roleCarDao.queryMustShow(param);
|
|
}
|
|
|
|
}
|
|
|