新增门户管理,可按不同门户加载不同后台路由

This commit is contained in:
zsvg
2022-05-30 06:10:01 +08:00
parent 0fb5629e6f
commit 8d696dc9b4
54 changed files with 2096 additions and 926 deletions
+2 -1
View File
@@ -43,7 +43,8 @@
10. 操作日志:用户的操作业务的日志的查看和管理。
11. 定时任务:定时任务的维护,通过cron表达式控制任务的执行频率。
12. 流程引擎:流程图展示,自解析bpmn.js,支持驳回、转办、废弃,跳转等功能
13. 消息机制:待办待阅功能,联通钉钉与企业微信接口
13. 在线表单:在线表单设计,配合流程可以实现表单数据流转
14. 消息机制:待办待阅功能,联通钉钉与企业微信接口
### ⚡ 近期计划
- [ ] 完善文档
@@ -32,8 +32,8 @@ public class TeFeatParamApi {
return RestResult.ok(main);
}
@GetMapping("options/{id}")
public RestResult getOptions(@PathVariable String id) {
@GetMapping("options")
public RestResult 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);
@@ -45,8 +45,8 @@ public class TeProdModelApi {
}
}
@GetMapping("zmodel/{id}")
public RestResult getFeat(@PathVariable String id) {
@GetMapping("zmodel")
public RestResult getFeat(String id) {
Zmodel zmodel = service.getZmodel(id);
return RestResult.ok(zmodel);
}
@@ -1,146 +0,0 @@
package vboot.core.config.db.init;
import vboot.core.module.sys.perm.menu.SysPermMenu;
import vboot.core.module.sys.perm.menu.SysPermMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class SysPermInit {
protected void initMenu() {
SysPermMenu menu1 = new SysPermMenu();
menu1.setId("Sys");
menu1.setName("系统管理");
menu1.setCode("Sys");
menu1.setComp("LAYOUT");
menu1.setPath("/sys");
menu1.setRedirect("/sys/org/user");
menu1.setOrnum(1);
menu1.setIcon("ant-design:setting-outlined");
menu1.setAvtag(true);
menu1.setShtag(true);
menu1.setType("D");
menuService.insert(menu1);
SysPermMenu menu11 = new SysPermMenu();
menu11.setId("SysOrg");
menu11.setName("组织架构");
menu11.setCode("SysOrg");
menu11.setComp("LAYOUT");
menu11.setPath("/sys/org");
menu11.setRedirect("/sys/org/user");
menu11.setOrnum(1);
menu11.setIcon("ant-design:partition-outlined");
menu11.setPid("Sys");
menu11.setAvtag(true);
menu11.setShtag(true);
menu11.setType("D");
menuService.insert(menu11);
SysPermMenu menu111 = new SysPermMenu();
menu111.setId("SysOrgDept");
menu111.setName("部门管理");
menu111.setCode("SysOrgDept");
menu111.setPath("/sys/org/dept");
menu111.setComp("/sys/org/dept/index.vue");
menu111.setOrnum(1);
menu111.setPid("SysOrg");
menu111.setCatag(false);
menu111.setAvtag(true);
menu111.setShtag(true);
menu111.setType("M");
menuService.insert(menu111);
SysPermMenu menu112 = new SysPermMenu();
menu112.setId("SysOrgUser");
menu112.setName("用户管理");
menu112.setCode("SysOrgUser");
menu112.setPath("/sys/org/user");
menu112.setComp("/sys/org/user/index.vue");
menu112.setOrnum(2);
menu112.setPid("SysOrg");
menu112.setCatag(false);
menu112.setAvtag(true);
menu112.setShtag(true);
menu112.setType("M");
menuService.insert(menu112);
SysPermMenu menu113 = new SysPermMenu();
menu113.setId("SysOrgPost");
menu113.setName("岗位管理");
menu113.setCode("SysOrgPost");
menu113.setPath("/sys/org/post");
menu113.setComp("/sys/org/post/index.vue");
menu113.setOrnum(3);
menu113.setPid("SysOrg");
menu113.setCatag(false);
menu113.setAvtag(true);
menu113.setShtag(true);
menu113.setType("M");
menuService.insert(menu113);
SysPermMenu menu114 = new SysPermMenu();
menu114.setId("SysOrgGroup");
menu114.setName("群组管理");
menu114.setCode("SysOrgGroup");
menu114.setPath("/sys/org/group");
menu114.setComp("/sys/org/group/index.vue");
menu114.setOrnum(4);
menu114.setPid("SysOrg");
menu114.setCatag(false);
menu114.setAvtag(true);
menu114.setShtag(true);
menu114.setType("M");
menuService.insert(menu114);
SysPermMenu menu12 = new SysPermMenu();
menu12.setId("SysPerm");
menu12.setName("权限管理");
menu12.setCode("SysPerm");
menu12.setComp("LAYOUT");
menu12.setPath("/sys/perm");
menu12.setRedirect("/sys/perm/menu");
menu12.setOrnum(2);
menu12.setIcon("ant-design:safety-certificate-outlined");
menu12.setPid("Sys");
menu12.setAvtag(true);
menu12.setShtag(true);
menu12.setType("D");
menuService.insert(menu12);
SysPermMenu menu121 = new SysPermMenu();
menu121.setId("SysPermMenu");
menu121.setName("菜单管理");
menu121.setCode("SysPermMenu");
menu121.setPath("/sys/perm/menu");
menu121.setComp("/sys/perm/menu/index.vue");
menu121.setOrnum(1);
menu121.setPid("SysPerm");
menu121.setCatag(false);
menu121.setAvtag(true);
menu121.setShtag(true);
menu121.setType("M");
menuService.insert(menu121);
SysPermMenu menu122 = new SysPermMenu();
menu122.setId("SysPermRole");
menu122.setName("角色管理");
menu122.setCode("SysPermRole");
menu122.setPath("/sys/perm/role");
menu122.setComp("/sys/perm/role/index.vue");
menu122.setOrnum(1);
menu122.setPid("SysPerm");
menu122.setCatag(false);
menu122.setAvtag(true);
menu122.setShtag(true);
menu122.setType("M");
menuService.insert(menu122);
}
@Autowired
private SysPermMenuService menuService;
}
@@ -1,4 +1,4 @@
package vboot.core.config.db.init;
package vboot.core.init;
import vboot.core.module.sys.org.user.SysOrgUserRepo;
import lombok.extern.slf4j.Slf4j;
@@ -16,9 +16,7 @@ public class DbInitListener implements ApplicationListener<ContextRefreshedEvent
@Value("${app.init.type}")
private String INIT_TYPE;
/**
* 首次数据库生成后,初始化组织架构,菜单,权限角色等信息
* 增加sa,admin管理员账号及相关测试账号
* 判断依据是sys_org_user是否含有id为sa的账号
* 首次数据库生成后,初始化组织架构,菜单,权限角色,接口等信息
*/
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
@@ -35,9 +33,15 @@ public class DbInitListener implements ApplicationListener<ContextRefreshedEvent
System.out.println("1.2 初始化用户完毕");
// sysOrgInit.initPost();
// sysOrgInit.initGroup();
sysPermInit.initMenu();
System.out.println("2.1 初始化菜单完毕");
sysPortalInit.initPortal();
sysPortalInit.initSysMenu();
sysPortalInit.initSaMenu();
System.out.println("2.1 初始化门户完毕");
}
sysApiInit.initApi();
} catch (Exception e) {
System.err.println("初始化出错");
e.printStackTrace();
@@ -47,12 +51,14 @@ public class DbInitListener implements ApplicationListener<ContextRefreshedEvent
@Autowired
private SysOrgUserRepo userDao;
@Autowired
private SysOrgInit sysOrgInit;
@Autowired
private SysPermInit sysPermInit;
private SysApiInit sysApiInit;
@Autowired
private SysPortalInit sysPortalInit;
}
@@ -0,0 +1,22 @@
package vboot.core.init;
import java.util.ArrayList;
import java.util.List;
public class SysApiCache {
public static List<Yapi> GET1_APIS=new ArrayList<>();
public static List<Yapi> GET2_APIS=new ArrayList<>();
public static List<Yapi> POST_APIS=new ArrayList<>();
public static List<Yapi> PUT_APIS=new ArrayList<>();
public static List<Yapi> DELETE_APIS=new ArrayList<>();
public static List<Yapi> PATCH_APIS=new ArrayList<>();
public static int AUTHPOS=0;
}
@@ -0,0 +1,272 @@
package vboot.core.init;
import cn.hutool.core.lang.ClassScanner;
import org.springframework.web.bind.annotation.*;
import vboot.core.common.dao.JdbcDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
import java.util.*;
@Component
public class SysApiInit {
protected void initApi() {
List<Yurl> codeUrlList = getScanList();
List<String> dbUrlList = jdbcDao.findStringList("select id from sys_api_main");
//收集最大权限位及最大权限位的最大权限码
String sql = "select max(u.pos) as pos,max(u.code) as code from sys_api_main u where u.pos = (select max(uu.pos) from sys_api_main uu)";
Map<String, Object> maxMap = jdbcDao.findMap(sql);
int pos = 0;
long code = 0;
if (maxMap != null && maxMap.get("pos") != null) {
pos = Integer.parseInt(String.valueOf(maxMap.get("pos")));
code = Long.parseLong(String.valueOf(maxMap.get("code")));
}
//比较两个list得到insertList
List<Object[]> insertList = new ArrayList<Object[]>();
List<Object[]> updateList = new ArrayList<Object[]>();
for (Yurl yurl : codeUrlList) {
boolean flag = false;
for (String dbUrlstr : dbUrlList) {
if (yurl.getId().equals(dbUrlstr)) {
flag = true;
break;
}
}
//插入
if (!flag) {
if (yurl.getType() == null) {
Object[] objects = new Object[7];
objects[0] = yurl.getId();
objects[1] = yurl.getPid();
objects[2] = 0;
objects[3] = 0;
objects[4] = yurl.getUrl();
objects[5] = yurl.getType();
objects[6] = new Date();
insertList.add(objects);
} else {
if (code >= (1L << 62)) {
pos = pos + 1;
code = 1;
} else {
if (code == 0) {
code = 1;
} else {
code = code << 1;
}
}
Object[] objects = new Object[7];
objects[0] = yurl.getId();
objects[1] = yurl.getPid();
objects[2] = pos;
objects[3] = code;
objects[4] = yurl.getUrl();
objects[5] = yurl.getType();
objects[6] = new Date();
insertList.add(objects);
}
} else {//更新
Object[] objects = new Object[3];
objects[0] = yurl.getPid();
objects[1] = yurl.getType();
objects[2] = yurl.getId();
updateList.add(objects);
}
}
//设置是否为公共资源
// for (Object[] objects : insertList) {
// if (objects[0].toString().contains("_c")) {
// objects[5] = 1;
// }
// }
//更新数据库
String initSql = "UPDATE sys_api_main SET avtag=0";
String updateSql = "UPDATE sys_api_main SET pid=?,type=?,avtag=1 WHERE id=?";
String insertSql = "INSERT INTO sys_api_main(id,pid,pos,code,url,type,crtim,avtag) VALUES(?,?,?,?,?,?,?,1)";
jdbcDao.update(initSql);
jdbcDao.batch(updateSql, updateList);
jdbcDao.batch(insertSql, insertList);
SysApiCache.AUTHPOS = pos;
//初始化所有用户权限
String updateUserSql = "update sys_org_user set retag=0";
jdbcDao.update(updateUserSql);
//将所有要求认证的权限放入application
String g1permSql = "SELECT url,pos,code from sys_api_main where avtag=1 and type='get' and id not like '%}:get'";
SysApiCache.GET1_APIS = getPerms(g1permSql);
String g2permSql = "SELECT url,pos,code from sys_api_main where avtag=1 and type='get' and id like '%}:get'";
SysApiCache.GET2_APIS = getPerms(g2permSql);
String postUrlSql = "SELECT url,pos,code from sys_api_main where avtag=1 and type='post'";
SysApiCache.POST_APIS = getPerms(postUrlSql);
String putUrlSql = "SELECT url,pos,code from sys_api_main where avtag=1 and type='put'";
SysApiCache.PUT_APIS = getPerms(putUrlSql);
String deleteUrlSql = "SELECT url,pos,code from sys_api_main where avtag= 1 and type='delete'";
SysApiCache.DELETE_APIS = getPerms(deleteUrlSql);
String patchUrlSql = "SELECT url,pos,code from sys_api_main where avtag=1 and type='patch'";
SysApiCache.PATCH_APIS = getPerms(patchUrlSql);
}
private List<Yurl> getScanList() {
List<Yurl> list = new ArrayList<>();
Set<Class<?>> classes = ClassScanner.scanPackage("vboot");
for (Class<?> clazz : classes) {
RequestMapping requestMapping = clazz.getAnnotation(RequestMapping.class);
if (requestMapping != null) {
String classUrl = requestMapping.value()[0];
//---> /authc 开头的不需要登录, /gen 只要登录就有权限 /sys 需要管理员才有权限 其余通过rbac权限机制判断
// if (!url.startsWith("authc")&&!url.startsWith("gen")&&!url.startsWith("sys")) {
if (!classUrl.startsWith("authc") && !classUrl.startsWith("gen")) {
Yurl topUrl = new Yurl();
topUrl.setId(classUrl.replaceAll("/", "-"));
if (!classUrl.startsWith("/")) {
classUrl = "/" + classUrl;
}
if(topUrl.getId().contains("-")){
topUrl.setPid(topUrl.getId().split("-")[0]);
}
topUrl.setUrl(classUrl);
list.add(topUrl);
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
GetMapping getMapping = method.getAnnotation(GetMapping.class);
if (getMapping != null) {
Yurl yurl = new Yurl();
String methodUrl = "";
if (getMapping.value().length > 0) {
methodUrl = getMapping.value()[0];
yurl.setUrl(topUrl.getUrl() + "/" + methodUrl);
methodUrl = methodUrl.replaceAll("/", "-");
yurl.setId(topUrl.getId() + "-" + methodUrl + ":get");
} else {
yurl.setId(topUrl.getId() + ":get");
yurl.setUrl(topUrl.getUrl());
}
yurl.setPid(topUrl.getId());
yurl.setType("get");
list.add(yurl);
continue;
}
PostMapping postMapping = method.getAnnotation(PostMapping.class);
if (postMapping != null) {
Yurl yurl = new Yurl();
String methodUrl = "";
if (postMapping.value().length > 0) {
methodUrl = postMapping.value()[0];
yurl.setUrl(topUrl.getUrl() + "/" + methodUrl);
methodUrl = methodUrl.replaceAll("/", "-");
yurl.setId(topUrl.getId() + "-" + methodUrl + ":post");
} else {
yurl.setId(topUrl.getId() + ":post");
yurl.setUrl(topUrl.getUrl());
}
yurl.setPid(topUrl.getId());
yurl.setType("post");
list.add(yurl);
continue;
}
PutMapping putMapping = method.getAnnotation(PutMapping.class);
if (putMapping != null) {
Yurl yurl = new Yurl();
String methodUrl = "";
if (putMapping.value().length > 0) {
methodUrl = putMapping.value()[0];
yurl.setUrl(topUrl.getUrl() + "/" + methodUrl);
methodUrl = methodUrl.replaceAll("/", "-");
yurl.setId(topUrl.getId() + "-" + methodUrl + ":put");
} else {
yurl.setId(topUrl.getId() + ":put");
yurl.setUrl(topUrl.getUrl());
}
yurl.setPid(topUrl.getId());
yurl.setType("put");
list.add(yurl);
continue;
}
DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class);
if (deleteMapping != null) {
Yurl yurl = new Yurl();
String methodUrl = "";
if (deleteMapping.value().length > 0) {
methodUrl = deleteMapping.value()[0];
yurl.setUrl(topUrl.getUrl() + "/" + methodUrl);
methodUrl = methodUrl.replaceAll("/", "-");
yurl.setId(topUrl.getId() + "-" + methodUrl + ":delete");
} else {
yurl.setId(topUrl.getId() + ":delete");
yurl.setUrl(topUrl.getUrl());
}
yurl.setPid(topUrl.getId());
yurl.setType("delete");
list.add(yurl);
continue;
}
//
PatchMapping patchMapping = method.getAnnotation(PatchMapping.class);
if (patchMapping != null) {
Yurl yurl = new Yurl();
String methodUrl = "";
if (patchMapping.value().length > 0) {
methodUrl = patchMapping.value()[0];
yurl.setUrl(topUrl.getUrl() + "/" + methodUrl);
methodUrl = methodUrl.replaceAll("/", "-");
yurl.setId(topUrl.getId() + "-" + methodUrl + ":patch");
} else {
yurl.setId(topUrl.getId() + ":patch");
yurl.setUrl(topUrl.getUrl());
}
yurl.setPid(topUrl.getId());
yurl.setType("patch");
list.add(yurl);
continue;
}
}
}
}
}
Set<String> rootSet = new HashSet<>();
for (Yurl yurl : list) {
if(yurl.getType()==null&&yurl.getPid()!=null){
rootSet.add(yurl.getPid());
}
}
for (String str : rootSet) {
Yurl yurl=new Yurl();
yurl.setId(str);
list.add(yurl);
}
return list;
}
private List<Yapi> getPerms(String sql) {
return jdbcDao.getTp().query(sql, (rs, rowNum) -> {
Yapi yperm = new Yapi();
String url = rs.getString("url");
if (url.endsWith("}")) {
yperm.setUrl(url.substring(0, url.lastIndexOf("/")));
} else {
yperm.setUrl(url);
}
yperm.setPos(rs.getInt("pos"));
yperm.setCode(rs.getLong("code"));
return yperm;
});
}
@Autowired
private JdbcDao jdbcDao;
}
@@ -1,4 +1,4 @@
package vboot.core.config.db.init;
package vboot.core.init;
import vboot.core.common.dao.JdbcDao;
import vboot.core.xutil.lang.XstringUtil;
@@ -0,0 +1,739 @@
package vboot.core.init;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import vboot.core.module.sys.portal.main.SysPortalMain;
import vboot.core.module.sys.portal.main.SysPortalMainService;
import vboot.core.module.sys.portal.menu.SysPortalMenu;
import vboot.core.module.sys.portal.menu.SysPortalMenuService;
@Component
public class SysPortalInit {
protected void initPortal() {
SysPortalMain sysPortalMain=new SysPortalMain();
sysPortalMain.setId("sys");
sysPortalMain.setOrnum(0);
sysPortalMain.setName("管理员门户");
mainService.save(sysPortalMain);
SysPortalMain sysPortalMain2=new SysPortalMain();
sysPortalMain2.setId("sa");
sysPortalMain2.setOrnum(1);
sysPortalMain2.setName("营销门户");
mainService.save(sysPortalMain2);
}
protected void initSysMenu() {
SysPortalMenu home = new SysPortalMenu();
home.setId("Home");
home.setName("首页");
home.setCode("Home");
home.setComp("/home/index");
home.setPath("/home");
home.setOrnum(0);
home.setIcon("iconfont icon-shouye");
home.setAvtag(true);
home.setShtag(true);
home.setType("M");
home.setPorid("sys");
menuService.insert(home);
SysPortalMenu menu1 = new SysPortalMenu();
menu1.setId("Sys");
menu1.setName("系统管理");
menu1.setCode("Sys");
menu1.setComp("LAYOUT");
menu1.setPath("/sys");
menu1.setRedirect("/sys/org/user");
menu1.setOrnum(1);
menu1.setIcon("iconfont icon-xitongshezhi");
menu1.setAvtag(true);
menu1.setShtag(true);
menu1.setType("D");
menu1.setPorid("sys");
menuService.insert(menu1);
SysPortalMenu menu11 = new SysPortalMenu();
menu11.setId("SysOrg");
menu11.setName("组织架构");
menu11.setCode("SysOrg");
menu11.setComp("LAYOUT");
menu11.setPath("/sys/org");
menu11.setRedirect("/sys/org/user");
menu11.setOrnum(1);
menu11.setIcon("ele-OfficeBuilding");
menu11.setPid("Sys");
menu11.setAvtag(true);
menu11.setShtag(true);
menu11.setType("D");
menu11.setPorid("sys");
menuService.insert(menu11);
SysPortalMenu menu111 = new SysPortalMenu();
menu111.setId("SysOrgDept");
menu111.setName("部门管理");
menu111.setCode("SysOrgDept");
menu111.setPath("/sys/org/dept");
menu111.setComp("/sys/org/dept/index");
menu111.setOrnum(10);
menu111.setIcon("ele-SetUp");
menu111.setPid("SysOrg");
menu111.setCatag(true);
menu111.setAvtag(true);
menu111.setShtag(true);
menu111.setType("M");
menu111.setPorid("sys");
menuService.insert(menu111);
SysPortalMenu menu111a = new SysPortalMenu();
menu111a.setId("SysOrgDeptEdit");
menu111a.setName("部门编辑");
menu111a.setCode("SysOrgDeptEdit");
menu111a.setPath("/sys/org/dept/edit");
menu111a.setComp("/sys/org/dept/edit");
menu111a.setOrnum(11);
menu111a.setIcon("iconfont icon-caidan");
menu111a.setPid("SysOrg");
menu111a.setCatag(true);
menu111a.setAvtag(true);
menu111a.setShtag(false);
menu111a.setType("M");
menu111a.setPorid("sys");
menuService.insert(menu111a);
SysPortalMenu menu112 = new SysPortalMenu();
menu112.setId("SysOrgUser");
menu112.setName("用户管理");
menu112.setCode("SysOrgUser");
menu112.setPath("/sys/org/user");
menu112.setComp("/sys/org/user/index");
menu112.setOrnum(20);
menu112.setIcon("ele-User");
menu112.setPid("SysOrg");
menu112.setCatag(true);
menu112.setAvtag(true);
menu112.setShtag(true);
menu112.setType("M");
menu112.setPorid("sys");
menuService.insert(menu112);
SysPortalMenu menu112a = new SysPortalMenu();
menu112a.setId("SysOrgUserEdit");
menu112a.setName("用户编辑");
menu112a.setCode("SysOrgUserEdit");
menu112a.setPath("/sys/org/user/edit");
menu112a.setComp("/sys/org/user/edit");
menu112a.setOrnum(21);
menu112a.setIcon("iconfont icon-caidan");
menu112a.setPid("SysOrg");
menu112a.setCatag(true);
menu112a.setAvtag(true);
menu112a.setShtag(false);
menu112a.setType("M");
menu112a.setPorid("sys");
menuService.insert(menu112a);
//
SysPortalMenu menu113 = new SysPortalMenu();
menu113.setId("SysOrgPost");
menu113.setName("岗位管理");
menu113.setCode("SysOrgPost");
menu113.setPath("/sys/org/post");
menu113.setComp("/sys/org/post/index");
menu113.setOrnum(31);
menu113.setIcon("ele-Help");
menu113.setPid("SysOrg");
menu113.setCatag(true);
menu113.setAvtag(true);
menu113.setShtag(true);
menu113.setType("M");
menu113.setPorid("sys");
menuService.insert(menu113);
SysPortalMenu menu113a = new SysPortalMenu();
menu113a.setId("SysOrgPostEdit");
menu113a.setName("岗位编辑");
menu113a.setCode("SysOrgPostEdit");
menu113a.setPath("/sys/org/post/edit");
menu113a.setComp("/sys/org/post/edit");
menu113a.setOrnum(32);
menu113a.setIcon("iconfont icon-caidan");
menu113a.setPid("SysOrg");
menu113a.setCatag(true);
menu113a.setAvtag(true);
menu113a.setShtag(false);
menu113a.setType("M");
menu113a.setPorid("sys");
menuService.insert(menu113a);
SysPortalMenu menu114 = new SysPortalMenu();
menu114.setId("SysOrgGroup");
menu114.setName("群组管理");
menu114.setCode("SysOrgGroup");
menu114.setPath("/sys/org/group");
menu114.setComp("/sys/org/group/index");
menu114.setOrnum(40);
menu114.setIcon("ele-Guide");
menu114.setPid("SysOrg");
menu114.setCatag(true);
menu114.setAvtag(true);
menu114.setShtag(true);
menu114.setType("M");
menu114.setPorid("sys");
menuService.insert(menu114);
SysPortalMenu menu114a = new SysPortalMenu();
menu114a.setId("SysOrgGroupEdit");
menu114a.setName("群组编辑");
menu114a.setCode("SysOrgGroupEdit");
menu114a.setPath("/sys/org/group/edit");
menu114a.setComp("/sys/org/group/edit");
menu114a.setOrnum(41);
menu114a.setIcon("iconfont icon-caidan");
menu114a.setPid("SysOrg");
menu114a.setCatag(true);
menu114a.setAvtag(true);
menu114a.setShtag(false);
menu114a.setType("M");
menu114a.setPorid("sys");
menuService.insert(menu114a);
SysPortalMenu menu12 = new SysPortalMenu();
menu12.setId("SysApi");
menu12.setName("接口管理");
menu12.setCode("SysApi");
menu12.setComp("LAYOUT");
menu12.setPath("/sys/api");
menu12.setRedirect("/sys/api/main");
menu12.setOrnum(2);
menu12.setIcon("ele-Lock");
menu12.setPid("Sys");
menu12.setAvtag(true);
menu12.setShtag(true);
menu12.setType("D");
menu12.setPorid("sys");
menuService.insert(menu12);
SysPortalMenu menu121 = new SysPortalMenu();
menu121.setId("SysApiMain");
menu121.setName("接口清单");
menu121.setCode("SysApiMain");
menu121.setPath("/sys/api/main");
menu121.setComp("/sys/api/main/index");
menu121.setOrnum(10);
menu121.setIcon("ele-Tickets");
menu121.setPid("SysApi");
menu121.setCatag(true);
menu121.setAvtag(true);
menu121.setShtag(true);
menu121.setType("M");
menu121.setPorid("sys");
menuService.insert(menu121);
SysPortalMenu menu121a = new SysPortalMenu();
menu121a.setId("SysApiMainEdit");
menu121a.setName("接口编辑");
menu121a.setCode("SysApiMainEdit");
menu121a.setPath("/sys/api/main/edit");
menu121a.setComp("/sys/api/main/edit");
menu121a.setOrnum(11);
menu121a.setIcon("ele-Tickets");
menu121a.setPid("SysApi");
menu121a.setCatag(true);
menu121a.setAvtag(true);
menu121a.setShtag(false);
menu121a.setType("M");
menu121a.setPorid("sys");
menuService.insert(menu121a);
SysPortalMenu menu122 = new SysPortalMenu();
menu122.setId("SysApiRole");
menu122.setName("接口角色");
menu122.setCode("SysApiRole");
menu122.setPath("/sys/api/role");
menu122.setComp("/sys/api/role/index");
menu122.setOrnum(20);
menu122.setIcon("ele-Tickets");
menu122.setPid("SysApi");
menu122.setCatag(true);
menu122.setAvtag(true);
menu122.setShtag(true);
menu122.setType("M");
menu122.setPorid("sys");
menuService.insert(menu122);
SysPortalMenu menu122a = new SysPortalMenu();
menu122a.setId("SysApiRoleEdit");
menu122a.setName("角色编辑");
menu122a.setCode("SysApiRoleEdit");
menu122a.setPath("/sys/api/role/edit");
menu122a.setComp("/sys/api/role/edit");
menu122a.setOrnum(21);
menu122a.setIcon("ele-Tickets");
menu122a.setPid("SysApi");
menu122a.setCatag(true);
menu122a.setAvtag(true);
menu122a.setShtag(false);
menu122a.setType("M");
menu122a.setPorid("sys");
menuService.insert(menu122a);
SysPortalMenu menu13 = new SysPortalMenu();
menu13.setId("SysPortal");
menu13.setName("门户管理");
menu13.setCode("SysPortal");
menu13.setComp("LAYOUT");
menu13.setPath("/sys/portal");
menu13.setRedirect("/sys/portal/main");
menu13.setOrnum(3);
menu13.setIcon("ele-Notebook");
menu13.setPid("Sys");
menu13.setAvtag(true);
menu13.setShtag(true);
menu13.setType("D");
menu13.setPorid("sys");
menuService.insert(menu13);
SysPortalMenu menu131 = new SysPortalMenu();
menu131.setId("SysPortalMain");
menu131.setName("门户清单");
menu131.setCode("SysPortalMain");
menu131.setPath("/sys/portal/main");
menu131.setComp("/sys/portal/main/index");
menu131.setOrnum(10);
menu131.setIcon("ele-Tickets");
menu131.setPid("SysPortal");
menu131.setCatag(true);
menu131.setAvtag(true);
menu131.setShtag(true);
menu131.setType("M");
menu131.setPorid("sys");
menuService.insert(menu131);
SysPortalMenu menu131a = new SysPortalMenu();
menu131a.setId("SysPortalMainEdit");
menu131a.setName("门户编辑");
menu131a.setCode("SysPortalMainEdit");
menu131a.setPath("/sys/portal/main/edit");
menu131a.setComp("/sys/portal/main/edit");
menu131a.setOrnum(11);
menu131a.setIcon("ele-Tickets");
menu131a.setPid("SysPortal");
menu131a.setCatag(true);
menu131a.setAvtag(true);
menu131a.setShtag(false);
menu131a.setType("M");
menu131a.setPorid("sys");
menuService.insert(menu131a);
SysPortalMenu menu132 = new SysPortalMenu();
menu132.setId("SysPortalMenu");
menu132.setName("门户菜单");
menu132.setCode("SysPortalMenu");
menu132.setPath("/sys/portal/menu");
menu132.setComp("/sys/portal/menu/index");
menu132.setOrnum(12);
menu132.setIcon("ele-Tickets");
menu132.setPid("SysPortal");
menu132.setCatag(true);
menu132.setAvtag(true);
menu132.setShtag(true);
menu132.setType("M");
menu132.setPorid("sys");
menuService.insert(menu132);
SysPortalMenu menu132a = new SysPortalMenu();
menu132a.setId("SysPortalMenuEdit");
menu132a.setName("菜单编辑");
menu132a.setCode("SysPortalMenuEdit");
menu132a.setPath("/sys/portal/menu/edit");
menu132a.setComp("/sys/portal/menu/edit");
menu132a.setOrnum(13);
menu132a.setIcon("ele-Tickets");
menu132a.setPid("SysPortal");
menu132a.setCatag(true);
menu132a.setAvtag(true);
menu132a.setShtag(false);
menu132a.setType("M");
menu132a.setPorid("sys");
menuService.insert(menu132a);
SysPortalMenu menu133 = new SysPortalMenu();
menu133.setId("SysPortalRole");
menu133.setName("门户角色");
menu133.setCode("SysPortalRole");
menu133.setPath("/sys/portal/role");
menu133.setComp("/sys/portal/role/index");
menu133.setOrnum(14);
menu133.setIcon("ele-Tickets");
menu133.setPid("SysPortal");
menu133.setCatag(true);
menu133.setAvtag(true);
menu133.setShtag(true);
menu133.setType("M");
menu133.setPorid("sys");
menuService.insert(menu133);
SysPortalMenu menu133a = new SysPortalMenu();
menu133a.setId("SysPortalRoleEdit");
menu133a.setName("角色编辑");
menu133a.setCode("SysPortalRoleEdit");
menu133a.setPath("/sys/portal/role/edit");
menu133a.setComp("/sys/portal/role/edit");
menu133a.setOrnum(15);
menu133a.setIcon("ele-Tickets");
menu133a.setPid("SysPortal");
menu133a.setCatag(true);
menu133a.setAvtag(true);
menu133a.setShtag(false);
menu133a.setType("M");
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);
//-----------------OA办公--------------------
SysPortalMenu menu2 = new SysPortalMenu();
menu2.setId("Oa");
menu2.setName("OA办公");
menu2.setCode("Oa");
menu2.setComp("LAYOUT");
menu2.setPath("/oa");
menu2.setRedirect("/oa/flow/temp");
menu2.setOrnum(2);
menu2.setIcon("ele-Menu");
menu2.setAvtag(true);
menu2.setShtag(true);
menu2.setType("D");
menu2.setPorid("sys");
menuService.insert(menu2);
SysPortalMenu menu21 = new SysPortalMenu();
menu21.setId("OaFlow");
menu21.setName("流程管理");
menu21.setCode("OaFlow");
menu21.setComp("LAYOUT");
menu21.setPath("/oa/flow");
menu21.setRedirect("/oa/flow/temp");
menu21.setOrnum(21);
menu21.setIcon("ele-Connection");
menu21.setPid("Oa");
menu21.setAvtag(true);
menu21.setShtag(true);
menu21.setType("D");
menu21.setPorid("sys");
menuService.insert(menu21);
SysPortalMenu menu211 = new SysPortalMenu();
menu211.setId("OaFlowCate");
menu211.setName("流程分类");
menu211.setCode("OaFlowCate");
menu211.setPath("/oa/flow/cate");
menu211.setComp("/oa/flow/cate/index");
menu211.setOrnum(211);
menu211.setIcon("ele-Tickets");
menu211.setPid("OaFlow");
menu211.setCatag(true);
menu211.setAvtag(true);
menu211.setShtag(true);
menu211.setType("M");
menu211.setPorid("sys");
menuService.insert(menu211);
SysPortalMenu menu211a = new SysPortalMenu();
menu211a.setId("OaFlowCateEdit");
menu211a.setName("流程分类编辑");
menu211a.setCode("OaFlowCateEdit");
menu211a.setPath("/oa/flow/cate/edit");
menu211a.setComp("/oa/flow/cate/edit");
menu211a.setOrnum(2111);
menu211a.setIcon("ele-Tickets");
menu211a.setPid("OaFlow");
menu211a.setCatag(true);
menu211a.setAvtag(true);
menu211a.setShtag(false);
menu211a.setType("M");
menu211a.setPorid("sys");
menuService.insert(menu211a);
SysPortalMenu menu212 = new SysPortalMenu();
menu212.setId("OaFlowTemp");
menu212.setName("流程模板");
menu212.setCode("OaFlowTemp");
menu212.setPath("/oa/flow/temp");
menu212.setComp("/oa/flow/temp/index");
menu212.setOrnum(212);
menu212.setIcon("ele-Tickets");
menu212.setPid("OaFlow");
menu212.setCatag(true);
menu212.setAvtag(true);
menu212.setShtag(true);
menu212.setType("M");
menu212.setPorid("sys");
menuService.insert(menu212);
SysPortalMenu menu212a = new SysPortalMenu();
menu212a.setId("OaFlowTempEdit");
menu212a.setName("流程模板编辑");
menu212a.setCode("OaFlowTempEdit");
menu212a.setPath("/oa/flow/temp/edit");
menu212a.setComp("/oa/flow/temp/edit");
menu212a.setOrnum(2121);
menu212a.setIcon("ele-Tickets");
menu212a.setPid("OaFlow");
menu212a.setCatag(true);
menu212a.setAvtag(true);
menu212a.setShtag(false);
menu212a.setType("M");
menu212a.setPorid("sys");
menuService.insert(menu212a);
SysPortalMenu menu213 = new SysPortalMenu();
menu213.setId("OaFlowMain");
menu213.setName("流程实例");
menu213.setCode("OaFlowMain");
menu213.setPath("/oa/flow/main");
menu213.setComp("/oa/flow/main/index");
menu213.setOrnum(213);
menu213.setIcon("ele-Tickets");
menu213.setPid("OaFlow");
menu213.setCatag(true);
menu213.setAvtag(true);
menu213.setShtag(true);
menu213.setType("M");
menu213.setPorid("sys");
menuService.insert(menu213);
SysPortalMenu menu213a = new SysPortalMenu();
menu213a.setId("OaFlowMainEdit");
menu213a.setName("流程实例编辑");
menu213a.setCode("OaFlowMainEdit");
menu213a.setPath("/oa/flow/main/edit");
menu213a.setComp("/oa/flow/main/edit");
menu213a.setOrnum(2131);
menu213a.setIcon("ele-Tickets");
menu213a.setPid("OaFlow");
menu213a.setCatag(true);
menu213a.setAvtag(true);
menu213a.setShtag(false);
menu213a.setType("M");
menu213a.setPorid("sys");
menuService.insert(menu213a);
SysPortalMenu menu213b = new SysPortalMenu();
menu213b.setId("OaFlowMainView");
menu213b.setName("流程实例查看");
menu213b.setCode("OaFlowMainView");
menu213b.setPath("/oa/flow/main/view");
menu213b.setComp("/oa/flow/main/view");
menu213b.setOrnum(2132);
menu213b.setIcon("ele-Tickets");
menu213b.setPid("OaFlow");
menu213b.setCatag(true);
menu213b.setAvtag(true);
menu213b.setShtag(false);
menu213b.setType("M");
menu213b.setPorid("sys");
menuService.insert(menu213b);
}
protected void initSaMenu() {
SysPortalMenu home = new SysPortalMenu();
home.setId("Sa-Home");
home.setName("营销首页");
home.setCode("Home");
home.setComp("/home/index2");
home.setPath("/home");
home.setOrnum(0);
home.setIcon("iconfont icon-shouye");
home.setAvtag(true);
home.setShtag(true);
home.setType("M");
home.setPorid("sa");
menuService.insert(home);
SysPortalMenu menu1 = new SysPortalMenu();
menu1.setId("Sa-Oa");
menu1.setName("日常办公");
menu1.setCode("Oa");
menu1.setComp("LAYOUT");
menu1.setPath("/oa");
menu1.setRedirect("/oa/flow/main");
menu1.setOrnum(2);
menu1.setIcon("ele-Menu");
menu1.setAvtag(true);
menu1.setShtag(true);
menu1.setType("D");
menu1.setPorid("sa");
menuService.insert(menu1);
SysPortalMenu menu11 = new SysPortalMenu();
menu11.setId("Sa-OaFlowMain");
menu11.setName("流程审批");
menu11.setCode("OaFlowMain");
menu11.setPath("/oa/flow/main");
menu11.setComp("/oa/flow/main/index");
menu11.setOrnum(21);
menu11.setIcon("ele-Tickets");
menu11.setPid("Sa-Oa");
menu11.setCatag(true);
menu11.setAvtag(true);
menu11.setShtag(true);
menu11.setType("M");
menu11.setPorid("sa");
menuService.insert(menu11);
SysPortalMenu menu2 = new SysPortalMenu();
menu2.setId("Sa-SaAgent");
menu2.setName("代理商管理");
menu2.setCode("SaAgent");
menu2.setComp("LAYOUT");
menu2.setPath("/sa/agent");
menu2.setRedirect("/sa/agent/main");
menu2.setOrnum(2);
menu2.setIcon("ele-GobletSquare");
menu2.setAvtag(true);
menu2.setShtag(true);
menu2.setType("D");
menu2.setPorid("sa");
menuService.insert(menu2);
SysPortalMenu menu21 = new SysPortalMenu();
menu21.setId("Sa-SaAgentMain");
menu21.setName("代理商清单");
menu21.setCode("SaAgentMain");
menu21.setPath("/sa/agent/main");
menu21.setComp("/sa/agent/main/index");
menu21.setOrnum(21);
menu21.setIcon("ele-Tickets");
menu21.setPid("Sa-SaAgent");
menu21.setCatag(true);
menu21.setAvtag(true);
menu21.setShtag(true);
menu21.setType("M");
menu21.setPorid("sa");
menuService.insert(menu21);
SysPortalMenu menu21a = new SysPortalMenu();
menu21a.setId("Sa-SaAgentMainEdit");
menu21a.setName("代理商编辑");
menu21a.setCode("SaAgentMainEdit");
menu21a.setPath("/sa/agent/main/edit");
menu21a.setComp("/sa/agent/main/edit");
menu21a.setOrnum(2);
menu21a.setIcon("ele-Tickets");
menu21a.setPid("Sa-SaAgent");
menu21a.setCatag(true);
menu21a.setAvtag(true);
menu21a.setShtag(false);
menu21a.setType("M");
menu21a.setPorid("sa");
menuService.insert(menu21a);
}
@Autowired
private SysPortalMainService mainService;
@Autowired
private SysPortalMenuService menuService;
}
@@ -1,18 +1,19 @@
package vboot.core.module.sys.perm.api;
package vboot.core.init;
import lombok.Data;
import java.io.Serializable;
@Data
public class Yperm implements Serializable
public class Yapi implements Serializable
{
private static final long serialVersionUID = 7712491509249951764L;
private int pos;
private long code;
private String id;
private String tcode;
private String url;
//get and set------------
}
@@ -0,0 +1,14 @@
package vboot.core.init;
import lombok.Data;
@Data
public class Yurl {
private String id ;
private String url ;
private String pid ;
private String type;
}
@@ -9,14 +9,14 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("bpm/audit/main")
public class BpmAuditMainApi {
@GetMapping("list/{proid}")
public RestResult list(@PathVariable 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));
}
// @GetMapping("list")
// public RestResult 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));
// }
//
@Autowired
private JdbcDao jdbcDao;
@@ -28,8 +28,8 @@ public class BpmProcMainApi {
return RestResult.ok(main);
}
@GetMapping("zbpm/{proid}")
public RestResult zbpm(@PathVariable String proid) {
@GetMapping("zbpm")
public RestResult 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 " +
@@ -127,8 +127,8 @@ public class BpmProcMainApi {
return RestResult.ok(list);
}
@GetMapping("xml/{proid}")
public RestResult xml(@PathVariable String proid) {
@GetMapping("xml")
public RestResult 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=?";
@@ -159,8 +159,8 @@ public class BpmProcMainApi {
return RestResult.ok(map);
}
@GetMapping("texml/{temid}")
public RestResult texml(@PathVariable String temid) {
@GetMapping("texml")
public RestResult 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);
@@ -25,10 +25,10 @@ public class GenAuthApi {
continue;
}
backMap.put(str, false);
String sql = "select ipos,lcode from sys_perm_api p where p.id = ?";
String sql = "select pos,code from sys_api_main p where p.id = ?";
try{
Map<String, Object> map = jdbcDao.findMap(sql, btns.get(str));
if (zuser.hasPerm(Integer.parseInt(""+map.get("ipos")) , Long.parseLong(""+map.get("lcode")))) {
if (zuser.hasPerm(Integer.parseInt(""+map.get("pos")) , Long.parseLong(""+map.get("code")))) {
backMap.put(str, true);
}
}catch (Exception e){
@@ -0,0 +1,52 @@
package vboot.core.module.sys.api.main;
import lombok.Data;
import vboot.core.module.sys.portal.menu.SysPortalMenu;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Entity
@Data
public class SysApiMain {
@Id
@Column(length = 64)
private String id;//接口ID
@Column(length = 64)
private String name;//接口名称
@Column(length = 64)
private String pid;//上级ID
@Column(length = 64)
private String url;//接口url
private Long code;//权限代码
private Integer pos;//权限位
// private Boolean cotag;//公共标记
@Column(length = 32)
private String type;//权限类型
private Boolean avtag;//可用标记
private String notes;//备注
@Column(updatable = false)
private Date crtim = new Date();//创建时间
private Date uptim ;//更新时间
@Transient
private List<SysApiMain> children = new ArrayList<>();
}
@@ -0,0 +1,91 @@
package vboot.core.module.sys.api.main;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.api.RestResult;
import vboot.core.common.dao.Sqler;
import vboot.core.common.pojo.Zinp;
import vboot.core.module.sys.portal.menu.SysPortalMenu;
import vboot.core.xutil.lang.XstringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("sys/api/main")
public class SysApiMainApi {
@GetMapping("tree")
public RestResult 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);
}
@GetMapping
public RestResult 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));
}
@GetMapping("list")
public RestResult list(String name) {
String sql="select * from sys_api_main where avtag=1";
return RestResult.ok( jdbcDao.findMapList(sql));
}
@GetMapping("type")
public RestResult type(String type) {
if(XstringUtil.isNotBlank(type)){
List<Zinp> stores=jdbcDao.findInpList("select id,pid from sys_api_main where pid like ?",type+"%");
return RestResult.ok(stores);
}else{
List<Zinp> stores=jdbcDao.findInpList("select id,pid from sys_api_main");
return RestResult.ok(stores);
}
}
@GetMapping("one/{id}")
public RestResult getOne(@PathVariable String id) {
SysApiMain main=repo.findById(id).get();
return RestResult.ok(main);
}
@PostMapping
public RestResult post(@RequestBody SysApiMain main) {
main.setAvtag(true);
// main.setType("");
repo.save(main);
return RestResult.ok();
}
@PutMapping
public RestResult put(@RequestBody SysApiMain main) {
main.setUptim(new Date());
repo.save(main);
return RestResult.ok();
}
@DeleteMapping("{ids}")
public RestResult delete(@PathVariable String[] ids) {
for (String id : ids) {
repo.deleteById(id);
}
return RestResult.ok();
}
@Autowired
private JdbcDao jdbcDao;
@Autowired
private SysApiMainRepo repo;
@Autowired
private SysApiMainService service;
}
@@ -0,0 +1,56 @@
package vboot.core.module.sys.api.main;
import org.springframework.stereotype.Component;
import vboot.core.init.SysApiCache;
import vboot.core.security.pojo.Zuser;
@Component
public class SysApiMainHand {
public boolean hasPerm(Zuser zuser, String method,String url){
if(zuser.isAdmin()){
return true;
}
boolean flag=false;
if("GET".equals(method)){
for (int i = 0; i < SysApiCache.GET1_APIS.size(); i++) {
if(SysApiCache.GET1_APIS.get(i).getUrl().equals(url)){
flag = zuser.hasPerm(SysApiCache.GET1_APIS.get(i).getPos(), SysApiCache.GET1_APIS.get(i).getCode());
break;
}
}
if(!flag){
String frontUrl=url.substring(0,url.lastIndexOf("/"));
for (int i = 0; i < SysApiCache.GET2_APIS.size(); i++) {
if(SysApiCache.GET2_APIS.get(i).getUrl().equals(frontUrl)){
flag = zuser.hasPerm(SysApiCache.GET2_APIS.get(i).getPos(), SysApiCache.GET2_APIS.get(i).getCode());
break;
}
}
}
}else if("POST".equals(method)){
for (int i = 0; i < SysApiCache.POST_APIS.size(); i++) {
if(SysApiCache.POST_APIS.get(i).getUrl().equals(url)){
flag = zuser.hasPerm(SysApiCache.POST_APIS.get(i).getPos(), SysApiCache.POST_APIS.get(i).getCode());
break;
}
}
}else if("PUT".equals(method)){
for (int i = 0; i < SysApiCache.PUT_APIS.size(); i++) {
if(SysApiCache.PUT_APIS.get(i).getUrl().equals(url)){
flag = zuser.hasPerm(SysApiCache.PUT_APIS.get(i).getPos(), SysApiCache.PUT_APIS.get(i).getCode());
break;
}
}
}else if("DELETE".equals(method)){
String frontUrl=url.substring(0,url.lastIndexOf("/"));
for (int i = 0; i < SysApiCache.DELETE_APIS.size(); i++) {
if(SysApiCache.DELETE_APIS.get(i).getUrl().equals(frontUrl)){
flag = zuser.hasPerm(SysApiCache.DELETE_APIS.get(i).getPos(), SysApiCache.DELETE_APIS.get(i).getCode());
break;
}
}
}
return flag;
}
}
@@ -0,0 +1,8 @@
package vboot.core.module.sys.api.main;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SysApiMainRepo extends JpaRepository<SysApiMain,String> {
}
@@ -0,0 +1,62 @@
package vboot.core.module.sys.api.main;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.dao.Sqler;
import java.util.ArrayList;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
public class SysApiMainService {
public List<SysApiMain> findTree(Sqler sqler) {
List<SysApiMain> list = jdbcDao.getTp().query(sqler.getSql(), sqler.getParams(), new BeanPropertyRowMapper<>(SysApiMain.class));
return buildByRecursive(list);
}
//使用递归方法建树
private List<SysApiMain> buildByRecursive(List<SysApiMain> nodes) {
List<SysApiMain> list = new ArrayList<>();
for (SysApiMain node : nodes) {
if (node.getPid() == null) {
list.add(findChildrenByTier(node, nodes));
} else {
boolean flag = false;
for (SysApiMain node2 : nodes) {
if (node.getPid().equals(node2.getId())) {
flag = true;
break;
}
}
if (!flag) {
list.add(findChildrenByTier(node, nodes));
}
}
}
return list;
}
//递归查找子节点
private SysApiMain findChildrenByTier(SysApiMain node, List<SysApiMain> nodes) {
for (SysApiMain item : nodes) {
if (node.getId().equals(item.getPid())) {
if (node.getChildren() == null) {
node.setChildren(new ArrayList<>());
}
node.getChildren().add(findChildrenByTier(item, nodes));
}
}
return node;
}
@Autowired
private JdbcDao jdbcDao;
}
@@ -1,10 +1,10 @@
package vboot.core.module.sys.perm.role;
package vboot.core.module.sys.api.role;
import lombok.Getter;
import lombok.Setter;
import vboot.core.common.entity.BaseMainEntity;
import vboot.core.module.sys.api.main.SysApiMain;
import vboot.core.module.sys.org.root.SysOrg;
import vboot.core.module.sys.perm.menu.SysPermMenu;
import javax.persistence.*;
import java.util.ArrayList;
@@ -13,7 +13,7 @@ import java.util.List;
@Entity
@Getter
@Setter
public class SysPermRole extends BaseMainEntity
public class SysApiRole extends BaseMainEntity
{
@Column(length = 32)
@@ -26,14 +26,14 @@ public class SysPermRole extends BaseMainEntity
//拥有的菜单
@ManyToMany
@JoinTable(name = "sys_perm_role_menu",
@JoinTable(name = "sys_api_role_api",
joinColumns = {@JoinColumn(name = "rid")},
inverseJoinColumns = {@JoinColumn(name = "mid")})
private List<SysPermMenu> menus = new ArrayList<>();
private List<SysApiMain> apis = new ArrayList<>();
//授权的用户
@ManyToMany
@JoinTable(name = "sys_perm_role_org",
@JoinTable(name = "sys_api_role_org",
joinColumns = {@JoinColumn(name = "rid")},
inverseJoinColumns = {@JoinColumn(name = "oid")})
private List<SysOrg> orgs = new ArrayList<>();
@@ -1,4 +1,4 @@
package vboot.core.module.sys.perm.role;
package vboot.core.module.sys.api.role;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.dao.Sqler;
@@ -7,9 +7,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("sys/perm/role")
public class SysPermRoleApi {
private String table = "sys_perm_role";
@RequestMapping("sys/api/role")
public class SysApiRoleApi {
private String table = "sys_api_role";
@GetMapping
public RestResult get(String id, String name) {
@@ -23,7 +23,7 @@ public class SysPermRoleApi {
@GetMapping("perms")
public RestResult 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_perm_api r LEFT JOIN sys_perm_role_api rr ON rr.pid=r.id AND rr.id=? where r.cotag = 0 ";
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));
} else {
@@ -34,27 +34,27 @@ public class SysPermRoleApi {
@GetMapping("one/{id}")
public RestResult getOne(@PathVariable String id) {
SysPermRole main = service.findOne(id);
SysApiRole main = service.findOne(id);
// main.setPerms(null);
return RestResult.ok(main);
}
@PostMapping
public RestResult post(@RequestBody SysPermRole main) {
public RestResult post(@RequestBody SysApiRole main) {
service.insert(main);
jdbcDao.update("update sys_org_user set retag = 0");
return RestResult.ok();
}
@PutMapping
public RestResult put(@RequestBody SysPermRole main) {
public RestResult put(@RequestBody SysApiRole main) {
service.update(main);
jdbcDao.update("update sys_org_user set retag = 0");
return RestResult.ok();
}
@PutMapping("flush")
@PostMapping("flush")
public RestResult flush() {
jdbcDao.update("update sys_org_user set retag = 0");
return RestResult.ok();
@@ -69,5 +69,5 @@ public class SysPermRoleApi {
private JdbcDao jdbcDao;
@Autowired
private SysPermRoleService service;
private SysApiRoleService service;
}
@@ -0,0 +1,7 @@
package vboot.core.module.sys.api.role;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SysApiRoleRepo extends JpaRepository<SysApiRole,String> {
}
@@ -1,4 +1,4 @@
package vboot.core.module.sys.perm.role;
package vboot.core.module.sys.api.role;
import vboot.core.common.service.BaseMainService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -7,11 +7,11 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@Service
public class SysPermRoleService extends BaseMainService<SysPermRole> {
public class SysApiRoleService extends BaseMainService<SysApiRole> {
//bean注入------------------------------
@Autowired
private SysPermRoleRepo repo;
private SysApiRoleRepo repo;
@PostConstruct
public void initDao() {
@@ -47,10 +47,11 @@ public class SysJobMainApi {
}
@PostMapping("start/{ids}")
public RestResult startJob(@PathVariable String[] ids) throws SchedulerException {
for (int i = 0; i < ids.length; i++) {
SysJobMain job = repo.findById(ids[i]).get();
@PostMapping("start")
public RestResult startJob(String ids) throws SchedulerException {
String[] idArr = ids.split(",");
for (int i = 0; i < idArr.length; i++) {
SysJobMain job = repo.findById(idArr[i]).get();
String[] arr= job.getReurl().split("/");
job.setJgroup(arr[0]);
job.setJid(arr[1]);
@@ -59,10 +60,11 @@ public class SysJobMainApi {
return RestResult.ok();
}
@PostMapping("stop/{ids}")
public RestResult stopJob(@PathVariable String[] ids) throws SchedulerException {
for (int i = 0; i < ids.length; i++) {
SysJobMain job = repo.findById(ids[i]).get();
@PostMapping("stop")
public RestResult stopJob(String ids) throws SchedulerException {
String[] idArr = ids.split(",");
for (int i = 0; i < idArr.length; i++) {
SysJobMain job = repo.findById(idArr[i]).get();
String[] arr= job.getReurl().split("/");
job.setJgroup(arr[0]);
job.setJid(arr[1]);
@@ -72,8 +74,8 @@ public class SysJobMainApi {
}
@PostMapping("once/{id}")
public RestResult startOnce(@PathVariable String id) throws InterruptedException, SchedulerException {
@PostMapping("once")
public RestResult startOnce(String id) throws InterruptedException, SchedulerException {
SysJobMain main=repo.findById(id).get();
String[] arr= main.getReurl().split("/");
main.setJgroup(arr[0]);
@@ -60,19 +60,6 @@ public class SysOrgUser {
private Boolean retag = false;//准备标记
@Column(length = 2000)
private String conds; //组织架构集,用户ID,所有上级部门ID,岗位ID,群组ID
@Column(length = 2000)
private String perms; //后台所有权限集,用于验证URL权限
@Column(length = 2000)
private String menus; //前台菜单缓存
@Column(length = 2000)
private String btns; //前台按钮缓存
public SysOrgUser() {
}
@@ -0,0 +1,29 @@
package vboot.core.module.sys.org.user;
import lombok.Data;
import javax.persistence.*;
@Entity
@Data
public class SysOrgUserCache {
@Id
@Column(length = 32)
private String id;
@Column(length = 2000)
private String conds;//组织架构集
@Column(length = 2000)
private String portals;//前台门户缓存
@Column(length = 2000)
private String perms;//后台所有权限集
@Lob
private String menus;//前台菜单缓存
@Lob
private String btns;//前台按钮缓存
}
@@ -1,34 +0,0 @@
package vboot.core.module.sys.perm.api;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
@Data
public class SysPermApi {
@Id
@Column(length = 64)
private String id;
@Column(length = 64)
private String name;
@Column(length = 64)
private String pid;
private Long lcode;
private Integer ipos;
private Boolean cotag;//公共标记
@Column(length = 32)
private String tcode;
private Boolean avtag;//可用标记
}
@@ -1,59 +0,0 @@
package vboot.core.module.sys.perm.api;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.api.RestResult;
import vboot.core.common.pojo.ZidName;
import vboot.core.common.pojo.Zinp;
import vboot.core.xutil.lang.XstringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("sys/perm/api")
public class SysPermApiApi {
@GetMapping("list")
public RestResult list(String name) {
List<ZidName> stores=jdbcDao.getIdNameListByTable("sys_perm_api",name);
return RestResult.ok(stores);
}
@GetMapping("type")
public RestResult type(String type) {
if(XstringUtil.isNotBlank(type)){
List<Zinp> stores=jdbcDao.findInpList("select id,pid,name from sys_perm_api where pid like ?",type+"%");
return RestResult.ok(stores);
}else{
List<Zinp> stores=jdbcDao.findInpList("select id,pid,name from sys_perm_api");
return RestResult.ok(stores);
}
}
@GetMapping("one/{id}")
public RestResult getOne(@PathVariable String id) {
SysPermApi main=repo.findById(id).get();
return RestResult.ok(main);
}
@PutMapping
public RestResult put(@RequestBody SysPermApi main) {
repo.save(main);
return RestResult.ok();
}
@DeleteMapping("{ids}")
public RestResult delete(@PathVariable String[] ids) {
for (String id : ids) {
repo.deleteById(id);
}
return RestResult.ok();
}
@Autowired
private JdbcDao jdbcDao;
@Autowired
private SysPermApiRepo repo;
}
@@ -1,8 +0,0 @@
package vboot.core.module.sys.perm.api;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SysPermApiRepo extends JpaRepository<SysPermApi,String> {
}
@@ -1,350 +0,0 @@
package vboot.core.module.sys.perm.api;
import cn.hutool.core.lang.ClassScanner;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.pojo.Zinp;
import vboot.core.xutil.lang.XmapUtil;
import vboot.core.xutil.web.XuserUtil;
import vboot.core.security.pojo.Zuser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Service
@Transactional(rollbackFor = Exception.class)
public class SysPermApiService {
private List<Yperm> g1perms;
private List<Yperm> g2perms;
private List<Yperm> sperms;
private List<Yperm> uperms;
private List<Yperm> dperms;
private List<Yperm> pperms;
public void initPerm() {
List<Zinp> javaList = getScanList();
// javaList.addAll(XmapUtil.getRootList());
List<String> ordList = jdbcDao.findStringList("select id from sys_perm_api");
//收集最大权限位及最大权限位的最大权限码
String sql = "select max(u.ipos) as ipos,max(u.lcode) as lcode from sys_perm_api u where u.ipos = (select max(uu.ipos) from sys_perm_api uu)";
Map<String, Object> maxMap = jdbcDao.findMap(sql);
int pos = 0;
long code = 0;
if (maxMap != null && maxMap.get("ipos") != null) {
pos = Integer.parseInt(String.valueOf(maxMap.get("ipos")));
code = Long.parseLong(String.valueOf(maxMap.get("lcode")));
}
//比较两个list得到insertList
List<Object[]> insertList = new ArrayList<Object[]>();
List<Object[]> updateList = new ArrayList<Object[]>();
for (Zinp zinp : javaList) {
boolean flag = false;
for (String ordstr : ordList) {
if (zinp.getId().equals(ordstr)) {
flag = true;
break;
}
}
//插入
if (!flag) {
if (!zinp.getId().startsWith("~")) {
Object[] objects = new Object[6];
objects[0] = zinp.getId();
objects[1] = zinp.getPid();
objects[2] = 0;
objects[3] = 0;
objects[4] = zinp.getName();
objects[5] = 0;
insertList.add(objects);
} else {
if (code >= (1L << 62)) {
pos = pos + 1;
code = 1;
} else {
if (code == 0) {
code = 1;
} else {
code = code << 1;
}
}
Object[] objects = new Object[6];
objects[0] = zinp.getId();
objects[1] = zinp.getPid();
objects[2] = pos;
objects[3] = code;
objects[4] = zinp.getName();
objects[5] = 0;
insertList.add(objects);
}
} else {//更新
Object[] objects = new Object[3];
objects[0] = zinp.getName();
objects[1] = zinp.getPid();
objects[2] = zinp.getId();
updateList.add(objects);
}
}
//设置是否为公共资源
for (Object[] objects : insertList) {
if (objects[0].toString().contains("_c")) {
objects[5] = 1;
}
}
//更新数据库
String initSql = "UPDATE sys_perm_api SET avtag=0";
String updateSql = "UPDATE sys_perm_api SET name=?,pid=?,avtag=1 WHERE id=?";
String insertSql = "INSERT INTO sys_perm_api(id,pid,ipos,lcode,name,cotag,avtag) VALUES(?,?,?,?,?,?,1)";
jdbcDao.update(initSql);
jdbcDao.batch(updateSql, updateList);
jdbcDao.batch(insertSql, insertList);
AUTHPOS = pos;
//初始化所有用户权限
String updateUserSql = "update sys_org_user set retag=0";
jdbcDao.update(updateUserSql);
//将所有要求认证的权限放入application
String g1permSql = "SELECT id,ipos,lcode,tcode from sys_perm_api where avtag= 1 and cotag = 0 and lcode<>0 and id like '~G%' and id not like '%}'";
this.g1perms = getPerms(g1permSql);
String g2permSql = "SELECT id,ipos,lcode,tcode from sys_perm_api where avtag = 1 and cotag = 0 and lcode<>0 and id like '~G%' and id like '%}'";
this.g2perms = getPerms(g2permSql);
String spermSql = "SELECT id,ipos,lcode,tcode from sys_perm_api where avtag = 1 and cotag = 0 and lcode<>0 and id like '~PO%'";
this.sperms = getPerms(spermSql);
String upermSql = "SELECT id,ipos,lcode,tcode from sys_perm_api where avtag = 1 and cotag = 0 and lcode<>0 and id like '~PU%'";
this.uperms = getPerms(upermSql);
String dpermSql = "SELECT id,ipos,lcode,tcode from sys_perm_api where avtag = 1 and cotag = 0 and lcode<>0 and id like '~D%'";
this.dperms = getPerms(dpermSql);
String ppermSql = "SELECT id,ipos,lcode,tcode from sys_perm_api where avtag = 1 and cotag = 0 and lcode<>0 and id like '~PA%'";
this.pperms = getPerms(ppermSql);
initAdmin();
}
public void initAdmin(){
//admin用户
String saSql="select u.usnam as id from sys_perm_label_org o inner join sys_org_user u on u.id=o.org inner join sys_perm_label l on l.id=o.id where l.code='admin'";
List<String> saList = jdbcDao.findStringList(saSql);
XuserUtil.admins = saList.toArray(new String[0]);
}
private List<Yperm> getPerms(String sql){
return jdbcDao.getTp().query(sql, (rs, rowNum) -> {
Yperm yperm = new Yperm();
String id=rs.getString("id").split(":")[1];
if(id.endsWith("}")){
yperm.setId(id.substring(0,id.lastIndexOf("/")));
}
else{
yperm.setId(id);
}
yperm.setPos(rs.getInt("ipos"));
yperm.setCode(rs.getLong("lcode"));
yperm.setTcode(rs.getString("tcode"));
return yperm;
});
}
@Autowired
private JdbcDao jdbcDao;
public static Integer AUTHPOS = 0;
private List<Zinp> getScanList() {
List<Zinp> list = new ArrayList<Zinp>();
Set<Class<?>> classes = ClassScanner.scanPackage("vboot");
for (Class<?> clazz : classes) {
RequestMapping requestMapping = clazz.getAnnotation(RequestMapping.class);
if (requestMapping != null) {
String url = requestMapping.value()[0];
//---> /n 开头的不需要登录, /co 只要登录就有权限 /sy 需要管理员才有权限 其余通过rbac权限机制判断
if (!url.startsWith("n")&&!url.startsWith("co")&&!url.startsWith("sy")) {
Zinp topInp = new Zinp();
topInp.setId(url);
if(!"".equals(requestMapping.name())){
topInp.setName(url+" "+requestMapping.name());
}else{
topInp.setName(XmapUtil.getName(url));
}
String[] arr=url.split("/");
String s = "";
for (int i = 0; i <arr.length-1 ; i++) {
s += arr[i] + "/";
}
if(arr.length>=1&&s.length()>0){
s=s.substring(0,s.length()-1);
}
if(!url.contains("/")&&url.length()==4){
topInp.setPid(url.substring(0,3));
}else{
topInp.setPid(s);
}
list.add(topInp);
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
GetMapping getMapping = method.getAnnotation(GetMapping.class);
if (getMapping != null) {
Zinp zinp = new Zinp();
String id = "~GET:/" + url;
if (getMapping.value().length > 0) {
id = "~GET:/" + url + "/" + getMapping.value()[0];
}
zinp.setId(id);
zinp.setPid(url);
if("".equals(getMapping.name())){
zinp.setName(id);
}else{
zinp.setName(getMapping.name());
}
// zinp.setName(XmapUtil.getName("/" + url + "/" + methodMapping.value()[0]));
if(!id.endsWith("_c")&&!id.endsWith("_n")){
list.add(zinp);
}
continue;
}
PostMapping postMapping = method.getAnnotation(PostMapping.class);
if (postMapping != null) {
Zinp zinp = new Zinp();
String id = "~POS:/" + url;
if (postMapping.value().length > 0) {
id = "~POS:/" + url + "/" + postMapping.value()[0];
}
zinp.setId(id);
zinp.setPid(url);
if("".equals(postMapping.name())){
zinp.setName(id);
}else{
zinp.setName(postMapping.name());
}
if(!id.endsWith("_c")&&!id.endsWith("_n")){
list.add(zinp);
}
continue;
}
PutMapping putMapping = method.getAnnotation(PutMapping.class);
if (putMapping != null) {
Zinp zinp = new Zinp();
String id = "~PUT:/" + url;
if (putMapping.value().length > 0) {
id = "~PUT:/" + url + "/" + putMapping.value()[0];
}
zinp.setId(id);
zinp.setPid(url);
if("".equals(putMapping.name())){
zinp.setName(id);
}else{
zinp.setName(putMapping.name());
}
if(!id.endsWith("_c")&&!id.endsWith("_n")){
list.add(zinp);
}
continue;
}
DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class);
if (deleteMapping != null) {
Zinp zinp = new Zinp();
String id = "~DEL:/" + url;
if (deleteMapping.value().length > 0) {
id = "~DEL:/" + url + "/" + deleteMapping.value()[0];
}
zinp.setId(id);
zinp.setPid(url);
if("".equals(deleteMapping.name())){
zinp.setName(id);
}else{
zinp.setName(deleteMapping.name());
}
if(!id.endsWith("_c")&&!id.endsWith("_n")){
list.add(zinp);
}
}
PatchMapping patchMapping = method.getAnnotation(PatchMapping.class);
if (patchMapping != null) {
Zinp zinp = new Zinp();
String id = "~PAT:/" + url;
if (patchMapping.value().length > 0) {
id = "~PAT:/" + url + "/" + patchMapping.value()[0];
}
zinp.setId(id);
zinp.setPid(url);
if("".equals(patchMapping.name())){
zinp.setName(id);
}else{
zinp.setName(patchMapping.name());
}
if(!id.endsWith("_c")&&!id.endsWith("_n")){
list.add(zinp);
}
}
}
}
}
}
return list;
}
public boolean hasPerm(Zuser zuser, String url, String type){
if(zuser.isAdmin()){
return true;
}
boolean flag=false;
if("pat".equals(type)){
for (int i = 0; i < pperms.size(); i++) {
if(pperms.get(i).getId().equals(url)){
flag = zuser.hasPerm(pperms.get(i).getPos(), pperms.get(i).getCode());
break;
}
}
}else if("get".equals(type)){
for (int i = 0; i < g1perms.size(); i++) {
if(g1perms.get(i).getId().equals(url)){
flag = zuser.hasPerm(g1perms.get(i).getPos(), g1perms.get(i).getCode());
break;
}
}
}
return flag;
}
public boolean hasPerm(Zuser zuser, String url){
return hasPerm(zuser, url, "pat");
}
//get and set---------
public List<Yperm> getG1perms() {
return g1perms;
}
public List<Yperm> getG2perms() {
return g2perms;
}
public List<Yperm> getSperms() {
return sperms;
}
public List<Yperm> getUperms() {
return uperms;
}
public List<Yperm> getDperms() {
return dperms;
}
}
@@ -1,30 +0,0 @@
package vboot.core.module.sys.perm.api;
public class Zperm
{
private int pos;
private long code;
//get and set-----------
public int getPos()
{
return pos;
}
public void setPos(int pos)
{
this.pos = pos;
}
public long getCode()
{
return code;
}
public void setCode(long code)
{
this.code = code;
}
}
@@ -1,16 +0,0 @@
package vboot.core.module.sys.perm.menu;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface SysPermMenuRepo extends JpaRepository<SysPermMenu, String> {
List<SysPermMenu> findByNameLikeOrderByOrnum(String name);
List<SysPermMenu> findByOrderByOrnum();
List<SysPermMenu> findByPid(String pid);
}
@@ -1,6 +0,0 @@
package vboot.core.module.sys.perm.role;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SysPermRoleRepo extends JpaRepository<SysPermRole,String> {
}
@@ -0,0 +1,24 @@
package vboot.core.module.sys.portal.main;
import lombok.Getter;
import lombok.Setter;
import vboot.core.common.entity.BaseMainEntity;
import vboot.core.module.sys.org.root.SysOrg;
import javax.persistence.*;
import java.util.List;
@Entity
@Getter
@Setter
public class SysPortalMain extends BaseMainEntity {
private Integer ornum;
private String notes;
@ManyToMany
@JoinTable(name = "sys_portal_main_viewer", joinColumns = {@JoinColumn(name = "mid")},
inverseJoinColumns = {@JoinColumn(name = "oid")})
private List<SysOrg> viewers;
}
@@ -0,0 +1,50 @@
package vboot.core.module.sys.portal.main;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vboot.core.common.api.RestResult;
import vboot.core.common.dao.Sqler;
@RestController
@RequestMapping("sys/portal/main")
public class SysPortalMainApi {
@GetMapping
public RestResult get(String name) {
Sqler sqler = new Sqler("sys_portal_main");
sqler.addLike("t.name", name);
sqler.addOrder("t.ornum");
return RestResult.ok(service.findPageData(sqler));
}
@GetMapping("list")
public RestResult getList() {
return RestResult.ok(service.findAll());
}
@GetMapping("one/{id}")
public RestResult getOne(@PathVariable String id) {
SysPortalMain main = service.findOne(id);
return RestResult.ok(main);
}
@PostMapping
public RestResult post(@RequestBody SysPortalMain main) {
return RestResult.ok(service.insert(main));
}
@PutMapping
public RestResult put(@RequestBody SysPortalMain main) {
return RestResult.ok(service.update(main));
}
@DeleteMapping("{ids}")
public RestResult delete(@PathVariable String[] ids) {
return RestResult.ok(service.delete(ids));
}
@Autowired
private SysPortalMainService service;
}
@@ -0,0 +1,9 @@
package vboot.core.module.sys.portal.main;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SysPortalMainRepo extends JpaRepository<SysPortalMain,String> {
}
@@ -0,0 +1,22 @@
package vboot.core.module.sys.portal.main;
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 SysPortalMainService extends BaseMainService<SysPortalMain> {
//----------bean注入------------
@Autowired
private SysPortalMainRepo repo;
@PostConstruct
public void initDao() {
super.setRepo(repo);
}
}
@@ -1,4 +1,4 @@
package vboot.core.module.sys.perm.menu;
package vboot.core.module.sys.portal.menu;
import lombok.Data;
@@ -12,7 +12,7 @@ import java.util.List;
@Entity
@Data
public class SysPermMenu {
public class SysPortalMenu {
@Id
@Column(length = 32)
@@ -20,6 +20,10 @@ public class SysPermMenu {
@Column(length = 32)
private String pid;
@Column(length = 32)
private String porid;//门户id
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// @JoinColumn(name = "pid")
// @OrderBy("ornum ASC")
@@ -28,7 +32,7 @@ public class SysPermMenu {
private String pname; //行项目
@Transient
private List<SysPermMenu> children = new ArrayList<>(); //行项目
private List<SysPortalMenu> children = new ArrayList<>(); //行项目
@Column(length = 32)
private String type;//类型 C:目录,M:菜单,B:按钮
@@ -64,17 +68,14 @@ public class SysPermMenu {
private Boolean avtag;//是否可用
private Boolean aftag=false;//是否固定
@Column(updatable = false)
private Date crtim = new Date();//创建时间
private Date uptim;//更新时间
//--------以后扩展用---------
@Column(length = 32)
private String tcode;
private String api;//api
private Long lcode;
private Integer ipos;
}
@@ -1,50 +1,44 @@
package vboot.core.module.sys.perm.menu;
package vboot.core.module.sys.portal.menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vboot.core.common.api.RestResult;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.dao.Sqler;
import vboot.core.xutil.lang.XstringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("sys/perm/menu")
public class SysPermMenuApi {
@RequestMapping("sys/portal/menu")
public class SysPortalMenuApi {
@GetMapping("tree")
public RestResult getTree(String name, String type) {
Sqler sqler = new Sqler("sys_perm_menu");
public RestResult getTree(String name, String porid) {
Sqler sqler = new Sqler("sys_portal_menu");
sqler.addLike("t.name", name);
sqler.addOrder("t.ornum");
sqler.addWhere("t.avtag=1");
sqler.addSelect("t.type,t.crtim,t.uptim,t.pid");
if(XstringUtil.isNotBlank(type)){
if("DM".equals(type)){
sqler.addWhere("t.type in ('D','M')");
}else{
return RestResult.ok(new ArrayList<>());
}
}
List<SysPermMenu> list = service.findTree(sqler);
sqler.addSelect("t.type,t.crtim,t.uptim,t.pid,t.shtag,t.path,t.comp");
sqler.addEqual("t.porid", porid);
List<SysPortalMenu> list = service.findTree(sqler);
return RestResult.ok(list);
}
//排除了自己
@GetMapping("listn")
public RestResult getListn( String id) {
List<SysPermMenu> list = service.findWithoutItself(id);
List<SysPortalMenu> list = service.findWithoutItself(id);
return RestResult.ok(list);
}
@GetMapping("one/{id}")
public RestResult id(@PathVariable String id, HttpServletRequest request) {
SysPermMenu main = service.findById(id);
SysPortalMenu main = service.findById(id);
if(main.getPid()!=null){
SysPermMenu parent = service.findById(main.getPid());
SysPortalMenu parent = service.findById(main.getPid());
main.setPname(parent.getName());
}
return RestResult.ok(main);
@@ -52,13 +46,13 @@ public class SysPermMenuApi {
@PostMapping
public RestResult post(@RequestBody SysPermMenu main) {
public RestResult post(@RequestBody SysPortalMenu main) {
System.out.println("插入");
return RestResult.ok(service.insert(main));
}
@PutMapping
public RestResult put(@RequestBody SysPermMenu main) {
public RestResult put(@RequestBody SysPortalMenu main) {
System.out.println("修改");
return RestResult.ok(service.update(main));
}
@@ -74,7 +68,7 @@ public class SysPermMenuApi {
private JdbcDao jdbcDao;
@Autowired
private SysPermMenuService service;
private SysPortalMenuService service;
}
@@ -0,0 +1,16 @@
package vboot.core.module.sys.portal.menu;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface SysPortalMenuRepo extends JpaRepository<SysPortalMenu, String> {
List<SysPortalMenu> findByNameLikeOrderByOrnum(String name);
List<SysPortalMenu> findByOrderByOrnum();
List<SysPortalMenu> findByPid(String pid);
}
@@ -1,28 +1,28 @@
package vboot.core.module.sys.perm.menu;
package vboot.core.module.sys.portal.menu;
import cn.hutool.core.util.StrUtil;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.dao.Sqler;
import vboot.core.xutil.lang.XstringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.dao.Sqler;
import vboot.core.xutil.lang.XstringUtil;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Transactional(rollbackFor = Exception.class)
public class SysPermMenuService {
public class SysPortalMenuService {
@Transactional(readOnly = true)
public SysPermMenu findById(String id) {
public SysPortalMenu findById(String id) {
return repo.findById(id).get();
}
public SysPermMenu insert(SysPermMenu main) {
public SysPortalMenu insert(SysPortalMenu main) {
if (main.getId() == null || "".equals(main.getId())) {
main.setId(XstringUtil.getUUID());
}
@@ -30,7 +30,7 @@ public class SysPermMenuService {
}
public SysPermMenu update(SysPermMenu main) {
public SysPortalMenu update(SysPortalMenu main) {
return repo.save(main);
}
@@ -38,7 +38,7 @@ public class SysPermMenuService {
Set<String> menuSet = new HashSet<>();
for (String id : ids) {
menuSet.add(id);
List<SysPermMenu> menuList = repo.findByPid(id);
List<SysPortalMenu> menuList = repo.findByPid(id);
addChild(menuList, menuSet);
}
for (String str : menuSet) {
@@ -47,24 +47,24 @@ public class SysPermMenuService {
return menuSet.size();
}
public void addChild(List<SysPermMenu> menuList, Set<String> menuSet) {
for (SysPermMenu menu : menuList) {
public void addChild(List<SysPortalMenu> menuList, Set<String> menuSet) {
for (SysPortalMenu menu : menuList) {
menuSet.add(menu.getId());
List<SysPermMenu> menus = repo.findByPid(menu.getId());
List<SysPortalMenu> menus = repo.findByPid(menu.getId());
if (menus != null && menus.size() != 0) {
addChild(menus, menuSet);
}
}
}
public List<SysPermMenu> findTree(Sqler sqler) {
List<SysPermMenu> list = jdbcDao.getTp().query(sqler.getSql(), sqler.getParams(), new BeanPropertyRowMapper<>(SysPermMenu.class));
public List<SysPortalMenu> findTree(Sqler sqler) {
List<SysPortalMenu> list = jdbcDao.getTp().query(sqler.getSql(), sqler.getParams(), new BeanPropertyRowMapper<>(SysPortalMenu.class));
return buildByRecursive(list);
}
public List<SysPermMenu> findAll(String name) {
List<SysPermMenu> list;
public List<SysPortalMenu> findAll(String name) {
List<SysPortalMenu> list;
if (StrUtil.isNotBlank(name)) {
list = repo.findByNameLikeOrderByOrnum("%" + name + "%");
} else {
@@ -74,70 +74,31 @@ public class SysPermMenuService {
}
public List<SysPermMenu> findWithoutItself(String id) {
List<SysPermMenu> list = repo.findByOrderByOrnum();
List<SysPermMenu> menus = buildByRecursiveWithoutItself(list, id);
public List<SysPortalMenu> findWithoutItself(String id) {
List<SysPortalMenu> list = repo.findByOrderByOrnum();
List<SysPortalMenu> menus = buildByRecursiveWithoutItself(list, id);
return menus;
}
//高性能转换,但是要求顶层有pid,这里假设为0
public static List<SysPermMenu> buildTree(List<SysPermMenu> pidList) {
Map<String, List<SysPermMenu>> pidListMap = pidList.stream().collect(Collectors.groupingBy(SysPermMenu::getPid));
public static List<SysPortalMenu> buildTree(List<SysPortalMenu> pidList) {
Map<String, List<SysPortalMenu>> pidListMap = pidList.stream().collect(Collectors.groupingBy(SysPortalMenu::getPid));
pidList.stream().forEach(item -> item.setChildren(pidListMap.get(item.getId())));
//返回结果也改为返回顶层节点的list
return pidListMap.get("0");
}
// private List<SysPermMenu> getTreeData(List<SysPermMenu> list) {
// List<SysPermMenu> tree = new LinkedList<>();
// if(null != list && !list.isEmpty()){
// for(SysPermMenu nodeVo: list){
// addToTreeNodeList(list, nodeVo);
// }
//
// for (SysPermMenu nodeVo: list){
// if(null == nodeVo.getPid()){
// tree.add(nodeVo);
// }
// }
// }
// return tree;
// }
//
// private void addToTreeNodeList(final List<SysPermMenu> nodeVoList, SysPermMenu treeNodeVo){
// if(null != nodeVoList && !nodeVoList.isEmpty()){
// for(SysPermMenu parentNodeVo: nodeVoList){
// if(parentNodeVo.getId().equals(treeNodeVo.getPid())){
// List<SysPermMenu> children = parentNodeVo.getChildren();
// boolean flag = true;
// for(SysPermMenu node: children){
// if(treeNodeVo.getId().equals(node.getId())){
// flag = false;
// }
// }
// if(flag){
// children.add(treeNodeVo);
// }
// break;
// }else{
// addToTreeNodeList(parentNodeVo.getChildren(), treeNodeVo);
// }
// }
// }
// }
//使用递归方法建树
private List<SysPermMenu> buildByRecursive(List<SysPermMenu> nodes) {
List<SysPermMenu> list = new ArrayList<>();
for (SysPermMenu node : nodes) {
private List<SysPortalMenu> buildByRecursive(List<SysPortalMenu> nodes) {
List<SysPortalMenu> list = new ArrayList<>();
for (SysPortalMenu node : nodes) {
if (node.getPid() == null) {
list.add(findChildrenByTier(node, nodes));
} else {
boolean flag = false;
for (SysPermMenu node2 : nodes) {
for (SysPortalMenu node2 : nodes) {
if (node.getPid().equals(node2.getId())) {
flag = true;
break;
@@ -152,8 +113,8 @@ public class SysPermMenuService {
}
//递归查找子节点
private SysPermMenu findChildrenByTier(SysPermMenu node, List<SysPermMenu> nodes) {
for (SysPermMenu item : nodes) {
private SysPortalMenu findChildrenByTier(SysPortalMenu node, List<SysPortalMenu> nodes) {
for (SysPortalMenu item : nodes) {
if (node.getId().equals(item.getPid())) {
if (node.getChildren() == null) {
node.setChildren(new ArrayList<>());
@@ -166,14 +127,14 @@ public class SysPermMenuService {
//使用递归方法建树不包含自己
private List<SysPermMenu> buildByRecursiveWithoutItself(List<SysPermMenu> nodes, String id) {
List<SysPermMenu> list = new ArrayList<>();
for (SysPermMenu node : nodes) {
private List<SysPortalMenu> buildByRecursiveWithoutItself(List<SysPortalMenu> nodes, String id) {
List<SysPortalMenu> list = new ArrayList<>();
for (SysPortalMenu node : nodes) {
if (node.getPid() == null && !node.getId().equals(id)) {
list.add(findChildrenByTierWithoutItself(node, nodes, id));
} else {
boolean flag = false;
for (SysPermMenu node2 : nodes) {
for (SysPortalMenu node2 : nodes) {
if (node.getPid() != null&&node.getPid().equals(node2.getId())) {
flag = true;
break;
@@ -188,8 +149,8 @@ public class SysPermMenuService {
}
//递归查找子节点不包含自己
private SysPermMenu findChildrenByTierWithoutItself(SysPermMenu node, List<SysPermMenu> nodes, String id) {
for (SysPermMenu item : nodes) {
private SysPortalMenu findChildrenByTierWithoutItself(SysPortalMenu node, List<SysPortalMenu> nodes, String id) {
for (SysPortalMenu item : nodes) {
if (node.getId().equals(item.getPid()) && (!item.getId().equals(id))) {
if (node.getChildren() == null) {
node.setChildren(new ArrayList<>());
@@ -202,7 +163,7 @@ public class SysPermMenuService {
@Autowired
private SysPermMenuRepo repo;
private SysPortalMenuRepo repo;
@Autowired
private JdbcDao jdbcDao;
@@ -0,0 +1,44 @@
package vboot.core.module.sys.portal.role;
import lombok.Getter;
import lombok.Setter;
import vboot.core.common.entity.BaseMainEntity;
import vboot.core.module.sys.org.root.SysOrg;
import vboot.core.module.sys.portal.menu.SysPortalMenu;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Getter
@Setter
public class SysPortalRole extends BaseMainEntity
{
@Column(length = 32)
private String porid;
@Column(length = 32)
private String type;
@Column(length = 32)
private String label;
private String notes;
//拥有的菜单
@ManyToMany
@JoinTable(name = "sys_portal_role_menu",
joinColumns = {@JoinColumn(name = "rid")},
inverseJoinColumns = {@JoinColumn(name = "mid")})
private List<SysPortalMenu> menus = new ArrayList<>();
//授权的用户
@ManyToMany
@JoinTable(name = "sys_portal_role_org",
joinColumns = {@JoinColumn(name = "rid")},
inverseJoinColumns = {@JoinColumn(name = "oid")})
private List<SysOrg> orgs = new ArrayList<>();
}
@@ -0,0 +1,73 @@
package vboot.core.module.sys.portal.role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vboot.core.common.api.RestResult;
import vboot.core.common.dao.JdbcDao;
import vboot.core.common.dao.Sqler;
@RestController
@RequestMapping("sys/portal/role")
public class SysPortalRoleApi {
private String table = "sys_portal_role";
@GetMapping
public RestResult 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));
}
// @GetMapping("perms")
// public RestResult 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));
// } else {
// allSql += " and r.pid like ?";
// return RestResult.ok(jdbcDao.findMapList(allSql, id, type + "%"));
// }
// }
@GetMapping("one/{id}")
public RestResult getOne(@PathVariable String id) {
SysPortalRole main = service.findOne(id);
// main.setPerms(null);
return RestResult.ok(main);
}
@PostMapping
public RestResult post(@RequestBody SysPortalRole main) {
service.insert(main);
jdbcDao.update("update sys_org_user set retag = 0");
return RestResult.ok();
}
@PutMapping
public RestResult put(@RequestBody SysPortalRole main) {
service.update(main);
jdbcDao.update("update sys_org_user set retag = 0");
return RestResult.ok();
}
@PostMapping("flush")
public RestResult flush() {
jdbcDao.update("update sys_org_user set retag = 0");
return RestResult.ok();
}
@DeleteMapping("{ids}")
public RestResult delete(@PathVariable String[] ids) {
return RestResult.ok(service.delete(ids));
}
@Autowired
private JdbcDao jdbcDao;
@Autowired
private SysPortalRoleService service;
}
@@ -0,0 +1,6 @@
package vboot.core.module.sys.portal.role;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SysPortalRoleRepo extends JpaRepository<SysPortalRole,String> {
}
@@ -0,0 +1,20 @@
package vboot.core.module.sys.portal.role;
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 SysPortalRoleService extends BaseMainService<SysPortalRole> {
//bean注入------------------------------
@Autowired
private SysPortalRoleRepo repo;
@PostConstruct
public void initDao() {
super.setRepo(repo);
}
}
@@ -98,6 +98,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/","/assets/**","/druid/**","/login", "/index.html","/vben.html","/vue.html","/favicon.ico","/resource/**","/_app.config.js");
// web.ignoring().antMatchers("/","/login","/getMenuList","/getUserInfo","/assets/**","/druid/**", "/index.html","/vben.html","/vue.html","/favicon.ico","/resource/**","/_app.config.js");
// web.ignoring().antMatchers("/assets/**","/**");
}
@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vboot.core.xutil.lang.XstringUtil;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
@@ -36,7 +37,6 @@ public class AuthcApi {
@PostMapping("/login")
public RestResult login(@Valid @RequestBody LoginVo loginVo, HttpServletRequest request) throws IOException, ClassNotFoundException {
// System.out.println("开始登录");
//1.登录验证
UserDo userDo = null;
try {
@@ -52,7 +52,7 @@ public class AuthcApi {
if (encodePassword.equals(userDo.getPacod())) {
passFlag = true;
} else {
passFlag = ldapHandler.authenticate(loginVo.getUsername(), loginVo.getPassword());//AD域密码验证
//passFlag = ldapHandler.authenticate(loginVo.getUsername(), loginVo.getPassword());//AD域密码验证
}
}
if (!passFlag) {
@@ -69,7 +69,8 @@ public class AuthcApi {
backMap.put("rtoken", rtoken);
Zuser zuser = new Zuser(userDo.getId(), userDo.getName(), loginVo.getUsername());
authnService.initZuser(zuser, userDo, backMap);//初始化用户
authcService.initZuser(zuser, userDo, backMap);//初始化用户
redisHandler.set(atokenUUID, zuser, appConfig.getJwt().getAtime());//默认8小时过期
@@ -86,13 +87,17 @@ public class AuthcApi {
System.out.println("username=" + username);
String uuid = IdUtil.simpleUUID();
String token = jwtHandler.createTokenByUuid(uuid);
Zuser zuser = authnService.getUser(username);
Zuser zuser = authcService.getUser(username);
redisHandler.set(uuid, zuser, 10000 / 1000);
Map<String, Object> backMap = new HashMap<>();
backMap.put("token", token);
return RestResult.ok(backMap);
}
@GetMapping("/logout")
public RestResult logout(Authentication auth) {
return RestResult.ok();
}
@GetMapping("/getUserInfo")
public RestResult getUserInfo(Authentication auth, HttpServletRequest request) {
@@ -102,42 +107,28 @@ public class AuthcApi {
}
@GetMapping("/getMenuList")
public RestResult getMenuList(Authentication auth) {
List<Zmenu> zmenuList = new ArrayList<>();
Zmenu zmenu = new Zmenu();
zmenu.setPath("/sys/org");
zmenu.setName("SysOrg");
zmenu.setComponent("LAYOUT");
zmenu.setRedirect("/sys/org/user");
Zmeta zmeta = new Zmeta();
zmeta.setOrderNo(1);
zmeta.setIcon("ant-design:apartment-outlined");
zmeta.setTitle("组织架构");
zmenu.setMeta(zmeta);
zmenuList.add(zmenu);
public RestResult getMenuList(String porid,Authentication auth, HttpServletRequest request) {
if(auth==null){
return RestResult.ok(409);
}
Map<String, Object> backMap = new HashMap<>();
Zuser zuser = (Zuser) auth.getPrincipal();
Zmenu zmenu2 = new Zmenu();
zmenu2.setPath("dept");
zmenu2.setName("SysOrgDept");
zmenu2.setComponent("/sys/org/dept/index.vue");
Zmeta zmeta2 = new Zmeta();
zmeta2.setOrderNo(1);
zmeta2.setIcon("ant-design:apartment-outlined");
zmeta2.setTitle("部门管理");
zmeta2.setIgnoreKeepAlive(false);
zmenu2.setMeta(zmeta2);
UserDo userDo = jdbcDao.getTp().queryForObject("select id,name,pacod,retag from sys_org_user where id=? and avtag=1",
new Object[]{zuser.getId()}, new BeanPropertyRowMapper<>(UserDo.class));
if(XstringUtil.isBlank(porid)){
authcService.initZuser(zuser, userDo, backMap);
}else{
authcService.initZuser2(zuser, backMap,porid);
}
sysLogLoginService.save(zuser,request);
zmenu.setChildren(new ArrayList<>());
zmenu.getChildren().add(zmenu2);
// return RestResult.ok(authnService.findMenuList(auth));
return RestResult.ok(zmenuList);
return RestResult.ok(backMap);
}
@Autowired
private AuthcService authnService;
private AuthcService authcService;
@Autowired
private AppConfig appConfig;
@@ -2,17 +2,16 @@ package vboot.core.security.authc;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import vboot.core.common.dao.JdbcDao;
import vboot.core.security.pojo.UserDo;
import vboot.core.security.pojo.Zmenu;
import vboot.core.security.pojo.Zmeta;
import vboot.core.security.pojo.Zuser;
import vboot.core.init.SysApiCache;
import vboot.core.init.Yapi;
import vboot.core.security.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -27,38 +26,42 @@ public class AuthcService {
zuser.setConds(conds);
//2.根据组织架构集conds查询前台菜单集:menus
List<Zmenu> menuList = findMenuList(zuser.getConds());
//3.根据组织架构集conds查询前台按钮集:btns
List<String> btnList = findBtnList(zuser.getConds());
//4.计算后台缓存的url权限集
List<String> permList = new ArrayList<>();
for (Zmenu menu : menuList) {
if (StrUtil.isNotBlank(menu.getPerm())) {
permList.add(menu.getPerm());
List<Zmenu> menuList;
List<Zportal> portalList;
if (zuser.isAdmin()) {
portalList = findAllPortalList();
menuList = findSysMenuList(portalList.get(0).getId());
} else {
portalList = findPortalList(zuser.getConds());
if (portalList != null && portalList.size() > 0) {
menuList = findMenuList(zuser.getConds(), portalList, portalList.get(0).getId());
} else {
menuList = findNoPowerMenuList();
}
}
permList.addAll(btnList);
zuser.setPermList(permList);
//5.设置前台返回数据
//3.根据组织架构集conds查询前台按钮集:btns
// 设置zuser的权限集(位与代码方式的权限集)
List<String> btnList = findBtnList(zuser);
//4.设置前台返回数据
menuList = buildTree(menuList);
backMap.put("portals", portalList);
backMap.put("menus", menuList);
backMap.put("btns", btnList);
backMap.put("zuser", zuser);
//6.更新用户,序列化保存数据,使下次这些数据可直接从数据库取
updateUser(zuser, menuList, btnList);
//5.更新用户,序列化保存数据,使下次这些数据可直接从数据库取
updateUser(zuser, menuList, btnList, portalList);
System.out.println("通过数据库");
} else {
String sql = "select conds,menus,btns,perms from sys_org_user where id=?";
String sql = "select conds,menus,btns,perms,portals from sys_org_user_cache where id=?";
Map<String, Object> map = jdbcDao.findMap(sql, zuser.getId());
zuser.setConds((String) map.get("conds"));
List<Zmenu> menuList = JSON.parseArray((String) map.get("menus"), Zmenu.class);
List<Zportal> portalList = JSON.parseArray((String) map.get("portals"), Zportal.class);
String[] btnArr = null;
String btns = (String) map.get("btns");
@@ -66,21 +69,22 @@ public class AuthcService {
btnArr = btns.split(";");
}
String[] permArr = null;
String[] permStrArr = null;
String perms = (String) map.get("perms");
if (perms != null) {
permArr = perms.split(";");
permStrArr = perms.split(";");
}
List<String> permList = new ArrayList<>();
if (permArr != null) {
permList = Arrays.asList(permArr);
long[] permLongArr = new long[permStrArr.length];
for (int i = 0; i < permStrArr.length; i++) {
permLongArr[i] = Long.parseLong(permStrArr[i]);
}
zuser.setPermArr(permLongArr);
zuser.setPermList(permList);
backMap.put("menus", menuList);
backMap.put("portals", portalList);
backMap.put("btns", btnArr);
backMap.put("zuser", zuser);
// System.out.println("通过缓存");
System.out.println("通过缓存");
}
// //初始化数据库user
@@ -112,6 +116,28 @@ public class AuthcService {
}
public void initZuser2(Zuser zuser, Map<String, Object> backMap, String porid) {
//2.根据组织架构集conds查询前台菜单集:menus
List<Zmenu> menuList;
List<Zportal> portalList;
if (zuser.isAdmin()) {
portalList = findAllPortalList();
menuList = findSysMenuList(porid);
} else {
portalList = findPortalList(zuser.getConds());
if (portalList != null && portalList.size() > 0) {
menuList = findMenuList(zuser.getConds(), portalList, porid);
} else {
menuList = findNoPowerMenuList();
}
}
//4.设置前台返回数据
menuList = buildTree(menuList);
backMap.put("portals", portalList);
backMap.put("menus", menuList);
}
// private void calcPerms(Zuser zuser,){
// //查询权限集合
// Integer posSum = SysPermApiService.AUTHPOS + 1;//取出最大权限位
@@ -127,6 +153,9 @@ public class AuthcService {
// }
// }
private void setPerms(Zuser zuser, List<Zmenu> zmenus) {
}
private String findConds(UserDo duser) {
StringBuilder conds = new StringBuilder();
@@ -166,15 +195,24 @@ public class AuthcService {
return jdbcDao.findStringList(sql);
}
public List<Zportal> findPortalList(String conds) {
String sql = "select distinct m.name,m.id from sys_portal_main m inner join sys_portal_role r on r.porid=m.id" +
" inner join sys_portal_role_org ro on ro.rid=r.id where m.avtag=1 and ro.oid in (" + conds + ") order by m.ornum";
return jdbcDao.getTp().query(sql, new BeanPropertyRowMapper<>(Zportal.class));
}
private List<Zmenu> findMenuList(String conds) {
String sql = "select distinct m.name,m.code,m.path,m.icon,m.comp,m.ornum,m.id,m.pid,m.perm from sys_perm_menu m inner join sys_perm_role_menu rm on rm.mid=m.id inner join sys_perm_role_org ru on ru.rid=rm.rid where m.type in ('D','M') and m.avtag=1 and ru.oid in (" + conds + ") order by m.ornum";
if(conds.contains("'sa'")||conds.contains("'vben'")){
sql = "select m.name,m.code,m.path,m.icon,m.comp,m.ornum,m.id,m.pid,m.perm from sys_perm_menu m where m.type in ('D','M') and m.avtag=1 order by m.ornum";
public List<Zmenu> findMenuList(String conds, List<Zportal> portalList, String porid) {
String portals = "";
for (Zportal zportal : portalList) {
portals += "'" + zportal.getId() + "',";
}
portals = portals.substring(0, portals.length() - 1);
List<Zmenu> list = jdbcDao.getTp().query(sql, (rs, rowNum) -> {
String direSql = "select m.porid,m.shtag,m.name,m.code,m.path,m.icon,m.comp,m.ornum,m.id,m.pid,m.perm from sys_portal_menu m where m.type = 'D' and m.porid in (" + portals + ") and m.avtag=1 order by m.ornum";
List<Zmenu> direList = jdbcDao.getTp().query(direSql, (rs, rowNum) -> {
Zmenu zmenu = new Zmenu();
zmenu.setType("D");
zmenu.setPorid(rs.getString("porid"));
zmenu.setId(rs.getString("id"));
zmenu.setPid(rs.getString("pid"));
zmenu.setPerm(rs.getString("perm"));
@@ -184,10 +222,174 @@ public class AuthcService {
Zmeta zmeta = new Zmeta();
zmeta.setTitle(rs.getString("name"));
zmeta.setOrderNo(rs.getInt("ornum"));
zmeta.setIsHide(!rs.getBoolean("shtag"));
if (!porid.equals(rs.getString("porid"))) {
zmeta.setIsHide(true);
}
zmeta.setIcon(rs.getString("icon"));
zmenu.setMeta(zmeta);
return zmenu;
});
String sql = "select distinct m.porid,m.shtag,m.type,m.name,m.code,m.path,m.icon,m.comp,m.ornum,m.id,m.pid,m.perm from sys_portal_menu m inner join sys_portal_role_menu rm on rm.mid=m.id inner join sys_portal_role_org ru on ru.rid=rm.rid where m.type = 'M' and m.porid in (" + portals + ") and m.avtag=1 and ru.oid in (" + conds + ") order by m.ornum";
List<Zmenu> list = jdbcDao.getTp().query(sql, (rs, rowNum) -> {
Zmenu zmenu = new Zmenu();
zmenu.setId(rs.getString("id"));
zmenu.setType("M");
zmenu.setPorid(rs.getString("porid"));
zmenu.setPid(rs.getString("pid"));
zmenu.setPerm(rs.getString("perm"));
zmenu.setName(rs.getString("code"));
zmenu.setPath(rs.getString("path"));
zmenu.setComponent(rs.getString("comp"));
Zmeta zmeta = new Zmeta();
zmeta.setTitle(rs.getString("name"));
zmeta.setIsHide(!rs.getBoolean("shtag"));
if (!porid.equals(rs.getString("porid"))) {
zmeta.setIsHide(true);
}
zmeta.setOrderNo(rs.getInt("ornum"));
zmeta.setIcon(rs.getString("icon"));
zmenu.setMeta(zmeta);
return zmenu;
});
List<Zmenu> shouldAddlist1 = new ArrayList<>();
for (Zmenu zdire : direList) {
for (Zmenu zmenu : list) {
if (zmenu.getPid().equals(zdire.getId())) {
shouldAddlist1.add(zdire);
break;
}
}
}
List<Zmenu> shouldAddlist2 = new ArrayList<>();
for (Zmenu zdire : direList) {
for (Zmenu zshould : shouldAddlist1) {
if (zshould.getPid() != null) {
if (zshould.getPid().equals(zdire.getId())) {
shouldAddlist2.add(zdire);
break;
}
}
}
}
List<Zmenu> shouldAddlist3 = new ArrayList<>();
for (Zmenu zdire : direList) {
for (Zmenu zshould : shouldAddlist2) {
if (zshould.getPid() != null) {
if (zshould.getPid().equals(zdire.getId())) {
shouldAddlist3.add(zdire);
break;
}
}
}
}
list.addAll(shouldAddlist1);
list.addAll(shouldAddlist2);
list.addAll(shouldAddlist3);
if (list.size() == 0) {
return findNoPowerMenuList();
}
if (portalList.size() == 1) {
return list;
}
//去除其他门户相同name或path的菜单
List<Zmenu> backList = new ArrayList<>();
for (Zmenu zmenu : list) {
if (porid.equals(zmenu.getPorid())) {
backList.add(zmenu);
}
}
for (Zmenu zmenu : list) {
if (!porid.equals(zmenu.getPorid())) {
boolean flag = false;
for (Zmenu backMenu : backList) {
if (backMenu.getName().equals(zmenu.getName()) || backMenu.getPath().equals(zmenu.getPath())) {
flag = true;
break;
}
}
if (!flag) {
backList.add(zmenu);
}
}
}
return backList;
}
public List<Zportal> findAllPortalList() {
String sql = "select id,name from sys_portal_main where avtag=1 order by ornum";
return jdbcDao.getTp().query(sql, new BeanPropertyRowMapper<>(Zportal.class));
}
public List<Zmenu> findSysMenuList(String porid) {
// String sql = "select m.shtag,m.type,m.name,m.code,m.path,m.icon,m.comp,m.ornum,m.id,m.pid,m.perm from sys_portal_menu m where m.porid='sys' and m.avtag=1 order by m.ornum";
String sql = "select m.porid,m.shtag,m.type,m.name,m.code,m.path,m.icon,m.comp,m.ornum,m.id,m.pid,m.perm from sys_portal_menu m where m.avtag=1 order by m.ornum";
List<Zmenu> list = jdbcDao.getTp().query(sql, (rs, rowNum) -> {
Zmenu zmenu = new Zmenu();
zmenu.setId(rs.getString("id"));
zmenu.setPorid(rs.getString("porid"));
zmenu.setPid(rs.getString("pid"));
zmenu.setPerm(rs.getString("perm"));
zmenu.setType(rs.getString("type"));
zmenu.setName(rs.getString("code"));
zmenu.setPath(rs.getString("path"));
zmenu.setComponent(rs.getString("comp"));
Zmeta zmeta = new Zmeta();
zmeta.setIsHide(!rs.getBoolean("shtag"));
if (!porid.equals(rs.getString("porid"))) {
zmeta.setIsHide(true);
}
zmeta.setTitle(rs.getString("name"));
zmeta.setOrderNo(rs.getInt("ornum"));
zmeta.setIcon(rs.getString("icon"));
zmenu.setMeta(zmeta);
return zmenu;
});
//去除其他门户相同name或path的菜单
List<Zmenu> backList = new ArrayList<>();
for (Zmenu zmenu : list) {
if (porid.equals(zmenu.getPorid())) {
backList.add(zmenu);
}
}
for (Zmenu zmenu : list) {
if (!porid.equals(zmenu.getPorid())) {
boolean flag = false;
for (Zmenu backMenu : backList) {
if (backMenu.getName().equals(zmenu.getName()) || backMenu.getPath().equals(zmenu.getPath())) {
flag = true;
break;
}
}
if (!flag) {
backList.add(zmenu);
}
}
}
return backList;
}
public List<Zmenu> findNoPowerMenuList() {
List<Zmenu> list = new ArrayList<>();
Zmenu zmenu = new Zmenu();
zmenu.setType("M");
zmenu.setId("Home");
zmenu.setName("Home");
zmenu.setPath("/home");
zmenu.setComponent("/home/noPower");
Zmeta zmeta = new Zmeta();
zmeta.setTitle("未授权");
zmeta.setOrderNo(0);
zmeta.setIsHide(false);
zmeta.setIcon("ele-Lock");
zmenu.setMeta(zmeta);
list.add(zmenu);
return list;
}
@@ -218,30 +420,59 @@ public class AuthcService {
}
private List<String> findBtnList(String conds) {
String sql = "select distinct m.perm id from sys_perm_menu m inner join sys_perm_role_menu rm on rm.mid=m.id inner join sys_perm_role_org ru on ru.rid=rm.rid where m.type = 'B' and m.avtag=1 and ru.oid in (" + conds + ") order by m.ornum";
if(conds.contains("'sa'")||conds.contains("'vben'")){
sql = "select m.perm id from sys_perm_menu m where m.type = 'B' and m.avtag=1 order by m.ornum";
}
return jdbcDao.findStringList(sql);
private List<Yapi> findYapiList(String conds) {
String sql = "select distinct m.id url,m.pos,m.code from sys_api_main m " +
"inner join sys_api_role_api rm on rm.mid=m.id " +
"inner join sys_api_role_org ru on ru.rid=rm.rid " +
"where m.avtag=1 and ru.oid in (" + conds + ") and code<>0";
return jdbcDao.getTp().query(sql, new BeanPropertyRowMapper<>(Yapi.class));
}
private void updateUser(Zuser zuser, List<Zmenu> menuList, List<String> btnList) {
private List<String> findBtnList(Zuser zuser) {
List<String> btnList = new ArrayList<>();
List<Yapi> apiList = findYapiList(zuser.getConds());
int posSum = SysApiCache.AUTHPOS + 1;
long[] permArr = new long[posSum];
for (Yapi api : apiList) {
for (int i = 0; i < posSum; i++) {
if (i == api.getPos()) {
permArr[i] += api.getCode();
}
}
btnList.add(api.getUrl());
}
zuser.setPermArr(permArr);
return btnList;
}
private void updateUser(Zuser zuser, List<Zmenu> menuList, List<String> btnList, List<Zportal> portalList) {
String menus = JSON.toJSONString(menuList);
String portals = JSON.toJSONString(portalList);
StringBuilder btns = new StringBuilder();
for (String str : btnList) {
btns.append(str).append(";");
}
StringBuilder perms = new StringBuilder();
for (String str : zuser.getPermList()) {
perms.append(str).append(";");
for (long perm : zuser.getPermArr()) {
perms.append(perm).append(";");
}
String sql = "update sys_org_user set conds=?,menus=?,btns=?,perms=?,retag=1 where id=?";
jdbcDao.update(sql, zuser.getConds(), menus, btns.toString(), perms.toString(), zuser.getId());
String existSql = "select count(*) from sys_org_user_cache where id=?";
Integer integer = jdbcDao.getTp().queryForObject(existSql, new Object[]{zuser.getId()}, Integer.class);
if (integer > 0) {
String sql = "update sys_org_user_cache set conds=?,menus=?,btns=?,perms=?,portals=? where id=?";
jdbcDao.update(sql, zuser.getConds(), menus, btns.toString(), perms.toString(), portals, zuser.getId());
} else {
String sql = "insert into sys_org_user_cache(id,conds,menus,btns,perms,portals) VALUES(?,?,?,?,?,?)";
jdbcDao.update(sql, zuser.getId(), zuser.getConds(), menus, btns.toString(), perms.toString(), portals);
}
String retagSql = "update sys_org_user set retag=1 where id=?";
jdbcDao.update(retagSql, zuser.getId());
}
@@ -1,5 +1,7 @@
package vboot.core.security.authz;
import org.springframework.beans.factory.annotation.Autowired;
import vboot.core.module.sys.api.main.SysApiMainHand;
import vboot.core.security.pojo.Zuser;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
@@ -10,16 +12,23 @@ import javax.servlet.http.HttpServletRequest;
public class AuthzHandler {
public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
String uri=request.getRequestURI();
Zuser zuser;
try {
Zuser zuser = (Zuser) authentication.getPrincipal();
zuser = (Zuser) authentication.getPrincipal();
} catch (Exception e) {
//e.printStackTrace();
return false;
}
String uri = request.getRequestURI();
String method = request.getMethod();
if("/getMenuList".equals(uri)||"/getUserInfo".equals(uri)){
return true;
}
return apiHand.hasPerm(zuser, method, uri);
return true;
}
@Autowired
private SysApiMainHand apiHand;
}
@@ -35,4 +35,9 @@ public class Zmenu implements Serializable {
private List<Zmenu> children;
private String type;
private String porid;
}
@@ -10,6 +10,8 @@ public class Zmeta implements Serializable {
private String title;
private Boolean isHide;
private String affix;
private String icon;
@@ -0,0 +1,9 @@
package vboot.core.security.pojo;
import lombok.Data;
@Data
public class Zportal {
private String id;
private String name;
}
@@ -23,10 +23,7 @@ public class Zuser implements UserDetails, Serializable {
private String usnam;//用户名
@JsonIgnore//前端不需要
private long[] permArr;//权限集,用于验证URL权限 比较下哪个方式快1
@JsonIgnore
private List<String> permList;//权限集,用于验证URL权限 比较下哪个方式快2
private long[] permArr;//权限集,用于验证URL权限
@JsonIgnore//前端不需要
private String conds;//组织架构集,用户ID,所有上级部门ID,岗位ID,群组ID
@@ -53,6 +50,9 @@ public class Zuser implements UserDetails, Serializable {
private boolean isAdmin;
public boolean isAdmin() {
if("sa".equals(usnam)||"admin".equals(usnam)){
return true;
}
return isAdmin;
}
@@ -30,8 +30,8 @@ public class BiEtlMainApi {
return RestResult.ok(service.findOne(id));
}
@PostMapping("once/{id}")
public RestResult edit_startOnce(@PathVariable String id) throws Exception {
@PostMapping("once")
public RestResult edit_startOnce(String id) throws Exception {
BiEtlMain kettle = service.findOne(id);
KetUtil.runTran(ATT_PATH + "/" + kettle.getZpath(), null, true);
return RestResult.ok();
@@ -51,19 +51,21 @@ public class BiEtlMainApi {
return RestResult.ok(service.update(main));
}
@PostMapping("start/{ids}")
public RestResult startJob(@PathVariable String[] ids) throws SchedulerException {
for (int i = 0; i < ids.length; i++) {
BiEtlMain kettle =service.findOne(ids[i]);
@PostMapping("start")
public RestResult startJob(String ids) throws SchedulerException {
String[] idArr = ids.split(",");
for (int i = 0; i < idArr.length; i++) {
BiEtlMain kettle =service.findOne(idArr[i]);
handler.startEtlJob(kettle);
}
return RestResult.ok();
}
@PostMapping("stop/{ids}")
public RestResult list_stop(@PathVariable String[] ids) throws SchedulerException {
for (int i = 0; i < ids.length; i++) {
BiEtlMain kettle = service.findOne(ids[i]);
@PostMapping("stop")
public RestResult stopJob(String ids) throws SchedulerException {
String[] idArr = ids.split(",");
for (int i = 0; i < idArr.length; i++) {
BiEtlMain kettle = service.findOne(idArr[i]);
handler.stopEtlJob(kettle);
}
return RestResult.ok();