当前位置:网站首页>[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
边栏推荐
- 【无标题】
- 保险公司怎么查高血压?
- ssh链接远程服务器 及 远程图形化界面的本地显示
- Redis cluster creation, capacity expansion and capacity reduction
- The dynamic analysis and calculation of expressions are really delicious for flee
- 【C#/VB.NET】 将PDF转为SVG/Image, SVG/Image转PDF
- 【无标题】8 简易版通讯录
- 机械观和系统观的科学思维方式各有什么特点和作用
- In depth learning
- 远端rostopic的本地rviz调用及显示
猜你喜欢

Daily question brushing record (11)

Yolov2 learning and summary

10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”

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

表达式的动态解析和计算,Flee用起来真香

. Net program configuration file operation (INI, CFG, config)

Important knowledge points of redis

【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案

Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"

Summary of remote connection of MySQL
随机推荐
Creating postgre enterprise database by ArcGIS
Mysql5.7 group by error
【C#/VB.NET】 将PDF转为SVG/Image, SVG/Image转PDF
Cannot get value with @value, null
(翻译)异步编程:Async/Await在ASP.NET中的介绍
2022年华东师范大学计科考研复试机试题-详细题解
Understand software testing
Nacos service installation
Cesium entity (entities) entity deletion method
【无标题】5 自用历程
DBNet:具有可微分二值化的实时场景文本检测
The dynamic analysis and calculation of expressions are really delicious for flee
Luogu problem list: [mathematics 1] basic mathematics problems
New knowledge! The virtual machine network card causes your DNS resolution to slow down
使用conda创建自己的深度学习环境
有意思的鼠標指針交互探究
Page text acquisition
Judge whether the date time exceeds 31 days
Numerical method for solving optimal control problem (I) -- gradient method
Various usages of MySQL backup database to create table select and how many days are left