yangys
2024-03-27 e48aa2ac8dea1be5db11c63edf0b912c4ad5ce65
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package com.qianwen.smartman.modules.visual.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import java.lang.invoke.SerializedLambda;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.qianwen.smartman.common.utils.ExtraLambdaQueryWrapper;
import com.qianwen.smartman.common.utils.Lambda;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.mp.base.BaseServiceImpl;
import com.qianwen.core.tool.node.ForestNodeMerger;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.visual.convert.VisualCompConvert;
import com.qianwen.smartman.modules.visual.convert.VisualCompTypeConvert;
import com.qianwen.smartman.modules.visual.entity.VisualComp;
import com.qianwen.smartman.modules.visual.entity.VisualCompType;
import com.qianwen.smartman.modules.visual.entity.VisualCompTypeEnum;
import com.qianwen.smartman.modules.visual.mapper.VisualCompTypeMapper;
import com.qianwen.smartman.modules.visual.service.IVisualCompService;
import com.qianwen.smartman.modules.visual.service.IVisualCompTypeService;
import com.qianwen.smartman.modules.visual.vo.VisualCompMenuDetailVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
@Service
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/visual/service/impl/VisualCompTypeServiceImpl.class */
public class VisualCompTypeServiceImpl extends BaseServiceImpl<VisualCompTypeMapper, VisualCompType> implements IVisualCompTypeService {
    private final IVisualCompService compService;
 
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -1041904421:
                if (implMethodName.equals("getParentId")) {
                    z = true;
                    break;
                }
                break;
            case -982778162:
                if (implMethodName.equals("getOrderNum")) {
                    z = false;
                    break;
                }
                break;
            case -75106384:
                if (implMethodName.equals("getType")) {
                    z = true;
                    break;
                }
                break;
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = true;
                    break;
                }
                break;
            case 803533544:
                if (implMethodName.equals("getStatus")) {
                    z = true;
                    break;
                }
                break;
        }
        switch (z) {
            case false:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualCompType") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getOrderNum();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualCompType") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getType();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualCompType") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getType();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualCompType") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getParentId();
                    };
                }
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/visual/entity/VisualCompType") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getParentId();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
 
    public VisualCompTypeServiceImpl(final IVisualCompService compService) {
        this.compService = compService;
    }
 
    @Override // org.springblade.modules.visual.service.IVisualCompTypeService
    @Transactional
    public boolean remove(List<Long> ids) {
        removeByIds(ids);
        List<VisualCompType> child = list(Lambda.in((v0) -> {
            return v0.getParentId();
        }, ids).select((v0) -> {
            return v0.getId();
        }));
        List<Long> childIds = (List) child.stream().map((v0) -> {
            return v0.getId();
        }).collect(Collectors.toList());
        removeByIds(childIds);
        return true;
    }
 
    @Override // org.springblade.modules.visual.service.IVisualCompTypeService
    public List<VisualCompMenuDetailVO> treeMenu(Map<String, Object> params) {
        List<Long> componentIds = (List) params.get("componentIds");
        List<VisualCompType> list = list((Wrapper) ((ExtraLambdaQueryWrapper) Lambda.create().eq((v0) -> {
            return v0.getStatus();
        }, Integer.valueOf(VisualCompTypeEnum.ENABLE.getValue()))).orderByAsc((v0) -> {
            return v0.getOrderNum();
        }));
        List<VisualCompMenuDetailVO> menuDetailVOS = VisualCompTypeConvert.INSTANCE.convertMenu(list);
        List<VisualComp> visualCompList = this.compService.list(Lambda.in((componentIds == null || componentIds.size() == 0) ? false : true, (v0) -> {
            return v0.getId();
        }, componentIds));
        list.stream().filter(item -> {
            return !Func.equals(item.getParentId(), 0L);
        }).forEach(item2 -> {
            List<VisualComp> compList = (List) visualCompList.stream().filter(comp -> {
                return comp.getType().equals(item2.getType());
            }).sorted(Comparator.comparing((v0) -> {
                return v0.getOrderNum();
            })).collect(Collectors.toList());
            List<VisualCompMenuDetailVO> visualCompMenuDetailVOS = (List) compList.stream().map(comp2 -> {
                return VisualCompConvert.INSTANCE.convertMenu(comp2, item2.getId());
            }).collect(Collectors.toList());
            menuDetailVOS.addAll(visualCompMenuDetailVOS);
        });
        return ForestNodeMerger.merge(menuDetailVOS);
    }
 
    @Transactional
    public boolean save(VisualCompType entity) {
        if (entity.getParentId() == null) {
            entity.setParentId(0L);
        }
        VisualCompType exist = (VisualCompType) getOne(Lambda.eq((v0) -> {
            return v0.getType();
        }, entity.getType()));
        if (exist != null) {
            throw new ServiceException("已经存在相同类型:" + exist.getName());
        }
        return super.save(entity);
    }
 
    @Transactional
    public boolean updateById(VisualCompType entity) {
        VisualCompType exist = (VisualCompType) getOne(Lambda.eq((v0) -> {
            return v0.getType();
        }, entity.getType()));
        if (exist != null && !exist.getId().equals(entity.getId())) {
            throw new ServiceException("已经存在相同的类型:" + exist.getName());
        }
        if (entity.getParentId().longValue() == 0) {
            ((LambdaUpdateChainWrapper) ((LambdaUpdateChainWrapper) lambdaUpdate().set((v0) -> {
                return v0.getStatus();
            }, entity.getStatus())).eq((v0) -> {
                return v0.getParentId();
            }, entity.getId())).update();
        }
        return super.updateById(entity);
    }
}