Administrator
1 days ago 490bceb5d9e911a5c4f687dd6570b6699ca11915
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package cc.mrbird.febs.ai.controller.memberRole;
 
import cc.mrbird.febs.ai.entity.*;
import cc.mrbird.febs.ai.res.AdminMoveChooseInfoVo;
import cc.mrbird.febs.ai.service.*;
import cc.mrbird.febs.common.entity.FebsConstant;
import cc.mrbird.febs.common.utils.FebsUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
 
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
 
/**
 * @author Administrator
 */
@Controller("AiMemberRoleView")
@RequestMapping(FebsConstant.VIEW_PREFIX + "modules/ai/memberRole")
@RequiredArgsConstructor
public class ViewController {
 
    private final AiMemberRoleService aiMemberRoleService;
    private final AiMemberRoleProductService aiMemberRoleProductService;
    private final AiMemberRolePointService aiMemberRolePointService;
    private final AiProductService aiProductService;
    private final AiProductPointService aiProductPointService;
 
    @GetMapping("list")
    @RequiresPermissions("memberRoleList:view")
    public String memberRoleList() {
 
        return FebsUtil.view("modules/ai/memberRole/list");
    }
 
    @GetMapping(value = "/add")
    @RequiresPermissions("memberRoleList:add")
    public String artAdd() {
 
        return FebsUtil.view("modules/ai/memberRole/add");
    }
 
    @GetMapping("info/{id}")
    @RequiresPermissions("memberRoleList:info")
    public String artInfo(@PathVariable String id, Model model) {
        AiMemberRole entity = aiMemberRoleService.getById(id);
        model.addAttribute("aiMemberRole", entity);
        return FebsUtil.view("modules/ai/memberRole/info");
    }
 
    @GetMapping("productSet/{id}")
    @RequiresPermissions("memberRoleList:productSet")
    public String productSet(@PathVariable String id, Model model) {
        List<AdminMoveChooseInfoVo> vos = new ArrayList<>();
        Set<String> productIds = new HashSet<>();
 
        AiMemberRole entity = aiMemberRoleService.getById(id);
        String companyId = entity.getCompanyId();
        if(ObjectUtil.isNotNull(entity)){
            //右侧数据
            LambdaQueryWrapper<AiMemberRoleProduct> query = Wrappers.lambdaQuery(AiMemberRoleProduct.class);
            if(StrUtil.isNotEmpty(id)){
                query.eq(AiMemberRoleProduct::getRoleId, id);
            }
            if(StrUtil.isNotEmpty(companyId)){
                query.eq(AiMemberRoleProduct::getCompanyId, companyId);
            }
            List<AiMemberRoleProduct> selectedList = aiMemberRoleProductService.selectListByQuery(query);
            if(CollUtil.isNotEmpty(selectedList)){
                //stream流操作happyMemberLabelRecords,获取memberId的set集合
                productIds = selectedList.stream().map(AiMemberRoleProduct::getProductId).collect(Collectors.toSet());
            }
 
            //左侧数据
            List<AiProduct> allList = aiProductService.selectList(companyId);
            if(CollUtil.isNotEmpty(allList)){
                //stream流操作mallMembers,生成一个新的List<MallMemberVo>
                vos = allList.stream().map(AiProduct -> {
                    AdminMoveChooseInfoVo vo = new AdminMoveChooseInfoVo();
                    vo.setId(AiProduct.getId());
                    vo.setName(AiProduct.getName());
                    return vo;
                }).collect(Collectors.toList());
            }
        }
 
        model.addAttribute("productAll", vos);
        model.addAttribute("productSelected", productIds);
        model.addAttribute("chooseId", id);
        return FebsUtil.view("modules/ai/memberRole/productSet");
    }
 
    @GetMapping("productPointSet/{id}")
    @RequiresPermissions("memberRoleList:productPointSet")
    public String productPointSet(@PathVariable String id, Model model) {
        List<AdminMoveChooseInfoVo> vos = new ArrayList<>();
        Set<String> productPointIds = new HashSet<>();
 
        AiMemberRole entity = aiMemberRoleService.getById(id);
        String companyId = entity.getCompanyId();
        if(ObjectUtil.isNotNull(entity)){
            //右侧数据
            LambdaQueryWrapper<AiMemberRolePoint> query = Wrappers.lambdaQuery(AiMemberRolePoint.class);
            if(StrUtil.isNotEmpty(id)){
                query.eq(AiMemberRolePoint::getRoleId, id);
            }
            if(StrUtil.isNotEmpty(companyId)){
                query.eq(AiMemberRolePoint::getCompanyId, companyId);
            }
            List<AiMemberRolePoint> selectedList = aiMemberRolePointService.selectListByQuery(query);
            if(CollUtil.isNotEmpty(selectedList)){
                //stream流操作happyMemberLabelRecords,获取memberId的set集合
                productPointIds = selectedList.stream().map(AiMemberRolePoint::getProductPointId).collect(Collectors.toSet());
            }
 
            //左侧数据
            List<AiProductPoint> allList = aiProductPointService.selectList(companyId);
            if(CollUtil.isNotEmpty(allList)){
                //stream流操作mallMembers,生成一个新的List<MallMemberVo>
                vos = allList.stream().map(AiProductPoint -> {
                    AdminMoveChooseInfoVo vo = new AdminMoveChooseInfoVo();
                    vo.setId(AiProductPoint.getId());
                    vo.setName(AiProductPoint.getTitle());
                    return vo;
                }).collect(Collectors.toList());
            }
        }
 
        model.addAttribute("productPointAll", vos);
        model.addAttribute("productPointSelected", productPointIds);
        model.addAttribute("choosePointId", id);
        return FebsUtil.view("modules/ai/memberRole/productPointSet");
    }
}