当前位置:网站首页>[Code] occasionally take values, judge blanks, look up tables, verify, etc
[Code] occasionally take values, judge blanks, look up tables, verify, etc
2022-07-03 06:40:00 【The gold digger said】
Think about it or record it , Continuous follow-up , Convenient for subsequent reference
obtain List<String>
// Get the table IDs duplicate removal
List<String> tIds = list.stream()
.map(TableColumn::getTableParentId)
.distinct()
.collect(Collectors.toList());
// Get the table IDs
List<String> tIds = tables.stream()
.map(Table::getId)
.collect(Collectors.toList());
// Use List<Map> Pay attention to case
List<String> ids = params.stream()
.map(e -> e.get("id"))
.collect(Collectors.toList());
// obtain Parameter.getCheckFormat
List<CheckFormat> checkFormat = Optional.ofNullable(parameter)
.map(u -> u.getCheckFormat())
.orElse(new ArrayList<>());
// Get maximum
FieldConfig maxFieldConfig = configs.stream()
.max(Comparator.comparing(FieldConfig::getOrderId))
.orElse(null);
Judgment parameters
// Judge : type
if (type == null || !Arrays.asList("40", "60", "80").contains(type)) {
String msg = " Select parameter type 40. library 60. surface 80. Field ";
return TableUtil.getInstance().errorReturn(code, msg, msg);
}
// Judge : Use List<Map>,if(list != null && list.size() > 0) ===》》 CollectionUtils.isNotEmpty(list);
if (CollectionUtils.isEmpty(ruleList)) {
String msg = " Rule not found ";
return apiErrorReturn(500, msg, msg);
}
Table query
// modify
LambdaUpdateWrapper<Dir> dirUpdate = Wrappers.lambdaUpdate();
dirUpdate.set(Dir::getName, source.getCnName());
dirUpdate.eq(Dir::getType, 13);
dirUpdate.eq(Dir::getCode, source.getCode());
directoryMapper.update(new SsDir(), dirUpdate);
// Inquire about
List<Integer> ids = params.stream().map(QuotaBO::getId).collect(Collectors.toList());
LambdaQueryWrapper<QuotaBO> queryQuota = Wrappers.lambdaQuery();
queryQuota.eq(QuotaBO::getIsDelete, 0);
queryQuota.in(QuotaBO::getId, ids);
List<QuotaBO> quotaList = quotaMapper.getList(queryQuota);
// Inquire about
QueryWrapper qw = new QueryWrapper<>();
qw.eq("COLUMN_NAME", columnName);
List<ColumnBO> list = colService.getListByPage(qw, pIndex, pSize);
// modify
UpdateWrapper<ColumnBO> uw = new UpdateWrapper<>();
uw.eq("ID", column.getId());
List<ColumnBO> list = colService.getListByPage(column, uw);
Data De duplication
// Use id To reprocess
bloodList = bloodList.stream()
.collect(Collectors.collectingAndThen(Collectors.toCollection(()
-> new TreeSet<>(Comparator.comparing(BloodBO::getId))), ArrayList::new));
Verify that... Exists
Don't add data repeatedly when there is data , When verifying whether the data already exists , Need to consider adding 、 modify ( When modifying, you need to ignore the existing conditions )
select count(1) as valid, concat(' Classification number 【' ,#{itemId}, '】 Already exists ') as message from pig_item
where IS_DELETE = 0
and ITEM_ID = #{itemId}
and (ID != #{idOld} or #{idOld} is null)
<select id="checkVerifyItemNum" resultType="java.lang.Integer">
<![CDATA[ select count(1) as valid from pig_item where IS_DELETE=0 and ITEM_ID = #{itemId} ]]>
<if test="id != null">
<![CDATA[ and (ID != #{id} or #{id} is null) ]]>
</if>
</select>
<![CDATA[ Content ]]>
The advantage of this writing method is not to escape if it is greater than or less than , It is inconvenient to write separately when judging the conditions
Multi-table query
Multiple table query ,left join down , The data is there , When there is more data , Query performance degradation .
with tmp_tab as (
select First query the data
),
tmp_desc as (
select Look up the data
) select * from tmp_desc
边栏推荐
猜你喜欢
Yolov3 learning notes
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
Create your own deep learning environment with CONDA
Ruoyi interface permission verification
利用C#实现Pdf转图片
每日刷題記錄 (十一)
【无标题】
“我为开源打榜狂”第一周榜单公布,160位开发者上榜
[set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)
Selenium ide installation recording and local project maintenance
随机推荐
MATLAB如何修改默认设置
Advanced technology management - do you know the whole picture of growth?
[C /vb.net] convert PDF to svg/image, svg/image to PDF
opencv
[5g NR] UE registration process
使用conda创建自己的深度学习环境
(翻译)异步编程:Async/Await在ASP.NET中的介绍
Use @data in Lombok to simplify entity class code
Shell conditional statement
[set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
Pdf files can only print out the first page
Condition annotation in uni-app realizes cross segment compatibility, navigation jump and parameter transfer, component creation and use, and life cycle function
2022 cisp-pte (III) command execution
Operation principle of lua on C: Foundation
pytorch练习小项目
100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners
The win7 computer can't start. Turn the CPU fan and stop it
Summary of the design and implementation of the weapon system similar to the paladin of vitality
[untitled] 8 simplified address book
Difference between shortest path and minimum spanning tree