- 博客(12)
- 收藏
- 关注
原创 CRUD随笔---持续更新中
stream的CRUD随笔,持续更新中 /** *更新方法 */ //写法一 this.lambdaUpdate().eq(Merchant::getId,request.getMerchantId()) .set(Merchant::getBankName,request.getMerchantName()); //写法二 finalMerchantmerchant=BeanConvertUtils.copyProperties(request,Merchant.class); returnRespons
2021-01-29 15:27:28
310
原创 分类树构建,上级随意变动,维护path
原型图: 思路:当前分类的上级变动,需要更新的数据就是当前分类下的所有子集 // 上级分类变更后,重新构建当前和其自己分类路径 /** * 修复路径 */ private void fixPath(String id) { final List<Category> lowerCategories = this.baseMapper.lowerRecursive(id); for (Category lowerCategory
2022-03-04 18:16:50
264
原创 关于多线程学习
//创建多线程 //必须指定线程池 @Resource private Executor executor; AtomicReference<List<POJO>> atomicReference = new AtomicReference<>(Collections.emptyList()); //无锁对象 List<CompletableFuture<List<POJO>>> futures = new
2021-10-11 14:10:32
194
原创 Comparator比较器
//比较int类型 list.sort(Comparator.comparingInt(String::length) .thenComparing(String::toLowerCase, Comparator.reverseOrder())); System.out.println(list); list.sort(Comparator.comparingInt(String::length).reversed() .the
2021-07-09 09:45:35
427
原创 mysql模糊查询忽略大小写
//问题:mysql的字符集改成严格区分大小写后,模糊搜索的时候不能忽略大小写。 //解决方案:把数据库字段转为小写,like后的参数也都转为小写 SELECT * FROM goods WHERE LOWER(goods_name) LIKE Lower(CONCAT("%", "WhOo忽略大小写", "%")) ...
2021-06-28 17:24:19
1563
原创 集合对象拷贝工具类
import com.alibaba.fastjson.JSON; import java.util.List; import org.springframework.util.CollectionUtils; /** @deprecated */ @Deprecated public class ObjectConversion { public ObjectConversion() { } public static <T> List<T> copy(
2021-06-22 14:45:14
288
原创 请求传开始时间和结束时间,比较数据库的开始时间和结束时间是否有重叠时间段
//这个校验我改了好几版,网上找了几个轮子都不能用,就自己花时间写了一个。 /** * parm:ds=数据库开始时间;de=数据库结束时间;rs=请求传开始时间;re=请求传结束时间; * (ds < re && de > rs) || (de < rs && ds > re) * */ 如有问题,欢迎指正交流,觉得轮子好用的话记得点赞呦。代码已经上生产环境了。 ...
2021-06-21 18:04:00
295
原创 steram流用法随笔持续更新中
//流排序 public static void main(String[] args) { List<String> list = Arrays.asList("111", "222", "333", "333", "222", "666", null, ""); list.stream().filter(Objects::nonNull).sorted(Comparator.comparing(String::toString, Comparator.
2021-06-16 13:23:05
270
原创 java精确计算的方法demo
package com.common; import java.math.BigDecimal; import java.util.Optional; /** 浮点型精确计算 @author common */ public class BigDecimals { /** 提供精确的加法运算 */ public static double add(Double v1, Double v2) { return new BigDecimal(Double.toString(Optional.ofNu
2021-06-15 10:57:20
1304
6
原创 Optional使用
所有方法: /** *对象A不为空取A,否则B */ Optional.ofNullable(user).orElseGet(User::new); /** *对象A不为空取A.prop, 否则取给定值 */ Optional.ofNullable(user).map(User::getUsername).orElse("Default Name"); /** *对象A为空,抛出异常 */ Optional.ofNullable(user).orElseThrow(RuntimeException::
2021-02-01 11:24:08
148
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅