VoTest

package com.example.user.vo;

import java.util.List;

/**
 * @Description
 * @Author TY
 * @Date 2021/7/4 14:31
 */
public class EventAnalysisVo {


    private List<FirstPageVo> firstPageVoList;

    public List<FirstPageVo> getFirstPageVoList(){
        return firstPageVoList;
    }

    public void setFirstPageVoToList(FirstPageVo firstPageVo) {
        this.firstPageVoList.add(firstPageVo);
    }

//    public static class FirstPageVo{
//
//        private String pageSn;
//        private String pageName;
//
//        public FirstPageVo(String pageSn,String pageName){
//            this.pageSn = pageSn;
//            this.pageName = pageName;
//        }
//
//
//        List<SecondPageVo> secondPageVoList = new ArrayList<>();
//        //json格式化不显示该字段
//        Map<String,SecondPageVo> areaSet = new ConcurrentHashMap<>();
//
//
//        public String getPageSn() {
//            return pageSn;
//        }
//
//        public void setPageSn(String pageSn) {
//            this.pageSn = pageSn;
//        }
//
//        public String getPageName() {
//            return pageName;
//        }
//
//        public void setPageName(String pageName) {
//            this.pageName = pageName;
//        }
//
//        public List<SecondPageVo> getSecondPageVoList() {
//            return secondPageVoList;
//        }
//
//        public void setSecondPageVoList(List<SecondPageVo> secondPageVoList) {
//            this.secondPageVoList = secondPageVoList;
//        }
//
//        public Map<String, SecondPageVo> getAreaSet() {
//            return areaSet;
//        }
//
//        public void setAreaSet(Map<String, SecondPageVo> areaSet) {
//            this.areaSet = areaSet;
//        }
//
//        public void setAreaToAreaSet(SecondPageVo secondPageVo){
//            SecondPageVo put = this.areaSet.put(secondPageVo.getAreaSn(), secondPageVo);
//            if(put == null){
//                secondPageVoList.add(secondPageVo);
//            }
//        }
//    }
//
//
//
//
//
//    public static class SecondPageVo{
//
//        private String areaSn;
//        private String areaName;
//
//        public SecondPageVo(String areaSn,String areaName){
//            this.areaSn = areaSn;
//            this.areaName = areaName;
//        }
//
//
//        List<ThirdPageVo> thirdPageVoList = new ArrayList<>();
//        //json格式化不显示该字段
//        Map<String,ThirdPageVo> buttonSet = new ConcurrentHashMap<>();
//
        public Map<String,ThirdPageVo> buttonSet =
//
//
//        public String getAreaSn() {
//            return areaSn;
//        }
//
//        public void setAreaSn(String areaSn) {
//            this.areaSn = areaSn;
//        }
//
//        public String getAreaName() {
//            return areaName;
//        }
//
//        public void setAreaName(String areaName) {
//            this.areaName = areaName;
//        }
//
//        public List<ThirdPageVo> getThirdPageVoList() {
//            return thirdPageVoList;
//        }
//
//        public void setThirdPageVoList(List<ThirdPageVo> thirdPageVoList) {
//            this.thirdPageVoList = thirdPageVoList;
//        }
//
//        public Map<String, ThirdPageVo> getButtonSet() {
//            return buttonSet;
//        }
//
//        public void setButtonSet(Map<String, ThirdPageVo> buttonSet) {
//            this.buttonSet = buttonSet;
//        }
//
//       public void setbuttonToButtonSet(ThirdPageVo thirdPageVo){
//           ThirdPageVo put = this.buttonSet.put(thirdPageVo.getButtonSn(), thirdPageVo);
//           if(put  == null){
//               this.thirdPageVoList.add(thirdPageVo);
//           }
//       }
//
//    }
//
//
//
//
//
//    public static class ThirdPageVo{
//
//        private String buttonSn;
//        private String buttonName;
//
//        public ThirdPageVo(String buttonSn,String buttonName){
//            this.buttonSn = buttonSn;
//            this.buttonName = buttonName;
//        }
//
//        public String getButtonSn() {
//            return buttonSn;
//        }
//
//        public void setButtonSn(String buttonSn) {
//            this.buttonSn = buttonSn;
//        }
//
//        public String getButtonName() {
//            return buttonName;
//        }
//
//        public void setButtonName(String buttonName) {
//            this.buttonName = buttonName;
//        }
//    }


}

package com.example.user.vo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description
 * @Author TY
 * @Date 2021/7/4 22:00
 */
public class FirstPageVo {


    private String pageSn;
    private String pageName;

    public FirstPageVo(String pageSn,String pageName){
        this.pageSn = pageSn;
        this.pageName = pageName;
    }


    List<SecondPageVo> secondPageVoList = new ArrayList<>();
    //json格式化不显示该字段
    Map<String, SecondPageVo> areaSet = new ConcurrentHashMap<>();


    public String getPageSn() {
        return pageSn;
    }

    public void setPageSn(String pageSn) {
        this.pageSn = pageSn;
    }

    public String getPageName() {
        return pageName;
    }

    public void setPageName(String pageName) {
        this.pageName = pageName;
    }

    public List<SecondPageVo> getSecondPageVoList() {
        return secondPageVoList;
    }

    public void setSecondPageVoList(List<SecondPageVo> secondPageVoList) {
        this.secondPageVoList = secondPageVoList;
    }

    public Map<String, SecondPageVo> getAreaSet() {
        return areaSet;
    }

    public void setAreaSet(Map<String, SecondPageVo> areaSet) {
        this.areaSet = areaSet;
    }

    public void setAreaToAreaSet(SecondPageVo secondPageVo){
        SecondPageVo put = this.areaSet.put(secondPageVo.getAreaSn(), secondPageVo);
        if(put == null){
            secondPageVoList.add(secondPageVo);
        }
    }
}

package com.example.user.vo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description
 * @Author TY
 * @Date 2021/7/4 22:00
 */
public class SecondPageVo {


    private String areaSn;
    private String areaName;

    public SecondPageVo(String areaSn,String areaName){
        this.areaSn = areaSn;
        this.areaName = areaName;
    }


    List<ThirdPageVo> thirdPageVoList = new ArrayList<>();
    //json格式化不显示该字段
    Map<String, ThirdPageVo> buttonSet = new ConcurrentHashMap<>();

//        public Map<String,ThirdPageVo> buttonSet =


    public String getAreaSn() {
        return areaSn;
    }

    public void setAreaSn(String areaSn) {
        this.areaSn = areaSn;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public List<ThirdPageVo> getThirdPageVoList() {
        return thirdPageVoList;
    }

    public void setThirdPageVoList(List<ThirdPageVo> thirdPageVoList) {
        this.thirdPageVoList = thirdPageVoList;
    }

    public Map<String, ThirdPageVo> getButtonSet() {
        return buttonSet;
    }

    public void setButtonSet(Map<String, ThirdPageVo> buttonSet) {
        this.buttonSet = buttonSet;
    }

    public void setbuttonToButtonSet(ThirdPageVo thirdPageVo){
        ThirdPageVo put = this.buttonSet.put(thirdPageVo.getButtonSn(), thirdPageVo);
        if(put  == null){
            this.thirdPageVoList.add(thirdPageVo);
        }
    }
}

package com.example.user.vo;

/**
 * @Description
 * @Author TY
 * @Date 2021/7/4 22:01
 */
public class ThirdPageVo {

    private String buttonSn;
    private String buttonName;

    public ThirdPageVo(String buttonSn,String buttonName){
        this.buttonSn = buttonSn;
        this.buttonName = buttonName;
    }

    public String getButtonSn() {
        return buttonSn;
    }

    public void setButtonSn(String buttonSn) {
        this.buttonSn = buttonSn;
    }

    public String getButtonName() {
        return buttonName;
    }

    public void setButtonName(String buttonName) {
        this.buttonName = buttonName;
    }
}

package com.example.user.service.impl;

import com.example.user.bean.EventAnalysis;
import com.example.user.dao.EventAnalysisMapper;
import com.example.user.service.EventVoService;
import com.example.user.vo.EventAnalysisVo;
import com.example.user.vo.FirstPageVo;
import com.example.user.vo.SecondPageVo;
import com.example.user.vo.ThirdPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description
 * @Author TY
 * @Date 2021/7/4 15:02
 */
@Service
public class EventVoServiceImpl implements EventVoService {

    @Autowired
    EventAnalysisMapper eventAnalysisMapper;

    @Override
    public EventAnalysisVo getEventAnalysisVo() {
        List<EventAnalysis> eventAnalyses = eventAnalysisMapper.selectAllInfo();
        Map<String,FirstPageVo> firstPageSet = new ConcurrentHashMap<>();
        eventAnalyses.forEach(bean ->{
            String pageSn = bean.getPageSn();
            String areaSn = bean.getAreaSn();
            String buttonSn = bean.getButtonSn();


            FirstPageVo firstPageVo = new FirstPageVo(pageSn, bean.getPageName());
            SecondPageVo secondPageVo = new SecondPageVo(areaSn, bean.getAreaName());
            ThirdPageVo thirdPageVo = new ThirdPageVo(buttonSn, bean.getButtonName());

            FirstPageVo firstPageVoFromMap = firstPageSet.get(pageSn);

            //若一级菜单为空,则直接将二级菜单和三级菜单添加进去
            if(firstPageVoFromMap == null){
                secondPageVo.setbuttonToButtonSet(thirdPageVo);
                firstPageVo.setAreaToAreaSet(secondPageVo);

                firstPageVo.getAreaSet().put(areaSn,secondPageVo);

                firstPageSet.put(pageSn,firstPageVo);

            }
            //若二级菜单为空,则直接将三级菜单添加进去
            Map<String, SecondPageVo> areaSet = firstPageVoFromMap.getAreaSet();
            SecondPageVo secondPageVoFromMap = areaSet.get(areaSn);
            if(secondPageVoFromMap == null){
                secondPageVo.setbuttonToButtonSet(thirdPageVo);
                firstPageVoFromMap.setAreaToAreaSet(secondPageVo);
            }

            //r若三级菜单为空,则只添加三级标签
            Map<String, ThirdPageVo> buttonSet = secondPageVoFromMap.getButtonSet();
            ThirdPageVo thirdPageVoFromMap = buttonSet.get(buttonSn);
            if(thirdPageVoFromMap == null){
                secondPageVo.setbuttonToButtonSet(thirdPageVo);
            }

        });
            //若都有则不用添加
            //处理返回值
            EventAnalysisVo eventAnalysisVo = new EventAnalysisVo();
            firstPageSet.values().forEach(firstPageVo -> {
                eventAnalysisVo.setFirstPageVoToList(firstPageVo);
            });

            System.out.println("eventAnalysisVo==="+eventAnalysisVo);

            return eventAnalysisVo;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值