当前位置:网站首页>[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
边栏推荐
- Floating menu operation
- 23 design models
- 机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)
- Install VM tools
- Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
- [open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
- YOLOV3学习笔记
- JMeter linked database
- The mechanical hard disk is connected to the computer through USB and cannot be displayed
- Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
猜你喜欢

【无标题】

Journal quotidien des questions (11)

Selenium - 改变窗口大小,不同机型呈现的宽高长度会不一样

Push box games C #

YOLOV1学习笔记

Time format record

Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface

SSH link remote server and local display of remote graphical interface

Scroll view specifies the starting position of the scrolling element

第8章、MapReduce 生产经验
随机推荐
【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案
卡特兰数(Catalan)的应用场景
[leetcode] day93 - intersection of two arrays II
“我为开源打榜狂”第一周榜单公布,160位开发者上榜
[untitled] 8 simplified address book
Redis cluster creation, capacity expansion and capacity reduction
How matlab modifies default settings
Mysql
100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners
YOLOV3学习笔记
【无标题】8 简易版通讯录
ruoyi接口权限校验
New knowledge! The virtual machine network card causes your DNS resolution to slow down
剖析虚幻渲染体系(16)- 图形驱动的秘密
利用C#实现Pdf转图片
Difference between shortest path and minimum spanning tree
Example of joint use of ros+pytoch (semantic segmentation)
error C2017: 非法的转义序列
Use abp Zero builds a third-party login module (I): Principles
Yolov2 learning and summary