|
|
@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
@ -30,6 +31,7 @@ import com.epmet.dao.GovStaffRoleTemplateDao; |
|
|
|
import com.epmet.dao.RoleDao; |
|
|
|
import com.epmet.dto.GovStaffRoleDTO; |
|
|
|
import com.epmet.dto.form.InitDefaultOperationsFormDTO; |
|
|
|
import com.epmet.dto.form.UpGovRoleFormDTO; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.GovStaffRoleEntity; |
|
|
|
import com.epmet.feign.GovAccessFeignClient; |
|
|
@ -42,10 +44,10 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 政府端角色表 |
|
|
@ -135,6 +137,22 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go |
|
|
|
return baseDao.listRolesByStaffId(staffId, orgId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询用户角色 |
|
|
|
* |
|
|
|
* @param staffIds |
|
|
|
* @param orgId |
|
|
|
* @return java.util.Map<java.lang.String, java.util.List < java.lang.String>> |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2021/7/1 15:30 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String, List<String>> getStaffRoles(List<String> staffIds, String orgId) { |
|
|
|
List<GovStaffRoleEntity> staffRoleList = baseDao.getStaffRoles(staffIds, orgId); |
|
|
|
return staffRoleList.stream().collect(Collectors.groupingBy(GovStaffRoleEntity::getCustomerId, |
|
|
|
Collectors.mapping(GovStaffRoleEntity :: getId, Collectors.toList()))); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<GovStaffRoleDTO> getGovStaffRoleList(GovStaffRoleDTO dto) { |
|
|
|
return baseDao.selectGovStaffRoleList(dto); |
|
|
@ -182,7 +200,34 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<GovStaffRoleResultDTO> listRolesByCustomer(String customerId) { |
|
|
|
return govStaffRoleDao.listRolesByCustomer(customerId); |
|
|
|
List<GovStaffRoleResultDTO> resultList = new ArrayList<>(); |
|
|
|
//1.查询系统默认角色列表数据
|
|
|
|
resultList = govStaffRoleTemplateDao.defaultRoleList(); |
|
|
|
//2.查询客户角色权限列表数据
|
|
|
|
List<GovStaffRoleResultDTO> cuList = govStaffRoleDao.listRolesByCustomer(customerId); |
|
|
|
//3.封装数据并返回
|
|
|
|
resultList.forEach(re -> { |
|
|
|
cuList.forEach(cu -> { |
|
|
|
if (re.getDefRoleKey().equals(cu.getRoleKey())) { |
|
|
|
re.setCustomerId(cu.getCustomerId()); |
|
|
|
re.setRoleId(cu.getRoleId()); |
|
|
|
re.setRoleKey(cu.getRoleKey()); |
|
|
|
re.setRoleName(cu.getRoleName()); |
|
|
|
re.setDescription(cu.getDescription()); |
|
|
|
re.setSort(cu.getSort()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
//4.按客户权限顺序排序
|
|
|
|
if(cuList.size()>NumConstant.ZERO){ |
|
|
|
Collections.sort(resultList, new Comparator<GovStaffRoleResultDTO>() { |
|
|
|
@Override |
|
|
|
public int compare(GovStaffRoleResultDTO o1, GovStaffRoleResultDTO o2) { |
|
|
|
return o1.getSort().compareTo(o2.getSort()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -221,12 +266,11 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go |
|
|
|
return govStaffRoleDao.updateColumnsById(roleId, roleName); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public void saveSortOrder(List<String> roleIdList) { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void saveSortOrder(String userId, List<String> roleIdList) { |
|
|
|
for (int i = 0 ; i < roleIdList.size() ; i++) { |
|
|
|
int r = govStaffRoleDao.updateSortById(roleIdList.get(i), i); |
|
|
|
System.out.println(r); |
|
|
|
int r = govStaffRoleDao.updateSortById(roleIdList.get(i), i, userId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -264,4 +308,41 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl<GovStaffRoleDao, Go |
|
|
|
}); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 默认权限保存排序 |
|
|
|
* @Author sun |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void saveDefaultSort(String userId, List<String> roleIdList) { |
|
|
|
for (int i = 0; i < roleIdList.size(); i++) { |
|
|
|
govStaffRoleTemplateDao.updateSortById(roleIdList.get(i), i, userId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @Description 修改角色名称或职责描述 |
|
|
|
* @Author sun |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void updateDefaultRole(UpGovRoleFormDTO formDTO) { |
|
|
|
if (govStaffRoleTemplateDao.upNameOrDescription(formDTO) < NumConstant.ONE) { |
|
|
|
throw new RenException("修改角色信息失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @Description 修改客户角色名称或职责描述 |
|
|
|
* @Author sun |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void updateCustomerRole(UpGovRoleFormDTO formDTO) { |
|
|
|
if (govStaffRoleDao.upNameOrDescription(formDTO) < NumConstant.ONE) { |
|
|
|
throw new RenException("修改角色信息失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |