forked from gitee/vben-java
增加服务器监控,迁移定时任务与登录日志到系统监控下,增加表单设计器单独使用,单表CRUD代码生成器
This commit is contained in:
@@ -40,7 +40,7 @@ public class SaAgentMain extends BaseMainEntity {
|
||||
private String level;//代理商资质
|
||||
|
||||
@Column(length = 32)
|
||||
private String senum;//流程号
|
||||
private String senum;//流水号
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String notes;
|
||||
|
||||
+15
-23
@@ -6,11 +6,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import vboot.app.module.te.allot.check.Zcheck;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.module.ass.addr.main.AssAddrMainHand;
|
||||
import vboot.core.module.ass.num.main.AssNumMainService;
|
||||
import vboot.core.xutil.file.ExcelUtil;
|
||||
import vboot.core.xutil.file.excel.ExcelResult;
|
||||
@@ -29,7 +27,7 @@ import java.util.Map;
|
||||
public class SaAgentMainApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name, String catid) {
|
||||
public R get(String name, String catid) {
|
||||
CompiledScript script = ScriptUtil.compile("var map={};var a=1;var b=2;map.xx="
|
||||
+ XnumberUtil.getRandom6() +"+a+b;map");
|
||||
try {
|
||||
@@ -42,19 +40,18 @@ public class SaAgentMainApi {
|
||||
Sqler sqler = new Sqler("sa_agent_main");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.addre,t.senum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@PostMapping("imp")
|
||||
public RestResult postImp(@RequestPart("file") MultipartFile file) throws Exception {
|
||||
public R postImp(@RequestPart("file") MultipartFile file) throws Exception {
|
||||
ExcelResult<Student> result = ExcelUtil.importExcel(file.getInputStream(), Student.class, new StudentImportListener());
|
||||
System.out.println(result);
|
||||
return RestResult.ok(result);
|
||||
// return RestResult.error(result);
|
||||
return R.ok(result);
|
||||
// return R.error(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("exp")
|
||||
public void getExp(HttpServletResponse response) throws Exception {
|
||||
Sqler sqler=new Sqler("t.id,t.name,t.crtim,t.uptim","sa_agent_main");
|
||||
@@ -90,32 +87,27 @@ public class SaAgentMainApi {
|
||||
return students;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
|
||||
SaAgentMain main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody SaAgentMain main) {
|
||||
String num = numService.getNum("AGENT");
|
||||
main.setSenum(num);
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody SaAgentMain main) {
|
||||
main.setSenum(numService.getNum("AGENT"));
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SaAgentMain main) {
|
||||
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody SaAgentMain main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -2,7 +2,7 @@ package vboot.app.module.sa.cust.main;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
|
||||
@@ -12,44 +12,44 @@ public class SaCustMainApi {
|
||||
|
||||
//分页查询项目清单
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("sa_cust_main");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.notes");
|
||||
return RestResult.ok(jdbcDao.findPageData(sqler));
|
||||
return R.ok(jdbcDao.findPageData(sqler));
|
||||
}
|
||||
|
||||
//查询单个项目
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
SaCustMain main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
//新增项目
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody SaCustMain main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody SaCustMain main) {
|
||||
return R.ok(service.insert(main));
|
||||
}
|
||||
|
||||
//修改项目
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SaCustMain main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody SaCustMain main) {
|
||||
return R.ok(service.update(main));
|
||||
}
|
||||
|
||||
//删除项目
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
|
||||
//同时使用JPA与mybatis-plus的事务测试
|
||||
@PostMapping("test")
|
||||
public RestResult postTest() {
|
||||
public R postTest() {
|
||||
service.test();
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.sa.draw.main;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,33 +10,33 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class SaDrawMainApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String catid) {
|
||||
public R get(String name,String catid) {
|
||||
Sqler sqler = new Sqler("sa_draw_main");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.catid", catid);
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
SaDrawMain main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody SaDrawMain main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody SaDrawMain main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SaDrawMain main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody SaDrawMain main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.sa.prod.group;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -11,44 +11,44 @@ public class SaProdGroupApi {
|
||||
|
||||
//分页查询项目清单
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("sa_prod_group");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.addre,t.notes");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
//查询单个项目
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
SaProdGroup main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
// //查询单个项目
|
||||
// @GetMapping("proj/{id}")
|
||||
// public RestResult getOneByProj(@PathVariable String id) {
|
||||
// public R getOneByProj(@PathVariable String id) {
|
||||
// List<SaProdGroup> groups = service.findAllByProjid(id);
|
||||
// return RestResult.ok(groups);
|
||||
// return R.ok(groups);
|
||||
// }
|
||||
|
||||
|
||||
//新增项目
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody SaProdGroup main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody SaProdGroup main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
//修改项目
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SaProdGroup main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody SaProdGroup main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
//删除项目
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.sa.prod.tem;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,33 +10,33 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class SaProdTemApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("sa_prod_tem");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addLeftJoin("m.name as modna", "te_prod_model m", "m.id=t.modid");
|
||||
sqler.addOrder("t.ornum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
SaProdTem main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody SaProdTem main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody SaProdTem main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SaProdTem main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody SaProdTem main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -2,7 +2,7 @@ package vboot.app.module.sa.proj.main;
|
||||
|
||||
import vboot.app.module.sa.prod.group.SaProdGroup;
|
||||
import vboot.app.module.sa.prod.group.SaProdGroupService;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.pojo.Zinp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
public class SaProjMainApi {
|
||||
|
||||
@GetMapping("tree")
|
||||
public RestResult getTree(String name) {
|
||||
public R getTree(String name) {
|
||||
List<Zinp> list = new ArrayList<>();
|
||||
Zinp zinp = new Zinp();
|
||||
zinp.setId("11");
|
||||
@@ -28,45 +28,45 @@ public class SaProjMainApi {
|
||||
zinp2.setName("测试2");
|
||||
list.add(zinp);
|
||||
list.add(zinp2);
|
||||
return RestResult.ok(list);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
//分页查询项目清单
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("sa_proj_main");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.addre,t.notes");
|
||||
System.out.println(new Date());
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
//查询单个项目
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
SaProjMain main = service.findOne(id);
|
||||
List<SaProdGroup> groups = groupService.findAllByProjid(id);
|
||||
main.setGroups(groups);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
//新增项目
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody SaProjMain main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody SaProjMain main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
//修改项目
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SaProjMain main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody SaProjMain main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
//删除项目
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+13
-15
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.allot.check;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,39 +10,37 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeAllotCheckApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String modid) {
|
||||
public R get(String name,String modid) {
|
||||
Sqler sqler = new Sqler("te_allot_check");
|
||||
sqler.addLike("t.name", name);
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeAllotCheck main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("checks")
|
||||
public RestResult checks(String id) {
|
||||
return RestResult.ok(service.findData(id));
|
||||
public R checks(String id) {
|
||||
return R.ok(service.findData(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeAllotCheck main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeAllotCheck main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeAllotCheck main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeAllotCheck main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.allot.drive;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,38 +10,38 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeAllotDriveApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String modid) {
|
||||
public R get(String name, String modid) {
|
||||
Sqler sqler = new Sqler("te_allot_drive");
|
||||
sqler.addLike("t.name", name);
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeAllotDrive main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("drives")
|
||||
public RestResult drives(String id) {
|
||||
return RestResult.ok(service.findData(id));
|
||||
public R drives(String id) {
|
||||
return R.ok(service.findData(id));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeAllotDrive main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeAllotDrive main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeAllotDrive main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeAllotDrive main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.allot.link;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,36 +10,36 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeAllotLinkApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String modid) {
|
||||
public R get(String name,String modid) {
|
||||
Sqler sqler = new Sqler("te_allot_link");
|
||||
sqler.addLike("t.name", name);
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeAllotLink main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@GetMapping("links")
|
||||
public RestResult links(String id) {
|
||||
return RestResult.ok(service.findData(id));
|
||||
public R links(String id) {
|
||||
return R.ok(service.findData(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeAllotLink main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeAllotLink main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeAllotLink main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeAllotLink main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.allot.param;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,36 +10,36 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeAllotParamApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String modid) {
|
||||
public R get(String name, String modid) {
|
||||
Sqler sqler = new Sqler("te_allot_param");
|
||||
sqler.addLike("t.name", name);
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeAllotParam main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@GetMapping("screens")
|
||||
public RestResult screens(String id) {
|
||||
return RestResult.ok(service.findData(id));
|
||||
public R screens(String id) {
|
||||
return R.ok(service.findData(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeAllotParam main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeAllotParam main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeAllotParam main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeAllotParam main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.feat.check;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -11,33 +11,33 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeFeatCheckApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String catid) {
|
||||
public R get(String name, String catid) {
|
||||
Sqler sqler = new Sqler("te_feat_check");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.catid", catid);
|
||||
sqler.addLeftJoin("c.name as catna", "te_prod_cate c", "c.id=t.catid");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeFeatCheck main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeFeatCheck main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeFeatCheck main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeFeatCheck main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeFeatCheck main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package vboot.app.module.te.feat.comp;
|
||||
|
||||
import vboot.app.module.te.allot.param.TeAllotParamService;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
@@ -13,34 +13,34 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeFeatCompApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("te_feat_comp");
|
||||
sqler.addLike("t.name", name);
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeFeatComp main = service.findOne(id);
|
||||
if (XstrUtil.isNotBlank(main.getPatid())) {
|
||||
main.setPatem(apService.findOne(main.getPatid()));
|
||||
}
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeFeatComp main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeFeatComp main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeFeatComp main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeFeatComp main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.feat.drive;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -11,33 +11,33 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeFeatDriveApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String catid) {
|
||||
public R get(String name,String catid) {
|
||||
Sqler sqler = new Sqler("te_feat_drive");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.catid", catid);
|
||||
sqler.addLeftJoin("c.name as catna", "te_prod_cate c", "c.id=t.catid");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeFeatDrive main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeFeatDrive main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeFeatDrive main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeFeatDrive main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeFeatDrive main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.feat.link;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -11,34 +11,34 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeFeatLinkApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String catid) {
|
||||
public R get(String name,String catid) {
|
||||
Sqler sqler = new Sqler("te_feat_link");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.catid", catid);
|
||||
sqler.addLeftJoin("c.name as catna", "te_prod_cate c", "c.id=t.catid");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeFeatLink main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeFeatLink main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeFeatLink main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeFeatLink main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeFeatLink main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+17
-17
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.feat.param;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.pojo.ZidName;
|
||||
@@ -15,56 +15,56 @@ import java.util.Map;
|
||||
public class TeFeatParamApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String scrid) {
|
||||
public R get(String name, String scrid) {
|
||||
Sqler sqler = new Sqler("te_feat_param");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.scrid", scrid);
|
||||
sqler.addLeftJoin("s.name as scrna", "te_feat_screen s", "s.id=t.scrid");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeFeatParam main = service.findOne(id);
|
||||
String sql = "select name from te_feat_screen where id=?";
|
||||
String scrna = jdbcDao.findOneString(sql, main.getScrid());
|
||||
main.setScrna(scrna);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@GetMapping("options")
|
||||
public RestResult getOptions(String id) {
|
||||
public R getOptions(String id) {
|
||||
String sql = "select id,name,code from te_feat_param_option where parid=?";
|
||||
List<Map<String, Object>> mapList = jdbcDao.findMapList(sql, id);
|
||||
return RestResult.ok(mapList);
|
||||
return R.ok(mapList);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getListByCate(String catid) {
|
||||
public R getListByCate(String catid) {
|
||||
String sql = "select t.id,t.name from te_feat_param t inner join te_feat_screen s on s.id=t.scrid " +
|
||||
"inner join te_prod_cate c on c.id=s.catid where s.catid=?";
|
||||
List<ZidName> idNameList = jdbcDao.findIdNameList(sql, catid);
|
||||
return RestResult.ok(idNameList);
|
||||
return R.ok(idNameList);
|
||||
}
|
||||
|
||||
@GetMapping("mallot")
|
||||
public RestResult mallot(String id) {
|
||||
return RestResult.ok(service.findData(id));
|
||||
public R mallot(String id) {
|
||||
return R.ok(service.findData(id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeFeatParam main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeFeatParam main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeFeatParam main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeFeatParam main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.feat.screen;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.pojo.Zinp;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,39 +13,39 @@ import java.util.List;
|
||||
public class TeFeatScreenApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String catid) {
|
||||
public R get(String name,String catid) {
|
||||
Sqler sqler = new Sqler("te_feat_screen");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.catid", catid);
|
||||
sqler.addLeftJoin("c.name as catna", "te_prod_cate c", "c.id=t.catid");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("tree")
|
||||
public RestResult getTree(String name) {
|
||||
public R getTree(String name) {
|
||||
List<Zinp> list = service.findTreeList(name);
|
||||
return RestResult.ok(list);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeFeatScreen main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeFeatScreen main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeFeatScreen main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeFeatScreen main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeFeatScreen main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.prod.cate;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -11,42 +11,42 @@ public class TeProdCateApi {
|
||||
|
||||
//分页特性分类
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("te_prod_cate");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.notes");
|
||||
sqler.addOrder("t.ornum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getList() {
|
||||
return RestResult.ok(service.findAll());
|
||||
public R getList() {
|
||||
return R.ok(service.findAll());
|
||||
}
|
||||
|
||||
//查询单个分类
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeProdCate cate = service.findOne(id);
|
||||
return RestResult.ok(cate);
|
||||
return R.ok(cate);
|
||||
}
|
||||
|
||||
//新增分类
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeProdCate cate) {
|
||||
return RestResult.ok(service.insert(cate));
|
||||
public R post(@RequestBody TeProdCate cate) {
|
||||
return R.ok(service.insert(cate));
|
||||
}
|
||||
|
||||
//修改分类
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeProdCate cate) {
|
||||
return RestResult.ok(service.update(cate));
|
||||
public R put(@RequestBody TeProdCate cate) {
|
||||
return R.ok(service.update(cate));
|
||||
}
|
||||
|
||||
//删除分类
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+18
-18
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.prod.model;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.pojo.Zinp;
|
||||
@@ -16,60 +16,60 @@ import java.util.Map;
|
||||
public class TeProdModelApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String catid) {
|
||||
public R get(String name, String catid) {
|
||||
Sqler sqler = new Sqler("te_prod_model");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.catid", catid);
|
||||
sqler.addLeftJoin("c.name as catna", "te_prod_cate c", "c.id=t.catid");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeProdModel main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getList(String serid,String catid) {
|
||||
public R getList(String serid, String catid) {
|
||||
if(XstrUtil.isNotBlank(catid)){
|
||||
String sql = "select m.id,m.name from te_prod_model m where m.catid=?";
|
||||
List<Map<String, Object>> mapList = jdbcDao.findMapList(sql, catid);
|
||||
return RestResult.ok(mapList);
|
||||
return R.ok(mapList);
|
||||
}else if(XstrUtil.isNotBlank(serid)){
|
||||
String sql = "select m.id,m.name from te_prod_model m where m.serid=?";
|
||||
List<Map<String, Object>> mapList = jdbcDao.findMapList(sql, serid);
|
||||
return RestResult.ok(mapList);
|
||||
return R.ok(mapList);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("zmodel")
|
||||
public RestResult getFeat(String id) {
|
||||
public R getFeat(String id) {
|
||||
Zmodel zmodel = service.getZmodel(id);
|
||||
return RestResult.ok(zmodel);
|
||||
return R.ok(zmodel);
|
||||
}
|
||||
|
||||
@GetMapping("tree")
|
||||
public RestResult getTree(String name) {
|
||||
public R getTree(String name) {
|
||||
List<Zinp> list = service.findTreeList(name);
|
||||
return RestResult.ok(list);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeProdModel main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeProdModel main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeProdModel main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeProdModel main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+13
-13
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.prod.serie;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,39 +10,39 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeProdSerieApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String catid) {
|
||||
public R get(String name,String catid) {
|
||||
Sqler sqler = new Sqler("te_prod_serie");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.catid", catid);
|
||||
sqler.addLeftJoin("c.name as catna", "te_prod_cate c", "c.id=t.catid");
|
||||
sqler.addOrder("t.ornum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getList(String catid) {
|
||||
return RestResult.ok(service.findAllByCatid(catid));
|
||||
public R getList(String catid) {
|
||||
return R.ok(service.findAllByCatid(catid));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeProdSerie main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeProdSerie main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeProdSerie main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeProdSerie main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeProdSerie main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -2,7 +2,7 @@ package vboot.app.module.te.prod.test;
|
||||
|
||||
import vboot.app.module.te.prod.cate.TeProdCate;
|
||||
import vboot.app.module.te.prod.cate.TeProdCateService;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -13,41 +13,41 @@ public class TeProdTestApi {
|
||||
|
||||
//分页特性分类
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("te_prod_test");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.notes");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getList() {
|
||||
return RestResult.ok(service.findAll());
|
||||
public R getList() {
|
||||
return R.ok(service.findAll());
|
||||
}
|
||||
|
||||
//查询单个分类
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeProdCate cate = service.findOne(id);
|
||||
return RestResult.ok(cate);
|
||||
return R.ok(cate);
|
||||
}
|
||||
|
||||
//新增分类
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeProdCate cate) {
|
||||
return RestResult.ok(service.insert(cate));
|
||||
public R post(@RequestBody TeProdCate cate) {
|
||||
return R.ok(service.insert(cate));
|
||||
}
|
||||
|
||||
//修改分类
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeProdCate cate) {
|
||||
return RestResult.ok(service.update(cate));
|
||||
public R put(@RequestBody TeProdCate cate) {
|
||||
return R.ok(service.update(cate));
|
||||
}
|
||||
|
||||
//删除分类
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+14
-14
@@ -1,7 +1,7 @@
|
||||
package vboot.app.module.te.prod.version;
|
||||
|
||||
import vboot.app.module.te.allot.param.TeAllotParamService;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
@@ -13,38 +13,38 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class TeProdVersionApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name, String modid) {
|
||||
public R get(String name, String modid) {
|
||||
Sqler sqler = new Sqler("te_prod_version");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addEqual("t.modid", modid);
|
||||
sqler.addLike("t.name" , name);
|
||||
sqler.addEqual("t.modid" , modid);
|
||||
sqler.addSelect("t.detag");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeProdVersion main = service.findOne(id);
|
||||
String modna = jdbcDao.findOneString("select name from te_prod_model where id=?", main.getModid());
|
||||
String modna = jdbcDao.findOneString("select name from te_prod_model where id=?" , main.getModid());
|
||||
main.setModna(modna);
|
||||
if (XstrUtil.isNotBlank(main.getPatid())) {
|
||||
main.setPatem(apService.findOne(main.getPatid()));
|
||||
}
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeProdVersion main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody TeProdVersion main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeProdVersion main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody TeProdVersion main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.tran.cate;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -11,42 +11,42 @@ public class TeTranCateApi {
|
||||
|
||||
//分页特性分类
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("te_tran_cate");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.notes");
|
||||
sqler.addOrder("t.ornum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getList() {
|
||||
return RestResult.ok(service.findAll());
|
||||
public R getList() {
|
||||
return R.ok(service.findAll());
|
||||
}
|
||||
|
||||
//查询单个分类
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeTranCate cate = service.findOne(id);
|
||||
return RestResult.ok(cate);
|
||||
return R.ok(cate);
|
||||
}
|
||||
|
||||
//新增分类
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeTranCate cate) {
|
||||
return RestResult.ok(service.insert(cate));
|
||||
public R post(@RequestBody TeTranCate cate) {
|
||||
return R.ok(service.insert(cate));
|
||||
}
|
||||
|
||||
//修改分类
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeTranCate cate) {
|
||||
return RestResult.ok(service.update(cate));
|
||||
public R put(@RequestBody TeTranCate cate) {
|
||||
return R.ok(service.update(cate));
|
||||
}
|
||||
|
||||
//删除分类
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.app.module.te.tran.main;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -11,42 +11,42 @@ public class TeTranMainApi {
|
||||
|
||||
//分页特性分类
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("te_tran_main");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.notes");
|
||||
sqler.addOrder("t.ornum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getList() {
|
||||
return RestResult.ok(service.findAll());
|
||||
public R getList() {
|
||||
return R.ok(service.findAll());
|
||||
}
|
||||
|
||||
//查询单个分类
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
TeTranMain cate = service.findOne(id);
|
||||
return RestResult.ok(cate);
|
||||
return R.ok(cate);
|
||||
}
|
||||
|
||||
//新增分类
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody TeTranMain cate) {
|
||||
return RestResult.ok(service.insert(cate));
|
||||
public R post(@RequestBody TeTranMain cate) {
|
||||
return R.ok(service.insert(cate));
|
||||
}
|
||||
|
||||
//修改分类
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody TeTranMain cate) {
|
||||
return RestResult.ok(service.update(cate));
|
||||
public R put(@RequestBody TeTranMain cate) {
|
||||
return R.ok(service.update(cate));
|
||||
}
|
||||
|
||||
//删除分类
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+31
-4
@@ -200,16 +200,23 @@
|
||||
<!--浏览器客户端识别结束-->
|
||||
|
||||
<!--服务器监控开始-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>ch.ethz.ganymed</groupId>-->
|
||||
<!-- <artifactId>ganymed-ssh2</artifactId>-->
|
||||
<!-- <version>262</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.ethz.ganymed</groupId>
|
||||
<artifactId>ganymed-ssh2</artifactId>
|
||||
<version>262</version>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>6.1.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.snmp4j</groupId>
|
||||
<artifactId>snmp4j</artifactId>
|
||||
<version>2.6.2</version>
|
||||
<version>2.6.3</version>
|
||||
</dependency>
|
||||
<!--服务器监控结束-->
|
||||
|
||||
@@ -301,6 +308,26 @@
|
||||
<version>5.23</version>
|
||||
</dependency>
|
||||
|
||||
<!-- io常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--velocity代码生成使用模板 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里JSON解析器 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package vboot.core.common.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class R extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String CODE_TAG = "code";
|
||||
|
||||
public static final String MSG_TAG = "message";
|
||||
|
||||
public static final String DATA_TAG = "result";
|
||||
|
||||
public R() {
|
||||
|
||||
}
|
||||
|
||||
public R(int code, String msg) {
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
}
|
||||
|
||||
public R(int code, String msg, Object data) {
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
super.put(DATA_TAG, data);
|
||||
}
|
||||
|
||||
public static R ok() {
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
public static R ok(Object data) {
|
||||
return R.ok("操作成功", data);
|
||||
}
|
||||
|
||||
public static R empty() {
|
||||
return R.ok("操作成功", new ArrayList<>());
|
||||
}
|
||||
|
||||
public static R ok(String msg, Object data) {
|
||||
return new R(0, msg, data);
|
||||
}
|
||||
|
||||
public static R error(Object data) {
|
||||
return R.error("操作失败", data);
|
||||
}
|
||||
|
||||
public static R error(String msg, Object data) {
|
||||
return new R(500, msg, data);
|
||||
}
|
||||
|
||||
public static R build(int code, String msg) {
|
||||
return new R(code, msg, null);
|
||||
}
|
||||
|
||||
public static R build(int code, String msg, Object data) {
|
||||
return new R(code, msg, data);
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package vboot.core.common.api;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class RestResult extends HashMap<String, Object> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String CODE_TAG = "code";
|
||||
|
||||
public static final String MSG_TAG = "message";
|
||||
|
||||
public static final String DATA_TAG = "result";
|
||||
|
||||
public RestResult() {
|
||||
|
||||
}
|
||||
|
||||
public RestResult(int code, String msg) {
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
}
|
||||
|
||||
public RestResult(int code, String msg, Object data) {
|
||||
super.put(CODE_TAG, code);
|
||||
super.put(MSG_TAG, msg);
|
||||
super.put(DATA_TAG, data);
|
||||
}
|
||||
|
||||
public static RestResult ok() {
|
||||
return RestResult.ok("操作成功");
|
||||
}
|
||||
|
||||
public static RestResult ok(Object data) {
|
||||
return RestResult.ok("操作成功", data);
|
||||
}
|
||||
|
||||
public static RestResult empty() {
|
||||
return RestResult.ok("操作成功", new ArrayList<>());
|
||||
}
|
||||
|
||||
public static RestResult ok(String msg, Object data) {
|
||||
return new RestResult(0, msg, data);
|
||||
}
|
||||
|
||||
public static RestResult error(Object data) {
|
||||
return RestResult.error("操作失败", data);
|
||||
}
|
||||
|
||||
public static RestResult error(String msg, Object data) {
|
||||
return new RestResult(500, msg, data);
|
||||
}
|
||||
|
||||
public static RestResult build(int code, String msg) {
|
||||
return new RestResult(code, msg, null);
|
||||
}
|
||||
|
||||
public static RestResult build(int code, String msg, Object data) {
|
||||
return new RestResult(code, msg, data);
|
||||
}
|
||||
}
|
||||
@@ -359,7 +359,6 @@ public class SysPortalInit {
|
||||
menu132a.setPorid("sys");
|
||||
menuService.insert(menu132a);
|
||||
|
||||
|
||||
SysPortalMenu menu133 = new SysPortalMenu();
|
||||
menu133.setId("SysPortalRole");
|
||||
menu133.setName("门户角色");
|
||||
@@ -392,112 +391,16 @@ public class SysPortalInit {
|
||||
menu133a.setPorid("sys");
|
||||
menuService.insert(menu133a);
|
||||
|
||||
SysPortalMenu menu14 = new SysPortalMenu();
|
||||
menu14.setId("SysJob");
|
||||
menu14.setName("定时任务");
|
||||
menu14.setCode("SysJob");
|
||||
menu14.setComp("LAYOUT");
|
||||
menu14.setPath("/sys/job");
|
||||
menu14.setRedirect("/sys/job/main");
|
||||
menu14.setOrnum(4);
|
||||
menu14.setIcon("ele-AlarmClock");
|
||||
menu14.setPid("Sys");
|
||||
menu14.setAvtag(true);
|
||||
menu14.setShtag(true);
|
||||
menu14.setType("D");
|
||||
menu14.setPorid("sys");
|
||||
menuService.insert(menu14);
|
||||
|
||||
SysPortalMenu menu141 = new SysPortalMenu();
|
||||
menu141.setId("SysJobMain");
|
||||
menu141.setName("任务清单");
|
||||
menu141.setCode("SysJobMain");
|
||||
menu141.setPath("/sys/job/main");
|
||||
menu141.setComp("/sys/job/main/index");
|
||||
menu141.setOrnum(1);
|
||||
menu141.setIcon("ele-Tickets");
|
||||
menu141.setPid("SysJob");
|
||||
menu141.setCatag(true);
|
||||
menu141.setAvtag(true);
|
||||
menu141.setShtag(true);
|
||||
menu141.setType("M");
|
||||
menu141.setPorid("sys");
|
||||
menuService.insert(menu141);
|
||||
|
||||
SysPortalMenu menu141a = new SysPortalMenu();
|
||||
menu141a.setId("SysJobMainEdit");
|
||||
menu141a.setName("任务编辑");
|
||||
menu141a.setCode("SysJobMainEdit");
|
||||
menu141a.setPath("/sys/job/main/edit");
|
||||
menu141a.setComp("/sys/job/main/edit");
|
||||
menu141a.setOrnum(2);
|
||||
menu141a.setIcon("ele-Tickets");
|
||||
menu141a.setPid("SysJob");
|
||||
menu141a.setCatag(true);
|
||||
menu141a.setAvtag(true);
|
||||
menu141a.setShtag(false);
|
||||
menu141a.setType("M");
|
||||
menu141a.setPorid("sys");
|
||||
menuService.insert(menu141a);
|
||||
|
||||
SysPortalMenu menu142 = new SysPortalMenu();
|
||||
menu142.setId("SysJobLog");
|
||||
menu142.setName("任务日志");
|
||||
menu142.setCode("SysJobLog");
|
||||
menu142.setPath("/sys/job/log");
|
||||
menu142.setComp("/sys/job/log/index");
|
||||
menu142.setOrnum(3);
|
||||
menu142.setIcon("ele-Tickets");
|
||||
menu142.setPid("SysJob");
|
||||
menu142.setCatag(true);
|
||||
menu142.setAvtag(true);
|
||||
menu142.setShtag(true);
|
||||
menu142.setType("M");
|
||||
menu142.setPorid("sys");
|
||||
menuService.insert(menu142);
|
||||
|
||||
SysPortalMenu menu15 = new SysPortalMenu();
|
||||
menu15.setId("SysLog");
|
||||
menu15.setName("系统日志");
|
||||
menu15.setCode("SysLog");
|
||||
menu15.setComp("LAYOUT");
|
||||
menu15.setPath("/sys/log");
|
||||
menu15.setRedirect("/sys/log/login");
|
||||
menu15.setOrnum(5);
|
||||
menu15.setIcon("ele-Notification");
|
||||
menu15.setPid("Sys");
|
||||
menu15.setAvtag(true);
|
||||
menu15.setShtag(true);
|
||||
menu15.setType("D");
|
||||
menu15.setPorid("sys");
|
||||
menuService.insert(menu15);
|
||||
|
||||
SysPortalMenu menu151 = new SysPortalMenu();
|
||||
menu151.setId("SysLogLogin");
|
||||
menu151.setName("登录日志");
|
||||
menu151.setCode("SysLogLogin");
|
||||
menu151.setPath("/sys/log/login");
|
||||
menu151.setComp("/sys/log/login/index");
|
||||
menu151.setOrnum(1);
|
||||
menu151.setIcon("ele-Tickets");
|
||||
menu151.setPid("SysLog");
|
||||
menu151.setCatag(true);
|
||||
menu151.setAvtag(true);
|
||||
menu151.setShtag(true);
|
||||
menu151.setType("M");
|
||||
menu151.setPorid("sys");
|
||||
menuService.insert(menu151);
|
||||
|
||||
//-----------------辅助工具--------------------
|
||||
//-----------------监控中心--------------------
|
||||
SysPortalMenu menu2 = new SysPortalMenu();
|
||||
menu2.setId("Ass");
|
||||
menu2.setName("辅助工具");
|
||||
menu2.setCode("Ass");
|
||||
menu2.setId("Mon");
|
||||
menu2.setName("监控中心");
|
||||
menu2.setCode("Mon");
|
||||
menu2.setComp("LAYOUT");
|
||||
menu2.setPath("/ass");
|
||||
menu2.setRedirect("/ass/dict/main");
|
||||
menu2.setPath("/mon");
|
||||
menu2.setRedirect("/mon/server/main");
|
||||
menu2.setOrnum(2);
|
||||
menu2.setIcon("ele-Help");
|
||||
menu2.setIcon("ele-DataLine");
|
||||
menu2.setAvtag(true);
|
||||
menu2.setShtag(true);
|
||||
menu2.setType("D");
|
||||
@@ -505,215 +408,374 @@ public class SysPortalInit {
|
||||
menuService.insert(menu2);
|
||||
|
||||
SysPortalMenu menu211 = new SysPortalMenu();
|
||||
menu211.setId("AssDictMain");
|
||||
menu211.setName("数据字典");
|
||||
menu211.setCode("AssDictMain");
|
||||
menu211.setPath("/ass/dict/main");
|
||||
menu211.setComp("/ass/dict/main/index");
|
||||
menu211.setId("MonLogLogin");
|
||||
menu211.setName("登录日志");
|
||||
menu211.setCode("MonLogLogin");
|
||||
menu211.setPath("/mon/log/login");
|
||||
menu211.setComp("/mon/log/login/index");
|
||||
menu211.setOrnum(211);
|
||||
menu211.setIcon("ele-Tickets");
|
||||
menu211.setPid("Ass");
|
||||
menu211.setCatag(false);
|
||||
menu211.setPid("Mon");
|
||||
menu211.setCatag(true);
|
||||
menu211.setAvtag(true);
|
||||
menu211.setShtag(true);
|
||||
menu211.setType("M");
|
||||
menu211.setPorid("sys");
|
||||
menuService.insert(menu211);
|
||||
|
||||
SysPortalMenu menu211b = new SysPortalMenu();
|
||||
menu211b.setId("AssDictData");
|
||||
menu211b.setName("数据字典");
|
||||
menu211b.setCode("AssDictData");
|
||||
menu211b.setPath("/ass/dict/data");
|
||||
menu211b.setComp("/ass/dict/data/index");
|
||||
menu211b.setOrnum(211);
|
||||
menu211b.setIcon("ele-Tickets");
|
||||
menu211b.setPid("Ass");
|
||||
menu211b.setCatag(false);
|
||||
menu211b.setAvtag(true);
|
||||
menu211b.setShtag(false);
|
||||
menu211b.setType("M");
|
||||
menu211b.setPorid("sys");
|
||||
menuService.insert(menu211b);
|
||||
SysPortalMenu menu261 = new SysPortalMenu();
|
||||
menu261.setId("MonJobMain");
|
||||
menu261.setName("定时任务");
|
||||
menu261.setCode("MonJobMain");
|
||||
menu261.setPath("/mon/job/main");
|
||||
menu261.setComp("/mon/job/main/index");
|
||||
menu261.setOrnum(261);
|
||||
menu261.setIcon("ele-Tickets");
|
||||
menu261.setPid("Mon");
|
||||
menu261.setCatag(true);
|
||||
menu261.setAvtag(true);
|
||||
menu261.setShtag(true);
|
||||
menu261.setType("M");
|
||||
menu261.setPorid("sys");
|
||||
menuService.insert(menu261);
|
||||
|
||||
SysPortalMenu menu212 = new SysPortalMenu();
|
||||
menu212.setId("AssNumMain");
|
||||
menu212.setName("编号策略");
|
||||
menu212.setCode("AssNumMain");
|
||||
menu212.setPath("/ass/num/main");
|
||||
menu212.setComp("/ass/num/main/index");
|
||||
menu212.setOrnum(212);
|
||||
menu212.setIcon("ele-Tickets");
|
||||
menu212.setPid("Ass");
|
||||
menu212.setCatag(false);
|
||||
menu212.setAvtag(true);
|
||||
menu212.setShtag(true);
|
||||
menu212.setType("M");
|
||||
menu212.setPorid("sys");
|
||||
menuService.insert(menu212);
|
||||
SysPortalMenu menu262 = new SysPortalMenu();
|
||||
menu262.setId("MonJobMainEdit");
|
||||
menu262.setName("任务编辑");
|
||||
menu262.setCode("MonJobMainEdit");
|
||||
menu262.setPath("/mon/job/main/edit");
|
||||
menu262.setComp("/mon/job/main/edit");
|
||||
menu262.setOrnum(262);
|
||||
menu262.setIcon("ele-Tickets");
|
||||
menu262.setPid("Mon");
|
||||
menu262.setCatag(true);
|
||||
menu262.setAvtag(true);
|
||||
menu262.setShtag(false);
|
||||
menu262.setType("M");
|
||||
menu262.setPorid("sys");
|
||||
menuService.insert(menu262);
|
||||
|
||||
SysPortalMenu menu213 = new SysPortalMenu();
|
||||
menu213.setId("AssAddrMain");
|
||||
menu213.setName("省市区县");
|
||||
menu213.setCode("AssAddrMain");
|
||||
menu213.setPath("/ass/addr/main");
|
||||
menu213.setComp("/ass/addr/main/index");
|
||||
menu213.setOrnum(213);
|
||||
menu213.setIcon("ele-Tickets");
|
||||
menu213.setPid("Ass");
|
||||
menu213.setCatag(false);
|
||||
menu213.setAvtag(true);
|
||||
menu213.setShtag(true);
|
||||
menu213.setType("M");
|
||||
menu213.setPorid("sys");
|
||||
menuService.insert(menu213);
|
||||
SysPortalMenu menu263 = new SysPortalMenu();
|
||||
menu263.setId("MonJobLog");
|
||||
menu263.setName("任务日志");
|
||||
menu263.setCode("MonJobLog");
|
||||
menu263.setPath("/mon/job/log");
|
||||
menu263.setComp("/mon/job/log/index");
|
||||
menu263.setOrnum(263);
|
||||
menu263.setIcon("ele-Tickets");
|
||||
menu263.setPid("Mon");
|
||||
menu263.setCatag(true);
|
||||
menu263.setAvtag(true);
|
||||
menu263.setShtag(false);
|
||||
menu263.setType("M");
|
||||
menu263.setPorid("sys");
|
||||
menuService.insert(menu263);
|
||||
|
||||
SysPortalMenu menu271 = new SysPortalMenu();
|
||||
menu271.setId("MonServerMain");
|
||||
menu271.setName("服务监控");
|
||||
menu271.setCode("MonServerMain");
|
||||
menu271.setPath("/mon/server/main");
|
||||
menu271.setComp("/mon/server/main/show");
|
||||
menu271.setOrnum(271);
|
||||
menu271.setIcon("ele-Tickets");
|
||||
menu271.setPid("Mon");
|
||||
menu271.setCatag(false);
|
||||
menu271.setAvtag(true);
|
||||
menu271.setShtag(true);
|
||||
menu271.setType("M");
|
||||
menu271.setPorid("sys");
|
||||
menuService.insert(menu271);
|
||||
|
||||
//-----------------OA办公--------------------
|
||||
//-----------------辅助工具--------------------
|
||||
SysPortalMenu menu3 = new SysPortalMenu();
|
||||
menu3.setId("Oa");
|
||||
menu3.setName("应用中心");
|
||||
menu3.setCode("Oa");
|
||||
menu3.setId("Ass");
|
||||
menu3.setName("辅助工具");
|
||||
menu3.setCode("Ass");
|
||||
menu3.setComp("LAYOUT");
|
||||
menu3.setPath("/oa");
|
||||
menu3.setRedirect("/oa/flow/temp");
|
||||
menu3.setPath("/ass");
|
||||
menu3.setRedirect("/ass/dict/main");
|
||||
menu3.setOrnum(3);
|
||||
menu3.setIcon("ele-Menu");
|
||||
menu3.setIcon("ele-Suitcase");
|
||||
menu3.setAvtag(true);
|
||||
menu3.setShtag(true);
|
||||
menu3.setType("D");
|
||||
menu3.setPorid("sys");
|
||||
menuService.insert(menu3);
|
||||
|
||||
SysPortalMenu menu31 = new SysPortalMenu();
|
||||
menu31.setId("OaFlow");
|
||||
menu31.setName("流程管理");
|
||||
menu31.setCode("OaFlow");
|
||||
menu31.setComp("LAYOUT");
|
||||
menu31.setPath("/oa/flow");
|
||||
menu31.setRedirect("/oa/flow/temp");
|
||||
menu31.setOrnum(31);
|
||||
menu31.setIcon("ele-Connection");
|
||||
menu31.setPid("Oa");
|
||||
menu31.setAvtag(true);
|
||||
menu31.setShtag(true);
|
||||
menu31.setType("D");
|
||||
menu31.setPorid("sys");
|
||||
menuService.insert(menu31);
|
||||
|
||||
SysPortalMenu menu311 = new SysPortalMenu();
|
||||
menu311.setId("OaFlowCate");
|
||||
menu311.setName("流程分类");
|
||||
menu311.setCode("OaFlowCate");
|
||||
menu311.setPath("/oa/flow/cate");
|
||||
menu311.setComp("/oa/flow/cate/index");
|
||||
menu311.setId("AssCogeForm");
|
||||
menu311.setName("表单设计");
|
||||
menu311.setCode("AssCogeForm");
|
||||
menu311.setPath("/ass/coge/form");
|
||||
menu311.setComp("/ass/coge/form/index");
|
||||
menu311.setOrnum(311);
|
||||
menu311.setIcon("ele-Tickets");
|
||||
menu311.setPid("OaFlow");
|
||||
menu311.setCatag(true);
|
||||
menu311.setPid("Ass");
|
||||
menu311.setCatag(false);
|
||||
menu311.setAvtag(true);
|
||||
menu311.setShtag(true);
|
||||
menu311.setType("M");
|
||||
menu311.setPorid("sys");
|
||||
menuService.insert(menu311);
|
||||
|
||||
SysPortalMenu menu311a = new SysPortalMenu();
|
||||
menu311a.setId("OaFlowCateEdit");
|
||||
menu311a.setName("流程分类编辑");
|
||||
menu311a.setCode("OaFlowCateEdit");
|
||||
menu311a.setPath("/oa/flow/cate/edit");
|
||||
menu311a.setComp("/oa/flow/cate/edit");
|
||||
menu311a.setOrnum(3111);
|
||||
menu311a.setIcon("ele-Tickets");
|
||||
menu311a.setPid("OaFlow");
|
||||
menu311a.setCatag(true);
|
||||
menu311a.setAvtag(true);
|
||||
menu311a.setShtag(false);
|
||||
menu311a.setType("M");
|
||||
menu311a.setPorid("sys");
|
||||
menuService.insert(menu311a);
|
||||
|
||||
SysPortalMenu menu312 = new SysPortalMenu();
|
||||
menu312.setId("OaFlowTemp");
|
||||
menu312.setName("流程模板");
|
||||
menu312.setCode("OaFlowTemp");
|
||||
menu312.setPath("/oa/flow/temp");
|
||||
menu312.setComp("/oa/flow/temp/index");
|
||||
menu312.setId("AssCogeFormEdit");
|
||||
menu312.setName("表单设计编辑");
|
||||
menu312.setCode("AssCogeFormEdit");
|
||||
menu312.setPath("/ass/coge/form/edit");
|
||||
menu312.setComp("/ass/coge/form/edit");
|
||||
menu312.setOrnum(312);
|
||||
menu312.setIcon("ele-Tickets");
|
||||
menu312.setPid("OaFlow");
|
||||
menu312.setCatag(true);
|
||||
menu312.setPid("Ass");
|
||||
menu312.setCatag(false);
|
||||
menu312.setAvtag(true);
|
||||
menu312.setShtag(true);
|
||||
menu312.setShtag(false);
|
||||
menu312.setType("M");
|
||||
menu312.setPorid("sys");
|
||||
menuService.insert(menu312);
|
||||
|
||||
SysPortalMenu menu312a = new SysPortalMenu();
|
||||
menu312a.setId("OaFlowTempEdit");
|
||||
menu312a.setName("流程模板编辑");
|
||||
menu312a.setCode("OaFlowTempEdit");
|
||||
menu312a.setPath("/oa/flow/temp/edit");
|
||||
menu312a.setComp("/oa/flow/temp/edit");
|
||||
menu312a.setOrnum(3121);
|
||||
menu312a.setIcon("ele-Tickets");
|
||||
menu312a.setPid("OaFlow");
|
||||
menu312a.setCatag(true);
|
||||
menu312a.setAvtag(true);
|
||||
menu312a.setShtag(false);
|
||||
menu312a.setType("M");
|
||||
menu312a.setPorid("sys");
|
||||
menuService.insert(menu312a);
|
||||
SysPortalMenu menu341 = new SysPortalMenu();
|
||||
menu341.setId("AssCogeTable");
|
||||
menu341.setName("代码生成");
|
||||
menu341.setCode("AssCogeTable");
|
||||
menu341.setPath("/ass/coge/table");
|
||||
menu341.setComp("/ass/coge/table/index");
|
||||
menu341.setOrnum(341);
|
||||
menu341.setIcon("ele-Tickets");
|
||||
menu341.setPid("Ass");
|
||||
menu341.setCatag(false);
|
||||
menu341.setAvtag(true);
|
||||
menu341.setShtag(true);
|
||||
menu341.setType("M");
|
||||
menu341.setPorid("sys");
|
||||
menuService.insert(menu341);
|
||||
|
||||
SysPortalMenu menu313 = new SysPortalMenu();
|
||||
menu313.setId("OaFlowMain");
|
||||
menu313.setName("流程实例");
|
||||
menu313.setCode("OaFlowMain");
|
||||
menu313.setPath("/oa/flow/main");
|
||||
menu313.setComp("/oa/flow/main/index");
|
||||
menu313.setOrnum(313);
|
||||
menu313.setIcon("ele-Tickets");
|
||||
menu313.setPid("OaFlow");
|
||||
menu313.setCatag(true);
|
||||
menu313.setAvtag(true);
|
||||
menu313.setShtag(true);
|
||||
menu313.setType("M");
|
||||
menu313.setPorid("sys");
|
||||
menuService.insert(menu313);
|
||||
SysPortalMenu menu342 = new SysPortalMenu();
|
||||
menu342.setId("AssCogeTableEdit");
|
||||
menu342.setName("代码生成");
|
||||
menu342.setCode("AssCogeTableEdit");
|
||||
menu342.setPath("/ass/coge/table/edit");
|
||||
menu342.setComp("/ass/coge/table/edit");
|
||||
menu342.setOrnum(342);
|
||||
menu342.setIcon("ele-Tickets");
|
||||
menu342.setPid("Ass");
|
||||
menu342.setCatag(false);
|
||||
menu342.setAvtag(true);
|
||||
menu342.setShtag(false);
|
||||
menu342.setType("M");
|
||||
menu342.setPorid("sys");
|
||||
menuService.insert(menu342);
|
||||
|
||||
SysPortalMenu menu313a = new SysPortalMenu();
|
||||
menu313a.setId("OaFlowMainEdit");
|
||||
menu313a.setName("流程实例编辑");
|
||||
menu313a.setCode("OaFlowMainEdit");
|
||||
menu313a.setPath("/oa/flow/main/edit");
|
||||
menu313a.setComp("/oa/flow/main/edit");
|
||||
menu313a.setOrnum(3131);
|
||||
menu313a.setIcon("ele-Tickets");
|
||||
menu313a.setPid("OaFlow");
|
||||
menu313a.setCatag(true);
|
||||
menu313a.setAvtag(true);
|
||||
menu313a.setShtag(false);
|
||||
menu313a.setType("M");
|
||||
menu313a.setPorid("sys");
|
||||
menuService.insert(menu313a);
|
||||
SysPortalMenu menu351 = new SysPortalMenu();
|
||||
menu351.setId("AssDictMain");
|
||||
menu351.setName("数据字典");
|
||||
menu351.setCode("AssDictMain");
|
||||
menu351.setPath("/ass/dict/main");
|
||||
menu351.setComp("/ass/dict/main/index");
|
||||
menu351.setOrnum(351);
|
||||
menu351.setIcon("ele-Tickets");
|
||||
menu351.setPid("Ass");
|
||||
menu351.setCatag(false);
|
||||
menu351.setAvtag(true);
|
||||
menu351.setShtag(true);
|
||||
menu351.setType("M");
|
||||
menu351.setPorid("sys");
|
||||
menuService.insert(menu351);
|
||||
|
||||
SysPortalMenu menu313b = new SysPortalMenu();
|
||||
menu313b.setId("OaFlowMainView");
|
||||
menu313b.setName("流程实例查看");
|
||||
menu313b.setCode("OaFlowMainView");
|
||||
menu313b.setPath("/oa/flow/main/view");
|
||||
menu313b.setComp("/oa/flow/main/view");
|
||||
menu313b.setOrnum(3132);
|
||||
menu313b.setIcon("ele-Tickets");
|
||||
menu313b.setPid("OaFlow");
|
||||
menu313b.setCatag(true);
|
||||
menu313b.setAvtag(true);
|
||||
menu313b.setShtag(false);
|
||||
menu313b.setType("M");
|
||||
menu313b.setPorid("sys");
|
||||
menuService.insert(menu313b);
|
||||
SysPortalMenu menu352 = new SysPortalMenu();
|
||||
menu352.setId("AssDictData");
|
||||
menu352.setName("字典数据");
|
||||
menu352.setCode("AssDictData");
|
||||
menu352.setPath("/ass/dict/data");
|
||||
menu352.setComp("/ass/dict/data/index");
|
||||
menu352.setOrnum(352);
|
||||
menu352.setIcon("ele-Tickets");
|
||||
menu352.setPid("Ass");
|
||||
menu352.setCatag(false);
|
||||
menu352.setAvtag(true);
|
||||
menu352.setShtag(false);
|
||||
menu352.setType("M");
|
||||
menu352.setPorid("sys");
|
||||
menuService.insert(menu352);
|
||||
|
||||
SysPortalMenu menu361 = new SysPortalMenu();
|
||||
menu361.setId("AssNumMain");
|
||||
menu361.setName("编号策略");
|
||||
menu361.setCode("AssNumMain");
|
||||
menu361.setPath("/ass/num/main");
|
||||
menu361.setComp("/ass/num/main/index");
|
||||
menu361.setOrnum(361);
|
||||
menu361.setIcon("ele-Tickets");
|
||||
menu361.setPid("Ass");
|
||||
menu361.setCatag(false);
|
||||
menu361.setAvtag(true);
|
||||
menu361.setShtag(true);
|
||||
menu361.setType("M");
|
||||
menu361.setPorid("sys");
|
||||
menuService.insert(menu361);
|
||||
|
||||
SysPortalMenu menu371 = new SysPortalMenu();
|
||||
menu371.setId("AssAddrMain");
|
||||
menu371.setName("省市区县");
|
||||
menu371.setCode("AssAddrMain");
|
||||
menu371.setPath("/ass/addr/main");
|
||||
menu371.setComp("/ass/addr/main/index");
|
||||
menu371.setOrnum(371);
|
||||
menu371.setIcon("ele-Tickets");
|
||||
menu371.setPid("Ass");
|
||||
menu371.setCatag(false);
|
||||
menu371.setAvtag(true);
|
||||
menu371.setShtag(true);
|
||||
menu371.setType("M");
|
||||
menu371.setPorid("sys");
|
||||
menuService.insert(menu371);
|
||||
|
||||
//-----------------OA办公--------------------
|
||||
SysPortalMenu menu4 = new SysPortalMenu();
|
||||
menu4.setId("Oa");
|
||||
menu4.setName("应用中心");
|
||||
menu4.setCode("Oa");
|
||||
menu4.setComp("LAYOUT");
|
||||
menu4.setPath("/oa");
|
||||
menu4.setRedirect("/oa/flow/temp");
|
||||
menu4.setOrnum(4);
|
||||
menu4.setIcon("ele-Menu");
|
||||
menu4.setAvtag(true);
|
||||
menu4.setShtag(true);
|
||||
menu4.setType("D");
|
||||
menu4.setPorid("sys");
|
||||
menuService.insert(menu4);
|
||||
|
||||
SysPortalMenu menu41 = new SysPortalMenu();
|
||||
menu41.setId("OaFlow");
|
||||
menu41.setName("流程管理");
|
||||
menu41.setCode("OaFlow");
|
||||
menu41.setComp("LAYOUT");
|
||||
menu41.setPath("/oa/flow");
|
||||
menu41.setRedirect("/oa/flow/temp");
|
||||
menu41.setOrnum(41);
|
||||
menu41.setIcon("ele-Connection");
|
||||
menu41.setPid("Oa");
|
||||
menu41.setAvtag(true);
|
||||
menu41.setShtag(true);
|
||||
menu41.setType("D");
|
||||
menu41.setPorid("sys");
|
||||
menuService.insert(menu41);
|
||||
|
||||
SysPortalMenu menu411 = new SysPortalMenu();
|
||||
menu411.setId("OaFlowCate");
|
||||
menu411.setName("流程分类");
|
||||
menu411.setCode("OaFlowCate");
|
||||
menu411.setPath("/oa/flow/cate");
|
||||
menu411.setComp("/oa/flow/cate/index");
|
||||
menu411.setOrnum(411);
|
||||
menu411.setIcon("ele-Tickets");
|
||||
menu411.setPid("OaFlow");
|
||||
menu411.setCatag(true);
|
||||
menu411.setAvtag(true);
|
||||
menu411.setShtag(true);
|
||||
menu411.setType("M");
|
||||
menu411.setPorid("sys");
|
||||
menuService.insert(menu411);
|
||||
|
||||
SysPortalMenu menu411a = new SysPortalMenu();
|
||||
menu411a.setId("OaFlowCateEdit");
|
||||
menu411a.setName("流程分类编辑");
|
||||
menu411a.setCode("OaFlowCateEdit");
|
||||
menu411a.setPath("/oa/flow/cate/edit");
|
||||
menu411a.setComp("/oa/flow/cate/edit");
|
||||
menu411a.setOrnum(4111);
|
||||
menu411a.setIcon("ele-Tickets");
|
||||
menu411a.setPid("OaFlow");
|
||||
menu411a.setCatag(true);
|
||||
menu411a.setAvtag(true);
|
||||
menu411a.setShtag(false);
|
||||
menu411a.setType("M");
|
||||
menu411a.setPorid("sys");
|
||||
menuService.insert(menu411a);
|
||||
|
||||
SysPortalMenu menu412 = new SysPortalMenu();
|
||||
menu412.setId("OaFlowTemp");
|
||||
menu412.setName("流程模板");
|
||||
menu412.setCode("OaFlowTemp");
|
||||
menu412.setPath("/oa/flow/temp");
|
||||
menu412.setComp("/oa/flow/temp/index");
|
||||
menu412.setOrnum(412);
|
||||
menu412.setIcon("ele-Tickets");
|
||||
menu412.setPid("OaFlow");
|
||||
menu412.setCatag(true);
|
||||
menu412.setAvtag(true);
|
||||
menu412.setShtag(true);
|
||||
menu412.setType("M");
|
||||
menu412.setPorid("sys");
|
||||
menuService.insert(menu412);
|
||||
|
||||
SysPortalMenu menu412a = new SysPortalMenu();
|
||||
menu412a.setId("OaFlowTempEdit");
|
||||
menu412a.setName("流程模板编辑");
|
||||
menu412a.setCode("OaFlowTempEdit");
|
||||
menu412a.setPath("/oa/flow/temp/edit");
|
||||
menu412a.setComp("/oa/flow/temp/edit");
|
||||
menu412a.setOrnum(4121);
|
||||
menu412a.setIcon("ele-Tickets");
|
||||
menu412a.setPid("OaFlow");
|
||||
menu412a.setCatag(true);
|
||||
menu412a.setAvtag(true);
|
||||
menu412a.setShtag(false);
|
||||
menu412a.setType("M");
|
||||
menu412a.setPorid("sys");
|
||||
menuService.insert(menu412a);
|
||||
|
||||
SysPortalMenu menu413 = new SysPortalMenu();
|
||||
menu413.setId("OaFlowMain");
|
||||
menu413.setName("流程实例");
|
||||
menu413.setCode("OaFlowMain");
|
||||
menu413.setPath("/oa/flow/main");
|
||||
menu413.setComp("/oa/flow/main/index");
|
||||
menu413.setOrnum(413);
|
||||
menu413.setIcon("ele-Tickets");
|
||||
menu413.setPid("OaFlow");
|
||||
menu413.setCatag(true);
|
||||
menu413.setAvtag(true);
|
||||
menu413.setShtag(true);
|
||||
menu413.setType("M");
|
||||
menu413.setPorid("sys");
|
||||
menuService.insert(menu413);
|
||||
|
||||
SysPortalMenu menu413a = new SysPortalMenu();
|
||||
menu413a.setId("OaFlowMainEdit");
|
||||
menu413a.setName("流程实例编辑");
|
||||
menu413a.setCode("OaFlowMainEdit");
|
||||
menu413a.setPath("/oa/flow/main/edit");
|
||||
menu413a.setComp("/oa/flow/main/edit");
|
||||
menu413a.setOrnum(4131);
|
||||
menu413a.setIcon("ele-Tickets");
|
||||
menu413a.setPid("OaFlow");
|
||||
menu413a.setCatag(true);
|
||||
menu413a.setAvtag(true);
|
||||
menu413a.setShtag(false);
|
||||
menu413a.setType("M");
|
||||
menu413a.setPorid("sys");
|
||||
menuService.insert(menu413a);
|
||||
|
||||
SysPortalMenu menu413b = new SysPortalMenu();
|
||||
menu413b.setId("OaFlowMainView");
|
||||
menu413b.setName("流程实例查看");
|
||||
menu413b.setCode("OaFlowMainView");
|
||||
menu413b.setPath("/oa/flow/main/view");
|
||||
menu413b.setComp("/oa/flow/main/view");
|
||||
menu413b.setOrnum(4132);
|
||||
menu413b.setIcon("ele-Tickets");
|
||||
menu413b.setPid("OaFlow");
|
||||
menu413b.setCatag(true);
|
||||
menu413b.setAvtag(true);
|
||||
menu413b.setShtag(false);
|
||||
menu413b.setType("M");
|
||||
menu413b.setPorid("sys");
|
||||
menuService.insert(menu413b);
|
||||
|
||||
//DEMO
|
||||
SysPortalMenu menu8 = new SysPortalMenu();
|
||||
menu8.setId("Demo");
|
||||
menu8.setName("Demo");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package vboot.core.common.service;
|
||||
|
||||
import vboot.core.common.api.PageData;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.entity.BaseCateEntity;
|
||||
@@ -80,22 +80,22 @@ public abstract class BaseCateService<T extends BaseCateEntity> {
|
||||
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public RestResult inpFind(String table){
|
||||
public R inpFind(String table){
|
||||
Sqler sqlHelper = new Sqler(table);
|
||||
sqlHelper.addSelect("pid");
|
||||
sqlHelper.addWhere("t.avtag = 1");
|
||||
sqlHelper.addOrder("t.ornum");
|
||||
return RestResult.ok(jdbcDao.findInpList(sqlHelper));
|
||||
return R.ok(jdbcDao.findInpList(sqlHelper));
|
||||
}
|
||||
|
||||
public RestResult inpDele(String table, String id){
|
||||
public R inpDele(String table, String id){
|
||||
String sql = "select id from " + table + " where tier like ? order by tier";
|
||||
List<String> stringList = jdbcDao.findStringList(sql, "%;" + id + ";%");
|
||||
for (String sid : stringList) {
|
||||
repo.deleteById(sid);
|
||||
}
|
||||
repo.deleteById(id);
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
public String insert(T cate) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package vboot.core.module.ass.addr.main;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.xutil.file.ExcelUtil;
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
@RequestMapping("ass/addr/main")
|
||||
public class AssAddrMainApi {
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("ass_addr_main");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addLeftJoin("t2.name as p2name","ass_addr_main t2","t2.id=t.pid");
|
||||
@@ -22,19 +22,19 @@ public class AssAddrMainApi {
|
||||
sqler.addLeftJoin("t4.name as p4name","ass_addr_main t4","t4.id=t3.pid");
|
||||
sqler.addSelect("t.type,t.crtim,t.uptim,t.cecoo");
|
||||
sqler.addOrder("t.id");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
AssAddrMain main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PutMapping("addrupdate")
|
||||
public RestResult addrupdate() {
|
||||
public R addrupdate() {
|
||||
addrHandle.addrInit();
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("exp")
|
||||
@@ -45,18 +45,18 @@ public class AssAddrMainApi {
|
||||
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody AssAddrMain main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody AssAddrMain main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody AssAddrMain main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody AssAddrMain main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package vboot.core.module.ass.coge.form;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import vboot.core.common.entity.BaseMainEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
public class AssCogeForm extends BaseMainEntity {
|
||||
|
||||
private String notes;
|
||||
|
||||
@Lob
|
||||
private String vform;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package vboot.core.module.ass.coge.form;
|
||||
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("ass/coge/form")
|
||||
public class AssCogeFormApi {
|
||||
|
||||
@GetMapping
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("ass_coge_form");
|
||||
sqler.addLike("t.name", name);
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public R getOne(@PathVariable String id) {
|
||||
AssCogeForm main = service.findOne(id);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public R post(@RequestBody AssCogeForm main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public R put(@RequestBody AssCogeForm main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AssCogeFormService service;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package vboot.core.module.ass.coge.form;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface AssCogeFormRepo extends JpaRepository<AssCogeForm,String> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package vboot.core.module.ass.coge.form;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import vboot.core.common.service.BaseMainService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Service
|
||||
public class AssCogeFormService extends BaseMainService<AssCogeForm> {
|
||||
|
||||
@Autowired
|
||||
private AssCogeFormRepo repo;
|
||||
|
||||
@PostConstruct
|
||||
public void initDao() {
|
||||
super.setRepo(repo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package vboot.core.module.ass.coge.table;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
public class AssCogeField {
|
||||
|
||||
@Id
|
||||
@Column(length = 32)
|
||||
@GeneratedValue(generator = "jpa-uuid")
|
||||
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
|
||||
private String id;//ID
|
||||
|
||||
private Integer ornum;//排序号
|
||||
|
||||
@Column(length = 32)
|
||||
private String name;//字段名称
|
||||
|
||||
@Column(length = 32)
|
||||
private String remark;//字段描述
|
||||
|
||||
@Column(length = 128)
|
||||
private String notes;//备注
|
||||
|
||||
@Column(length = 32)
|
||||
private String type;//字段类型
|
||||
|
||||
@Column(length = 32)
|
||||
private String length;//字段长度
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// /** 编号 */
|
||||
// private Long columnId;
|
||||
//
|
||||
// /** 归属表编号 */
|
||||
// private Long tableId;
|
||||
//
|
||||
// /** 列名称 */
|
||||
// private String columnName;
|
||||
//
|
||||
// /** 列描述 */
|
||||
// private String columnComment;
|
||||
//
|
||||
// /** 列类型 */
|
||||
// private String columnType;
|
||||
//
|
||||
// /** JAVA类型 */
|
||||
// private String javaType;
|
||||
//
|
||||
// /** JAVA字段名 */
|
||||
// @NotBlank(message = "Java属性不能为空")
|
||||
// private String javaField;
|
||||
//
|
||||
// /** 是否主键(1是) */
|
||||
// private String isPk;
|
||||
//
|
||||
// /** 是否自增(1是) */
|
||||
// private String isIncrement;
|
||||
//
|
||||
// /** 是否必填(1是) */
|
||||
// private String isRequired;
|
||||
//
|
||||
// /** 是否为插入字段(1是) */
|
||||
// private String isInsert;
|
||||
//
|
||||
// /** 是否编辑字段(1是) */
|
||||
// private String isEdit;
|
||||
//
|
||||
// /** 是否列表字段(1是) */
|
||||
// private String isList;
|
||||
//
|
||||
// /** 是否查询字段(1是) */
|
||||
// private String isQuery;
|
||||
//
|
||||
// /** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */
|
||||
// private String queryType;
|
||||
//
|
||||
// /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */
|
||||
// private String htmlType;
|
||||
//
|
||||
// /** 字典类型 */
|
||||
// private String dictType;
|
||||
//
|
||||
// /** 排序 */
|
||||
// private Integer sort;
|
||||
//
|
||||
// public boolean isSuperColumn()
|
||||
// {
|
||||
// return isSuperColumn(this.javaField);
|
||||
// }
|
||||
//
|
||||
// public static boolean isSuperColumn(String javaField)
|
||||
// {
|
||||
// return StringUtils.equalsAnyIgnoreCase(javaField,
|
||||
// // BaseEntity
|
||||
// "createBy", "createTime", "updateBy", "updateTime", "remark",
|
||||
// // TreeEntity
|
||||
// "parentName", "parentId", "orderNum", "ancestors");
|
||||
// }
|
||||
//
|
||||
// public boolean isPk()
|
||||
// {
|
||||
// return isPk(this.isPk);
|
||||
// }
|
||||
//
|
||||
// public boolean isPk(String isPk)
|
||||
// {
|
||||
// return isPk != null && StringUtils.equals("1", isPk);
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package vboot.core.module.ass.coge.table;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import vboot.core.common.entity.BaseMainEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
public class AssCogeTable extends BaseMainEntity {
|
||||
|
||||
@Column(length = 64)
|
||||
private String bunam;//业务名
|
||||
|
||||
private Integer ornum;//排序号
|
||||
|
||||
@Column(length = 64)
|
||||
private String remark;//表描述
|
||||
|
||||
private String notes;//备注
|
||||
|
||||
@Column(length = 64)
|
||||
private String mode;//生成模式
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@JoinColumn(name = "tabid")
|
||||
@OrderBy("ornum ASC")
|
||||
private List<AssCogeField> fields = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// /** 编号 */
|
||||
// private Long tableId;
|
||||
//
|
||||
// /** 表名称 */
|
||||
// @NotBlank(message = "表名称不能为空")
|
||||
// private String tableName="aaa";
|
||||
//
|
||||
// /** 表描述 */
|
||||
// @NotBlank(message = "表描述不能为空")
|
||||
// private String tableComment="aaa";
|
||||
//
|
||||
// /** 关联父表的表名 */
|
||||
// private String subTableName;
|
||||
//
|
||||
// /** 本表关联父表的外键名 */
|
||||
// private String subTableFkName;
|
||||
//
|
||||
// /** 实体类名称(首字母大写) */
|
||||
// @NotBlank(message = "实体类名称不能为空")
|
||||
// private String className="aaa";
|
||||
//
|
||||
// /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
||||
// private String tplCategory;
|
||||
//
|
||||
// /** 生成包路径 */
|
||||
// @NotBlank(message = "生成包路径不能为空")
|
||||
// private String packageName="aaa";
|
||||
//
|
||||
// /** 生成模块名 */
|
||||
// @NotBlank(message = "生成模块名不能为空")
|
||||
// private String moduleName="aaa";
|
||||
//
|
||||
// /** 生成业务名 */
|
||||
// @NotBlank(message = "生成业务名不能为空")
|
||||
// private String businessName="aaa";
|
||||
//
|
||||
// /** 生成功能名 */
|
||||
// @NotBlank(message = "生成功能名不能为空")
|
||||
// private String functionName="aaa";
|
||||
//
|
||||
// /** 生成作者 */
|
||||
// @NotBlank(message = "作者不能为空")
|
||||
// private String functionAuthor="aaa";
|
||||
//
|
||||
// /** 生成代码方式(0zip压缩包 1自定义路径) */
|
||||
// private String genType;
|
||||
//
|
||||
// /** 生成路径(不填默认项目路径) */
|
||||
// private String genPath;
|
||||
//
|
||||
//
|
||||
// /** 其它生成选项 */
|
||||
// private String options;
|
||||
//
|
||||
// /** 树编码字段 */
|
||||
// private String treeCode;
|
||||
//
|
||||
// /** 树父编码字段 */
|
||||
// private String treeParentCode;
|
||||
//
|
||||
// /** 树名称字段 */
|
||||
// private String treeName;
|
||||
//
|
||||
// /** 上级菜单ID字段 */
|
||||
// private String parentMenuId;
|
||||
//
|
||||
// /** 上级菜单名称字段 */
|
||||
// private String parentMenuName;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package vboot.core.module.ass.coge.table;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.module.ass.coge.velocity.GenCode;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("ass/coge/table")
|
||||
public class AssCogeTableApi {
|
||||
|
||||
private String table = "ass_coge_table";
|
||||
|
||||
@GetMapping
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler(table);
|
||||
sqler.addLike("t.name" , name);
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("/zip")
|
||||
public void getZip(HttpServletResponse response, String id) throws IOException {
|
||||
byte[] data = service.downloadCode(id);
|
||||
genCode(response, data);
|
||||
}
|
||||
|
||||
@GetMapping("/show")
|
||||
public R getShow(String id) throws IOException {
|
||||
List<GenCode> genCodes = service.previewCode(id);
|
||||
return R.ok(genCodes);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public R getOne(@PathVariable String id) {
|
||||
AssCogeTable main = service.findOne(id);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public R getList() {
|
||||
return R.ok(service.findAll());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public R post(@RequestBody AssCogeTable main) throws DocumentException {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public R put(@RequestBody AssCogeTable main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AssCogeTableService service;
|
||||
|
||||
/**
|
||||
* 生成zip文件
|
||||
*/
|
||||
private void genCode(HttpServletResponse response, byte[] data) throws IOException {
|
||||
response.reset();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MMddHHmmss");
|
||||
String time= sdf.format(new Date());
|
||||
String fileName="vboot-"+time+".zip";
|
||||
response.addHeader("Access-Control-Allow-Origin" , "*");
|
||||
response.addHeader("Access-Control-Expose-Headers" , "Content-Disposition,download-filename");
|
||||
response.setHeader("Content-Disposition" , "attachment; filename="+fileName);
|
||||
response.setHeader("download-filename" , fileName);
|
||||
response.addHeader("Content-Length" , "" + data.length);
|
||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||
IOUtils.write(data, response.getOutputStream());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package vboot.core.module.ass.coge.table;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import vboot.core.module.sys.org.group.SysOrgGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface AssCogeTableRepo extends JpaRepository<AssCogeTable,String> {
|
||||
|
||||
AssCogeTable findByName(String name);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package vboot.core.module.ass.coge.table;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.Velocity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import vboot.core.common.service.BaseMainService;
|
||||
import vboot.core.module.ass.coge.velocity.GenCode;
|
||||
import vboot.core.module.ass.coge.velocity.VelocityInitializer;
|
||||
import vboot.core.module.ass.coge.velocity.VelocityUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AssCogeTableService extends BaseMainService<AssCogeTable> {
|
||||
|
||||
public List<GenCode> previewCode(String id)
|
||||
{
|
||||
AssCogeTable table = repo.findById(id).get();
|
||||
List<GenCode> genCodes=new ArrayList<>();
|
||||
// Map<String, String> dataMap = new LinkedHashMap<>();
|
||||
// 查询表信息
|
||||
// 设置主子表信息
|
||||
// setSubTable(table);
|
||||
// // 设置主键列信息
|
||||
// setPkColumn(table);
|
||||
VelocityInitializer.initVelocity();
|
||||
|
||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||
|
||||
// 获取模板列表
|
||||
List<String> templates = VelocityUtils.getTemplateList("crud");
|
||||
for (String template : templates)
|
||||
{
|
||||
// 渲染模板
|
||||
StringWriter sw = new StringWriter();
|
||||
Template tpl = Velocity.getTemplate(template, "UTF-8");
|
||||
tpl.merge(context, sw);
|
||||
GenCode genCode=new GenCode();
|
||||
String[] arr=template.split("/");
|
||||
genCode.setTitle(arr[arr.length-1].replace(".vm",""));
|
||||
genCode.setContent( sw.toString());
|
||||
genCodes.add(genCode);
|
||||
}
|
||||
return genCodes;
|
||||
}
|
||||
|
||||
public byte[] downloadCode(String id)
|
||||
{
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||
generatorCode(id, zip);
|
||||
IOUtils.closeQuietly(zip);
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表信息并生成代码
|
||||
*/
|
||||
private void generatorCode(String id, ZipOutputStream zip)
|
||||
{
|
||||
// 查询表信息
|
||||
AssCogeTable table = repo.findById(id).get();
|
||||
// 设置主子表信息
|
||||
// setPkColumn(table);
|
||||
|
||||
VelocityInitializer.initVelocity();
|
||||
|
||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||
|
||||
// 获取模板列表
|
||||
// List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||
List<String> templates = VelocityUtils.getTemplateList("crud");
|
||||
for (String template : templates)
|
||||
{
|
||||
// 渲染模板
|
||||
StringWriter sw = new StringWriter();
|
||||
Template tpl = Velocity.getTemplate(template, "UTF-8");
|
||||
tpl.merge(context, sw);
|
||||
try
|
||||
{
|
||||
// 添加到zip
|
||||
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
||||
IOUtils.write(sw.toString(), zip, "UTF-8");
|
||||
IOUtils.closeQuietly(sw);
|
||||
zip.flush();
|
||||
zip.closeEntry();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
log.error("渲染模板失败,表名:" + table.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------bean注入------------
|
||||
@Autowired
|
||||
private AssCogeTableRepo repo;
|
||||
|
||||
@PostConstruct
|
||||
public void initDao() {
|
||||
super.setRepo(repo);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package vboot.core.module.ass.coge.velocity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GenCode {
|
||||
|
||||
private String type;
|
||||
|
||||
private String title;
|
||||
|
||||
private String path;
|
||||
|
||||
private String content;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package vboot.core.module.ass.coge.velocity;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 读取代码生成相关配置
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "gen")
|
||||
@PropertySource(value = { "classpath:generator.yml" })
|
||||
public class GenConfig
|
||||
{
|
||||
/** 作者 */
|
||||
public static String author;
|
||||
|
||||
/** 生成包路径 */
|
||||
public static String packageName;
|
||||
|
||||
/** 自动去除表前缀,默认是false */
|
||||
public static boolean autoRemovePre;
|
||||
|
||||
/** 表前缀(类名不会包含表前缀) */
|
||||
public static String tablePrefix;
|
||||
|
||||
public static String getAuthor()
|
||||
{
|
||||
return author;
|
||||
}
|
||||
|
||||
@Value("${author}")
|
||||
public void setAuthor(String author)
|
||||
{
|
||||
GenConfig.author = author;
|
||||
}
|
||||
|
||||
public static String getPackageName()
|
||||
{
|
||||
return packageName;
|
||||
}
|
||||
|
||||
@Value("${packageName}")
|
||||
public void setPackageName(String packageName)
|
||||
{
|
||||
GenConfig.packageName = packageName;
|
||||
}
|
||||
|
||||
public static boolean getAutoRemovePre()
|
||||
{
|
||||
return autoRemovePre;
|
||||
}
|
||||
|
||||
@Value("${autoRemovePre}")
|
||||
public void setAutoRemovePre(boolean autoRemovePre)
|
||||
{
|
||||
GenConfig.autoRemovePre = autoRemovePre;
|
||||
}
|
||||
|
||||
public static String getTablePrefix()
|
||||
{
|
||||
return tablePrefix;
|
||||
}
|
||||
|
||||
@Value("${tablePrefix}")
|
||||
public void setTablePrefix(String tablePrefix)
|
||||
{
|
||||
GenConfig.tablePrefix = tablePrefix;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package vboot.core.module.ass.coge.velocity;
|
||||
|
||||
/**
|
||||
* 代码生成通用常量
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class GenConstants
|
||||
{
|
||||
/** 单表(增删改查) */
|
||||
public static final String TPL_CRUD = "crud";
|
||||
|
||||
/** 树表(增删改查) */
|
||||
public static final String TPL_TREE = "tree";
|
||||
|
||||
/** 主子表(增删改查) */
|
||||
public static final String TPL_SUB = "sub";
|
||||
|
||||
/** 树编码字段 */
|
||||
public static final String TREE_CODE = "treeCode";
|
||||
|
||||
/** 树父编码字段 */
|
||||
public static final String TREE_PARENT_CODE = "treeParentCode";
|
||||
|
||||
/** 树名称字段 */
|
||||
public static final String TREE_NAME = "treeName";
|
||||
|
||||
/** 上级菜单ID字段 */
|
||||
public static final String PARENT_MENU_ID = "parentMenuId";
|
||||
|
||||
/** 上级菜单名称字段 */
|
||||
public static final String PARENT_MENU_NAME = "parentMenuName";
|
||||
|
||||
/** 数据库字符串类型 */
|
||||
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
|
||||
|
||||
/** 数据库文本类型 */
|
||||
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
|
||||
|
||||
/** 数据库时间类型 */
|
||||
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
|
||||
|
||||
/** 数据库数字类型 */
|
||||
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
|
||||
"bit", "bigint", "float", "double", "decimal" };
|
||||
|
||||
/** 页面不需要编辑字段 */
|
||||
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
|
||||
|
||||
/** 页面不需要显示的列表字段 */
|
||||
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||
"update_time" };
|
||||
|
||||
/** 页面不需要查询字段 */
|
||||
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
|
||||
"update_time", "remark" };
|
||||
|
||||
/** Entity基类字段 */
|
||||
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
|
||||
|
||||
/** Tree基类字段 */
|
||||
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };
|
||||
|
||||
/** 文本框 */
|
||||
public static final String HTML_INPUT = "input";
|
||||
|
||||
/** 文本域 */
|
||||
public static final String HTML_TEXTAREA = "textarea";
|
||||
|
||||
/** 下拉框 */
|
||||
public static final String HTML_SELECT = "select";
|
||||
|
||||
/** 单选框 */
|
||||
public static final String HTML_RADIO = "radio";
|
||||
|
||||
/** 复选框 */
|
||||
public static final String HTML_CHECKBOX = "checkbox";
|
||||
|
||||
/** 日期控件 */
|
||||
public static final String HTML_DATETIME = "datetime";
|
||||
|
||||
/** 图片上传控件 */
|
||||
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
|
||||
|
||||
/** 文件上传控件 */
|
||||
public static final String HTML_FILE_UPLOAD = "fileUpload";
|
||||
|
||||
/** 富文本控件 */
|
||||
public static final String HTML_EDITOR = "editor";
|
||||
|
||||
/** 字符串类型 */
|
||||
public static final String TYPE_STRING = "String";
|
||||
|
||||
/** 整型 */
|
||||
public static final String TYPE_INTEGER = "Integer";
|
||||
|
||||
/** 长整型 */
|
||||
public static final String TYPE_LONG = "Long";
|
||||
|
||||
/** 浮点型 */
|
||||
public static final String TYPE_DOUBLE = "Double";
|
||||
|
||||
/** 高精度计算类型 */
|
||||
public static final String TYPE_BIGDECIMAL = "BigDecimal";
|
||||
|
||||
/** 时间类型 */
|
||||
public static final String TYPE_DATE = "Date";
|
||||
|
||||
/** 模糊查询 */
|
||||
public static final String QUERY_LIKE = "LIKE";
|
||||
|
||||
/** 相等查询 */
|
||||
public static final String QUERY_EQ = "EQ";
|
||||
|
||||
/** 需要 */
|
||||
public static final String REQUIRE = "1";
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
package vboot.core.module.ass.coge.velocity;
|
||||
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
import vboot.core.xutil.ruoyi.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 代码生成器 工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class GenUtils
|
||||
{
|
||||
/**
|
||||
* 初始化表信息
|
||||
*/
|
||||
// public static void initTable(AssCogeTable genTable, String operName)
|
||||
// {
|
||||
// genTable.setClassName(convertClassName(genTable.getTableName()));
|
||||
// genTable.setPackageName(GenConfig.getPackageName());
|
||||
// genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
||||
// genTable.setBusinessName(getBusinessName(genTable.getTableName()));
|
||||
// genTable.setFunctionName(replaceText(genTable.getTableComment()));
|
||||
// genTable.setFunctionAuthor(GenConfig.getAuthor());
|
||||
//// genTable.setCreateBy(operName);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 初始化列属性字段
|
||||
*/
|
||||
// public static void initColumnField(AssCogeField column, AssCogeTable table)
|
||||
// {
|
||||
// String dataType = getDbType(column.getColumnType());
|
||||
// String columnName = column.getColumnName();
|
||||
// column.setTableId(table.getTableId());
|
||||
//// column.setCreateBy(table.getCreateBy());
|
||||
// // 设置java字段名
|
||||
// column.setJavaField(StringUtils.toCamelCase(columnName));
|
||||
// // 设置默认类型
|
||||
// column.setJavaType(GenConstants.TYPE_STRING);
|
||||
// column.setQueryType(GenConstants.QUERY_EQ);
|
||||
//
|
||||
// if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
|
||||
// {
|
||||
// // 字符串长度超过500设置为文本域
|
||||
// Integer columnLength = getColumnLength(column.getColumnType());
|
||||
// String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
||||
// column.setHtmlType(htmlType);
|
||||
// }
|
||||
// else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
|
||||
// {
|
||||
// column.setJavaType(GenConstants.TYPE_DATE);
|
||||
// column.setHtmlType(GenConstants.HTML_DATETIME);
|
||||
// }
|
||||
// else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType))
|
||||
// {
|
||||
// column.setHtmlType(GenConstants.HTML_INPUT);
|
||||
//
|
||||
// // 如果是浮点型 统一用BigDecimal
|
||||
// String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
||||
// if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0)
|
||||
// {
|
||||
// column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||
// }
|
||||
// // 如果是整形
|
||||
// else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10)
|
||||
// {
|
||||
// column.setJavaType(GenConstants.TYPE_INTEGER);
|
||||
// }
|
||||
// // 长整形
|
||||
// else
|
||||
// {
|
||||
// column.setJavaType(GenConstants.TYPE_LONG);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 插入字段(默认所有字段都需要插入)
|
||||
// column.setIsInsert(GenConstants.REQUIRE);
|
||||
//
|
||||
// // 编辑字段
|
||||
// if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk())
|
||||
// {
|
||||
// column.setIsEdit(GenConstants.REQUIRE);
|
||||
// }
|
||||
// // 列表字段
|
||||
// if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk())
|
||||
// {
|
||||
// column.setIsList(GenConstants.REQUIRE);
|
||||
// }
|
||||
// // 查询字段
|
||||
// if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk())
|
||||
// {
|
||||
// column.setIsQuery(GenConstants.REQUIRE);
|
||||
// }
|
||||
//
|
||||
// // 查询字段类型
|
||||
// if (StringUtils.endsWithIgnoreCase(columnName, "name"))
|
||||
// {
|
||||
// column.setQueryType(GenConstants.QUERY_LIKE);
|
||||
// }
|
||||
// // 状态字段设置单选框
|
||||
// if (StringUtils.endsWithIgnoreCase(columnName, "status"))
|
||||
// {
|
||||
// column.setHtmlType(GenConstants.HTML_RADIO);
|
||||
// }
|
||||
// // 类型&性别字段设置下拉框
|
||||
// else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
||||
// || StringUtils.endsWithIgnoreCase(columnName, "sex"))
|
||||
// {
|
||||
// column.setHtmlType(GenConstants.HTML_SELECT);
|
||||
// }
|
||||
// // 图片字段设置图片上传控件
|
||||
// else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
|
||||
// {
|
||||
// column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
|
||||
// }
|
||||
// // 文件字段设置文件上传控件
|
||||
// else if (StringUtils.endsWithIgnoreCase(columnName, "file"))
|
||||
// {
|
||||
// column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
|
||||
// }
|
||||
// // 内容字段设置富文本控件
|
||||
// else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
|
||||
// {
|
||||
// column.setHtmlType(GenConstants.HTML_EDITOR);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 校验数组是否包含指定值
|
||||
*
|
||||
* @param arr 数组
|
||||
* @param targetValue 值
|
||||
* @return 是否包含
|
||||
*/
|
||||
public static boolean arraysContains(String[] arr, String targetValue)
|
||||
{
|
||||
return Arrays.asList(arr).contains(targetValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模块名
|
||||
*
|
||||
* @param packageName 包名
|
||||
* @return 模块名
|
||||
*/
|
||||
public static String getModuleName(String packageName)
|
||||
{
|
||||
int lastIndex = packageName.lastIndexOf(".");
|
||||
int nameLength = packageName.length();
|
||||
return StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务名
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @return 业务名
|
||||
*/
|
||||
public static String getBusinessName(String tableName)
|
||||
{
|
||||
int lastIndex = tableName.lastIndexOf("_");
|
||||
int nameLength = tableName.length();
|
||||
return StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 表名转换成Java类名
|
||||
*
|
||||
* @param tableName 表名称
|
||||
* @return 类名
|
||||
*/
|
||||
public static String convertClassName(String tableName)
|
||||
{
|
||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
||||
String tablePrefix = GenConfig.getTablePrefix();
|
||||
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
|
||||
{
|
||||
String[] searchList = StringUtils.split(tablePrefix, ",");
|
||||
tableName = replaceFirst(tableName, searchList);
|
||||
}
|
||||
return StringUtils.convertToCamelCase(tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量替换前缀
|
||||
*
|
||||
* @param replacementm 替换值
|
||||
* @param searchList 替换列表
|
||||
* @return
|
||||
*/
|
||||
public static String replaceFirst(String replacementm, String[] searchList)
|
||||
{
|
||||
String text = replacementm;
|
||||
for (String searchString : searchList)
|
||||
{
|
||||
if (replacementm.startsWith(searchString))
|
||||
{
|
||||
text = replacementm.replaceFirst(searchString, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键字替换
|
||||
*
|
||||
* @param text 需要被替换的名字
|
||||
* @return 替换后的名字
|
||||
*/
|
||||
public static String replaceText(String text)
|
||||
{
|
||||
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型字段
|
||||
*
|
||||
* @param columnType 列类型
|
||||
* @return 截取后的列类型
|
||||
*/
|
||||
public static String getDbType(String columnType)
|
||||
{
|
||||
if (StringUtils.indexOf(columnType, "(") > 0)
|
||||
{
|
||||
return StringUtils.substringBefore(columnType, "(");
|
||||
}
|
||||
else
|
||||
{
|
||||
return columnType;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段长度
|
||||
*
|
||||
* @param columnType 列类型
|
||||
* @return 截取后的列类型
|
||||
*/
|
||||
public static Integer getColumnLength(String columnType)
|
||||
{
|
||||
if (StringUtils.indexOf(columnType, "(") > 0)
|
||||
{
|
||||
String length = StringUtils.substringBetween(columnType, "(", ")");
|
||||
return Integer.valueOf(length);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package vboot.core.module.ass.coge.velocity;
|
||||
|
||||
import org.apache.velocity.app.Velocity;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* VelocityEngine工厂
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class VelocityInitializer
|
||||
{
|
||||
/**
|
||||
* 初始化vm方法
|
||||
*/
|
||||
public static void initVelocity()
|
||||
{
|
||||
Properties p = new Properties();
|
||||
try
|
||||
{
|
||||
// 加载classpath目录下的vm文件
|
||||
p.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
||||
// 定义字符集
|
||||
p.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
|
||||
// 初始化Velocity引擎,指定配置Properties
|
||||
Velocity.init(p);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,448 @@
|
||||
package vboot.core.module.ass.coge.velocity;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
//import com.ruoyi.common.constant.GenConstants;
|
||||
//import com.ruoyi.common.utils.DateUtils;
|
||||
//import com.ruoyi.common.utils.StringUtils;
|
||||
//import com.ruoyi.generator.domain.GenTable;
|
||||
//import com.ruoyi.generator.domain.GenTableColumn;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import vboot.core.module.ass.coge.table.AssCogeField;
|
||||
import vboot.core.module.ass.coge.table.AssCogeTable;
|
||||
import vboot.core.xutil.ruoyi.DateUtils;
|
||||
import vboot.core.xutil.ruoyi.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 模板处理工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class VelocityUtils
|
||||
{
|
||||
/** 项目空间路径 */
|
||||
private static final String PROJECT_PATH = "main/java";
|
||||
|
||||
/** mybatis空间路径 */
|
||||
private static final String MYBATIS_PATH = "main/resources/mapper";
|
||||
|
||||
/** 默认上级菜单,系统工具 */
|
||||
private static final String DEFAULT_PARENT_MENU_ID = "3";
|
||||
|
||||
/**
|
||||
* 设置模板变量信息
|
||||
*
|
||||
* @return 模板列表
|
||||
*/
|
||||
public static VelocityContext prepareContext(AssCogeTable genTable)
|
||||
{
|
||||
String basePackageName="vboot.app.module.";
|
||||
String[] arr= genTable.getName().split("_");
|
||||
String modulePackageName="";
|
||||
for (String str : arr) {
|
||||
modulePackageName+= str+".";
|
||||
}
|
||||
modulePackageName = modulePackageName.substring(0, modulePackageName.length() - 1);
|
||||
String packageName = basePackageName+modulePackageName;
|
||||
|
||||
// String moduleName = genTable.getModuleName();
|
||||
// String businessName = genTable.getBusinessName();
|
||||
//
|
||||
// String tplCategory = genTable.getTplCategory();
|
||||
// String functionName = genTable.getFunctionName();
|
||||
|
||||
VelocityContext velocityContext = new VelocityContext();
|
||||
// velocityContext.put("tplCategory", genTable.getTplCategory());
|
||||
// velocityContext.put("tableName", genTable.getTableName());
|
||||
// velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
||||
// velocityContext.put("ClassName", genTable.getClassName());
|
||||
// velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
||||
// velocityContext.put("moduleName", genTable.getModuleName());
|
||||
// velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
|
||||
// velocityContext.put("businessName", genTable.getBusinessName());
|
||||
// velocityContext.put("basePackage", getPackagePrefix(packageName));
|
||||
velocityContext.put("packageName", packageName);
|
||||
velocityContext.put("fields", genTable.getFields());
|
||||
|
||||
// velocityContext.put("author", genTable.getFunctionAuthor());
|
||||
velocityContext.put("datetime", DateUtils.getDate());
|
||||
// velocityContext.put("pkColumn", genTable.getPkColumn());
|
||||
velocityContext.put("importList", getImportList(genTable));
|
||||
// velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
||||
// velocityContext.put("columns", genTable.getColumns());
|
||||
velocityContext.put("table", genTable);
|
||||
// velocityContext.put("dicts", getDicts(genTable));
|
||||
// setMenuVelocityContext(velocityContext, genTable);
|
||||
// if (GenConstants.TPL_TREE.equals(tplCategory))
|
||||
// {
|
||||
// setTreeVelocityContext(velocityContext, genTable);
|
||||
// }
|
||||
// if (GenConstants.TPL_SUB.equals(tplCategory))
|
||||
// {
|
||||
// setSubVelocityContext(velocityContext, genTable);
|
||||
// }
|
||||
return velocityContext;
|
||||
}
|
||||
|
||||
// public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
|
||||
// {
|
||||
// String options = genTable.getOptions();
|
||||
// JSONObject paramsObj = JSON.parseObject(options);
|
||||
// String parentMenuId = getParentMenuId(paramsObj);
|
||||
// context.put("parentMenuId", parentMenuId);
|
||||
// }
|
||||
|
||||
// public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
|
||||
// {
|
||||
// String options = genTable.getOptions();
|
||||
// JSONObject paramsObj = JSON.parseObject(options);
|
||||
// String treeCode = getTreecode(paramsObj);
|
||||
// String treeParentCode = getTreeParentCode(paramsObj);
|
||||
// String treeName = getTreeName(paramsObj);
|
||||
//
|
||||
// context.put("treeCode", treeCode);
|
||||
// context.put("treeParentCode", treeParentCode);
|
||||
// context.put("treeName", treeName);
|
||||
// context.put("expandColumn", getExpandColumn(genTable));
|
||||
// if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
|
||||
// {
|
||||
// context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||
// }
|
||||
// if (paramsObj.containsKey(GenConstants.TREE_NAME))
|
||||
// {
|
||||
// context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void setSubVelocityContext(VelocityContext context, AssCogeTable genTable)
|
||||
{
|
||||
// AssCogeTable subTable = genTable.getSubTable();
|
||||
// String subTableName = genTable.getSubTableName();
|
||||
// String subTableFkName = genTable.getSubTableFkName();
|
||||
// String subClassName = genTable.getSubTable().getClassName();
|
||||
// String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
|
||||
//
|
||||
// context.put("subTable", subTable);
|
||||
// context.put("subTableName", subTableName);
|
||||
// context.put("subTableFkName", subTableFkName);
|
||||
// context.put("subTableFkClassName", subTableFkClassName);
|
||||
// context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
|
||||
// context.put("subClassName", subClassName);
|
||||
// context.put("subclassName", StringUtils.uncapitalize(subClassName));
|
||||
// context.put("subImportList", getImportList(genTable.getSubTable()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模板信息
|
||||
*
|
||||
* @return 模板列表
|
||||
*/
|
||||
public static List<String> getTemplateList(String tplCategory)
|
||||
{
|
||||
List<String> templates = new ArrayList<String>();
|
||||
templates.add("vms/main/entity.java.vm");
|
||||
templates.add("vms/main/repo.java.vm");
|
||||
templates.add("vms/main/service.java.vm");
|
||||
templates.add("vms/main/api.java.vm");
|
||||
templates.add("vms/main/index.vue.vm");
|
||||
templates.add("vms/main/edit.vue.vm");
|
||||
// templates.add("vms/java/domain.java.vm");
|
||||
// templates.add("vms/java/mapper.java.vm");
|
||||
// templates.add("vms/java/service.java.vm");
|
||||
// templates.add("vms/java/serviceImpl.java.vm");
|
||||
// templates.add("vms/java/controller.java.vm");
|
||||
// templates.add("vms/xml/mapper.xml.vm");
|
||||
// templates.add("vms/sql/sql.vm");
|
||||
// templates.add("vms/js/api.js.vm");
|
||||
// if (GenConstants.TPL_CRUD.equals(tplCategory))
|
||||
// {
|
||||
// templates.add("vms/vue/index.vue.vm");
|
||||
// }
|
||||
// else if (GenConstants.TPL_TREE.equals(tplCategory))
|
||||
// {
|
||||
// templates.add("vms/vue/index-tree.vue.vm");
|
||||
// }
|
||||
// else if (GenConstants.TPL_SUB.equals(tplCategory))
|
||||
// {
|
||||
// templates.add("vms/vue/index.vue.vm");
|
||||
// templates.add("vms/java/sub-domain.java.vm");
|
||||
// }
|
||||
return templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件名
|
||||
*/
|
||||
public static String getFileName(String template, AssCogeTable genTable)
|
||||
{
|
||||
System.out.println(111111111);
|
||||
// 文件名称
|
||||
String fileName = "";
|
||||
// 包路径
|
||||
// String packageName = genTable.getPackageName();
|
||||
String packageName = "fdsafdsa";
|
||||
// 模块名
|
||||
// String moduleName = genTable.getModuleName();
|
||||
// 大写类名
|
||||
// String className = genTable.getClassName();
|
||||
String className = genTable.getBunam();
|
||||
// 业务名称
|
||||
// String businessName = genTable.getBusinessName();
|
||||
String businessName = genTable.getBunam();
|
||||
|
||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
|
||||
// String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
||||
String vuePath = "vue";
|
||||
if (template.contains("entity.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("java/{}/{}.java",
|
||||
genTable.getName().replace("_","/"), className);
|
||||
}
|
||||
else if (template.contains("repo.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("java/{}/{}Repo.java",
|
||||
genTable.getName().replace("_","/"), className);
|
||||
}
|
||||
else if (template.contains("service.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("java/{}/{}Service.java",
|
||||
genTable.getName().replace("_","/"), className);
|
||||
}else if (template.contains("api.java.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("java/{}/{}Api.java",
|
||||
genTable.getName().replace("_","/"), className);
|
||||
}else if (template.contains("index.vue.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("vue/{}/index.vue",
|
||||
genTable.getName().replace("_","/"));
|
||||
}else if (template.contains("edit.vue.vm"))
|
||||
{
|
||||
fileName = StringUtils.format("vue/{}/edit.vue",
|
||||
genTable.getName().replace("_","/"));
|
||||
}
|
||||
// else if (template.contains("domain.java.vm"))
|
||||
// {
|
||||
// fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
||||
// }
|
||||
// else if (template.contains("mapper.java.vm"))
|
||||
// {
|
||||
// fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
||||
// }
|
||||
//// else if (template.contains("service.java.vm"))
|
||||
//// {
|
||||
//// fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
|
||||
//// }
|
||||
// else if (template.contains("serviceImpl.java.vm"))
|
||||
// {
|
||||
// fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
||||
// }
|
||||
// else if (template.contains("controller.java.vm"))
|
||||
// {
|
||||
// fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
|
||||
// }
|
||||
// else if (template.contains("mapper.xml.vm"))
|
||||
// {
|
||||
// fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
||||
// }
|
||||
// else if (template.contains("sql.vm"))
|
||||
// {
|
||||
// fileName = businessName + "Menu.sql";
|
||||
// }
|
||||
// else if (template.contains("api.js.vm"))
|
||||
// {
|
||||
// fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
||||
// }
|
||||
// else if (template.contains("index.vue.vm"))
|
||||
// {
|
||||
// fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
// }
|
||||
// else if (template.contains("index-tree.vue.vm"))
|
||||
// {
|
||||
// fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
// }
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取包前缀
|
||||
*
|
||||
* @param packageName 包名称
|
||||
* @return 包前缀名称
|
||||
*/
|
||||
public static String getPackagePrefix(String packageName)
|
||||
{
|
||||
int lastIndex = packageName.lastIndexOf(".");
|
||||
return StringUtils.substring(packageName, 0, lastIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据列类型获取导入包
|
||||
*
|
||||
* @param genTable 业务表对象
|
||||
* @return 返回需要导入的包列表
|
||||
*/
|
||||
public static HashSet<String> getImportList(AssCogeTable genTable)
|
||||
{
|
||||
List<AssCogeField> columns = genTable.getFields();
|
||||
// AssCogeTable subGenTable = genTable.getSubTable();
|
||||
HashSet<String> importList = new HashSet<String>();
|
||||
// if (StringUtils.isNotNull(subGenTable))
|
||||
// {
|
||||
// importList.add("java.util.List");
|
||||
// }
|
||||
// for (GenTableColumn column : columns)
|
||||
// {
|
||||
// if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
|
||||
// {
|
||||
// importList.add("java.util.Date");
|
||||
// importList.add("com.fasterxml.jackson.annotation.JsonFormat");
|
||||
// }
|
||||
// else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType()))
|
||||
// {
|
||||
// importList.add("java.math.BigDecimal");
|
||||
// }
|
||||
// }
|
||||
return importList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据列类型获取字典组
|
||||
*
|
||||
* @param genTable 业务表对象
|
||||
* @return 返回字典组
|
||||
*/
|
||||
// public static String getDicts(GenTable genTable)
|
||||
// {
|
||||
// List<GenTableColumn> columns = genTable.getColumns();
|
||||
// Set<String> dicts = new HashSet<String>();
|
||||
// addDicts(dicts, columns);
|
||||
// if (StringUtils.isNotNull(genTable.getSubTable()))
|
||||
// {
|
||||
// List<GenTableColumn> subColumns = genTable.getSubTable().getColumns();
|
||||
// addDicts(dicts, subColumns);
|
||||
// }
|
||||
// return StringUtils.join(dicts, ", ");
|
||||
// }
|
||||
|
||||
/**
|
||||
* 添加字典列表
|
||||
*
|
||||
* @param dicts 字典列表
|
||||
* @param columns 列集合
|
||||
*/
|
||||
// public static void addDicts(Set<String> dicts, List<AssCogeField> columns)
|
||||
// {
|
||||
// for (AssCogeField column : columns)
|
||||
// {
|
||||
// if (!column.isSuperColumn() && StringUtils.isNotEmpty(column.getDictType()) && StringUtils.equalsAny(
|
||||
// column.getHtmlType(),
|
||||
// new String[] { GenConstants.HTML_SELECT, GenConstants.HTML_RADIO, GenConstants.HTML_CHECKBOX }))
|
||||
// {
|
||||
// dicts.add("'" + column.getDictType() + "'");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取权限前缀
|
||||
*
|
||||
* @param moduleName 模块名称
|
||||
* @param businessName 业务名称
|
||||
* @return 返回权限前缀
|
||||
*/
|
||||
public static String getPermissionPrefix(String moduleName, String businessName)
|
||||
{
|
||||
return StringUtils.format("{}:{}", moduleName, businessName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上级菜单ID字段
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 上级菜单ID字段
|
||||
*/
|
||||
// public static String getParentMenuId(JSONObject paramsObj)
|
||||
// {
|
||||
// if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)
|
||||
// && StringUtils.isNotEmpty(paramsObj.getString(GenConstants.PARENT_MENU_ID)))
|
||||
// {
|
||||
// return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
||||
// }
|
||||
// return DEFAULT_PARENT_MENU_ID;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取树编码
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树编码
|
||||
*/
|
||||
public static String getTreecode(JSONObject paramsObj)
|
||||
{
|
||||
if (paramsObj.containsKey(GenConstants.TREE_CODE))
|
||||
{
|
||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取树父编码
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树父编码
|
||||
*/
|
||||
public static String getTreeParentCode(JSONObject paramsObj)
|
||||
{
|
||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
|
||||
{
|
||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取树名称
|
||||
*
|
||||
* @param paramsObj 生成其他选项
|
||||
* @return 树名称
|
||||
*/
|
||||
public static String getTreeName(JSONObject paramsObj)
|
||||
{
|
||||
if (paramsObj.containsKey(GenConstants.TREE_NAME))
|
||||
{
|
||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需要在哪一列上面显示展开按钮
|
||||
*
|
||||
* @param genTable 业务表对象
|
||||
* @return 展开按钮列序号
|
||||
*/
|
||||
// public static int getExpandColumn(AssCogeTable genTable)
|
||||
// {
|
||||
// String options = genTable.getOptions();
|
||||
// JSONObject paramsObj = JSON.parseObject(options);
|
||||
// String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
||||
// int num = 0;
|
||||
// for (AssCogeField column : genTable.getFields())
|
||||
// {
|
||||
//// if (column.isList())
|
||||
//// {
|
||||
//// num++;
|
||||
//// String columnName = column.getColumnName();
|
||||
//// if (columnName.equals(treeName))
|
||||
//// {
|
||||
//// break;
|
||||
//// }
|
||||
//// }
|
||||
// }
|
||||
// return num;
|
||||
// }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.ass.dict.cate;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -12,32 +12,32 @@ public class AssDictCateApi {
|
||||
private String table = "ass_dict_cate";
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler(table);
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addSelect("t.notes,t.ornum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
AssDictCate cate = service.findOne(id);
|
||||
return RestResult.ok(cate);
|
||||
return R.ok(cate);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody AssDictCate main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody AssDictCate cate) {
|
||||
return R.ok(service.insert(cate));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody AssDictCate main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody AssDictCate cate) {
|
||||
return R.ok(service.update(cate));
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.ass.dict.data;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -15,7 +15,7 @@ public class AssDictDataApi {
|
||||
private String table = "ass_dict_data";
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name,String maiid) {
|
||||
public R get(String name, String maiid) {
|
||||
Sqler sqler = new Sqler(table);
|
||||
if(XstrUtil.isNotBlank(name)){
|
||||
sqler.addWhere("(t.name like ? or t.id like ?)","%"+name+"%","%"+name+"%");
|
||||
@@ -23,36 +23,36 @@ public class AssDictDataApi {
|
||||
sqler.addEqual("t.maiid", maiid);
|
||||
sqler.addSelect("t.notes,t.ornum,t.code");
|
||||
sqler.addOrder("t.ornum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getList(String maiid) {
|
||||
public R getList(String maiid) {
|
||||
Sqler sqler = new Sqler(table);
|
||||
sqler.addEqual("t.maiid",maiid);
|
||||
sqler.addOrder("t.ornum");
|
||||
return RestResult.ok( jdbcDao.findIdNameList(sqler));
|
||||
return R.ok( jdbcDao.findIdNameList(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
AssDictData main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody AssDictData main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody AssDictData main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody AssDictData main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody AssDictData main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.ass.dict.main;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -15,40 +15,40 @@ public class AssDictMainApi {
|
||||
private String table = "ass_dict_main";
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler(table);
|
||||
if(XstrUtil.isNotBlank(name)){
|
||||
sqler.addWhere("(t.name like ? or t.id like ?)","%"+name+"%","%"+name+"%");
|
||||
}
|
||||
sqler.addSelect("t.notes,t.ornum,t.code");
|
||||
sqler.addOrder("t.ornum");
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
AssDictMain main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult getList() {
|
||||
return RestResult.ok(service.findAll());
|
||||
public R getList() {
|
||||
return R.ok(service.findAll());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody AssDictMain main) throws DocumentException {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody AssDictMain main) throws DocumentException {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody AssDictMain main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody AssDictMain main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.ass.num.main;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,45 +13,45 @@ import java.util.Date;
|
||||
public class AssNumMainApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("t.*","ass_num_main");
|
||||
sqler.addLike("t.name",name);
|
||||
sqler.addSelect("t.nupre,t.nunex,t.numod");
|
||||
return RestResult.ok(service.findPageData(sqler)) ;
|
||||
return R.ok(service.findPageData(sqler)) ;
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
AssNumMain main=repo.findById(id).get();
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public synchronized RestResult post(@RequestBody AssNumMain main) {
|
||||
public synchronized R post(@RequestBody AssNumMain main) {
|
||||
if(repo.existsById(main.getId())){
|
||||
return RestResult.build(201,"编号已存在,请修改编号");
|
||||
return R.build(201,"编号已存在,请修改编号");
|
||||
}
|
||||
main.setNflag(true);
|
||||
repo.save(main);
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult pust(@RequestBody AssNumMain main) {
|
||||
public R pust(@RequestBody AssNumMain main) {
|
||||
if(XstrUtil.isBlank(main.getNunex())){
|
||||
main.setNflag(true);
|
||||
}
|
||||
main.setUptim(new Date());
|
||||
repo.save(main);
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
for (String id : ids) {
|
||||
repo.deleteById(id);
|
||||
}
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -27,7 +27,7 @@ public class AssNumMainService {
|
||||
|
||||
//生成客户编码
|
||||
//编码前缀+"-"+利用日期位格式生成当前的日期[yyyyMMdd ]+"-"+0001 c-20220914-0001
|
||||
String back = (num.getNupre() == null ? "" : num.getNupre()) + DateFormatUtils.format(new Date(), dateType) + firstSerialNum;
|
||||
String back = (num.getNupre() == null ? "" : num.getNupre()) + curDate + firstSerialNum;
|
||||
//修改代码规则表
|
||||
//下一个流水号="0002"
|
||||
num.setNunex(nextSerialNum);
|
||||
@@ -51,7 +51,7 @@ public class AssNumMainService {
|
||||
String nextSerialNum = NumUtil.getNextSerialNum(nextseq);
|
||||
//生成客户编码
|
||||
//编码前缀+"-"+利用日期位格式生成当前的日期[yyyyMMdd ]+"-"+0001
|
||||
String back = (num.getNupre() == null ? "" : num.getNupre()) + DateFormatUtils.format(new Date(), dateType) + nextseq;
|
||||
String back = (num.getNupre() == null ? "" : num.getNupre()) + sysCurDate + nextseq;
|
||||
//修改代码规则表
|
||||
//下一个流水号="0003"
|
||||
num.setNunex(nextSerialNum);
|
||||
@@ -67,7 +67,7 @@ public class AssNumMainService {
|
||||
String nextSerialNum = NumUtil.getNextSerialNum(firstSerialNum);
|
||||
//生成客户编码
|
||||
//编码前缀+"-"+利用日期位格式生成当前的日期[yyyyMMdd ]+"-"+0001
|
||||
String back = (num.getNupre() == null ? "" : num.getNupre()) + DateFormatUtils.format(new Date(), dateType) + firstSerialNum;
|
||||
String back = (num.getNupre() == null ? "" : num.getNupre()) + sysCurDate + firstSerialNum;
|
||||
//修改代码规则表
|
||||
//下一个流水号="0002"
|
||||
num.setNunex(nextSerialNum);
|
||||
|
||||
@@ -27,15 +27,16 @@ public class NumUtil {
|
||||
|
||||
public static String getNum(String numNow, String hintType) {
|
||||
String numNext = "";
|
||||
String todayYYYYMM=XdateUtil.getYYYYMM();
|
||||
if("yyyymmxx".equals(hintType)){
|
||||
if(numNow==null){
|
||||
numNext= XdateUtil.getYYYYMM()+getFirstSerialNum(2);
|
||||
numNext=todayYYYYMM +getFirstSerialNum(2);
|
||||
}else{
|
||||
String yyyymm=numNow.substring(0,6);
|
||||
if(XdateUtil.getYYYYMM().equals(yyyymm)){
|
||||
if(todayYYYYMM.equals(yyyymm)){
|
||||
numNext= yyyymm+getNextSerialNum(numNow.substring(numNow.length() -2));
|
||||
}else{
|
||||
numNext= XdateUtil.getYYYYMM()+getFirstSerialNum(2);
|
||||
numNext= todayYYYYMM+getFirstSerialNum(2);
|
||||
}
|
||||
}
|
||||
}else if("xxxxxx".equals(hintType)){
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package vboot.core.module.bpm.audit.main;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -10,11 +9,11 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class BpmAuditMainApi {
|
||||
|
||||
// @GetMapping("list")
|
||||
// public RestResult list(String proid) {
|
||||
// public R list(String proid) {
|
||||
// String sql = "select t.id,t.crtim,t.facna,t.facno,t.opnot,t.opinf,o.name as haman from bpm_audit_main t " +
|
||||
// "inner join sys_org o on o.id=t.haman " +
|
||||
// "where t.proid=? order by t.crtim";
|
||||
// return RestResult.ok(jdbcDao.findMapList(sql,proid));
|
||||
// return R.ok(jdbcDao.findMapList(sql,proid));
|
||||
// }
|
||||
//
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.bpm.proc.main;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.pojo.Zinp;
|
||||
@@ -16,20 +16,20 @@ import java.util.*;
|
||||
public class BpmProcMainApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name, String catid) {
|
||||
public R get(String name, String catid) {
|
||||
Sqler sqler = new Sqler("bpm_proc_main");
|
||||
sqler.addLike("t.name", name);
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
BpmProcMain main = service.findOne(id);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@GetMapping("zbpm")
|
||||
public RestResult zbpm(String proid) {
|
||||
public R zbpm(String proid) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//审批记录
|
||||
String sql = "select t.id,t.crtim,t.facna,t.facno,t.opnot,t.opinf,o.name as haman from bpm_audit_main t " +
|
||||
@@ -80,11 +80,11 @@ public class BpmProcMainApi {
|
||||
map.put("cuExmen", cuExmen);
|
||||
map.put("cutag", cutag);
|
||||
map.put("zbpm", zbpm);
|
||||
return RestResult.ok(map);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
@GetMapping("target")
|
||||
public RestResult target(String proid, String facno) {
|
||||
public R target(String proid, String facno) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Znode nextNode;
|
||||
//如果是之前被驳回的节点则,通过后要判断是否直接返回驳回的节点
|
||||
@@ -107,13 +107,13 @@ public class BpmProcMainApi {
|
||||
if (bacMap != null) {
|
||||
map.put("bacid", bacMap.get("id"));
|
||||
}
|
||||
return RestResult.ok(map);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
|
||||
//返回当前节点之前的已走过的节点
|
||||
@GetMapping("refnodes")
|
||||
public RestResult refNodes(String proid, String facno) {
|
||||
public R refNodes(String proid, String facno) {
|
||||
String sql = "select distinct t.facno id,t.facna name,t.haman exman from bpm_audit_main t " +
|
||||
"where proid=? and opkey in('dsubmit','pass') order by t.crtim";
|
||||
List<Map<String, Object>> mapList = jdbcDao.findMapList(sql, proid);
|
||||
@@ -124,11 +124,11 @@ public class BpmProcMainApi {
|
||||
}
|
||||
list.add(map);
|
||||
}
|
||||
return RestResult.ok(list);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@GetMapping("xml")
|
||||
public RestResult xml(String proid) {
|
||||
public R xml(String proid) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String xmlSql = "select t.orxml id from bpm_proc_temp t " +
|
||||
"inner join bpm_proc_main m on m.temid=t.id where m.id=?";
|
||||
@@ -156,11 +156,11 @@ public class BpmProcMainApi {
|
||||
map.put("xml", orxml);
|
||||
map.put("nodeList", nodeList);
|
||||
map.put("lineList", lineSet);
|
||||
return RestResult.ok(map);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
@GetMapping("texml")
|
||||
public RestResult texml(String temid) {
|
||||
public R texml(String temid) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String sql = "select t.orxml from bpm_proc_temp t where t.id=?";
|
||||
String orxml = jdbcDao.findOneString(sql, temid);
|
||||
@@ -171,37 +171,37 @@ public class BpmProcMainApi {
|
||||
map.put("tarna", nextNode.getFacna());
|
||||
map.put("tamen", tamen);
|
||||
map.put("xml", orxml);
|
||||
return RestResult.ok(map);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
// @PostMapping("hpass")
|
||||
// public RestResult hpass(@RequestBody Zbpm zbpm) {
|
||||
// public R hpass(@RequestBody Zbpm zbpm) {
|
||||
//
|
||||
//
|
||||
// service.handlerPass(zbpm);
|
||||
// return RestResult.ok();
|
||||
// return R.ok();
|
||||
// }
|
||||
|
||||
// @PostMapping("hrefuse")
|
||||
// public RestResult hrefuse(@RequestBody Zbpm zbpm) {
|
||||
// public R hrefuse(@RequestBody Zbpm zbpm) {
|
||||
//
|
||||
// service.handlerRefuse(zbpm);
|
||||
// return RestResult.ok();
|
||||
// return R.ok();
|
||||
// }
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody BpmProcMain main) {
|
||||
return RestResult.ok(service.insert(main));
|
||||
public R post(@RequestBody BpmProcMain main) {
|
||||
return R.ok(service.insert(main).getId());
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody BpmProcMain main) {
|
||||
return RestResult.ok(service.update(main));
|
||||
public R put(@RequestBody BpmProcMain main) {
|
||||
return R.ok(service.update(main).getId());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.gen.num;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -11,8 +11,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class GenNumApi {
|
||||
|
||||
@GetMapping("uuid")
|
||||
public RestResult uuid() {
|
||||
return RestResult.ok(XstrUtil.getUUID());
|
||||
public R uuid() {
|
||||
return R.ok(XstrUtil.getUUID());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.gen.org.rece;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.xutil.web.XuserUtil;
|
||||
@@ -17,7 +17,7 @@ import java.util.Map;
|
||||
public class GenOrgReceApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(Integer type) {
|
||||
public R get(Integer type) {
|
||||
List<Map<String, Object>> mapList = new ArrayList<>();
|
||||
String userId = XuserUtil.getUserId();
|
||||
if ((type & 8) != 0) {//用户
|
||||
@@ -41,15 +41,15 @@ public class GenOrgReceApi {
|
||||
mapList.addAll(jdbcDao.findMapList(postSqler));
|
||||
}
|
||||
// sqler.addDescOrder("t.uptim");
|
||||
return RestResult.ok(mapList);
|
||||
return R.ok(mapList);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody List<SysOrgRece> reces) {
|
||||
public R post(@RequestBody List<SysOrgRece> reces) {
|
||||
if(reces!=null&&reces.size()>0){
|
||||
service.update(reces);
|
||||
}
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.gen.org.root;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.pojo.Ztree;
|
||||
@@ -17,25 +17,25 @@ public class GenOrgDeptApi {
|
||||
|
||||
//查询部门树
|
||||
@GetMapping("tree")
|
||||
public RestResult getTree(String name) {
|
||||
public R getTree(String name) {
|
||||
Sqler sqler = new Sqler("sys_org_dept");
|
||||
sqler.addSelect("t.pid");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addOrder("t.ornum");
|
||||
sqler.addWhere("t.avtag=1");
|
||||
List<Ztree> list = jdbcDao.findTreeList(sqler);
|
||||
return RestResult.ok(list);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
//查询部门树
|
||||
@GetMapping("list")
|
||||
public RestResult getList(String name) {
|
||||
public R getList(String name) {
|
||||
Sqler sqler = new Sqler("sys_org_dept");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addOrder("t.ornum");
|
||||
sqler.addWhere("t.avtag=1");
|
||||
sqler.addSelect("t.pid");
|
||||
return RestResult.ok(jdbcDao.findMapList(sqler));
|
||||
return R.ok(jdbcDao.findMapList(sqler));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.gen.org.root;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
@@ -19,10 +19,10 @@ public class GenOrgMainApi {
|
||||
|
||||
//根据部门ID,查询下级所有的部门,岗位,用户
|
||||
@GetMapping()
|
||||
public RestResult get(String deptid, Integer type, String name) {
|
||||
public R get(String deptid, Integer type, String name) {
|
||||
List<Map<String, Object>> mapList = new ArrayList<>();
|
||||
if(XstrUtil.isBlank(name)&& XstrUtil.isBlank(deptid)){
|
||||
return RestResult.ok(mapList);
|
||||
return R.ok(mapList);
|
||||
}
|
||||
if ((type & 2) != 0) {//部门
|
||||
Sqler deptSqler = new Sqler("sys_org_dept");
|
||||
@@ -51,7 +51,7 @@ public class GenOrgMainApi {
|
||||
}
|
||||
mapList.addAll(jdbcDao.findMapList(userSqler));
|
||||
}
|
||||
return RestResult.ok(mapList);
|
||||
return R.ok(mapList);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.gen.sys.auth;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.security.pojo.Zuser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -16,7 +16,7 @@ import java.util.Map;
|
||||
public class GenAuthApi {
|
||||
|
||||
@PostMapping(value="btns")
|
||||
public RestResult getBtns(HttpServletRequest request, @RequestBody Map<String,String> btns) {
|
||||
public R getBtns(HttpServletRequest request, @RequestBody Map<String,String> btns) {
|
||||
Zuser zuser = null;
|
||||
Map<String, Boolean> backMap = new HashMap<>();
|
||||
for (String str : btns.keySet()) {
|
||||
@@ -35,12 +35,12 @@ public class GenAuthApi {
|
||||
|
||||
}
|
||||
}
|
||||
return RestResult.ok(backMap);
|
||||
return R.ok(backMap);
|
||||
}
|
||||
|
||||
//获取用户信息,如果没有登录到不了这里
|
||||
@GetMapping("user")
|
||||
public RestResult getUser(HttpServletRequest request,String id) {
|
||||
public R getUser(HttpServletRequest request,String id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Zuser zuser= null;
|
||||
if("sa".equals(id)){
|
||||
@@ -60,7 +60,7 @@ public class GenAuthApi {
|
||||
|
||||
}
|
||||
map.put("zuser", zuser);
|
||||
return RestResult.build(200, "已登录",map);
|
||||
return R.build(200, "已登录",map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package vboot.core.module.gen.sys.org;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
@@ -17,43 +17,43 @@ import javax.servlet.http.HttpServletRequest;
|
||||
@RequestMapping("gen/org")
|
||||
public class GenOrgApi {
|
||||
@GetMapping(value="watag")
|
||||
public RestResult getWatag(HttpServletRequest request) {
|
||||
public R getWatag(HttpServletRequest request) {
|
||||
Zuser zuser = null;
|
||||
String sql = "update sys_org_user set watag=0 where id=?";
|
||||
jdbcDao.update(sql, zuser.getId());
|
||||
zuser.setWatag(false);
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping(value="choose")
|
||||
public RestResult getChoose(String name, String type) {
|
||||
public R getChoose(String name, String type) {
|
||||
Sqler sqlHelper = new Sqler("id,pid,name","sys_org_main");
|
||||
sqlHelper.addWhere("t.avtag = 1");
|
||||
sqlHelper.addWhere(XstrUtil.isNotBlank(type),"type in ("+type+")");
|
||||
sqlHelper.addLike("name",name);
|
||||
sqlHelper.addEqual("t.label", "ekp");
|
||||
return RestResult.ok(jdbcDao.findInpList(sqlHelper));
|
||||
return R.ok(jdbcDao.findInpList(sqlHelper));
|
||||
}
|
||||
|
||||
@GetMapping("search")
|
||||
public RestResult getSearch(String name, String type) {
|
||||
public R getSearch(String name, String type) {
|
||||
Sqler sqlHelper = new Sqler("t.id,t.name","sys_org_main");
|
||||
sqlHelper.addLeftJoin("t2.name as pid", "sys_org t2", "t2.id=t.pid");
|
||||
sqlHelper.addWhere("t.avtag = 1");
|
||||
sqlHelper.addLike("t.name",name);
|
||||
sqlHelper.addWhere(XstrUtil.isNotBlank(type),"t.type in ("+type+")");
|
||||
return RestResult.ok(jdbcDao.findInpList(sqlHelper));
|
||||
return R.ok(jdbcDao.findInpList(sqlHelper));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("dept/{id}")
|
||||
public RestResult getDept(@PathVariable String id, String type) {
|
||||
public R getDept(@PathVariable String id, String type) {
|
||||
Sqler sqlHelper = new Sqler("t.id,t.name","sys_org_main");
|
||||
sqlHelper.addLeftJoin("t2.name as pid", "sys_org t2", "t2.id=t.pid");
|
||||
sqlHelper.addWhere("t.avtag = 1");
|
||||
sqlHelper.addWhere(XstrUtil.isNotBlank(type),"t.type in ("+type+")");
|
||||
sqlHelper.addWhere("t.pid = ?",id);
|
||||
return RestResult.ok(jdbcDao.findInpList(sqlHelper));
|
||||
return R.ok(jdbcDao.findInpList(sqlHelper));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package vboot.core.module.sys.job.log;
|
||||
package vboot.core.module.mon.job.log;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -8,7 +8,7 @@ import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class SysJobLog {
|
||||
public class MonJobLog {
|
||||
|
||||
@Id
|
||||
@Column(length = 32)
|
||||
@@ -0,0 +1,42 @@
|
||||
package vboot.core.module.mon.job.log;
|
||||
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("mon/job/log")
|
||||
public class MonJobLogApi {
|
||||
|
||||
private String table = "mon_job_log";
|
||||
|
||||
@GetMapping
|
||||
public R get(String name) {
|
||||
Sqler sqler = new Sqler("t.id,t.name,t.sttim,t.entim,t.ret", table);
|
||||
// XreqUtil.setPageParam(sqler);
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addOrder("t.entim desc");
|
||||
System.out.println(sqler.getSql());
|
||||
return R.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public R getOne(@PathVariable String id) {
|
||||
return R.ok(service.findOne(id));
|
||||
}
|
||||
|
||||
@DeleteMapping("all")
|
||||
public R deleteAll() {
|
||||
service.deleteAll();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private MonJobLogService service;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package vboot.core.module.mon.job.log;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface MonJobLogRepo extends JpaRepository<MonJobLog,String> {
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
package vboot.core.module.sys.job.log;
|
||||
package vboot.core.module.mon.job.log;
|
||||
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
@@ -11,7 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Slf4j
|
||||
public class SysJobLogService {
|
||||
public class MonJobLogService {
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public PageData findPageData(Sqler sqler) {
|
||||
@@ -31,12 +31,12 @@ public class SysJobLogService {
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public SysJobLog findOne(String id) {
|
||||
public MonJobLog findOne(String id) {
|
||||
return repo.findById(id).get();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private SysJobLogRepo repo;
|
||||
private MonJobLogRepo repo;
|
||||
|
||||
|
||||
@Autowired
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package vboot.core.module.sys.job.main;
|
||||
package vboot.core.module.mon.job.main;
|
||||
|
||||
import vboot.core.module.sys.job.root.IJob;
|
||||
import vboot.core.module.sys.job.root.IJobGroup;
|
||||
import vboot.core.module.mon.job.root.IJob;
|
||||
import vboot.core.module.mon.job.root.IJobGroup;
|
||||
import vboot.core.xutil.lang.XtimeUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@IJobGroup
|
||||
@Component
|
||||
public class SysJobDemo
|
||||
public class MonJobDemo
|
||||
{
|
||||
private static boolean usingFlag = false;
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package vboot.core.module.sys.job.main;
|
||||
package vboot.core.module.mon.job.main;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
@@ -11,7 +11,7 @@ import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class SysJobMain
|
||||
public class MonJobMain
|
||||
{
|
||||
@Id
|
||||
@Column(length = 32)
|
||||
+25
-25
@@ -1,35 +1,35 @@
|
||||
package vboot.core.module.sys.job.main;
|
||||
package vboot.core.module.mon.job.main;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.module.sys.job.root.SysJobHandler;
|
||||
import vboot.core.module.mon.job.root.MonJobHandler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sys/job/main")
|
||||
public class SysJobMainApi {
|
||||
@RequestMapping("mon/job/main")
|
||||
public class MonJobMainApi {
|
||||
|
||||
private String table = "sys_job_main";
|
||||
private String table = "mon_job_main";
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String id, String name) {
|
||||
public R get(String id, String name) {
|
||||
Sqler sqler = new Sqler("t.id,t.name,t.reurl,t.cron,t.avtag,t.code,t.crtim,t.notes", table);
|
||||
sqler.addLike("t.name", name);
|
||||
return RestResult.ok(jdbcDao.findPageData(sqler));
|
||||
return R.ok(jdbcDao.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
SysJobMain main=repo.findById(id).get();
|
||||
return RestResult.ok(main);
|
||||
public R getOne(@PathVariable String id) {
|
||||
MonJobMain main=repo.findById(id).get();
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SysJobMain main) throws SchedulerException {
|
||||
SysJobMain dbJob = repo.findById(main.getId()).get();
|
||||
public R put(@RequestBody MonJobMain main) throws SchedulerException {
|
||||
MonJobMain dbJob = repo.findById(main.getId()).get();
|
||||
if(dbJob.getAvtag()){
|
||||
String[] arr= dbJob.getReurl().split("/");
|
||||
dbJob.setJgroup(arr[0]);
|
||||
@@ -43,53 +43,53 @@ public class SysJobMainApi {
|
||||
main.setJid(arr2[1]);
|
||||
handler.startJob(main);
|
||||
}
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("start")
|
||||
public RestResult startJob(String ids) throws SchedulerException {
|
||||
public R startJob(String ids) throws SchedulerException {
|
||||
String[] idArr = ids.split(",");
|
||||
for (int i = 0; i < idArr.length; i++) {
|
||||
SysJobMain job = repo.findById(idArr[i]).get();
|
||||
MonJobMain job = repo.findById(idArr[i]).get();
|
||||
String[] arr= job.getReurl().split("/");
|
||||
job.setJgroup(arr[0]);
|
||||
job.setJid(arr[1]);
|
||||
handler.startJob(job);
|
||||
}
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("stop")
|
||||
public RestResult stopJob(String ids) throws SchedulerException {
|
||||
public R stopJob(String ids) throws SchedulerException {
|
||||
String[] idArr = ids.split(",");
|
||||
for (int i = 0; i < idArr.length; i++) {
|
||||
SysJobMain job = repo.findById(idArr[i]).get();
|
||||
MonJobMain job = repo.findById(idArr[i]).get();
|
||||
String[] arr= job.getReurl().split("/");
|
||||
job.setJgroup(arr[0]);
|
||||
job.setJid(arr[1]);
|
||||
handler.stopJob(job);
|
||||
}
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("once")
|
||||
public RestResult startOnce(String id) throws InterruptedException, SchedulerException {
|
||||
SysJobMain main=repo.findById(id).get();
|
||||
public R startOnce(String id) throws InterruptedException, SchedulerException {
|
||||
MonJobMain main=repo.findById(id).get();
|
||||
String[] arr= main.getReurl().split("/");
|
||||
main.setJgroup(arr[0]);
|
||||
main.setJid(arr[1]);
|
||||
handler.onceJob(main);
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private SysJobHandler handler;
|
||||
private MonJobHandler handler;
|
||||
|
||||
@Autowired
|
||||
private SysJobMainRepo repo;
|
||||
private MonJobMainRepo repo;
|
||||
|
||||
@Autowired
|
||||
private JdbcDao jdbcDao;
|
||||
@@ -0,0 +1,8 @@
|
||||
package vboot.core.module.mon.job.main;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface MonJobMainRepo extends JpaRepository<MonJobMain,String> {
|
||||
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,10 +1,10 @@
|
||||
package vboot.core.module.sys.job.main;
|
||||
package vboot.core.module.mon.job.main;
|
||||
|
||||
import cn.hutool.core.lang.ClassScanner;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
import vboot.core.module.sys.job.root.IJobGroup;
|
||||
import vboot.core.module.mon.job.root.IJobGroup;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import vboot.core.module.sys.job.root.IJob;
|
||||
import vboot.core.module.mon.job.root.IJob;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -17,11 +17,11 @@ import java.util.Set;
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Slf4j
|
||||
public class SysJobMainService {
|
||||
public class MonJobMainService {
|
||||
|
||||
public List<SysJobMain> getJobList(){
|
||||
List<SysJobMain> scanJobList = getScanJobList();
|
||||
List<SysJobMain> dbJobList = repo.findAll();
|
||||
public List<MonJobMain> getJobList(){
|
||||
List<MonJobMain> scanJobList = getScanJobList();
|
||||
List<MonJobMain> dbJobList = repo.findAll();
|
||||
for (int j = 0; j < dbJobList.size(); j++) {
|
||||
boolean flag = false;
|
||||
for (int i = 0; i < scanJobList.size(); i++) {
|
||||
@@ -51,9 +51,9 @@ public class SysJobMainService {
|
||||
return scanJobList;
|
||||
}
|
||||
|
||||
private List<SysJobMain> getScanJobList()
|
||||
private List<MonJobMain> getScanJobList()
|
||||
{
|
||||
List<SysJobMain> list = new ArrayList<SysJobMain>();
|
||||
List<MonJobMain> list = new ArrayList<MonJobMain>();
|
||||
Set<Class<?>> classes = ClassScanner.scanPackage("vboot");
|
||||
for (Class<?> clazz : classes)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ public class SysJobMainService {
|
||||
IJob xjob = method.getAnnotation(IJob.class);
|
||||
if (xjob != null)
|
||||
{
|
||||
SysJobMain job = new SysJobMain();
|
||||
MonJobMain job = new MonJobMain();
|
||||
job.setId(XstrUtil.getUUID());
|
||||
job.setCron(xjob.cron());
|
||||
job.setJgroup(XstrUtil.toLowerfirst(clazz.getSimpleName()));
|
||||
@@ -100,5 +100,5 @@ public class SysJobMainService {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private SysJobMainRepo repo;
|
||||
private MonJobMainRepo repo;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package vboot.core.module.sys.job.root;
|
||||
package vboot.core.module.mon.job.root;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package vboot.core.module.sys.job.root;
|
||||
package vboot.core.module.mon.job.root;
|
||||
|
||||
@java.lang.annotation.Documented
|
||||
@java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE})
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package vboot.core.module.sys.job.root;
|
||||
package vboot.core.module.mon.job.root;
|
||||
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
+8
-8
@@ -1,8 +1,8 @@
|
||||
package vboot.core.module.sys.job.root;
|
||||
package vboot.core.module.mon.job.root;
|
||||
|
||||
import vboot.core.module.sys.job.log.SysJobLog;
|
||||
import vboot.core.module.sys.job.log.SysJobLogRepo;
|
||||
import vboot.core.module.sys.job.main.SysJobMain;
|
||||
import vboot.core.module.mon.job.log.MonJobLog;
|
||||
import vboot.core.module.mon.job.log.MonJobLogRepo;
|
||||
import vboot.core.module.mon.job.main.MonJobMain;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
import vboot.core.xutil.lang.XtimeUtil;
|
||||
import vboot.core.xutil.web.XspringUtil;
|
||||
@@ -14,14 +14,14 @@ import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class SysJobFactory implements Job {
|
||||
public class MonJobFactory implements Job {
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) {
|
||||
SysJobMain job = (SysJobMain) context.getMergedJobDataMap().get("job");
|
||||
MonJobMain job = (MonJobMain) context.getMergedJobDataMap().get("job");
|
||||
Method method = ReflectionUtils.findMethod(XspringUtil.getBean(job.getJgroup()).getClass(), job.getJid());
|
||||
SysJobLog log = new SysJobLog();
|
||||
MonJobLog log = new MonJobLog();
|
||||
log.setId(XstrUtil.getUUID());
|
||||
SysJobLogRepo syJobMlogDao= (SysJobLogRepo) XspringUtil.getBean("sysJobLogRepo");
|
||||
MonJobLogRepo syJobMlogDao= (MonJobLogRepo) XspringUtil.getBean("monJobLogRepo");
|
||||
log.setName(job.getName());
|
||||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
+13
-13
@@ -1,8 +1,8 @@
|
||||
package vboot.core.module.sys.job.root;
|
||||
package vboot.core.module.mon.job.root;
|
||||
|
||||
|
||||
import vboot.core.module.sys.job.main.SysJobMain;
|
||||
import vboot.core.module.sys.job.main.SysJobMainRepo;
|
||||
import vboot.core.module.mon.job.main.MonJobMain;
|
||||
import vboot.core.module.mon.job.main.MonJobMainRepo;
|
||||
import org.quartz.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -12,13 +12,13 @@ import java.util.List;
|
||||
|
||||
//任务调度处理
|
||||
@Component
|
||||
public class SysJobHandler {
|
||||
public class MonJobHandler {
|
||||
// 任务调度
|
||||
@Autowired
|
||||
private Scheduler scheduler;
|
||||
|
||||
//开始执行所有任务
|
||||
public void startAllJobs(List<SysJobMain> jobList) throws SchedulerException {
|
||||
public void startAllJobs(List<MonJobMain> jobList) throws SchedulerException {
|
||||
for (int i = 0; i < jobList.size(); i++) {
|
||||
if (jobList.get(i).getAvtag()) {
|
||||
String[] arr= jobList.get(i).getReurl().split("/");
|
||||
@@ -30,10 +30,10 @@ public class SysJobHandler {
|
||||
scheduler.start();
|
||||
}
|
||||
|
||||
private void initJob(Scheduler scheduler, SysJobMain job) throws SchedulerException {
|
||||
private void initJob(Scheduler scheduler, MonJobMain job) throws SchedulerException {
|
||||
// 通过JobBuilder构建JobDetail实例,JobDetail规定只能是实现Job接口的实例
|
||||
// JobDetail 是具体Job实例
|
||||
JobDetail jobDetail = JobBuilder.newJob(SysJobFactory.class).withIdentity(job.getJid(), job.getJgroup()).build();
|
||||
JobDetail jobDetail = JobBuilder.newJob(MonJobFactory.class).withIdentity(job.getJid(), job.getJgroup()).build();
|
||||
// 基于表达式构建触发器
|
||||
jobDetail.getJobDataMap().put("job", job);
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCron());
|
||||
@@ -45,7 +45,7 @@ public class SysJobHandler {
|
||||
}
|
||||
|
||||
//禁用任务
|
||||
public void stopJob(SysJobMain job) throws SchedulerException {
|
||||
public void stopJob(MonJobMain job) throws SchedulerException {
|
||||
JobKey jobKey = JobKey.jobKey(job.getJid(), job.getJgroup());
|
||||
scheduler.deleteJob(jobKey);
|
||||
job.setAvtag(false);
|
||||
@@ -53,11 +53,11 @@ public class SysJobHandler {
|
||||
}
|
||||
|
||||
//启用任务
|
||||
public void startJob(SysJobMain job) throws SchedulerException {
|
||||
public void startJob(MonJobMain job) throws SchedulerException {
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(job.getJid(), job.getJgroup());
|
||||
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||
if (null == trigger) {
|
||||
JobDetail jobDetail = JobBuilder.newJob(SysJobFactory.class)
|
||||
JobDetail jobDetail = JobBuilder.newJob(MonJobFactory.class)
|
||||
.withIdentity(job.getJid(), job.getJgroup()).build();
|
||||
jobDetail.getJobDataMap().put("job", job);
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCron());
|
||||
@@ -74,12 +74,12 @@ public class SysJobHandler {
|
||||
}
|
||||
|
||||
//立即执行一次
|
||||
public void onceJob(SysJobMain job) throws SchedulerException, InterruptedException {
|
||||
public void onceJob(MonJobMain job) throws SchedulerException, InterruptedException {
|
||||
if (job.getAvtag()) {
|
||||
JobKey jobKey = JobKey.jobKey(job.getJid(), job.getJgroup());
|
||||
scheduler.triggerJob(jobKey);
|
||||
} else {
|
||||
JobDetail jobDetail = JobBuilder.newJob(SysJobFactory.class)
|
||||
JobDetail jobDetail = JobBuilder.newJob(MonJobFactory.class)
|
||||
.withIdentity(job.getJid(), job.getJgroup()).build();
|
||||
jobDetail.getJobDataMap().put("job", job);
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCron());
|
||||
@@ -156,7 +156,7 @@ public class SysJobHandler {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private SysJobMainRepo repo;
|
||||
private MonJobMainRepo repo;
|
||||
|
||||
|
||||
}
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
package vboot.core.module.sys.job.root;
|
||||
package vboot.core.module.mon.job.root;
|
||||
|
||||
import vboot.core.module.sys.job.main.SysJobMain;
|
||||
import vboot.core.module.sys.job.main.SysJobMainService;
|
||||
import vboot.core.module.mon.job.main.MonJobMain;
|
||||
import vboot.core.module.mon.job.main.MonJobMainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,18 +13,18 @@ import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class SysJobListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
public class MonJobListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
@Autowired
|
||||
private SysJobHandler handler;
|
||||
private MonJobHandler handler;
|
||||
|
||||
@Autowired
|
||||
private SysJobMainService sysJobMainService;
|
||||
private MonJobMainService monJobMainService;
|
||||
|
||||
|
||||
//初始启动quartz
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
List<SysJobMain> dbJobList = sysJobMainService.getJobList();
|
||||
List<MonJobMain> dbJobList = monJobMainService.getJobList();
|
||||
try {
|
||||
handler.startAllJobs(dbJobList);
|
||||
// log.info("----SYS定时调度任务开启----");
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package vboot.core.module.sys.log.login;
|
||||
package vboot.core.module.mon.log.login;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
public class SysLogLogin {
|
||||
public class MonLogLogin {
|
||||
@Id
|
||||
@Column(length = 32)
|
||||
private String id;
|
||||
@@ -0,0 +1,45 @@
|
||||
package vboot.core.module.mon.log.login;
|
||||
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.api.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("mon/log/login")
|
||||
public class MonLogLoginApi {
|
||||
|
||||
@GetMapping
|
||||
public R get(String name) {
|
||||
Sqler sqlHelper = new Sqler("t.*", "mon_log_login");
|
||||
sqlHelper.addLike("t.name", name);
|
||||
sqlHelper.addOrder("t.crtim desc");
|
||||
return R.ok(jdbcDao.findPageData(sqlHelper));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public R getOne(@PathVariable String id) {
|
||||
return R.ok(repo.findById(id).get());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
for (String id : ids) {
|
||||
repo.deleteById(id);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("all")
|
||||
public R deleteAll() {
|
||||
repo.deleteAll();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private JdbcDao jdbcDao;
|
||||
|
||||
@Autowired
|
||||
private MonLogLoginRepo repo;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package vboot.core.module.mon.log.login;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface MonLogLoginRepo extends JpaRepository<MonLogLogin,String> {
|
||||
|
||||
}
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
package vboot.core.module.sys.log.login;
|
||||
package vboot.core.module.mon.log.login;
|
||||
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
@@ -16,15 +16,15 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SysLogLoginService {
|
||||
public class MonLogLoginService {
|
||||
|
||||
@Autowired
|
||||
private SysLogLoginRepo repo;
|
||||
private MonLogLoginRepo repo;
|
||||
|
||||
@Async
|
||||
public void save(Zuser zuser, HttpServletRequest request){
|
||||
|
||||
SysLogLogin logLogin = new SysLogLogin();
|
||||
MonLogLogin logLogin = new MonLogLogin();
|
||||
logLogin.setId(XstrUtil.getUUID());
|
||||
try {
|
||||
String agent = request.getHeader("User-Agent");
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package vboot.core.module.mon.server.main;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @website https://el-admin.vip
|
||||
* @description 用于关闭各种连接,缺啥补啥
|
||||
* @date 2021-03-05
|
||||
**/
|
||||
public class CloseUtil {
|
||||
|
||||
public static void close(Closeable closeable) {
|
||||
if (null != closeable) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (Exception e) {
|
||||
// 静默关闭
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void close(AutoCloseable closeable) {
|
||||
if (null != closeable) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (Exception e) {
|
||||
// 静默关闭
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package vboot.core.module.mon.server.main;
|
||||
|
||||
/**
|
||||
* 常用静态常量
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-26
|
||||
*/
|
||||
public class ElAdminConstant {
|
||||
|
||||
/**
|
||||
* 用于IP定位转换
|
||||
*/
|
||||
public static final String REGION = "内网IP|内网IP";
|
||||
/**
|
||||
* win 系统
|
||||
*/
|
||||
public static final String WIN = "win";
|
||||
|
||||
/**
|
||||
* mac 系统
|
||||
*/
|
||||
public static final String MAC = "mac";
|
||||
|
||||
/**
|
||||
* 常用接口
|
||||
*/
|
||||
public static class Url {
|
||||
// IP归属地查询
|
||||
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package vboot.core.module.mon.server.main;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.poi.excel.BigExcelWriter;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import vboot.core.common.exception.BadRequestException;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.security.MessageDigest;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* File工具类,扩展 hutool 工具包
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-27
|
||||
*/
|
||||
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
|
||||
|
||||
/**
|
||||
* 系统临时目录
|
||||
* <br>
|
||||
* windows 包含路径分割符,但Linux 不包含,
|
||||
* 在windows \\==\ 前提下,
|
||||
* 为安全起见 同意拼装 路径分割符,
|
||||
* <pre>
|
||||
* java.io.tmpdir
|
||||
* windows : C:\Users/xxx\AppData\Local\Temp\
|
||||
* linux: /temp
|
||||
* </pre>
|
||||
*/
|
||||
public static final String SYS_TEM_DIR = System.getProperty("java.io.tmpdir") + File.separator;
|
||||
/**
|
||||
* 定义GB的计算常量
|
||||
*/
|
||||
private static final int GB = 1024 * 1024 * 1024;
|
||||
/**
|
||||
* 定义MB的计算常量
|
||||
*/
|
||||
private static final int MB = 1024 * 1024;
|
||||
/**
|
||||
* 定义KB的计算常量
|
||||
*/
|
||||
private static final int KB = 1024;
|
||||
|
||||
/**
|
||||
* 格式化小数
|
||||
*/
|
||||
private static final DecimalFormat DF = new DecimalFormat("0.00");
|
||||
|
||||
public static final String IMAGE = "图片";
|
||||
public static final String TXT = "文档";
|
||||
public static final String MUSIC = "音乐";
|
||||
public static final String VIDEO = "视频";
|
||||
public static final String OTHER = "其他";
|
||||
|
||||
|
||||
/**
|
||||
* MultipartFile转File
|
||||
*/
|
||||
public static File toFile(MultipartFile multipartFile) {
|
||||
// 获取文件名
|
||||
String fileName = multipartFile.getOriginalFilename();
|
||||
// 获取文件后缀
|
||||
String prefix = "." + getExtensionName(fileName);
|
||||
File file = null;
|
||||
try {
|
||||
// 用uuid作为文件名,防止生成的临时文件重复
|
||||
file = new File(SYS_TEM_DIR + IdUtil.simpleUUID() + prefix);
|
||||
// MultipartFile to File
|
||||
multipartFile.transferTo(file);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件扩展名,不带 .
|
||||
*/
|
||||
public static String getExtensionName(String filename) {
|
||||
if ((filename != null) && (filename.length() > 0)) {
|
||||
int dot = filename.lastIndexOf('.');
|
||||
if ((dot > -1) && (dot < (filename.length() - 1))) {
|
||||
return filename.substring(dot + 1);
|
||||
}
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Java文件操作 获取不带扩展名的文件名
|
||||
*/
|
||||
public static String getFileNameNoEx(String filename) {
|
||||
if ((filename != null) && (filename.length() > 0)) {
|
||||
int dot = filename.lastIndexOf('.');
|
||||
if ((dot > -1) && (dot < (filename.length()))) {
|
||||
return filename.substring(0, dot);
|
||||
}
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件大小转换
|
||||
*/
|
||||
public static String getSize(long size) {
|
||||
String resultSize;
|
||||
if (size / GB >= 1) {
|
||||
//如果当前Byte的值大于等于1GB
|
||||
resultSize = DF.format(size / (float) GB) + "GB ";
|
||||
} else if (size / MB >= 1) {
|
||||
//如果当前Byte的值大于等于1MB
|
||||
resultSize = DF.format(size / (float) MB) + "MB ";
|
||||
} else if (size / KB >= 1) {
|
||||
//如果当前Byte的值大于等于1KB
|
||||
resultSize = DF.format(size / (float) KB) + "KB ";
|
||||
} else {
|
||||
resultSize = size + "B ";
|
||||
}
|
||||
return resultSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* inputStream 转 File
|
||||
*/
|
||||
static File inputStreamToFile(InputStream ins, String name){
|
||||
File file = new File(SYS_TEM_DIR + name);
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
}
|
||||
OutputStream os = null;
|
||||
try {
|
||||
os = new FileOutputStream(file);
|
||||
int bytesRead;
|
||||
int len = 8192;
|
||||
byte[] buffer = new byte[len];
|
||||
while ((bytesRead = ins.read(buffer, 0, len)) != -1) {
|
||||
os.write(buffer, 0, bytesRead);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
CloseUtil.close(os);
|
||||
CloseUtil.close(ins);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件名解析成文件的上传路径
|
||||
*/
|
||||
public static File upload(MultipartFile file, String filePath) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
||||
String name = getFileNameNoEx(file.getOriginalFilename());
|
||||
String suffix = getExtensionName(file.getOriginalFilename());
|
||||
String nowStr = "-" + format.format(date);
|
||||
try {
|
||||
String fileName = name + nowStr + "." + suffix;
|
||||
String path = filePath + fileName;
|
||||
// getCanonicalFile 可解析正确各种路径
|
||||
File dest = new File(path).getCanonicalFile();
|
||||
// 检测是否存在目录
|
||||
if (!dest.getParentFile().exists()) {
|
||||
if (!dest.getParentFile().mkdirs()) {
|
||||
System.out.println("was not successful.");
|
||||
}
|
||||
}
|
||||
// 文件写入
|
||||
file.transferTo(dest);
|
||||
return dest;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*/
|
||||
public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException {
|
||||
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
|
||||
File file = new File(tempPath);
|
||||
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
|
||||
// 一次性写出内容,使用默认样式,强制输出标题
|
||||
writer.write(list, true);
|
||||
SXSSFSheet sheet = (SXSSFSheet)writer.getSheet();
|
||||
//上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法
|
||||
sheet.trackAllColumnsForAutoSizing();
|
||||
//列宽自适应
|
||||
writer.autoSizeColumnAll();
|
||||
//response为HttpServletResponse对象
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
||||
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
|
||||
response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
// 终止后删除临时文件
|
||||
file.deleteOnExit();
|
||||
writer.flush(out, true);
|
||||
//此处记得关闭输出Servlet流
|
||||
IoUtil.close(out);
|
||||
}
|
||||
|
||||
public static String getFileType(String type) {
|
||||
String documents = "txt doc pdf ppt pps xlsx xls docx";
|
||||
String music = "mp3 wav wma mpa ram ra aac aif m4a";
|
||||
String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg";
|
||||
String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg";
|
||||
if (image.contains(type)) {
|
||||
return IMAGE;
|
||||
} else if (documents.contains(type)) {
|
||||
return TXT;
|
||||
} else if (music.contains(type)) {
|
||||
return MUSIC;
|
||||
} else if (video.contains(type)) {
|
||||
return VIDEO;
|
||||
} else {
|
||||
return OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkSize(long maxSize, long size) {
|
||||
// 1M
|
||||
int len = 1024 * 1024;
|
||||
if (size > (maxSize * len)) {
|
||||
throw new BadRequestException("文件超出规定大小:" + maxSize + "MB");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两个文件是否相同
|
||||
*/
|
||||
public static boolean check(File file1, File file2) {
|
||||
String img1Md5 = getMd5(file1);
|
||||
String img2Md5 = getMd5(file2);
|
||||
if(img1Md5 != null){
|
||||
return img1Md5.equals(img2Md5);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断两个文件是否相同
|
||||
*/
|
||||
public static boolean check(String file1Md5, String file2Md5) {
|
||||
return file1Md5.equals(file2Md5);
|
||||
}
|
||||
|
||||
private static byte[] getByte(File file) {
|
||||
// 得到文件长度
|
||||
byte[] b = new byte[(int) file.length()];
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = new FileInputStream(file);
|
||||
try {
|
||||
System.out.println(in.read(b));
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
} finally {
|
||||
CloseUtil.close(in);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
private static String getMd5(byte[] bytes) {
|
||||
// 16进制字符
|
||||
char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
try {
|
||||
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
|
||||
mdTemp.update(bytes);
|
||||
byte[] md = mdTemp.digest();
|
||||
int j = md.length;
|
||||
char[] str = new char[j * 2];
|
||||
int k = 0;
|
||||
// 移位 输出字符串
|
||||
for (byte byte0 : md) {
|
||||
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
|
||||
str[k++] = hexDigits[byte0 & 0xf];
|
||||
}
|
||||
return new String(str);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
* @param request /
|
||||
* @param response /
|
||||
* @param file /
|
||||
*/
|
||||
public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, boolean deleteOnExit) {
|
||||
response.setCharacterEncoding(request.getCharacterEncoding());
|
||||
response.setContentType("application/octet-stream");
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
|
||||
IOUtils.copy(fis, response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
if (deleteOnExit) {
|
||||
file.deleteOnExit();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMd5(File file) {
|
||||
return getMd5(getByte(file));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package vboot.core.module.mon.server.main;
|
||||
|
||||
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.CentralProcessor.TickType;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.software.os.FileSystem;
|
||||
import oshi.software.os.OSFileStore;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
import oshi.util.Util;
|
||||
import vboot.core.module.mon.server.pojo.*;
|
||||
import vboot.core.xutil.ruoyi.Arith;
|
||||
import vboot.core.xutil.ruoyi.IpUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
//服务器相关信息
|
||||
public class MonServerMain
|
||||
{
|
||||
private static final int OSHI_WAIT_SECOND = 1000;
|
||||
|
||||
/**
|
||||
* CPU相关信息
|
||||
*/
|
||||
private Cpu cpu = new Cpu();
|
||||
|
||||
/**
|
||||
* 內存相关信息
|
||||
*/
|
||||
private Mem mem = new Mem();
|
||||
|
||||
/**
|
||||
* JVM相关信息
|
||||
*/
|
||||
private Jvm jvm = new Jvm();
|
||||
|
||||
/**
|
||||
* 服务器相关信息
|
||||
*/
|
||||
private Sys sys = new Sys();
|
||||
|
||||
/**
|
||||
* 磁盘相关信息
|
||||
*/
|
||||
private List<SysFile> sysFiles = new LinkedList<SysFile>();
|
||||
|
||||
public Cpu getCpu()
|
||||
{
|
||||
return cpu;
|
||||
}
|
||||
|
||||
public void setCpu(Cpu cpu)
|
||||
{
|
||||
this.cpu = cpu;
|
||||
}
|
||||
|
||||
public Mem getMem()
|
||||
{
|
||||
return mem;
|
||||
}
|
||||
|
||||
public void setMem(Mem mem)
|
||||
{
|
||||
this.mem = mem;
|
||||
}
|
||||
|
||||
public Jvm getJvm()
|
||||
{
|
||||
return jvm;
|
||||
}
|
||||
|
||||
public void setJvm(Jvm jvm)
|
||||
{
|
||||
this.jvm = jvm;
|
||||
}
|
||||
|
||||
public Sys getSys()
|
||||
{
|
||||
return sys;
|
||||
}
|
||||
|
||||
public void setSys(Sys sys)
|
||||
{
|
||||
this.sys = sys;
|
||||
}
|
||||
|
||||
public List<SysFile> getSysFiles()
|
||||
{
|
||||
return sysFiles;
|
||||
}
|
||||
|
||||
public void setSysFiles(List<SysFile> sysFiles)
|
||||
{
|
||||
this.sysFiles = sysFiles;
|
||||
}
|
||||
|
||||
public void copyTo() throws Exception
|
||||
{
|
||||
SystemInfo si = new SystemInfo();
|
||||
HardwareAbstractionLayer hal = si.getHardware();
|
||||
|
||||
setCpuInfo(hal.getProcessor());
|
||||
|
||||
setMemInfo(hal.getMemory());
|
||||
|
||||
setSysInfo();
|
||||
|
||||
setJvmInfo();
|
||||
|
||||
setSysFiles(si.getOperatingSystem());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置CPU信息
|
||||
*/
|
||||
private void setCpuInfo(CentralProcessor processor)
|
||||
{
|
||||
// CPU信息
|
||||
long[] prevTicks = processor.getSystemCpuLoadTicks();
|
||||
Util.sleep(OSHI_WAIT_SECOND);
|
||||
long[] ticks = processor.getSystemCpuLoadTicks();
|
||||
long nice = ticks[TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()];
|
||||
long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()];
|
||||
long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()];
|
||||
long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()];
|
||||
long cSys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()];
|
||||
long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()];
|
||||
long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()];
|
||||
long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()];
|
||||
long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
|
||||
cpu.setCpuNum(processor.getLogicalProcessorCount());
|
||||
cpu.setTotal(totalCpu);
|
||||
cpu.setSys(cSys);
|
||||
cpu.setUsed(user);
|
||||
cpu.setWait(iowait);
|
||||
cpu.setFree(idle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置内存信息
|
||||
*/
|
||||
private void setMemInfo(GlobalMemory memory)
|
||||
{
|
||||
mem.setTotal(memory.getTotal());
|
||||
mem.setUsed(memory.getTotal() - memory.getAvailable());
|
||||
mem.setFree(memory.getAvailable());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置服务器信息
|
||||
*/
|
||||
private void setSysInfo()
|
||||
{
|
||||
Properties props = System.getProperties();
|
||||
sys.setComputerName(IpUtils.getHostName());
|
||||
sys.setComputerIp(IpUtils.getHostIp());
|
||||
sys.setOsName(props.getProperty("os.name"));
|
||||
sys.setOsArch(props.getProperty("os.arch"));
|
||||
sys.setUserDir(props.getProperty("user.dir"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Java虚拟机
|
||||
*/
|
||||
private void setJvmInfo()
|
||||
{
|
||||
Properties props = System.getProperties();
|
||||
jvm.setTotal(Runtime.getRuntime().totalMemory());
|
||||
jvm.setMax(Runtime.getRuntime().maxMemory());
|
||||
jvm.setFree(Runtime.getRuntime().freeMemory());
|
||||
jvm.setVersion(props.getProperty("java.version"));
|
||||
jvm.setHome(props.getProperty("java.home"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置磁盘信息
|
||||
*/
|
||||
private void setSysFiles(OperatingSystem os)
|
||||
{
|
||||
FileSystem fileSystem = os.getFileSystem();
|
||||
List<OSFileStore> fsArray = fileSystem.getFileStores();
|
||||
for (OSFileStore fs : fsArray)
|
||||
{
|
||||
long free = fs.getUsableSpace();
|
||||
long total = fs.getTotalSpace();
|
||||
long used = total - free;
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setDirName(fs.getMount());
|
||||
sysFile.setSysTypeName(fs.getType());
|
||||
sysFile.setTypeName(fs.getName());
|
||||
sysFile.setTotal(convertFileSize(total));
|
||||
sysFile.setFree(convertFileSize(free));
|
||||
sysFile.setUsed(convertFileSize(used));
|
||||
sysFile.setUsage(Arith.mul(Arith.div(used, total, 4), 100));
|
||||
sysFiles.add(sysFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节转换
|
||||
*
|
||||
* @param size 字节大小
|
||||
* @return 转换后值
|
||||
*/
|
||||
public String convertFileSize(long size)
|
||||
{
|
||||
long kb = 1024;
|
||||
long mb = kb * 1024;
|
||||
long gb = mb * 1024;
|
||||
if (size >= gb)
|
||||
{
|
||||
return String.format("%.1f GB", (float) size / gb);
|
||||
}
|
||||
else if (size >= mb)
|
||||
{
|
||||
float f = (float) size / mb;
|
||||
return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f);
|
||||
}
|
||||
else if (size >= kb)
|
||||
{
|
||||
float f = (float) size / kb;
|
||||
return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format("%d B", size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package vboot.core.module.mon.server.main;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import oshi.software.os.windows.WindowsOperatingSystem;
|
||||
import vboot.core.common.api.R;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("mon/server/main")
|
||||
public class MonServerMainApi {
|
||||
|
||||
@Autowired
|
||||
private MonitorServiceImpl monitorService;
|
||||
|
||||
@GetMapping
|
||||
public R get() throws Exception {
|
||||
MonServerMain server = new MonServerMain();
|
||||
server.copyTo();
|
||||
// return R.ok(monitorService.getServers());
|
||||
return R.ok(server);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package vboot.core.module.mon.server.main;
|
||||
|
||||
import cn.hutool.core.date.BetweenFormatter.Level;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.hardware.VirtualMemory;
|
||||
import oshi.software.os.FileSystem;
|
||||
import oshi.software.os.OSFileStore;
|
||||
import oshi.software.os.OperatingSystem;
|
||||
import oshi.util.FormatUtil;
|
||||
import oshi.util.Util;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class MonitorServiceImpl {
|
||||
|
||||
private final DecimalFormat df = new DecimalFormat("0.00");
|
||||
|
||||
public Map<String,Object> getServers(){
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>(8);
|
||||
try {
|
||||
SystemInfo si = new SystemInfo();
|
||||
OperatingSystem os = si.getOperatingSystem();
|
||||
HardwareAbstractionLayer hal = si.getHardware();
|
||||
// 系统信息
|
||||
resultMap.put("sys", getSystemInfo(os));
|
||||
// cpu 信息
|
||||
resultMap.put("cpu", getCpuInfo(hal.getProcessor()));
|
||||
// 内存信息
|
||||
resultMap.put("memory", getMemoryInfo(hal.getMemory()));
|
||||
// 交换区信息
|
||||
resultMap.put("swap", getSwapInfo(hal.getMemory()));
|
||||
// 磁盘
|
||||
resultMap.put("disk", getDiskInfo(os));
|
||||
resultMap.put("time", DateUtil.format(new Date(), "HH:mm:ss"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取磁盘信息
|
||||
* @return /
|
||||
*/
|
||||
private Map<String,Object> getDiskInfo(OperatingSystem os) {
|
||||
Map<String,Object> diskInfo = new LinkedHashMap<>();
|
||||
FileSystem fileSystem = os.getFileSystem();
|
||||
List<OSFileStore> fsArray = fileSystem.getFileStores();
|
||||
String osName = System.getProperty("os.name");
|
||||
long available = 0, total = 0;
|
||||
for (OSFileStore fs : fsArray){
|
||||
// windows 需要将所有磁盘分区累加,linux 和 mac 直接累加会出现磁盘重复的问题,待修复
|
||||
if(osName.toLowerCase().startsWith(ElAdminConstant.WIN)) {
|
||||
available += fs.getUsableSpace();
|
||||
total += fs.getTotalSpace();
|
||||
} else {
|
||||
available = fs.getUsableSpace();
|
||||
total = fs.getTotalSpace();
|
||||
break;
|
||||
}
|
||||
}
|
||||
long used = total - available;
|
||||
diskInfo.put("total", total > 0 ? FileUtil.getSize(total) : "?");
|
||||
diskInfo.put("available", FileUtil.getSize(available));
|
||||
diskInfo.put("used", FileUtil.getSize(used));
|
||||
if(total != 0){
|
||||
diskInfo.put("usageRate", df.format(used/(double)total * 100));
|
||||
} else {
|
||||
diskInfo.put("usageRate", 0);
|
||||
}
|
||||
return diskInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取交换区信息
|
||||
* @param memory /
|
||||
* @return /
|
||||
*/
|
||||
private Map<String,Object> getSwapInfo(GlobalMemory memory) {
|
||||
Map<String,Object> swapInfo = new LinkedHashMap<>();
|
||||
VirtualMemory virtualMemory = memory.getVirtualMemory();
|
||||
long total = virtualMemory.getSwapTotal();
|
||||
long used = virtualMemory.getSwapUsed();
|
||||
swapInfo.put("total", FormatUtil.formatBytes(total));
|
||||
swapInfo.put("used", FormatUtil.formatBytes(used));
|
||||
swapInfo.put("available", FormatUtil.formatBytes(total - used));
|
||||
if(used == 0){
|
||||
swapInfo.put("usageRate", 0);
|
||||
} else {
|
||||
swapInfo.put("usageRate", df.format(used/(double)total * 100));
|
||||
}
|
||||
return swapInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内存信息
|
||||
* @param memory /
|
||||
* @return /
|
||||
*/
|
||||
private Map<String,Object> getMemoryInfo(GlobalMemory memory) {
|
||||
Map<String,Object> memoryInfo = new LinkedHashMap<>();
|
||||
memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal()));
|
||||
memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable()));
|
||||
memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable()));
|
||||
memoryInfo.put("usageRate", df.format((memory.getTotal() - memory.getAvailable())/(double)memory.getTotal() * 100));
|
||||
return memoryInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Cpu相关信息
|
||||
* @param processor /
|
||||
* @return /
|
||||
*/
|
||||
private Map<String,Object> getCpuInfo(CentralProcessor processor) {
|
||||
Map<String,Object> cpuInfo = new LinkedHashMap<>();
|
||||
cpuInfo.put("name", processor.getProcessorIdentifier().getName());
|
||||
cpuInfo.put("package", processor.getPhysicalPackageCount() + "个物理CPU");
|
||||
cpuInfo.put("core", processor.getPhysicalProcessorCount() + "个物理核心");
|
||||
cpuInfo.put("coreNumber", processor.getPhysicalProcessorCount());
|
||||
cpuInfo.put("logic", processor.getLogicalProcessorCount() + "个逻辑CPU");
|
||||
// CPU信息
|
||||
long[] prevTicks = processor.getSystemCpuLoadTicks();
|
||||
// 等待1秒...
|
||||
Util.sleep(1000);
|
||||
long[] ticks = processor.getSystemCpuLoadTicks();
|
||||
long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()];
|
||||
long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()];
|
||||
long sys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
|
||||
long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()];
|
||||
long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()];
|
||||
long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()];
|
||||
long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
|
||||
long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()];
|
||||
long totalCpu = user + nice + sys + idle + iowait + irq + softirq + steal;
|
||||
cpuInfo.put("used", df.format(100d * user / totalCpu + 100d * sys / totalCpu));
|
||||
cpuInfo.put("idle", df.format(100d * idle / totalCpu));
|
||||
return cpuInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统相关信息,系统、运行天数、系统IP
|
||||
* @param os /
|
||||
* @return /
|
||||
*/
|
||||
private Map<String,Object> getSystemInfo(OperatingSystem os){
|
||||
Map<String,Object> systemInfo = new LinkedHashMap<>();
|
||||
// jvm 运行时间
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
Date date = new Date(time);
|
||||
// 计算项目运行时间
|
||||
String formatBetween = DateUtil.formatBetween(date, new Date(), Level.HOUR);
|
||||
// 系统信息
|
||||
systemInfo.put("os", os.toString());
|
||||
systemInfo.put("day", formatBetween);
|
||||
// systemInfo.put("ip", StringUtils.getLocalIp());
|
||||
systemInfo.put("ip", "10.0.0.111");
|
||||
return systemInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package vboot.core.module.mon.server.pojo;
|
||||
|
||||
|
||||
import vboot.core.xutil.ruoyi.Arith;
|
||||
|
||||
/**
|
||||
* CPU相关信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class Cpu
|
||||
{
|
||||
/**
|
||||
* 核心数
|
||||
*/
|
||||
private int cpuNum;
|
||||
|
||||
/**
|
||||
* CPU总的使用率
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* CPU系统使用率
|
||||
*/
|
||||
private double sys;
|
||||
|
||||
/**
|
||||
* CPU用户使用率
|
||||
*/
|
||||
private double used;
|
||||
|
||||
/**
|
||||
* CPU当前等待率
|
||||
*/
|
||||
private double wait;
|
||||
|
||||
/**
|
||||
* CPU当前空闲率
|
||||
*/
|
||||
private double free;
|
||||
|
||||
public int getCpuNum()
|
||||
{
|
||||
return cpuNum;
|
||||
}
|
||||
|
||||
public void setCpuNum(int cpuNum)
|
||||
{
|
||||
this.cpuNum = cpuNum;
|
||||
}
|
||||
|
||||
public double getTotal()
|
||||
{
|
||||
return Arith.round(Arith.mul(total, 100), 2);
|
||||
}
|
||||
|
||||
public void setTotal(double total)
|
||||
{
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public double getSys()
|
||||
{
|
||||
return Arith.round(Arith.mul(sys / total, 100), 2);
|
||||
}
|
||||
|
||||
public void setSys(double sys)
|
||||
{
|
||||
this.sys = sys;
|
||||
}
|
||||
|
||||
public double getUsed()
|
||||
{
|
||||
return Arith.round(Arith.mul(used / total, 100), 2);
|
||||
}
|
||||
|
||||
public void setUsed(double used)
|
||||
{
|
||||
this.used = used;
|
||||
}
|
||||
|
||||
public double getWait()
|
||||
{
|
||||
return Arith.round(Arith.mul(wait / total, 100), 2);
|
||||
}
|
||||
|
||||
public void setWait(double wait)
|
||||
{
|
||||
this.wait = wait;
|
||||
}
|
||||
|
||||
public double getFree()
|
||||
{
|
||||
return Arith.round(Arith.mul(free / total, 100), 2);
|
||||
}
|
||||
|
||||
public void setFree(double free)
|
||||
{
|
||||
this.free = free;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package vboot.core.module.mon.server.pojo;
|
||||
|
||||
|
||||
import vboot.core.xutil.ruoyi.Arith;
|
||||
import vboot.core.xutil.ruoyi.DateUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
/**
|
||||
* JVM相关信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class Jvm
|
||||
{
|
||||
/**
|
||||
* 当前JVM占用的内存总数(M)
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* JVM最大可用内存总数(M)
|
||||
*/
|
||||
private double max;
|
||||
|
||||
/**
|
||||
* JVM空闲内存(M)
|
||||
*/
|
||||
private double free;
|
||||
|
||||
/**
|
||||
* JDK版本
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* JDK路径
|
||||
*/
|
||||
private String home;
|
||||
|
||||
public double getTotal()
|
||||
{
|
||||
return Arith.div(total, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setTotal(double total)
|
||||
{
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public double getMax()
|
||||
{
|
||||
return Arith.div(max, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setMax(double max)
|
||||
{
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public double getFree()
|
||||
{
|
||||
return Arith.div(free, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setFree(double free)
|
||||
{
|
||||
this.free = free;
|
||||
}
|
||||
|
||||
public double getUsed()
|
||||
{
|
||||
return Arith.div(total - free, (1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public double getUsage()
|
||||
{
|
||||
return Arith.mul(Arith.div(total - free, total, 4), 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取JDK名称
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return ManagementFactory.getRuntimeMXBean().getVmName();
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version)
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getHome()
|
||||
{
|
||||
return home;
|
||||
}
|
||||
|
||||
public void setHome(String home)
|
||||
{
|
||||
this.home = home;
|
||||
}
|
||||
|
||||
/**
|
||||
* JDK启动时间
|
||||
*/
|
||||
public String getStartTime()
|
||||
{
|
||||
return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate());
|
||||
}
|
||||
|
||||
/**
|
||||
* JDK运行时间
|
||||
*/
|
||||
public String getRunTime()
|
||||
{
|
||||
return DateUtils.getDatePoor(DateUtils.getNowDate(), DateUtils.getServerStartDate());
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行参数
|
||||
*/
|
||||
public String getInputArgs()
|
||||
{
|
||||
return ManagementFactory.getRuntimeMXBean().getInputArguments().toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package vboot.core.module.mon.server.pojo;
|
||||
|
||||
|
||||
import vboot.core.xutil.ruoyi.Arith;
|
||||
|
||||
/**
|
||||
* 內存相关信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class Mem
|
||||
{
|
||||
/**
|
||||
* 内存总量
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* 已用内存
|
||||
*/
|
||||
private double used;
|
||||
|
||||
/**
|
||||
* 剩余内存
|
||||
*/
|
||||
private double free;
|
||||
|
||||
public double getTotal()
|
||||
{
|
||||
return Arith.div(total, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setTotal(long total)
|
||||
{
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public double getUsed()
|
||||
{
|
||||
return Arith.div(used, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setUsed(long used)
|
||||
{
|
||||
this.used = used;
|
||||
}
|
||||
|
||||
public double getFree()
|
||||
{
|
||||
return Arith.div(free, (1024 * 1024 * 1024), 2);
|
||||
}
|
||||
|
||||
public void setFree(long free)
|
||||
{
|
||||
this.free = free;
|
||||
}
|
||||
|
||||
public double getUsage()
|
||||
{
|
||||
return Arith.mul(Arith.div(used, total, 4), 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package vboot.core.module.mon.server.pojo;
|
||||
|
||||
/**
|
||||
* 系统相关信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class Sys
|
||||
{
|
||||
/**
|
||||
* 服务器名称
|
||||
*/
|
||||
private String computerName;
|
||||
|
||||
/**
|
||||
* 服务器Ip
|
||||
*/
|
||||
private String computerIp;
|
||||
|
||||
/**
|
||||
* 项目路径
|
||||
*/
|
||||
private String userDir;
|
||||
|
||||
/**
|
||||
* 操作系统
|
||||
*/
|
||||
private String osName;
|
||||
|
||||
/**
|
||||
* 系统架构
|
||||
*/
|
||||
private String osArch;
|
||||
|
||||
public String getComputerName()
|
||||
{
|
||||
return computerName;
|
||||
}
|
||||
|
||||
public void setComputerName(String computerName)
|
||||
{
|
||||
this.computerName = computerName;
|
||||
}
|
||||
|
||||
public String getComputerIp()
|
||||
{
|
||||
return computerIp;
|
||||
}
|
||||
|
||||
public void setComputerIp(String computerIp)
|
||||
{
|
||||
this.computerIp = computerIp;
|
||||
}
|
||||
|
||||
public String getUserDir()
|
||||
{
|
||||
return userDir;
|
||||
}
|
||||
|
||||
public void setUserDir(String userDir)
|
||||
{
|
||||
this.userDir = userDir;
|
||||
}
|
||||
|
||||
public String getOsName()
|
||||
{
|
||||
return osName;
|
||||
}
|
||||
|
||||
public void setOsName(String osName)
|
||||
{
|
||||
this.osName = osName;
|
||||
}
|
||||
|
||||
public String getOsArch()
|
||||
{
|
||||
return osArch;
|
||||
}
|
||||
|
||||
public void setOsArch(String osArch)
|
||||
{
|
||||
this.osArch = osArch;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package vboot.core.module.mon.server.pojo;
|
||||
|
||||
/**
|
||||
* 系统文件相关信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysFile
|
||||
{
|
||||
/**
|
||||
* 盘符路径
|
||||
*/
|
||||
private String dirName;
|
||||
|
||||
/**
|
||||
* 盘符类型
|
||||
*/
|
||||
private String sysTypeName;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 总大小
|
||||
*/
|
||||
private String total;
|
||||
|
||||
/**
|
||||
* 剩余大小
|
||||
*/
|
||||
private String free;
|
||||
|
||||
/**
|
||||
* 已经使用量
|
||||
*/
|
||||
private String used;
|
||||
|
||||
/**
|
||||
* 资源的使用率
|
||||
*/
|
||||
private double usage;
|
||||
|
||||
public String getDirName()
|
||||
{
|
||||
return dirName;
|
||||
}
|
||||
|
||||
public void setDirName(String dirName)
|
||||
{
|
||||
this.dirName = dirName;
|
||||
}
|
||||
|
||||
public String getSysTypeName()
|
||||
{
|
||||
return sysTypeName;
|
||||
}
|
||||
|
||||
public void setSysTypeName(String sysTypeName)
|
||||
{
|
||||
this.sysTypeName = sysTypeName;
|
||||
}
|
||||
|
||||
public String getTypeName()
|
||||
{
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName)
|
||||
{
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public String getTotal()
|
||||
{
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(String total)
|
||||
{
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
public String getFree()
|
||||
{
|
||||
return free;
|
||||
}
|
||||
|
||||
public void setFree(String free)
|
||||
{
|
||||
this.free = free;
|
||||
}
|
||||
|
||||
public String getUsed()
|
||||
{
|
||||
return used;
|
||||
}
|
||||
|
||||
public void setUsed(String used)
|
||||
{
|
||||
this.used = used;
|
||||
}
|
||||
|
||||
public double getUsage()
|
||||
{
|
||||
return usage;
|
||||
}
|
||||
|
||||
public void setUsage(double usage)
|
||||
{
|
||||
this.usage = usage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package vboot.core.module.mon.server.snmp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MemoryData {
|
||||
private String address;
|
||||
private String totalSize;
|
||||
private String userdSize;
|
||||
private String unit;
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package vboot.core.module.mon.server.snmp;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* snmp协议工具类配置文件
|
||||
*/
|
||||
public class SnmpConfig
|
||||
{
|
||||
private SnmpConfig(){}
|
||||
|
||||
/**
|
||||
* get cpu描述信息
|
||||
*/
|
||||
public static final String SNMPGET_CPUDESC=".1.3.6.1.2.1.1.1.0.255.1";
|
||||
|
||||
/**
|
||||
* walk 网络接口描述
|
||||
*/
|
||||
public static final String SNMPWALK_IFDESCR=".1.3.6.1.2.1.2.2.1.2";
|
||||
|
||||
/**
|
||||
* walk 接口物理地址
|
||||
*/
|
||||
public static final String SNMPWALK_IFPHYSADDRESS=".1.3.6.1.2.1.2.2.1.6";
|
||||
|
||||
/**
|
||||
* get IO负载
|
||||
*/
|
||||
public static final String SNMPGET_IOLOAD=".1.3.6.1.2.1.1.1.0.255.0";
|
||||
|
||||
/**
|
||||
* 硬盘大小
|
||||
*/
|
||||
public static final String SNMPGET_DSKTOTAL=".1.3.6.1.4.1.2021.9.1.6";
|
||||
|
||||
/**
|
||||
* walk cpu 负载
|
||||
*/
|
||||
public static final String SNMPWALK_HRPROCESSLOAD=".1.3.6.1.2.1.25.3.3.1.2";
|
||||
|
||||
/**
|
||||
* walk cpu 空闲率
|
||||
*/
|
||||
public static final String SNMPWALK_SSCPUIDLE=".1.3.6.1.4.1.2021.11.11.0";
|
||||
|
||||
/**
|
||||
* walk 存储设备描述
|
||||
*/
|
||||
public static final String SNMPWALK_HRSTORAGEDESCR=".1.3.6.1.2.1.25.2.3.1.3";
|
||||
/**
|
||||
* walk 存储设备描述
|
||||
*/
|
||||
public static final String SNMPWALK_AHU=".1.3.6.1.2.1.25.2.3.1.4";
|
||||
/**
|
||||
* walk 存储设备描述
|
||||
*/
|
||||
public static final String SNMPWALK_AUR=".1.3.6.1.2.1.25.2.3.1.5";
|
||||
|
||||
/**
|
||||
*walk 存储设备使用大小
|
||||
* 内存使用多少,跟总容量相除就是占用率
|
||||
*/
|
||||
public static final String SNMPWALK_HRSTORAGEUSED=".1.3.6.1.2.1.25.2.3.1.6";
|
||||
/**
|
||||
*walk 内存占用
|
||||
* 各个进程占用的内存
|
||||
*/
|
||||
public static final String SNMPWALK_MEMORY_WIN=".1.3.6.1.2.1.25.5.1.1.2";
|
||||
|
||||
/**
|
||||
*walk 存储设备使用率
|
||||
*
|
||||
*/
|
||||
public static final String SNMPWALK_DSKPERCENT=".1.3.6.1.4.1.2021.9.1.9";
|
||||
|
||||
/**
|
||||
* get 获取内存大小
|
||||
*/
|
||||
public static final String SNMPGET_HRMEMORYSIZE=".1.3.6.1.2.1.25.2.2.0";
|
||||
|
||||
/**
|
||||
* 获取机器名
|
||||
*/
|
||||
public static final String SNMPWALK_SYSNAME=".1.3.6.1.2.1.1.5";
|
||||
|
||||
/**
|
||||
* 性能参数ID-cpu使用率
|
||||
*/
|
||||
public static final Integer PERFORMANCE_PARAM_CPUUSAGE=1;
|
||||
|
||||
/**
|
||||
* 性能参数ID-内存使用率
|
||||
*/
|
||||
public static final Integer PERFORMANCE_PARAM_MEMORYUSAGE=2;
|
||||
|
||||
/**
|
||||
* 性能参数ID-io带宽占用率
|
||||
*/
|
||||
public static final Integer PERFORMANCE_PARAM_IOUSAGE=3;
|
||||
|
||||
/**
|
||||
* decimal 类型1024,用于除法计算
|
||||
*/
|
||||
public static final BigDecimal DEVIDE_NUM=new BigDecimal("1024");
|
||||
|
||||
/**
|
||||
* get方式获取内存大小
|
||||
*/
|
||||
public static final String GET_MEMORY="1.3.6.1.2.1.25.2.2.0";
|
||||
|
||||
/**
|
||||
* 获取系统描述
|
||||
*/
|
||||
public static final String SYS_DSC="1.3.6.1.2.1.1.1.0";
|
||||
|
||||
/**
|
||||
* 获取网络接口数量
|
||||
*/
|
||||
public static final String IF_NUM="1.3.6.1.2.1.2.1.0";
|
||||
|
||||
/**
|
||||
* 获取cpu核数
|
||||
*/
|
||||
public static final String CPU_NUM="1.3.6.1.2.1.25.3.3.1.2";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
package vboot.core.module.mon.server.snmp;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.snmp4j.*;
|
||||
import org.snmp4j.mp.MessageProcessingModel;
|
||||
import org.snmp4j.mp.SnmpConstants;
|
||||
import org.snmp4j.smi.GenericAddress;
|
||||
import org.snmp4j.smi.OID;
|
||||
import org.snmp4j.smi.OctetString;
|
||||
import org.snmp4j.smi.VariableBinding;
|
||||
import org.snmp4j.transport.DefaultUdpTransportMapping;
|
||||
import org.snmp4j.util.PDUFactory;
|
||||
import org.snmp4j.util.TableEvent;
|
||||
import org.snmp4j.util.TableUtils;
|
||||
import vboot.core.xutil.ruoyi.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class SnmpDisk {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String ip = "localhost";
|
||||
String community = "public";
|
||||
String system = "windows";
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("name", "D:");
|
||||
array.add(obj);
|
||||
MemoryData memoryData = collectDisk(ip, community, array, system);
|
||||
System.out.println(memoryData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//获取磁盘相关信息
|
||||
public static MemoryData collectDisk(String ip, String community, JSONArray array, String system) throws Exception {
|
||||
//system: windows, linux
|
||||
String name; //磁盘名称
|
||||
BigDecimal totalSize = new BigDecimal("0");
|
||||
BigDecimal usedSize = new BigDecimal("0");
|
||||
BigDecimal unit1024 = new BigDecimal("1024");
|
||||
String binaryVal;
|
||||
TransportMapping transport = null;
|
||||
Snmp snmp = null;
|
||||
CommunityTarget target;
|
||||
String DISK_OID = "1.3.6.1.2.1.25.2.1.4";
|
||||
String[] oids = {
|
||||
"1.3.6.1.2.1.25.2.3.1.2", // type 存储单元类型
|
||||
"1.3.6.1.2.1.25.2.3.1.3", // descr
|
||||
"1.3.6.1.2.1.25.2.3.1.4", // unit 存储单元大小
|
||||
"1.3.6.1.2.1.25.2.3.1.5", // size 总存储单元数
|
||||
"1.3.6.1.2.1.25.2.3.1.6" // used 使用存储单元数;
|
||||
};
|
||||
try {
|
||||
target = new CommunityTarget();
|
||||
target.setCommunity(new OctetString(community)); //设置snmp共同体(社区名称)
|
||||
target.setRetries(2); //设置超时重试次数
|
||||
target.setAddress(GenericAddress.parse("udp:"+ ip +"/161")); //设定主机的地址
|
||||
target.setTimeout(1000*5); //设置超时的时间
|
||||
target.setVersion(SnmpConstants.version2c); //设置使用的snmp版本
|
||||
|
||||
transport = new DefaultUdpTransportMapping(); //设定采取的协议
|
||||
snmp = new Snmp(transport); //创建SNMP对象
|
||||
snmp.listen();// 监听消息
|
||||
|
||||
TableUtils tableUtils = new TableUtils(snmp, new PDUFactory() {
|
||||
@Override
|
||||
public PDU createPDU(Target arg0) {
|
||||
PDU request = new PDU();
|
||||
request.setType(PDU.GET);
|
||||
return request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PDU createPDU(MessageProcessingModel messageProcessingModel) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
OID[] columns = new OID[oids.length];
|
||||
for (int i = 0; i < oids.length; i++) {
|
||||
columns[i] = new OID(oids[i]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<TableEvent> list = tableUtils.getTable(target, columns, null, null);
|
||||
if (list.size() == 1 && list.get(0).getColumns() == null) {
|
||||
log.info(ip + ":未取到数据");
|
||||
System.out.println(JSONArray.toJSON(list).toString());
|
||||
} else {
|
||||
for (TableEvent event : list) {
|
||||
VariableBinding[] values = event.getColumns();
|
||||
if (values == null || !DISK_OID.equals(values[0].getVariable().toString())) {
|
||||
continue;
|
||||
}
|
||||
// unit 存储单元大小
|
||||
String unit = StringUtils.changeValBinary(values[2].getVariable().toString());
|
||||
// size 总存储单元数
|
||||
String totalSizeCell = StringUtils.changeValBinary(values[3].getVariable().toString());
|
||||
// used 使用存储单元数
|
||||
String usedSizeCell = StringUtils.changeValBinary(values[4].getVariable().toString());
|
||||
|
||||
//磁盘名称
|
||||
name = getChinese(values[1].getVariable().toString());
|
||||
if(name==null || "".equals(name)) {
|
||||
name = values[1].getVariable().toString();
|
||||
}
|
||||
//System.out.println(name);
|
||||
boolean check = checkDiskName(array, name, system); //是否统计
|
||||
if(check) {
|
||||
BigDecimal unitBig = new BigDecimal(unit +"");
|
||||
totalSize = totalSize.add(
|
||||
new BigDecimal(totalSizeCell +"").multiply(unitBig)
|
||||
.divide(unit1024, 2, BigDecimal.ROUND_HALF_UP)
|
||||
.divide(unit1024, 2, BigDecimal.ROUND_HALF_UP)
|
||||
.divide(unit1024, 2, BigDecimal.ROUND_HALF_UP));
|
||||
usedSize = usedSize.add(
|
||||
new BigDecimal(usedSizeCell +"").multiply(unitBig)
|
||||
.divide(unit1024, 2, BigDecimal.ROUND_HALF_UP)
|
||||
.divide(unit1024, 2, BigDecimal.ROUND_HALF_UP)
|
||||
.divide(unit1024, 2, BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
|
||||
|
||||
//System.out.println("totalSize:" + (long)totalSizeCell*unit/(1024*1024*1024)+"G");
|
||||
//System.out.println("usedSize" + (long)usedSizeCell*unit/(1024*1024*1024)+"G");
|
||||
//System.out.println("%%:" + (long)usedSizeCell*100/totalSizeCell+"%");
|
||||
// System.out.println(getChinese(values[1].getVariable().toString())+"
|
||||
// 磁盘大小:"+(long)totalSize*unit/(1024*1024*1024)+"G
|
||||
// 磁盘使用率为:"+(long)usedSize*100/totalSize+"%");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
log.error("未能连接到snmp服务:" + ip);
|
||||
} finally {
|
||||
try {
|
||||
if (transport != null)
|
||||
transport.close();
|
||||
if (snmp != null)
|
||||
snmp.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
DecimalFormat setDouble_1 = new DecimalFormat("0.0"); //保留1位小数
|
||||
MemoryData memoryData = new MemoryData();
|
||||
memoryData.setTotalSize(setDouble_1.format(totalSize));
|
||||
memoryData.setUserdSize(setDouble_1.format(usedSize));
|
||||
memoryData.setAddress(ip);
|
||||
memoryData.setUnit("G");
|
||||
|
||||
//System.out.println("totalSize:" + setDouble_1.format(totalSize) + "G");
|
||||
//System.out.println("usedSize:" + setDouble_1.format(usedSize) + "G");
|
||||
//System.out.println("usedSize" + (long)usedSize*100/totalSize+"%");
|
||||
|
||||
return memoryData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否需要统计
|
||||
* @param array
|
||||
* @param name
|
||||
* @param system
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkDiskName(JSONArray array, String name, String system) {
|
||||
boolean check = false; //是否统计
|
||||
//不维护则取全部
|
||||
if(array.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
JSONObject obj = new JSONObject();
|
||||
String setName;
|
||||
for(int i=0; i<array.size(); i++) {
|
||||
obj = array.getJSONObject(i);
|
||||
setName = obj.getString("name");
|
||||
if("windows".equals(system)) {
|
||||
if(name.contains(setName)) {
|
||||
check = true;
|
||||
}
|
||||
}
|
||||
if("linux".equals(system)) {
|
||||
if(name.equals(setName)) {
|
||||
check = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return check;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取磁盘的中文名字
|
||||
* 解决snmp4j中文乱码问题
|
||||
*/
|
||||
public static String getChinese(String octetString){
|
||||
int COLON_SIZE = 0;
|
||||
if (octetString == null || "".equals(octetString) || "null".equalsIgnoreCase(octetString))
|
||||
return "";
|
||||
try {
|
||||
String[] temps = octetString.split(":");
|
||||
if (temps.length < COLON_SIZE)
|
||||
return octetString;
|
||||
byte[] bs = new byte[temps.length];
|
||||
for (int i = 0; i < temps.length; i++)
|
||||
bs[i] = (byte) Integer.parseInt(temps[i], 16);
|
||||
return new String(bs, "GB2312");
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将16进制的时间转换成标准的时间格式
|
||||
*/
|
||||
private static String hexToDateTime(String hexString) {
|
||||
if (hexString == null || "".equals(hexString))
|
||||
return "";
|
||||
String dateTime = "";
|
||||
try {
|
||||
byte[] values = OctetString.fromHexString(hexString).getValue();
|
||||
int year, month, day, hour, minute;
|
||||
|
||||
year = values[0] * 256 + 256 + values[1];
|
||||
month = values[2];
|
||||
day = values[3];
|
||||
hour = values[4];
|
||||
minute = values[5];
|
||||
|
||||
char format_str[] = new char[22];
|
||||
int index = 3;
|
||||
int temp = year;
|
||||
for (; index >= 0; index--) {
|
||||
format_str[index] = (char) (48 + (temp - temp / 10 * 10));
|
||||
temp /= 10;
|
||||
}
|
||||
format_str[4] = '-';
|
||||
index = 6;
|
||||
temp = month;
|
||||
for (; index >= 5; index--) {
|
||||
format_str[index] = (char) (48 + (temp - temp / 10 * 10));
|
||||
temp /= 10;
|
||||
}
|
||||
format_str[7] = '-';
|
||||
index = 9;
|
||||
temp = day;
|
||||
for (; index >= 8; index--) {
|
||||
format_str[index] = (char) (48 + (temp - temp / 10 * 10));
|
||||
temp /= 10;
|
||||
}
|
||||
format_str[10] = ' ';
|
||||
index = 12;
|
||||
temp = hour;
|
||||
for (; index >= 11; index--) {
|
||||
format_str[index] = (char) (48 + (temp - temp / 10 * 10));
|
||||
temp /= 10;
|
||||
}
|
||||
format_str[13] = ':';
|
||||
index = 15;
|
||||
temp = minute;
|
||||
for (; index >= 14; index--) {
|
||||
format_str[index] = (char) (48 + (temp - temp / 10 * 10));
|
||||
temp /= 10;
|
||||
}
|
||||
dateTime = new String(format_str, 0, format_str.length).substring(0, 16);
|
||||
} catch (Exception e) {
|
||||
// LogFactory.getLog(getClass()).error(e);
|
||||
}
|
||||
return dateTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,510 @@
|
||||
package vboot.core.module.mon.server.snmp;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.snmp4j.CommunityTarget;
|
||||
import org.snmp4j.PDU;
|
||||
import org.snmp4j.Snmp;
|
||||
import org.snmp4j.event.ResponseEvent;
|
||||
import org.snmp4j.mp.SnmpConstants;
|
||||
import org.snmp4j.smi.OID;
|
||||
import org.snmp4j.smi.OctetString;
|
||||
import org.snmp4j.smi.UdpAddress;
|
||||
import org.snmp4j.smi.VariableBinding;
|
||||
import org.snmp4j.transport.DefaultUdpTransportMapping;
|
||||
import org.snmp4j.util.DefaultPDUFactory;
|
||||
import org.snmp4j.util.TableEvent;
|
||||
import org.snmp4j.util.TableUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* snmp协议工具类
|
||||
* 获取服务器cpu,内存,及硬盘占用
|
||||
*/
|
||||
public class SnmpUtil
|
||||
{
|
||||
private static Logger logger = LogManager.getLogger(SnmpUtil.class);
|
||||
private static Snmp snmp = null;
|
||||
private CommunityTarget target;
|
||||
|
||||
@SuppressWarnings("squid:S3010")
|
||||
public SnmpUtil(String intranetDeviceIp, Integer snmpPort) throws IOException
|
||||
{
|
||||
if (snmp == null)
|
||||
{
|
||||
snmp = new Snmp(new DefaultUdpTransportMapping());
|
||||
snmp.listen();
|
||||
}
|
||||
//初始化CommunityTarget
|
||||
target = new CommunityTarget();
|
||||
target.setCommunity(new OctetString("public"));
|
||||
target.setVersion(SnmpConstants.version2c);
|
||||
target.setAddress(new UdpAddress(intranetDeviceIp + "/" + snmpPort));
|
||||
target.setTimeout(1000);
|
||||
target.setRetries(1);
|
||||
}
|
||||
|
||||
private ResponseEvent snmpGet(String oid)
|
||||
{
|
||||
PDU pdu = new PDU();
|
||||
pdu.addOID(new VariableBinding(new OID(oid)));
|
||||
ResponseEvent re=null;
|
||||
try
|
||||
{
|
||||
re = snmp.get(pdu, target);
|
||||
}catch (Exception e){
|
||||
logger.info("snmpGet 异常"+e.getMessage());
|
||||
}
|
||||
return re;
|
||||
}
|
||||
|
||||
private List<TableEvent> snmpWalk(String oid)
|
||||
{
|
||||
TableUtils utils = new TableUtils(snmp, new DefaultPDUFactory(PDU.GETBULK));
|
||||
OID[] columnOid = new OID[]{new OID(oid)};
|
||||
return utils.getTable(target, columnOid, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cpu负载
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getCpuUsage()
|
||||
{
|
||||
List<TableEvent> list = snmpWalk(SnmpConfig.SNMPWALK_HRPROCESSLOAD);
|
||||
BigDecimal usage = new BigDecimal("0");
|
||||
for (TableEvent tableEvent : list)
|
||||
{
|
||||
try
|
||||
{
|
||||
String s=tableEvent.toString().split("=")[3].split("]")[0].trim();
|
||||
if (!"-4,exception".equals(s)){
|
||||
usage=usage.add(new BigDecimal(tableEvent.toString().split("=")[3].split("]")[0].trim()));
|
||||
}else {
|
||||
return new BigDecimal("-1");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.info("获取cpu负载失败"+e.getMessage());
|
||||
return new BigDecimal("-1");
|
||||
}
|
||||
}
|
||||
usage = usage.divide(new BigDecimal(list.size()),2,BigDecimal.ROUND_HALF_UP);
|
||||
return usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cpu使用率
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getCpu()
|
||||
{
|
||||
BigDecimal totalSize;
|
||||
ResponseEvent responseEvent = snmpGet(SnmpConfig.SNMPWALK_SSCPUIDLE);
|
||||
if(responseEvent!=null&&responseEvent.getResponse()!=null){
|
||||
totalSize=new BigDecimal(responseEvent.getResponse().toString().split("=")[4].split("]")[0].trim());
|
||||
}else {
|
||||
return new BigDecimal("-1");
|
||||
}
|
||||
return new BigDecimal("100").subtract(totalSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取磁盘占用率
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getDiskUsageForWindows()
|
||||
{
|
||||
BigDecimal multiply=new BigDecimal("-1");
|
||||
try
|
||||
{
|
||||
BigDecimal diskSize = getDiskSize();
|
||||
BigDecimal diskUsed = getDiskUsed();
|
||||
if (BigDecimal.ZERO.compareTo(diskSize)<0&&BigDecimal.ZERO.compareTo(diskUsed)<0){
|
||||
multiply = getDiskUsed().divide(getDiskSize(), 3, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.info("获取windows磁盘占用异常"+e.getMessage());
|
||||
}
|
||||
|
||||
return multiply;
|
||||
}
|
||||
/**
|
||||
* 获取磁盘占用率
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getDiskUsage()
|
||||
{
|
||||
BigDecimal totalSize=null;
|
||||
//org.snmp4j.util.TableEvent[index=null,vbs=null,status=-1,exception=null,report=null]
|
||||
List<TableEvent> tableEvents = snmpWalk(SnmpConfig.SNMPWALK_DSKPERCENT);
|
||||
if(tableEvents.isEmpty()){
|
||||
totalSize = getDiskUsageForWindows();
|
||||
return totalSize;
|
||||
}
|
||||
for(int i=0;i<tableEvents.size();i++){
|
||||
if ("-1,exception".equals(tableEvents.get(i).toString().split("=")[3].split("]")[0].trim())){
|
||||
return new BigDecimal("-1");
|
||||
}
|
||||
String s=tableEvents.get(i).toString().split("=")[3].split("]")[0].trim();
|
||||
if (!"-4,exception".equals(s)){
|
||||
totalSize= new BigDecimal(tableEvents.get(i).toString().split("=")[3].split("]")[0].trim());
|
||||
}else {
|
||||
return new BigDecimal("-1");
|
||||
}
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内存使用率
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getMemoryUsage(){
|
||||
BigDecimal usage;
|
||||
BigDecimal totalSize;
|
||||
try
|
||||
{
|
||||
ResponseEvent event = snmpGet(SnmpConfig.SNMPGET_HRMEMORYSIZE);
|
||||
if (event != null && event.getResponse() != null)
|
||||
{
|
||||
totalSize = new BigDecimal(event.getResponse().toString().split("=")[4].split("]")[0].trim());
|
||||
usage = getMemoryUsed();
|
||||
return usage.multiply(new BigDecimal("100")).divide(totalSize, 0, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BigDecimal("-1");
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.info("获取内存使用率失败"+e.getMessage());
|
||||
return new BigDecimal("-1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取内存已使用
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getMemoryUsed(){
|
||||
List<TableEvent> list=snmpWalk(SnmpConfig.SNMPWALK_HRSTORAGEDESCR);
|
||||
int index=0;
|
||||
for(int i=0;i<list.size();i++){
|
||||
String trim = list.get(i).toString().split("=")[3].split("]")[0].trim();
|
||||
if(trim.contains("Physical memory")){
|
||||
//linux系统
|
||||
index=i;
|
||||
List<TableEvent> usedList=snmpWalk(SnmpConfig.SNMPWALK_HRSTORAGEUSED);
|
||||
return new BigDecimal(usedList.get(index).toString().split("=")[3].split("]")[0].trim());
|
||||
}else if (trim.contains("Physical Memory")){
|
||||
//windows系统
|
||||
List<TableEvent> list1=snmpWalk(SnmpConfig.SNMPWALK_MEMORY_WIN);
|
||||
BigDecimal re=new BigDecimal("0");
|
||||
for (int j=0;j<list1.size();j++){
|
||||
String trim1 = list1.get(j).toString().split("=")[3].split("]")[0].trim();
|
||||
BigDecimal b = new BigDecimal(trim1);
|
||||
re=re.add(b);
|
||||
}
|
||||
return re;
|
||||
}
|
||||
}
|
||||
return new BigDecimal("0");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取磁盘
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getDiskSize(){
|
||||
List<TableEvent> list=snmpWalk(SnmpConfig.SNMPWALK_HRSTORAGEDESCR);
|
||||
BigDecimal diskSize=new BigDecimal(-1);
|
||||
if (!list.isEmpty()){
|
||||
diskSize=new BigDecimal("0");
|
||||
List<TableEvent> usedList1=snmpWalk(SnmpConfig.SNMPWALK_AHU);
|
||||
List<TableEvent> usedList2=snmpWalk(SnmpConfig.SNMPWALK_AUR);
|
||||
for(int i=0;i<list.size();i++){
|
||||
boolean re=list.get(i).toString().split("=")[3].split("]")[0].trim().contains(":")||list.get(i).toString().split("=")[3].split("]")[0].trim().contains("/");
|
||||
if(re){
|
||||
diskSize=diskSize.add(new BigDecimal(usedList1.get(i).toString().split("=")[3].split("]")[0].trim()).multiply(new BigDecimal(usedList2.get(i).toString().split("=")[3].split("]")[0].trim())).divide(new BigDecimal("1073741824"),2,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
return diskSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取磁盘已使用
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getDiskUsed(){
|
||||
List<TableEvent> list=snmpWalk(SnmpConfig.SNMPWALK_HRSTORAGEDESCR);
|
||||
BigDecimal diskSize=new BigDecimal(-1);
|
||||
if (!list.isEmpty()){
|
||||
diskSize=new BigDecimal("0");
|
||||
List<TableEvent> usedList1=snmpWalk(SnmpConfig.SNMPWALK_AHU);
|
||||
List<TableEvent> usedList2=snmpWalk(SnmpConfig.SNMPWALK_HRSTORAGEUSED);
|
||||
for(int i=0;i<list.size();i++){
|
||||
boolean re=list.get(i).toString().split("=")[3].split("]")[0].trim().contains(":")||list.get(i).toString().split("=")[3].split("]")[0].trim().contains("/");
|
||||
if(re){
|
||||
diskSize=diskSize.add(new BigDecimal(usedList1.get(i).toString().split("=")[3].split("]")[0].trim()).multiply(new BigDecimal(usedList2.get(i).toString().split("=")[3].split("]")[0].trim())).divide(new BigDecimal("1073741824"),2,BigDecimal.ROUND_HALF_UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
return diskSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取IO负载
|
||||
* @return
|
||||
*/
|
||||
public Float getIOUsage(){
|
||||
ResponseEvent event=snmpGet(SnmpConfig.SNMPGET_IOLOAD);
|
||||
if(event!=null&&event.getResponse()!=null){
|
||||
float usage=Float.parseFloat(event.getResponse().toString().split("=")[4].split("]")[0].trim());
|
||||
if(usage>1){
|
||||
return usage;
|
||||
}else{
|
||||
return usage*100;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取性某性能参数数据
|
||||
* @param parameterId
|
||||
* @return
|
||||
*/
|
||||
public Object getData(Integer parameterId) {
|
||||
Object data=null;
|
||||
try{
|
||||
if(parameterId.equals(SnmpConfig.PERFORMANCE_PARAM_CPUUSAGE)){
|
||||
data=getCpuUsage();
|
||||
}else if(parameterId.equals(SnmpConfig.PERFORMANCE_PARAM_MEMORYUSAGE)){
|
||||
data=getMemoryUsage();
|
||||
}else if(parameterId.equals(SnmpConfig.PERFORMANCE_PARAM_IOUSAGE)){
|
||||
data=getIOUsage();
|
||||
}
|
||||
}catch(Exception e){
|
||||
logger.info("获取性能参数异常"+e.getMessage());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备物理地址
|
||||
* @return
|
||||
*/
|
||||
public String getMacAddress(){
|
||||
try
|
||||
{
|
||||
List<TableEvent> list = snmpWalk(SnmpConfig.SNMPWALK_IFDESCR);
|
||||
int index = 0;
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
if (list.get(i).toString().split("=")[3].split("]")[0].trim().contains("eth"))
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
List<TableEvent> ifAddressList = snmpWalk(SnmpConfig.SNMPWALK_IFPHYSADDRESS);
|
||||
return ifAddressList.get(index).toString().split("=")[3].split("]")[0].trim();
|
||||
}catch (Exception e){
|
||||
logger.info("获取物理地址失败"+e.getMessage());
|
||||
return "failure";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备内存大小 单位为GB
|
||||
* @return
|
||||
*/
|
||||
public String getMemoryDesc() {
|
||||
ResponseEvent event =snmpGet(SnmpConfig.SNMPGET_HRMEMORYSIZE);
|
||||
Long bytes =Long.parseLong(event==null?"0":event.getResponse().toString().split("=")[4].split("]")[0].trim());
|
||||
float gb =bytes/1024.0f/1024.0f;
|
||||
DecimalFormat decimalFormat =new DecimalFormat(".00");
|
||||
return decimalFormat.format(gb)+"GB";
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IOException
|
||||
* 获取cpu描述信息
|
||||
* @return
|
||||
*/
|
||||
public String getCpuDesc() throws IOException {
|
||||
ResponseEvent event=snmpGet(SnmpConfig.SNMPGET_CPUDESC);
|
||||
return event==null? "":event.getResponse().toString().split("=")[4].split("]")[0].trim().split(":")[1].trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取存储设备大小 (空盘空间不足百分百)
|
||||
* @param deviceCode
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getDiskSize(String deviceCode){
|
||||
|
||||
List<TableEvent> list = snmpWalk(SnmpConfig.SNMPGET_DSKTOTAL);
|
||||
BigDecimal diskSize=new BigDecimal(-1);
|
||||
if (list!=null){
|
||||
try
|
||||
{
|
||||
for (TableEvent tableEvent:list){
|
||||
diskSize=new BigDecimal(tableEvent.toString().split("=")[3].split("]")[0].trim()).divide(SnmpConfig.DEVIDE_NUM).divide(SnmpConfig.DEVIDE_NUM,2,RoundingMode.HALF_UP);
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.info("获取磁盘大小失败"+e.getMessage());
|
||||
}
|
||||
}
|
||||
if (BigDecimal.ZERO.compareTo(diskSize)>0){
|
||||
diskSize = getDiskSize();
|
||||
}
|
||||
return diskSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取磁盘描述
|
||||
* @param deviceCode
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public BigDecimal getDiskDesc(String deviceCode) {
|
||||
return getDiskSize(deviceCode).divide(SnmpConfig.DEVIDE_NUM,2,RoundingMode.HALF_UP).divide(SnmpConfig.DEVIDE_NUM,2,RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
* snmp协议检测
|
||||
*/
|
||||
public boolean snmpCheck() {
|
||||
ResponseEvent re=snmpGet(".1.3.6.1.4.1.2021.255.1");
|
||||
return re == null || re.getResponse() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取机器名
|
||||
* @return
|
||||
*/
|
||||
public String getSysName(){
|
||||
String name=null;
|
||||
try{
|
||||
List<TableEvent> list = snmpWalk(SnmpConfig.SNMPWALK_SYSNAME);
|
||||
if (list!=null){
|
||||
for (TableEvent tableEvent:list){
|
||||
name=(tableEvent.toString().split("=")[3].split("]")[0].trim());
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.info("获取机器名失败"+e.getMessage());
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内存总大小(实际值)
|
||||
* @return
|
||||
*/
|
||||
public BigDecimal getMemoryTotalSize(){
|
||||
try
|
||||
{
|
||||
ResponseEvent event = snmpGet(SnmpConfig.GET_MEMORY);
|
||||
if (event!=null&&event.getResponse()!=null){
|
||||
String trim = event.getResponse().toString().split("=")[4].split("]")[0].trim();
|
||||
return new BigDecimal(trim).divide(SnmpConfig.DEVIDE_NUM,2, RoundingMode.HALF_UP).divide(SnmpConfig.DEVIDE_NUM,2, RoundingMode.HALF_UP);
|
||||
}else {
|
||||
throw new RuntimeException("获取内存信息失败");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.info("获取内存总大小失败"+e.getMessage());
|
||||
}
|
||||
return new BigDecimal("-1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统描述
|
||||
* @return
|
||||
*/
|
||||
public String getSysDsc(){
|
||||
try
|
||||
{
|
||||
ResponseEvent event = snmpGet(SnmpConfig.SYS_DSC);
|
||||
if (event!=null&&event.getResponse()!=null){
|
||||
return event.getResponse().toString().split("=")[4].split("]")[0].trim();
|
||||
}else {
|
||||
throw new RuntimeException("获取系统描述信息失败");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.info("获取系统描述信息失败"+e.getMessage());
|
||||
}
|
||||
return "failure";
|
||||
}
|
||||
/**
|
||||
* 获取接口数
|
||||
* @return
|
||||
*/
|
||||
public Integer getIfNumber(){
|
||||
try
|
||||
{
|
||||
ResponseEvent event = snmpGet(SnmpConfig.IF_NUM);
|
||||
if (event!=null&&event.getResponse()!=null){
|
||||
String trim = event.getResponse().toString().split("=")[4].split("]")[0].trim();
|
||||
return Integer.parseInt(trim);
|
||||
}else {
|
||||
throw new RuntimeException("获取接口信息失败");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.info("获取接口数量失败"+e.getMessage());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cpu核数(n个cpu有n条数据)
|
||||
* @return
|
||||
*/
|
||||
public Integer getCpuNum(){
|
||||
List<TableEvent> list = snmpWalk(SnmpConfig.CPU_NUM);
|
||||
Integer num=-1;
|
||||
if (list!=null){
|
||||
num=list.size();
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException
|
||||
{
|
||||
String snmpIp = "localhost";
|
||||
Integer snmpPort = 161;
|
||||
SnmpUtil snmpUtil = new SnmpUtil(snmpIp, snmpPort);
|
||||
|
||||
|
||||
System.out.println("机器名称"+snmpUtil.getSysName());
|
||||
System.out.println("磁盘大小 "+ snmpUtil.getDiskSize("devide"));
|
||||
System.out.println("物理地址"+snmpUtil.getMacAddress());
|
||||
System.out.println("cpu "+snmpUtil.getCpuUsage());
|
||||
System.out.println("内存 "+snmpUtil.getMemoryUsage());
|
||||
System.out.println("磁盘 "+snmpUtil.getDiskUsage());
|
||||
System.out.println("系统基本描述信息"+snmpUtil.getSysDsc());
|
||||
System.out.println("网络接口数量 "+snmpUtil.getIfNumber());
|
||||
System.out.println("cpu核数 "+snmpUtil.getCpuNum());
|
||||
|
||||
//System.out.println("windows磁盘:" + snmpUtil.getDiskUsageForWindows());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package vboot.core.module.sys.api.main;
|
||||
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.pojo.Zinp;
|
||||
import vboot.core.xutil.lang.XstrUtil;
|
||||
@@ -16,67 +16,67 @@ import java.util.List;
|
||||
public class SysApiMainApi {
|
||||
|
||||
@GetMapping("tree")
|
||||
public RestResult getTree(String id) {
|
||||
public R getTree(String id) {
|
||||
Sqler sqler = new Sqler("t.id,t.id as name,t.pid","sys_api_main");
|
||||
sqler.addLike("t.id", id);
|
||||
sqler.addWhere("t.avtag=1");
|
||||
List<SysApiMain> list = service.findTree(sqler);
|
||||
return RestResult.ok(list);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String id) {
|
||||
public R get(String id) {
|
||||
Sqler sqler = new Sqler("t.id,t.url,t.type", "sys_api_main");
|
||||
sqler.addLike("t.id", id);
|
||||
sqler.addOrder("t.crtim");
|
||||
sqler.addSelect("t.notes,t.crtim");
|
||||
return RestResult.ok(jdbcDao.findPageData(sqler));
|
||||
return R.ok(jdbcDao.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public RestResult list(String name) {
|
||||
public R list(String name) {
|
||||
String sql="select * from sys_api_main where avtag=1";
|
||||
return RestResult.ok( jdbcDao.findMapList(sql));
|
||||
return R.ok( jdbcDao.findMapList(sql));
|
||||
}
|
||||
|
||||
@GetMapping("type")
|
||||
public RestResult type(String type) {
|
||||
public R type(String type) {
|
||||
if(XstrUtil.isNotBlank(type)){
|
||||
List<Zinp> stores=jdbcDao.findInpList("select id,pid from sys_api_main where pid like ?",type+"%");
|
||||
return RestResult.ok(stores);
|
||||
return R.ok(stores);
|
||||
}else{
|
||||
List<Zinp> stores=jdbcDao.findInpList("select id,pid from sys_api_main");
|
||||
return RestResult.ok(stores);
|
||||
return R.ok(stores);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
SysApiMain main=repo.findById(id).get();
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody SysApiMain main) {
|
||||
public R post(@RequestBody SysApiMain main) {
|
||||
main.setAvtag(true);
|
||||
// main.setType("");
|
||||
repo.save(main);
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SysApiMain main) {
|
||||
public R put(@RequestBody SysApiMain main) {
|
||||
main.setUptim(new Date());
|
||||
repo.save(main);
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
for (String id : ids) {
|
||||
repo.deleteById(id);
|
||||
}
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -2,7 +2,7 @@ package vboot.core.module.sys.api.role;
|
||||
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.api.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -12,57 +12,57 @@ public class SysApiRoleApi {
|
||||
private String table = "sys_api_role";
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String id, String name) {
|
||||
public R get(String id, String name) {
|
||||
Sqler sqler = new Sqler("t.id,t.crtim,t.name", table);
|
||||
sqler.addLeftJoin("o.name as crman", "sys_org o", "o.id=t.crman");
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addLike("t.id", id);
|
||||
sqler.addOrder("t.crtim desc");
|
||||
return RestResult.ok(jdbcDao.findPageData(sqler));
|
||||
return R.ok(jdbcDao.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("perms")
|
||||
public RestResult getPerms(String id, String type) {
|
||||
public R getPerms(String id, String type) {
|
||||
String allSql = "SELECT r.id as \"id\",r.pid as \"pid\",r.name as \"name\",case when rr.id is null then null else 'true' end as \"checked\" FROM sys_api_main r LEFT JOIN sys_api_role_api rr ON rr.pid=r.id AND rr.id=? where r.cotag = 0 ";
|
||||
if ("all".equals(type)) {
|
||||
return RestResult.ok(jdbcDao.findMapList(allSql, id));
|
||||
return R.ok(jdbcDao.findMapList(allSql, id));
|
||||
} else {
|
||||
allSql += " and r.pid like ?";
|
||||
return RestResult.ok(jdbcDao.findMapList(allSql, id, type + "%"));
|
||||
return R.ok(jdbcDao.findMapList(allSql, id, type + "%"));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
public R getOne(@PathVariable String id) {
|
||||
SysApiRole main = service.findOne(id);
|
||||
// main.setPerms(null);
|
||||
return RestResult.ok(main);
|
||||
return R.ok(main);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
public RestResult post(@RequestBody SysApiRole main) {
|
||||
public R post(@RequestBody SysApiRole main) {
|
||||
service.insert(main);
|
||||
jdbcDao.update("update sys_org_user set retag = 0");
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public RestResult put(@RequestBody SysApiRole main) {
|
||||
public R put(@RequestBody SysApiRole main) {
|
||||
service.update(main);
|
||||
jdbcDao.update("update sys_org_user set retag = 0");
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("flush")
|
||||
public RestResult flush() {
|
||||
public R flush() {
|
||||
jdbcDao.update("update sys_org_user set retag = 0");
|
||||
return RestResult.ok();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
public R delete(@PathVariable String[] ids) {
|
||||
return R.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package vboot.core.module.sys.job.log;
|
||||
|
||||
import vboot.core.common.api.RestResult;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sys/job/log")
|
||||
public class SysJobLogApi {
|
||||
|
||||
private String table = "sys_job_log";
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
Sqler sqler = new Sqler("t.id,t.name,t.sttim,t.entim,t.ret", table);
|
||||
// XreqUtil.setPageParam(sqler);
|
||||
sqler.addLike("t.name", name);
|
||||
sqler.addOrder("t.entim desc");
|
||||
System.out.println(sqler.getSql());
|
||||
return RestResult.ok(service.findPageData(sqler));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
return RestResult.ok(service.findOne(id));
|
||||
}
|
||||
|
||||
@DeleteMapping("all")
|
||||
public RestResult deleteAll() {
|
||||
service.deleteAll();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
return RestResult.ok(service.delete(ids));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private SysJobLogService service;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package vboot.core.module.sys.job.log;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SysJobLogRepo extends JpaRepository<SysJobLog,String> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package vboot.core.module.sys.job.main;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SysJobMainRepo extends JpaRepository<SysJobMain,String> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package vboot.core.module.sys.log.login;
|
||||
|
||||
import vboot.core.common.dao.JdbcDao;
|
||||
import vboot.core.common.dao.Sqler;
|
||||
import vboot.core.common.api.RestResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sys/log/login")
|
||||
public class SysLogLoginApi {
|
||||
|
||||
@GetMapping
|
||||
public RestResult get(String name) {
|
||||
Sqler sqlHelper = new Sqler("t.*", "sys_log_login");
|
||||
sqlHelper.addLike("t.name", name);
|
||||
sqlHelper.addOrder("t.crtim desc");
|
||||
return RestResult.ok(jdbcDao.findPageData(sqlHelper));
|
||||
}
|
||||
|
||||
@GetMapping("one/{id}")
|
||||
public RestResult getOne(@PathVariable String id) {
|
||||
return RestResult.ok(repo.findById(id).get());
|
||||
}
|
||||
|
||||
@DeleteMapping("{ids}")
|
||||
public RestResult delete(@PathVariable String[] ids) {
|
||||
for (String id : ids) {
|
||||
repo.deleteById(id);
|
||||
}
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
@DeleteMapping("all")
|
||||
public RestResult deleteAll() {
|
||||
repo.deleteAll();
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private JdbcDao jdbcDao;
|
||||
|
||||
@Autowired
|
||||
private SysLogLoginRepo repo;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package vboot.core.module.sys.log.login;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SysLogLoginRepo extends JpaRepository<SysLogLogin,String> {
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user