当前位置:网站首页>[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
边栏推荐
- 【5G NR】UE注册流程
- 方差迭代公式推导
- 【C#/VB.NET】 将PDF转为SVG/Image, SVG/Image转PDF
- Read blog type data from mysql, Chinese garbled code - solved
- Use @data in Lombok to simplify entity class code
- 【code】偶尔取值、判空、查表、验证等
- Nacos service installation
- Naive Bayes in machine learning
- [5g NR] UE registration process
- 2022年华东师范大学计科考研复试机试题-详细题解
猜你喜欢
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
【无标题】
Personally design a highly concurrent seckill system
Yolov1 learning notes
Summary of UI module design and practical application of agent mode
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
DBNet:具有可微分二值化的实时场景文本检测
These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products
10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”
随机推荐
[set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
表达式的动态解析和计算,Flee用起来真香
Mysql database
Some thoughts on machine learning
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
【类和对象】深入浅出类和对象
远端rostopic的本地rviz调用及显示
论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
Openresty best practices
UTC时间、GMT时间、CST时间
Yolov2 learning and summary
学习笔记 -- k-d tree 和 ikd-Tree 原理及对比
SSH link remote server and local display of remote graphical interface
Create your own deep learning environment with CONDA
方差迭代公式推导
How does the insurance company check hypertension?
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
Selenium - 改变窗口大小,不同机型呈现的宽高长度会不一样
The difference between CONDA and pip
卡特兰数(Catalan)的应用场景