refactor(权限点):保存接口增加返回当前信息
This commit is contained in:
parent
a79b7419d3
commit
60b7f72655
@ -38,7 +38,7 @@ public interface PermissionPointApi {
|
|||||||
|
|
||||||
/** 保存权限点 - 新增或更新 **/
|
/** 保存权限点 - 新增或更新 **/
|
||||||
@PostMapping(value = "/api/v1/permissionPoint/save")
|
@PostMapping(value = "/api/v1/permissionPoint/save")
|
||||||
ApiResult<Void> savePermissionPoint(@RequestBody PermissionPointDTO dto);
|
ApiResult<PermissionPointDTO> savePermissionPoint(@RequestBody PermissionPointDTO dto);
|
||||||
|
|
||||||
/** 删除权限点 - 直接删除 **/
|
/** 删除权限点 - 直接删除 **/
|
||||||
@PostMapping(value = "/api/v1/permissionPoint/delete/{permissionId}")
|
@PostMapping(value = "/api/v1/permissionPoint/delete/{permissionId}")
|
||||||
|
|||||||
@ -156,4 +156,7 @@ public class PermissionPointDTO {
|
|||||||
*/
|
*/
|
||||||
private Integer delegatedType;
|
private Integer delegatedType;
|
||||||
|
|
||||||
|
/** 业务编码 **/
|
||||||
|
private String businessNo;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,4 +25,7 @@ public class PermissionPointTreeQueryReq {
|
|||||||
|
|
||||||
/** 权限点所属工作台 **/
|
/** 权限点所属工作台 **/
|
||||||
private List<String> terminalList;
|
private List<String> terminalList;
|
||||||
|
|
||||||
|
/** 权限点ID列表 **/
|
||||||
|
private List<Long> ids;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class PermissionPointController implements PermissionPointApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResult<Void> savePermissionPoint(PermissionPointDTO dto) {
|
public ApiResult<PermissionPointDTO> savePermissionPoint(PermissionPointDTO dto) {
|
||||||
permissionPointService.save(dto);
|
permissionPointService.save(dto);
|
||||||
return ApiResult.ok();
|
return ApiResult.ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public interface PermissionPointService {
|
|||||||
PermissionPointVO getDetail(Long permissionId);
|
PermissionPointVO getDetail(Long permissionId);
|
||||||
|
|
||||||
/** 保存权限点 **/
|
/** 保存权限点 **/
|
||||||
void save(PermissionPointDTO dto);
|
PermissionPointDTO save(PermissionPointDTO dto);
|
||||||
|
|
||||||
/** 删除权限点 **/
|
/** 删除权限点 **/
|
||||||
void delete(Long permissionId);
|
void delete(Long permissionId);
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import cn.axzo.basics.common.BeanMapper;
|
|||||||
import cn.axzo.basics.common.util.TreeUtil;
|
import cn.axzo.basics.common.util.TreeUtil;
|
||||||
import cn.axzo.framework.domain.web.BizException;
|
import cn.axzo.framework.domain.web.BizException;
|
||||||
import cn.axzo.framework.domain.web.code.BaseCode;
|
import cn.axzo.framework.domain.web.code.BaseCode;
|
||||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
|
||||||
import cn.axzo.tyr.client.model.enums.FeatureType;
|
import cn.axzo.tyr.client.model.enums.FeatureType;
|
||||||
import cn.axzo.tyr.client.model.permission.PermissionPointDTO;
|
import cn.axzo.tyr.client.model.permission.PermissionPointDTO;
|
||||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
||||||
@ -158,7 +157,7 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
|||||||
vo.setPathName(pathName);
|
vo.setPathName(pathName);
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
//所有父级处理
|
//查询所有父级
|
||||||
List<String> split = StrUtil.split(vo.getPath(), FEATURE_PATH_DELIMITER, true, true);
|
List<String> split = StrUtil.split(vo.getPath(), FEATURE_PATH_DELIMITER, true, true);
|
||||||
List<Long> ids = split.stream()
|
List<Long> ids = split.stream()
|
||||||
.filter(x -> !StrUtil.equals(FEATURE_NO_PARENT, x))
|
.filter(x -> !StrUtil.equals(FEATURE_NO_PARENT, x))
|
||||||
@ -167,6 +166,7 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
|||||||
Map<Long, SaasFeature> parentsMapping = this.saasFeatureDao.listByIds(ids)
|
Map<Long, SaasFeature> parentsMapping = this.saasFeatureDao.listByIds(ids)
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.toMap(SaasFeature::getId, Function.identity()));
|
.collect(Collectors.toMap(SaasFeature::getId, Function.identity()));
|
||||||
|
//填充层级父级名称 直接父级信息
|
||||||
for (Long parentId : ids) {
|
for (Long parentId : ids) {
|
||||||
pathName.add(parentsMapping.get(parentId).getFeatureName());
|
pathName.add(parentsMapping.get(parentId).getFeatureName());
|
||||||
}
|
}
|
||||||
@ -180,16 +180,14 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(PermissionPointDTO dto) {
|
public PermissionPointDTO save(PermissionPointDTO dto) {
|
||||||
if (dto.getId() == null) {
|
if (dto.getId() == null) {
|
||||||
doInsert(dto);
|
return doInsert(dto);
|
||||||
} else {
|
|
||||||
doUpdate(dto);
|
|
||||||
}
|
}
|
||||||
|
return doUpdate(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doUpdate(PermissionPointDTO dto) {
|
private PermissionPointDTO doUpdate(PermissionPointDTO dto) {
|
||||||
SaasFeature feature = getAndCheck(dto.getId());
|
SaasFeature feature = getAndCheck(dto.getId());
|
||||||
SaasFeature saasFeature = BeanMapper.copyBean(dto, SaasFeature.class);
|
SaasFeature saasFeature = BeanMapper.copyBean(dto, SaasFeature.class);
|
||||||
//清理不可更新的数据
|
//清理不可更新的数据
|
||||||
@ -198,7 +196,10 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
|||||||
saasFeature.setPath(null);
|
saasFeature.setPath(null);
|
||||||
saasFeature.setSort(null);
|
saasFeature.setSort(null);
|
||||||
saasFeature.setTerminal(null);
|
saasFeature.setTerminal(null);
|
||||||
|
saasFeature.setBusinessNo(null);
|
||||||
this.saasFeatureDao.updateById(saasFeature);
|
this.saasFeatureDao.updateById(saasFeature);
|
||||||
|
dto.setBusinessNo(feature.getBusinessNo());
|
||||||
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SaasFeature getAndCheck(Long permissionId) {
|
private SaasFeature getAndCheck(Long permissionId) {
|
||||||
@ -210,7 +211,7 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
|||||||
return feature;
|
return feature;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doInsert(PermissionPointDTO dto) {
|
private PermissionPointDTO doInsert(PermissionPointDTO dto) {
|
||||||
SaasFeature saasFeature = BeanMapper.copyBean(dto, SaasFeature.class);
|
SaasFeature saasFeature = BeanMapper.copyBean(dto, SaasFeature.class);
|
||||||
SaasFeature parent;
|
SaasFeature parent;
|
||||||
if (dto.getParentId() == null || dto.getParentId() < 1) {
|
if (dto.getParentId() == null || dto.getParentId() < 1) {
|
||||||
@ -225,6 +226,9 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
|||||||
saasFeature.setParentBusinessNo(parent.getBusinessNo());
|
saasFeature.setParentBusinessNo(parent.getBusinessNo());
|
||||||
saasFeature.setPath(parent.getPath() + parent.getId() + FEATURE_PATH_DELIMITER);
|
saasFeature.setPath(parent.getPath() + parent.getId() + FEATURE_PATH_DELIMITER);
|
||||||
this.saasFeatureDao.save(saasFeature);
|
this.saasFeatureDao.save(saasFeature);
|
||||||
|
dto.setId(saasFeature.getId());
|
||||||
|
dto.setBusinessNo(saasFeature.getBusinessNo());
|
||||||
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Throwable.class)
|
@Transactional(rollbackFor = Throwable.class)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user