MCPcopy Create free account
hub / github.com/EhsanTang/ApiManager / v6ToV7

Method v6ToV7

api/src/test/java/unitTest/Update.java:56–102  ·  view source on GitHub ↗

V6版本升级成V7版本,下载源代码后,请执行该方法升级数据库 需要提供接口(有些用户没有下载源码,直接安装的无法执行该代码) @throws IOException @throws MyException

()

Source from the content-addressed store, hash-verified

54 * @throws MyException
55 */
56 @Test
57 public void v6ToV7() throws MyException, IOException{
58 for(Module module : moduleService.findByMap(null, null,null)){
59 // 请除无效module
60 if(MyString.isEmpty(module.getProjectId())){
61 moduleService.delete(module);
62 }else{
63 Project project = projectService.get(module.getProjectId());
64 Module p = moduleService.get(module.getProjectId());
65 if(MyString.isEmpty(project.getId()) && !MyString.isEmpty(p.getId())){
66 // 新建项目
67 project.setId(p.getId());
68 project.setCreateTime(p.getCreateTime());
69 project.setName(p.getName());
70 project.setRemark(p.getRemark());
71 project.setSequence(p.getSequence());
72 project.setStatus(ProjectStatus.COMMON.getStatus());
73 project.setType(ProjectType.PRIVATE.getType());
74 project.setUserId(p.getUserId());
75 projectService.save(project);
76 projectService.update("update Project set id='"+p.getId()+"' where id = '"+project.getId()+"'", null);
77 }
78 }
79
80 }
81 // 同步数据字典,从项目迁移到模块,项目下没有模块则不迁移
82 for(Article article: articleService.findByMap(Tools.getMap("type", ArticleType.DICTIONARY.name()), null, null)){
83 Project p = projectService.get(article.getModuleId());
84 if(MyString.isEmpty(p.getId())){
85 articleService.delete(article);
86 }else{
87 List<Module> modules = moduleService.findByMap(Tools.getMap("projectId", p.getId()), null, null);
88 if(modules.size()>0){
89 article.setModuleId(modules.get(0).getId());
90 articleService.update(article);
91 }
92 }
93 }
94
95 // 删除模块中的项目
96 for(Module module : moduleService.findByMap(null, null,null)){
97 if(MyString.isEmpty(module.getProjectId())){
98 moduleService.delete(module);
99 }
100 }
101
102 }
103
104}

Callers

nothing calls this directly

Calls 15

isEmptyMethod · 0.95
setNameMethod · 0.95
getNameMethod · 0.95
setRemarkMethod · 0.95
getRemarkMethod · 0.95
setTypeMethod · 0.95
setUserIdMethod · 0.95
getUserIdMethod · 0.95
getMapMethod · 0.95
setSequenceMethod · 0.80
getSequenceMethod · 0.80
setStatusMethod · 0.80

Tested by

no test coverage detected