凯发k8官方网
收集整理的这篇文章主要介绍了
java——后端vue动态路由配置类javabean封装
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
https://router.vuejs.org/zh/
package cn.edu.zstu.shihua.xihu.dto;import cn.edu.zstu.shihua.xihu.entity.menu;
import cn.edu.zstu.shihua.xihu.entity.meta;
import cn.edu.zstu.shihua.xihu.model.resource;
import io.swagger.annotations.apimodel;
import io.swagger.annotations.apimodelproperty;
import lombok.data;
import lombok.equalsandhashcode;/*** @author shentuzhigang* @version 1.0.0* @date 2020-07-26 15:13*/
@data
@equalsandhashcode(callsuper = false)
@apimodel(value = "vue路由配置")
public class vuerouteconfig {/*routeconfig {path: stringname?: stringcomponent?: componentcomponents?: dictionary
redirect?: redirectoptionalias?: string | string[]children?: routeconfig[]meta?: anybeforeenter?: navigationguardprops?: boolean | object | routepropsfunctioncasesensitive?: booleanpathtoregexpoptions?: pathtoregexpoptions}*/@apimodelproperty(name = "路径",value = "路径")private string path;@apimodelproperty(name = "组件",value = "组件")private string component;@apimodelproperty(name = "名称",value = "名称")private string name;@apimodelproperty(name = "重定向",value = "重定向")private string redirect;@apimodelproperty(name = "别名",value = "别名")private string alias;@apimodelproperty(name = "元",value = "元")private meta meta;@apimodelproperty(name = "子菜单",value = "子菜单")private list children;
}
package cn.edu.zstu.shihua.xihu.entity;import io.swagger.annotations.apimodel;
import io.swagger.annotations.apimodelproperty;
import lombok.data;
import lombok.equalsandhashcode;/*** @author shentuzhigang* @version 1.0.0* @date 2020-07-26 14:14*/
@data
@equalsandhashcode(callsuper = false)
@apimodel(value = "元")
public class meta {@apimodelproperty(name = "标题",value = "标题")private string title;@apimodelproperty(name = "链接",value = "链接")private string link;@apimodelproperty(name = "图标class",value = "图标class")private string iconclass;@apimodelproperty(name = "保持",value = "保持")private boolean keepalive;@apimodelproperty(name = "是否需要授权",value = "是否需要授权")private boolean requireauth;
}
构建参考:
resource为数据库model
public static vuerouteconfig build(list resources){map map = new hashmap<>();map> listmap = new hashmap<>();for (resource resource : resources){map.put(resource.getid(),resource);if(listmap.get(resource.getparentid())==null){listmap.put(resource.getparentid(),new arraylist<>());}listmap.get(resource.getparentid()).add(resource.getid());}return findchildren(map,listmap,map.get(1));}private static vuerouteconfig findchildren(map map,map> listmap,resource resource) {vuerouteconfig vuerouteconfig = new vuerouteconfig();vuerouteconfig.setname(resource.getname());vuerouteconfig.setcomponent(resource.getcomponent());meta meta = new meta();meta.seticonclass(resource.geticonclass());meta.setkeepalive(resource.getkeepalive());meta.setrequireauth(resource.getrequireauth());vuerouteconfig.setmeta(meta);vuerouteconfig.setpath(resource.getpath());list vuerouteconfigs = new arraylist<>();list integers = listmap.get(resource.getid());if(integers==null){return vuerouteconfig;}for(integer id:integers){vuerouteconfigs.add(findchildren(map,listmap,map.get(id)));}vuerouteconfig.setchildren(vuerouteconfigs);return vuerouteconfig;}
https://blog.csdn.net/frankcheng5143/article/details/52958486
https://blog.csdn.net/frankcheng5143/article/details/72723958
https://www.cnblogs.com/fenghua12/p/5281902.html
总结
以上是凯发k8官方网为你收集整理的java——后端vue动态路由配置类javabean封装的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发k8官方网网站内容还不错,欢迎将凯发k8官方网推荐给好友。