最新一版2.0
parent
8e16bf16a9
commit
dd88506d9e
|
@ -10,10 +10,7 @@ import net.srt.framework.common.utils.Result;
|
||||||
import net.srt.framework.common.utils.TreeNodeVo;
|
import net.srt.framework.common.utils.TreeNodeVo;
|
||||||
import net.srt.service.MetamodelService;
|
import net.srt.service.MetamodelService;
|
||||||
import net.srt.vo.MetamodelVO;
|
import net.srt.vo.MetamodelVO;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -38,4 +35,11 @@ public class MetamodelController {
|
||||||
MetamodelEntity entity = metamodelService.getById(id);
|
MetamodelEntity entity = metamodelService.getById(id);
|
||||||
return Result.ok(MetamodelConvert.INSTANCE.convert(entity));
|
return Result.ok(MetamodelConvert.INSTANCE.convert(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary = "保存")
|
||||||
|
public Result<String> save(@RequestBody MetamodelVO vo){
|
||||||
|
metamodelService.save(vo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,12 @@ package net.srt.service;
|
||||||
import net.srt.entity.MetamodelEntity;
|
import net.srt.entity.MetamodelEntity;
|
||||||
import net.srt.framework.common.utils.TreeNodeVo;
|
import net.srt.framework.common.utils.TreeNodeVo;
|
||||||
import net.srt.framework.mybatis.service.BaseService;
|
import net.srt.framework.mybatis.service.BaseService;
|
||||||
|
import net.srt.vo.MetamodelVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface MetamodelService extends BaseService<MetamodelEntity> {
|
public interface MetamodelService extends BaseService<MetamodelEntity> {
|
||||||
List<TreeNodeVo> listTree();
|
List<TreeNodeVo> listTree();
|
||||||
|
|
||||||
|
void save(MetamodelVO vo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.srt.service.impl;
|
package net.srt.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import net.srt.convert.MetamodelConvert;
|
||||||
import net.srt.dao.MetamodelDao;
|
import net.srt.dao.MetamodelDao;
|
||||||
import net.srt.entity.MetamodelEntity;
|
import net.srt.entity.MetamodelEntity;
|
||||||
import net.srt.framework.common.utils.BeanUtil;
|
import net.srt.framework.common.utils.BeanUtil;
|
||||||
|
@ -8,7 +9,9 @@ import net.srt.framework.common.utils.BuildTreeUtils;
|
||||||
import net.srt.framework.common.utils.TreeNodeVo;
|
import net.srt.framework.common.utils.TreeNodeVo;
|
||||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.srt.service.MetamodelService;
|
import net.srt.service.MetamodelService;
|
||||||
|
import net.srt.vo.MetamodelVO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
|
@ -32,4 +35,35 @@ public class MetamodelServiceImpl extends BaseServiceImpl<MetamodelDao, Metamode
|
||||||
});
|
});
|
||||||
return BuildTreeUtils.buildTree(treeNodeVos);
|
return BuildTreeUtils.buildTree(treeNodeVos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(MetamodelVO vo) {
|
||||||
|
MetamodelEntity entity = MetamodelConvert.INSTANCE.convert(vo);
|
||||||
|
entity.setPath(recursionPath(entity,null));
|
||||||
|
entity.setProjectId(getProjectId());
|
||||||
|
entity.setBuiltin(0);
|
||||||
|
buildField(entity);
|
||||||
|
baseMapper.insert(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildField(MetamodelEntity entity) {
|
||||||
|
if(entity.getIfLeaf() == 0){
|
||||||
|
entity.setIcon("/src/assets/model.png");
|
||||||
|
}else {
|
||||||
|
entity.setIcon("/src/assets/folder.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String recursionPath(MetamodelEntity metamodelEntity,String path){
|
||||||
|
if(StringUtil.isBlank(path)){
|
||||||
|
path = metamodelEntity.getName();
|
||||||
|
}
|
||||||
|
if(metamodelEntity.getParentId()!=0){
|
||||||
|
MetamodelEntity parent = getById(metamodelEntity.getParentId());
|
||||||
|
path = parent.getName() + "/" + path;
|
||||||
|
return recursionPath(parent,path);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue