/
LabelManagerMapper.java
210 lines (154 loc) · 7.95 KB
/
LabelManagerMapper.java
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
208
209
210
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.linkis.manager.dao;
import org.apache.linkis.common.ServiceInstance;
import org.apache.linkis.manager.common.entity.label.LabelKeyValue;
import org.apache.linkis.manager.common.entity.persistence.PersistenceLabel;
import org.apache.linkis.manager.common.entity.persistence.PersistenceLabelRel;
import org.apache.linkis.manager.common.entity.persistence.PersistenceNode;
import org.apache.linkis.manager.common.entity.persistence.PersistenceResource;
import org.apache.ibatis.annotations.*;
import org.apache.linkis.manager.label.entity.Label;
import java.util.List;
import java.util.Map;
@Mapper
public interface LabelManagerMapper {
void registerLabel(@Param("persistenceLabel") PersistenceLabel persistenceLabel);
void registerLabelKeyValues(@Param("labelValueKeyAndContent") Map<String, String> labelValueKeyAndContent, @Param("labelId") int labelId);
PersistenceLabel getLabel(@Param("id") int id);
void deleteLabel(@Param("id") int id);
void deleteByLabel(@Param("labelKey") String labelKey, @Param("labelStringValue") String labelStringValue);
void deleteLabelKeyVaules(@Param("id") int id);
void updateLabel(@Param("id") int id, @Param("persistenceLabel") PersistenceLabel persistenceLabel);
void addLabelServiceInstance(@Param("instance") String instance, @Param("labelIds") List<Integer> labelIds);
List<PersistenceLabel> getLabelByServiceInstance(@Param("instance") String instance);
List<PersistenceLabel> getLabelByResource(@Param("persistenceResource") PersistenceResource persistenceResource);
void addLabelsAndResource(@Param("resourceId") int resourceId, @Param("labelIds") List<Integer> labelIds);
List<PersistenceResource> getResourcesByLabel(@Param("labelKey") String labelKey, @Param("stringValue") String stringValue);
List<Integer> getLabelIdsByInstance(@Param("instance") String instance);
List<PersistenceLabel> getLabelsByInstance(@Param("instance") String instance);
List<PersistenceNode> getInstanceByLabelId(@Param("labelId") int labelId);
List<PersistenceResource> getResourcesByLabels(@Param("labels") List<? extends Label> labels);
List<String> getInstanceIdsByLabelIds(@Param("labelIds") List<Integer> labelIds);
List<PersistenceLabel> getLabelsByLabelIds(@Param("labelIds") List<Integer> labelIds);
void addLabelsByUser(@Param("userName") String userName, @Param("labelIds") List<Integer> labelIds);
List<String> getUserNameByLabelId(@Param("labelId") int labelId);
List<String> getUserNamesByLabelIds(@Param("labelIds") List<Integer> labelIds);
List<PersistenceLabel> getLabelsByUser(@Param("userName") String userName);
List<PersistenceLabel> getLabelsByLabelKey(@Param("labelKey") String labelKey);
void deleteLabelResourceByByTicketId(@Param("ticketId") String ticketId);
void deleteLabelIdsAndInstance(@Param("instance") String instance, @Param("labelIds") List<Integer> labelIds);
void deleteLabelIdsByUser(@Param("userName") String userName, @Param("labelIds") List<Integer> labelIds);
void deleteUserById(int labelId);
/**
* 通过lavel value 同时返回instance信息和label信息
*
* @param labelKeyAndValuesMap
* @return
*/
List<Map<String, Object>> dimListNodeRelationsByKeyValueMap(@Param("keyValueMap") Map<String, Map<String, String>> labelKeyAndValuesMap, @Param("valueRelation") String name);
List<Map<String, Object>> getNodeRelationsByLabels(@Param("labels") List<PersistenceLabel> labels);
/**
* 通过instance信息,同时返回instance信息和label信息
*
* @param serviceInstances
* @return
*/
List<Map<String, Object>> listLabelRelationByServiceInstance(@Param("nodes") List<ServiceInstance> serviceInstances);
/**
* 通过labelkey 和StringValue找到唯一的label
*
* @param labelKey
* @param stringValue
* @return
*/
PersistenceLabel getLabelByKeyValue(@Param("labelKey") String labelKey, @Param("stringValue") String stringValue);
List<ServiceInstance> getNodeByLabelKeyValue(@Param("labelKey") String labelKey, @Param("stringValue") String stringValue);
/**
* @param values,可能是多个label的散列 all 和 and 类型的 查询
* @return
*/
List<PersistenceLabel> listResourceLabelByValues(@Param("values") List<LabelKeyValue> values);
/**
* 通过labelId获取到resource
*
* @param labelId
* @return
*/
List<PersistenceResource> listResourceByLaBelId(Integer labelId);
/**
* 通过labelId删除资源,还有资源和label的关联,并不会删除label表记录
*
* @param labelId
*/
void deleteResourceByLabelId(Integer labelId);
void deleteResourceByLabelIdInDirect(Integer labelId);
/**
* 同 {@link LabelManagerMapper#deleteResourceByLabelId(Integer)}
* 和下面的batchdelete有点重复,主要是sql给的是= batch 的话给的是in
*
* @param singletonMap
*/
Integer selectLabelIdByLabelKeyValuesMaps(@Param("labelKeyValues") Map<String, Map<String, String>> singletonMap);
void deleteResourceByLabelKeyValuesMaps(Integer id);
void deleteResourceByLabelKeyValuesMapsInDirect(Integer id);
/**
* 批量删除 不删除label
*
* @param notBlankIds
*/
void batchDeleteResourceByLabelId(@Param("labelIds") List<Integer> notBlankIds);
void batchDeleteResourceByLabelIdInDirect(@Param("labelIds") List<Integer> notBlankIds);
/**
* 批量删除 不删除label
*
* @param keyValueMaps
*/
void batchDeleteResourceByLabelKeyValuesMaps(@Param("labelKeyValues") Map<String, Map<String, String>> keyValueMaps);
/**
* ALL,AND搜索,根据key,value找到label集合,不对instance和resource进行关联,效率稍比{@link LabelManagerMapper#dimListLabelByKeyValueMap(Map, String)}
*
* @param keyValueMap
* @return
*/
@Deprecated
List<PersistenceLabel> listLabelByKeyValueMap(@Param("keyValueMap") Map<String, Map<String, String>> keyValueMap);
/**
* 模糊搜索,根据value,valueRelation 找到label集合,不对instance和resource进行关联
*
* @param valueList
* @return
*/
List<PersistenceLabel> dimListLabelByValueList(@Param("valueList") List<Map<String, String>> valueList, @Param("valueRelation") String valueRelation);
/**
* 模糊搜索,根据key,value,valueRelation 找到label集合,不对instance和resource进行关联
*
* @param keyValueMap
* @param name
* @return
*/
List<PersistenceLabel> dimListLabelByKeyValueMap(@Param("keyValueMap") Map<String, Map<String, String>> keyValueMap, @Param("valueRelation") String name);
/**
* 和{@link LabelManagerMapper#dimListLabelByKeyValueMap(Map, String)} 区别只是多了关联和资源表
*
* @param labelKeyAndValuesMap
* @param name
* @return
*/
List<PersistenceLabel> dimlistResourceLabelByKeyValueMap(@Param("keyValueMap") Map<String, Map<String, String>> labelKeyAndValuesMap, @Param("valueRelation") String name);
List<PersistenceLabelRel> listLabelBySQLPattern(@Param("pattern") String pattern, @Param("labelKey") String labelKey);
}