zhitong.yu
2024-03-21 6beef2ce75f15a8b3d4394b83da62071c686eb3d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.hxzk.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hxzk.mapper.DaoHangDao;
import com.hxzk.pojo.*;
import com.hxzk.service.TbDaoHangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.List;
 
@Service
public class DaoHangServiceImpl extends ServiceImpl<DaoHangDao, TbDaohang> implements TbDaoHangService {
 
    @Autowired
    DaoHangDao daoHangDao;
 
    @Override
    public Init findDaoHangAll() {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        List<TbDaohang> daohangs = baseMapper.selectList(queryWrapper);
        queryWrapper.eq("level","1");
        queryWrapper.eq("ishow","1");
        List<TbDaohang> Yidaohang = baseMapper.selectList(queryWrapper);
        Init init = new Init();
        homeInfo homeInfo = new homeInfo();
        homeInfo.setTitle("管理后台");
        homeInfo.setHref("../HouTai/ShouYe.jsp");
        init.setHomeInfo(homeInfo);
        menuInfo menuInfo = new menuInfo();
        menuInfo.setTitle("常规管理");
        menuInfo.setIcon("fa fa-address-book");
        menuInfo.setHref("");
        menuInfo.setTarget("_self");
        init2 init2 = new init2();
        init2.setHref(daohangs.get(0).getSrc());
        init2.setTitle("<img src=../Icon/"+daohangs.get(0).getIcon()+" style=width:25px>&nbsp;"+daohangs.get(0).getName());
        init2.setTarget("_blank");
        List child = new ArrayList<>();
        child.add(init2);
 
        for (int i = 1; i <Yidaohang.size();i++){
            init3 init3 = new init3();
            //如果是一级菜单,则不添加跳转功能
                init3.setTitle("<img src=../Icon/" + Yidaohang.get(i).getIcon() + " style=width:25px>&nbsp;" + Yidaohang.get(i).getName());                //根据parent 查询子级菜单
                List<TbDaohang> ErDaohang = new ArrayList<>();
                QueryWrapper queryWrapper1 = new QueryWrapper<>();
                queryWrapper1.eq("parents",Yidaohang.get(i).getParent());
                queryWrapper1.eq("ishow","1");
                ErDaohang = baseMapper.selectList(queryWrapper1);
                List<init2> ziint = new ArrayList<>();
                for (int j = 0 ; j <ErDaohang.size();j++){
                    init2 ziji = new init2();
                    ziji.setTitle(ErDaohang.get(j).getName());
                    ziji.setTarget("_self");
                    ziji.setHref(ErDaohang.get(j).getSrc());
                    ziint.add(ziji);
                }
                init3.setChild(ziint);
                child.add(init3);
        }
        menuInfo.setChild(child);
        List<menuInfo> menuInfos = new ArrayList<>();
        menuInfos.add(menuInfo);
        init.setMenuInfo(menuInfos);
        return init;
    }
 
    @Override
    public PageInfo<TbDaohang> findAll(Integer page, Integer limit) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        PageHelper.startPage(page,limit);
        List<TbDaohang> cardList = baseMapper.selectList(queryWrapper);
        PageInfo<TbDaohang> info = new PageInfo<>(cardList);
        return info;
    }
 
    @Override
    public void UpDaoHang(TbDaohang daohang) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",daohang.getId());
        baseMapper.update(daohang,queryWrapper);
    }
 
    @Override
    public TbDaohang findOne(Integer id) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id",id);
        return baseMapper.selectOne(queryWrapper);
    }
 
    @Override
    public void UpDaoHangIshow(String parents) {
        daoHangDao.upDaoHangIshow(parents);
    }
}