Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102
This commit is contained in:
commit
3766422f3b
@ -26,7 +26,7 @@ import java.util.List;
|
||||
public interface SaasBasicDictApi {
|
||||
|
||||
/**
|
||||
* 获取字典树所有节点
|
||||
* 获取字典树节点
|
||||
*
|
||||
* @param req 根据自身需求传入参数
|
||||
* @return
|
||||
@ -42,11 +42,11 @@ public interface SaasBasicDictApi {
|
||||
*/
|
||||
@PostMapping("api/dict/node-tree")
|
||||
ApiResult<List<BasicDictTreeResp>> getBasicDictNodeTree(
|
||||
@EnumValidator(enumClass = DictTypeFiledEnum.class, message = "枚举类型错误")
|
||||
DictTypeFiledEnum type);
|
||||
@EnumValidator(enumClass = DictTypeFiledEnum.class, message = "枚举类型错误")
|
||||
DictTypeFiledEnum type);
|
||||
|
||||
/**
|
||||
* 获取字典节点详情
|
||||
* 通过type和code获取字典节点详情
|
||||
*
|
||||
* @param req 传入type和code
|
||||
* @return
|
||||
@ -58,16 +58,17 @@ public interface SaasBasicDictApi {
|
||||
* 添加字典
|
||||
*
|
||||
* @param req 其中name同一个父级节点,名称不能重复,codeMap全局唯一
|
||||
* @return
|
||||
* @return 节点id
|
||||
*/
|
||||
@PostMapping("api/dict/create")
|
||||
ApiResult<Long> create(@RequestBody @Validated BasicDictCreateReq req);
|
||||
|
||||
/**
|
||||
* 编辑字典
|
||||
* 目前只支持更新字典名称
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
* @param req 字典id和name
|
||||
* @return 更新状态
|
||||
*/
|
||||
@PostMapping("api/dict/update")
|
||||
ApiResult<Boolean> update(@RequestBody @Validated BasicDictUpdateReq req);
|
||||
@ -75,12 +76,18 @@ public interface SaasBasicDictApi {
|
||||
/**
|
||||
* 更新字典状态
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
* @param req 字典id和status
|
||||
* @return 更新状态
|
||||
*/
|
||||
@PostMapping("api/dict//update-status")
|
||||
@PostMapping("api/dict/update-status")
|
||||
ApiResult<Boolean> updateStatus(@RequestBody @Validated BasicDictUpdateStatusReq req);
|
||||
|
||||
/**
|
||||
* 通过id获取字典节点
|
||||
*
|
||||
* @param id 节点id
|
||||
* @return 一个字典节点
|
||||
*/
|
||||
@GetMapping("api/dict/get")
|
||||
ApiResult<BasicDictNodeResp> get(@RequestParam Long id);
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public class BasicDictQueryReq {
|
||||
/**
|
||||
* 字典code
|
||||
*/
|
||||
private String code;
|
||||
private List<String> codes;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
package cn.axzo.tyr.server.repository;
|
||||
|
||||
import cn.axzo.basics.common.BeanMapper;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictNodeReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictQueryReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictUpdateReq;
|
||||
import cn.axzo.tyr.client.model.dict.request.BasicDictUpdateStatusReq;
|
||||
import cn.axzo.tyr.client.model.dict.response.BasicDictNodeResp;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasBasicDict;
|
||||
import cn.axzo.tyr.server.repository.mapper.SaasBasicDictMapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -27,12 +29,10 @@ public class SaasBasicDictDao extends ServiceImpl<SaasBasicDictMapper, SaasBasic
|
||||
public List<BasicDictNodeResp> getBasicDictNodeList(BasicDictQueryReq req) {
|
||||
LambdaQueryChainWrapper<SaasBasicDict> queryChainWrapper = lambdaQuery();
|
||||
if (Objects.nonNull(req)) {
|
||||
queryChainWrapper
|
||||
.in(!CollectionUtils.isEmpty(req.getIds()), SaasBasicDict::getId, req.getIds())
|
||||
.eq(Objects.nonNull(req.getParentId()), SaasBasicDict::getParentId, req.getParentId())
|
||||
queryChainWrapper.eq(Objects.nonNull(req.getParentId()), SaasBasicDict::getParentId, req.getParentId())
|
||||
.eq(Objects.nonNull(req.getWorkspaceType()), SaasBasicDict::getWorkspaceType, Objects.nonNull(req.getWorkspaceType()) ? req.getWorkspaceType().getValue() : "")
|
||||
.eq(Objects.nonNull(req.getType()), SaasBasicDict::getType, Objects.nonNull(req.getType()) ? req.getType().getValue() : "")
|
||||
.eq(Objects.nonNull(req.getCode()), SaasBasicDict::getCode, req.getCode())
|
||||
.in(Objects.nonNull(req.getCodes()), SaasBasicDict::getCode, req.getCodes())
|
||||
.eq(Objects.nonNull(req.getStatus()), SaasBasicDict::getStatus, Boolean.TRUE.equals(req.getStatus()) ? 1 : 0)
|
||||
.like(Objects.nonNull(req.getName()), SaasBasicDict::getName, req.getName());
|
||||
}
|
||||
@ -46,4 +46,18 @@ public class SaasBasicDictDao extends ServiceImpl<SaasBasicDictMapper, SaasBasic
|
||||
.one();
|
||||
return BeanMapper.copyBean(saasBasicDict, BasicDictNodeResp.class, (s, b) -> b.setStatus(s.getStatus() == 1));
|
||||
}
|
||||
|
||||
public ApiResult<Boolean> updateStatus(BasicDictUpdateStatusReq req) {
|
||||
boolean update = lambdaUpdate().eq(SaasBasicDict::getId, req.getId())
|
||||
.set(SaasBasicDict::getStatus, req.getStatus() ? 1 : 0)
|
||||
.update();
|
||||
return ApiResult.ok(update);
|
||||
}
|
||||
|
||||
public ApiResult<Boolean> update(BasicDictUpdateReq req) {
|
||||
boolean update = lambdaUpdate().eq(SaasBasicDict::getId, req.getId())
|
||||
.set(SaasBasicDict::getName, req.getId())
|
||||
.update();
|
||||
return ApiResult.ok(update);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,7 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
||||
|
||||
/**
|
||||
* 获取节点树
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@ -48,7 +49,7 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
||||
// 获取所有节点
|
||||
List<BasicDictNodeResp> basicDictNodeList = saasBasicDictDao.getBasicDictNodeList(null);
|
||||
// 单侧树
|
||||
if (Objects.nonNull(type)){
|
||||
if (Objects.nonNull(type)) {
|
||||
List<BasicDictNodeResp> unilateralTreeNodeList = basicDictNodeList.stream()
|
||||
.filter(b -> b.getType().equals(type.getValue()) || b.getType().equals(DictTypeFiledEnum.WORKSPACE.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
@ -59,6 +60,7 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
||||
|
||||
/**
|
||||
* 根据节点列表构建节点树
|
||||
*
|
||||
* @param nodeList 节点列表
|
||||
* @return 节点树
|
||||
*/
|
||||
@ -73,17 +75,17 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
||||
nodeList.forEach(node -> {
|
||||
BasicDictTreeResp treeNode = BeanMapper.copyBean(node, BasicDictTreeResp.class);
|
||||
map.put(node.getId(), treeNode);
|
||||
if (node.getParentId() == 0){
|
||||
if (node.getParentId() == 0) {
|
||||
root.add(treeNode);
|
||||
}
|
||||
});
|
||||
map.values().forEach(treeNode -> {
|
||||
BasicDictTreeResp parent = map.get(treeNode.getParentId());
|
||||
if (Objects.nonNull(parent)){
|
||||
if (Objects.isNull(parent.getChildren())){
|
||||
parent.setChildren(new ArrayList<>());
|
||||
}
|
||||
parent.getChildren().add(treeNode);
|
||||
if (Objects.nonNull(parent)) {
|
||||
if (Objects.isNull(parent.getChildren())) {
|
||||
parent.setChildren(new ArrayList<>());
|
||||
}
|
||||
parent.getChildren().add(treeNode);
|
||||
}
|
||||
});
|
||||
|
||||
@ -108,12 +110,12 @@ public class SaasBasicDictServiceImpl implements SaasBasicDictService {
|
||||
|
||||
@Override
|
||||
public ApiResult<Boolean> update(BasicDictUpdateReq req) {
|
||||
return null;
|
||||
return saasBasicDictDao.update(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Boolean> updateStauts(BasicDictUpdateStatusReq req) {
|
||||
return null;
|
||||
return saasBasicDictDao.updateStatus(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user