14 changed files with 801 additions and 7 deletions
@ -0,0 +1,11 @@ |
|||||
|
package com.hxgk.lowcode.mapper; |
||||
|
|
||||
|
import com.hxgk.lowcode.model.entity.Appmenus; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
@Mapper |
||||
|
public interface AppmenusMapper { |
||||
|
ArrayList<Appmenus> getMenuList(@Param("appkey") String appmenusAppkey); |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.hxgk.lowcode.mapper; |
||||
|
|
||||
|
import com.hxgk.lowcode.model.entity.CustomerFormGroup; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface CustomerFormGroupMapper { |
||||
|
ArrayList<CustomerFormGroup> getAllCustomerFormGroup(); |
||||
|
} |
||||
@ -0,0 +1,148 @@ |
|||||
|
package com.hxgk.lowcode.model.entity; |
||||
|
|
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Repository |
||||
|
public class Appmenus { |
||||
|
|
||||
|
private String id; |
||||
|
private String label; |
||||
|
private Integer type; |
||||
|
private String svg; |
||||
|
private Integer pclsShow; |
||||
|
private Integer waplsShow; |
||||
|
private String parent; |
||||
|
private String appkey; |
||||
|
private String createrTime; |
||||
|
private String editTime; |
||||
|
private String creater; |
||||
|
private Integer isLock; |
||||
|
private Integer sort; |
||||
|
private Integer state; |
||||
|
private Integer isMain; |
||||
|
|
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(String id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getLabel() { |
||||
|
return label; |
||||
|
} |
||||
|
|
||||
|
public void setLabel(String label) { |
||||
|
this.label = label; |
||||
|
} |
||||
|
|
||||
|
public Integer getType() { |
||||
|
return type; |
||||
|
} |
||||
|
|
||||
|
public void setType(Integer type) { |
||||
|
this.type = type; |
||||
|
} |
||||
|
|
||||
|
public String getSvg() { |
||||
|
return svg; |
||||
|
} |
||||
|
|
||||
|
public void setSvg(String svg) { |
||||
|
this.svg = svg; |
||||
|
} |
||||
|
|
||||
|
public Integer getPclsShow() { |
||||
|
return pclsShow; |
||||
|
} |
||||
|
|
||||
|
public void setPclsShow(Integer pclsShow) { |
||||
|
this.pclsShow = pclsShow; |
||||
|
} |
||||
|
|
||||
|
public Integer getWaplsShow() { |
||||
|
return waplsShow; |
||||
|
} |
||||
|
|
||||
|
public void setWaplsShow(Integer waplsShow) { |
||||
|
this.waplsShow = waplsShow; |
||||
|
} |
||||
|
|
||||
|
public String getParent() { |
||||
|
return parent; |
||||
|
} |
||||
|
|
||||
|
public void setParent(String parent) { |
||||
|
this.parent = parent; |
||||
|
} |
||||
|
|
||||
|
public String getAppkey() { |
||||
|
return appkey; |
||||
|
} |
||||
|
|
||||
|
public void setAppkey(String appkey) { |
||||
|
this.appkey = appkey; |
||||
|
} |
||||
|
|
||||
|
public String getCreaterTime() { |
||||
|
return createrTime; |
||||
|
} |
||||
|
|
||||
|
public void setCreaterTime(String createrTime) { |
||||
|
this.createrTime = createrTime; |
||||
|
} |
||||
|
|
||||
|
public String getEditTime() { |
||||
|
return editTime; |
||||
|
} |
||||
|
|
||||
|
public void setEditTime(String editTime) { |
||||
|
this.editTime = editTime; |
||||
|
} |
||||
|
|
||||
|
public String getCreater() { |
||||
|
return creater; |
||||
|
} |
||||
|
|
||||
|
public void setCreater(String creater) { |
||||
|
this.creater = creater; |
||||
|
} |
||||
|
|
||||
|
public Integer getIsLock() { |
||||
|
return isLock; |
||||
|
} |
||||
|
|
||||
|
public void setIsLock(Integer isLock) { |
||||
|
this.isLock = isLock; |
||||
|
} |
||||
|
|
||||
|
public Integer getSort() { |
||||
|
return sort; |
||||
|
} |
||||
|
|
||||
|
public void setSort(Integer sort) { |
||||
|
this.sort = sort; |
||||
|
} |
||||
|
|
||||
|
public Integer getState() { |
||||
|
return state; |
||||
|
} |
||||
|
|
||||
|
public void setState(Integer state) { |
||||
|
this.state = state; |
||||
|
} |
||||
|
|
||||
|
public Integer getIsMain() { |
||||
|
return isMain; |
||||
|
} |
||||
|
|
||||
|
public void setIsMain(Integer isMain) { |
||||
|
this.isMain = isMain; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,79 @@ |
|||||
|
package com.hxgk.lowcode.model.entity; |
||||
|
|
||||
|
import org.springframework.stereotype.Repository; |
||||
|
|
||||
|
@Repository |
||||
|
public class CustomerFormGroup { |
||||
|
private String id; |
||||
|
private String title; |
||||
|
private String superior; |
||||
|
private String sort; |
||||
|
private String ordid; |
||||
|
private String state; |
||||
|
private String time; |
||||
|
private String icon; |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(String id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getTitle() { |
||||
|
return title; |
||||
|
} |
||||
|
|
||||
|
public void setTitle(String title) { |
||||
|
this.title = title; |
||||
|
} |
||||
|
|
||||
|
public String getSuperior() { |
||||
|
return superior; |
||||
|
} |
||||
|
|
||||
|
public void setSuperior(String superior) { |
||||
|
this.superior = superior; |
||||
|
} |
||||
|
|
||||
|
public String getSort() { |
||||
|
return sort; |
||||
|
} |
||||
|
|
||||
|
public void setSort(String sort) { |
||||
|
this.sort = sort; |
||||
|
} |
||||
|
|
||||
|
public String getOrdid() { |
||||
|
return ordid; |
||||
|
} |
||||
|
|
||||
|
public void setOrdid(String ordid) { |
||||
|
this.ordid = ordid; |
||||
|
} |
||||
|
|
||||
|
public String getState() { |
||||
|
return state; |
||||
|
} |
||||
|
|
||||
|
public void setState(String state) { |
||||
|
this.state = state; |
||||
|
} |
||||
|
|
||||
|
public String getTime() { |
||||
|
return time; |
||||
|
} |
||||
|
|
||||
|
public void setTime(String time) { |
||||
|
this.time = time; |
||||
|
} |
||||
|
|
||||
|
public String getIcon() { |
||||
|
return icon; |
||||
|
} |
||||
|
|
||||
|
public void setIcon(String icon) { |
||||
|
this.icon = icon; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
package com.hxgk.lowcode.service; |
||||
|
|
||||
|
import com.hxgk.lowcode.model.entity.CustomerForm; |
||||
|
import com.hxgk.lowcode.model.entity.Tree; |
||||
|
|
||||
|
public interface AppmenusService { |
||||
|
Tree getAppTree(String appmenusAppkey, CustomerForm customerForm); |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
package com.hxgk.lowcode.service; |
||||
|
|
||||
|
import com.hxgk.lowcode.model.entity.CustomerFormGroup; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
|
||||
|
public interface CustomerFormGroupService { |
||||
|
|
||||
|
public ArrayList<CustomerFormGroup> getAllCustomerFormGroup(); |
||||
|
} |
||||
@ -0,0 +1,138 @@ |
|||||
|
package com.hxgk.lowcode.service.impl; |
||||
|
|
||||
|
import com.baomidou.dynamic.datasource.annotation.DS; |
||||
|
import com.hxgk.lowcode.mapper.AppmenusMapper; |
||||
|
import com.hxgk.lowcode.model.entity.Appmenus; |
||||
|
import com.hxgk.lowcode.model.entity.CustomerForm; |
||||
|
import com.hxgk.lowcode.model.entity.Tree; |
||||
|
import com.hxgk.lowcode.service.AppmenusService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
@DS("tidbintranetappplatform") |
||||
|
public class AppmenusSerciceImpl implements AppmenusService { |
||||
|
|
||||
|
@Autowired |
||||
|
AppmenusMapper appmenusMapper; |
||||
|
@Override |
||||
|
public Tree getAppTree(String appmenusAppkey, CustomerForm customerForm) { |
||||
|
ArrayList<Appmenus> appmenusList = appmenusMapper.getMenuList(appmenusAppkey); |
||||
|
//if(appmenusAppkey.equals("307150721797591040")){
|
||||
|
//先把所有都转成tree对象
|
||||
|
Tree customerFormTreeObj = convertCustomerFormToTreeObj(customerForm); |
||||
|
ArrayList<Tree> treeObjList = convertAppmenusToTreeObj(appmenusList); |
||||
|
treeObjList.add(customerFormTreeObj); |
||||
|
Tree tree = createTree(treeObjList,appmenusAppkey); |
||||
|
System.out.println(1); |
||||
|
//}
|
||||
|
|
||||
|
return tree; |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
*如上图信息,要求用递归的方式把ArrayList<Appmenus>和CustomerForm转换成一个Tree对象 |
||||
|
*customerForm作为tree的根节点, |
||||
|
*当Appmenus的parent等于customerForm的signCode时,说明是根节点的儿子节点, |
||||
|
*customerForm的id作为tree的根节点id,customerForm的name作为tree的label,customerForm的groupId作为tree的parentId |
||||
|
*Appmenus中的parent和id属性可以确定树关系 |
||||
|
*要求Appmenus的id填充为Tree的id,Appmenus的parent填充为Tree的parentId,Appmenus的所有其它属性填充到Tree的treeAttrs中 |
||||
|
* */ |
||||
|
|
||||
|
|
||||
|
public static Tree convertCustomerFormToTreeObj(CustomerForm customerForm){ |
||||
|
Tree tree = new Tree(); |
||||
|
tree.setId(customerForm.getSignCode()); |
||||
|
tree.setLabel(customerForm.getName()); |
||||
|
tree.setParentId(customerForm.getGroupId()); |
||||
|
HashMap<String, Object> attrs = new HashMap<>(); |
||||
|
attrs.put("tablename", customerForm.getTablename()); |
||||
|
attrs.put("classify", customerForm.getClassify()); |
||||
|
attrs.put("permit", customerForm.getPermit()); |
||||
|
attrs.put("states", customerForm.getStates()); |
||||
|
attrs.put("createrTime", customerForm.getCreaterTime()); |
||||
|
attrs.put("editTime", customerForm.getEditTime()); |
||||
|
attrs.put("permitstr", customerForm.getPermitstr()); |
||||
|
attrs.put("flowkey", customerForm.getFlowkey()); |
||||
|
attrs.put("userpermit", customerForm.getUserpermit()); |
||||
|
attrs.put("postpermit", customerForm.getPostpermit()); |
||||
|
attrs.put("icon", customerForm.getIcon()); |
||||
|
attrs.put("flowIsOpen", customerForm.getFlowIsOpen()); |
||||
|
attrs.put("listjson", customerForm.getListjson()); |
||||
|
attrs.put("signCode", customerForm.getSignCode()); |
||||
|
attrs.put("describe", customerForm.getDescribe()); |
||||
|
attrs.put("orgpermit", customerForm.getOrgpermit()); |
||||
|
attrs.put("appManager", customerForm.getAppManager()); |
||||
|
attrs.put("appRoleManager", customerForm.getAppRoleManager()); |
||||
|
attrs.put("app0rgman", customerForm.getAppOrgMan()); |
||||
|
tree.setTreeAttrs(attrs); |
||||
|
return tree; |
||||
|
} |
||||
|
|
||||
|
public static ArrayList<Tree> convertAppmenusToTreeObj(ArrayList<Appmenus> appmenusList){ |
||||
|
ArrayList<Tree> list = new ArrayList<>(); |
||||
|
for(Appmenus appmenus:appmenusList){ |
||||
|
Tree tree = new Tree(); |
||||
|
tree.setId(appmenus.getId()); |
||||
|
tree.setParentId(appmenus.getParent()); |
||||
|
tree.setLabel(appmenus.getLabel()); |
||||
|
HashMap<String, Object> attrs = new HashMap<>(); |
||||
|
|
||||
|
attrs.put("type", appmenus.getType()); |
||||
|
attrs.put("svg", appmenus.getSvg()); |
||||
|
attrs.put("pclSShow", appmenus.getPclsShow()); |
||||
|
attrs.put("waplsShow", appmenus.getWaplsShow()); |
||||
|
attrs.put("appkey", appmenus.getAppkey()); |
||||
|
attrs.put("createrTime", appmenus.getCreaterTime()); |
||||
|
attrs.put("editTime", appmenus.getEditTime()); |
||||
|
attrs.put("creater", appmenus.getCreater()); |
||||
|
attrs.put("isLock", appmenus.getIsLock()); |
||||
|
attrs.put("sort", appmenus.getSort()); |
||||
|
attrs.put("state", appmenus.getState()); |
||||
|
attrs.put("isMain", appmenus.getIsMain()); |
||||
|
tree.setTreeAttrs(attrs); |
||||
|
list.add(tree); |
||||
|
} |
||||
|
return list; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
//构造树形结构
|
||||
|
public static Tree createTree(List<Tree> sourceList,String appmenusAppkey){ |
||||
|
Tree result = new Tree(); |
||||
|
for (Tree tree : sourceList) { |
||||
|
//找到根节点进行处理,找下一级节点
|
||||
|
if(tree.getTreeAttrs().get("signCode")!=null&&tree.getTreeAttrs().get("signCode").equals(appmenusAppkey)){ |
||||
|
//把所有的根节点放到一个list
|
||||
|
result = findChildren(tree, sourceList); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
public static Tree findChildren(Tree rootTree,List<Tree> list){ |
||||
|
//这个方法是在找rootTree的所有子节点,然后返回rootTree
|
||||
|
for (Tree tree : list) { |
||||
|
if(rootTree.getId().equals(tree.getParentId())){ |
||||
|
if(rootTree.getChildren() == null){ |
||||
|
rootTree.setChildren(new ArrayList<>()); |
||||
|
} |
||||
|
// 把这个节点tree作为新的根节点继续向下构造树,再把构造的结果作为rootTree的子节点
|
||||
|
rootTree.getChildren().add(findChildren(tree,list)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return rootTree; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
package com.hxgk.lowcode.service.impl; |
||||
|
|
||||
|
import com.baomidou.dynamic.datasource.annotation.DS; |
||||
|
import com.hxgk.lowcode.mapper.CustomerFormGroupMapper; |
||||
|
import com.hxgk.lowcode.model.entity.CustomerFormGroup; |
||||
|
import com.hxgk.lowcode.service.CustomerFormGroupService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
@Service |
||||
|
@DS("tidbintranetappplatform") |
||||
|
public class CustomerFormGroupServiceImpl implements CustomerFormGroupService { |
||||
|
@Autowired |
||||
|
CustomerFormGroupMapper customerFormGroupMapper; |
||||
|
@Override |
||||
|
public ArrayList<CustomerFormGroup> getAllCustomerFormGroup() { |
||||
|
return customerFormGroupMapper.getAllCustomerFormGroup(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
|
<mapper namespace="com.hxgk.lowcode.mapper.AppmenusMapper"> |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
<select id="getMenuList" resultType="com.hxgk.lowcode.model.entity.Appmenus"> |
||||
|
|
||||
|
select * from appmenus where appkey = #{appkey} and isLock =2 and state=1 |
||||
|
|
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,14 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
|
<mapper namespace="com.hxgk.lowcode.mapper.CustomerFormGroupMapper"> |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
<select id="getAllCustomerFormGroup" resultType="com.hxgk.lowcode.model.entity.CustomerFormGroup"> |
||||
|
|
||||
|
select * from customer_form_group where state = 1 |
||||
|
|
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
Loading…
Reference in new issue