diff --git a/framework/src/main/java/cn/lili/common/utils/StringUtils.java b/framework/src/main/java/cn/lili/common/utils/StringUtils.java index d7307f78..bad8dbe6 100644 --- a/framework/src/main/java/cn/lili/common/utils/StringUtils.java +++ b/framework/src/main/java/cn/lili/common/utils/StringUtils.java @@ -1,6 +1,5 @@ package cn.lili.common.utils; -import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; import java.beans.BeanInfo; @@ -10,7 +9,6 @@ import java.lang.reflect.Method; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Random; import java.util.regex.Matcher; @@ -49,99 +47,6 @@ public class StringUtils extends StrUtil { return result.toString(); } - /** - * 将object转为数字 - * - * @param obj 需要转object的对象 - * @param checked 如果为true格式不正确抛出异常 - * @return - */ - public static int toInt(Object obj, boolean checked) { - int value = 0; - if (obj == null) { - return 0; - } - try { - value = Convert.toInt(obj.toString()); - } catch (Exception ex) { - if (checked) { - throw new RuntimeException("整型数字格式不正确"); - } else { - return 0; - } - } - return value; - } - - /** - * 将一个字串转为long,如果无空,则返回默认值 - * - * @param str 要转换的数字字串 - * @param defaultValue 默认值 - * @return - */ - public static Long toLong(String str, Long defaultValue) { - Long value = defaultValue; - if (str == null || "".equals(str)) { - return defaultValue; - } - try { - value = Long.parseLong(str); - } catch (Exception ex) { - return defaultValue; - } - return value; - } - - /** - * 将一个object转为double 如果object 为 null 则返回0; - * - * @param obj 需要转成Double的对象 - * @param checked 如果为true格式不正确抛出异常 - * @return - */ - public static Double toDouble(Object obj, boolean checked) { - Double value = 0d; - if (obj == null) { - if (checked) { - throw new RuntimeException("数字格式不正确"); - } else { - return 0D; - } - } - try { - value = Double.valueOf(obj.toString()); - } catch (Exception ex) { - if (checked) { - throw new RuntimeException("数字格式不正确"); - } else { - return 0D; - } - } - return value; - } - - /** - * 将一个字串转为Double,如果无空,则返回默认值 - * - * @param str 要转换的数字字串 - * @param defaultValue 默认值 - * @return - */ - public static Double toDouble(String str, Double defaultValue) { - Double value = defaultValue; - if (str == null || "".equals(str)) { - return 0d; - } - try { - value = Double.valueOf(str); - } catch (Exception ex) { - ex.printStackTrace(); - value = defaultValue; - } - return value; - } - /** * 获取随机数 * @@ -158,18 +63,6 @@ public class StringUtils extends StrUtil { return sRand; } - - /** - * 判断一个数组是否为空,并且长度大于0 - * - * @param list - * @return true 不空/false 空 - */ - public static boolean isNotEmpty(List list) { - - return list != null && list.size() > 0; - } - /** * 切个字符串,如果超出长度则切割 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java index 5d7b054b..fb39ca83 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java @@ -1,11 +1,14 @@ package cn.lili.modules.goods.serviceimpl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONUtil; import cn.lili.common.utils.PageUtil; -import cn.lili.common.utils.StringUtils; -import cn.lili.modules.goods.entity.dos.*; +import cn.lili.modules.goods.entity.dos.Category; +import cn.lili.modules.goods.entity.dos.DraftGoods; +import cn.lili.modules.goods.entity.dos.GoodsGallery; +import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dto.DraftGoodsDTO; import cn.lili.modules.goods.entity.dto.DraftGoodsSearchParams; import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; @@ -135,16 +138,16 @@ public class DraftGoodsServiceImpl extends ServiceImpl i } //设置规格商品缩略图 //如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前 - if (spec.getValue() != null && StringUtils.isNotEmpty(spec.getValue().toString())) { + if (spec.getValue() != null && StrUtil.isNotEmpty(spec.getValue().toString())) { thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail(); small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall(); } diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java index ee9a1172..8c59d279 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/dto/OrderSearchParams.java @@ -1,5 +1,6 @@ package cn.lili.modules.order.order.entity.dto; +import cn.hutool.core.util.StrUtil; import cn.lili.common.security.context.UserContext; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.utils.DateUtil; @@ -97,60 +98,56 @@ public class OrderSearchParams extends PageVO { QueryWrapper wrapper = new QueryWrapper<>(); //关键字查询 - if (StringUtils.isNotEmpty(keywords)) { + if (StrUtil.isNotEmpty(keywords)) { wrapper.like("o.sn", keywords); wrapper.like("oi.goods_name", keywords); } //按卖家查询 - wrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), "o.store_id", UserContext.getCurrentUser().getStoreId()); + wrapper.eq(StrUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.STORE.name()), "o.store_id", UserContext.getCurrentUser().getStoreId()); //店铺查询 - wrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MANAGER.name()) + wrapper.eq(StrUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MANAGER.name()) && StringUtils.isNotEmpty(storeId), "o.store_id", storeId); //按买家查询 - wrapper.eq(StringUtils.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name()), "o.member_id", UserContext.getCurrentUser().getId()); + wrapper.eq(StrUtil.equals(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name()), "o.member_id", UserContext.getCurrentUser().getId()); //按照买家查询 - wrapper.like(StringUtils.isNotEmpty(memberId), "o.member_id", memberId); + wrapper.like(StrUtil.isNotEmpty(memberId), "o.member_id", memberId); //按订单编号查询 - wrapper.like(StringUtils.isNotEmpty(orderSn), "o.sn", orderSn); + wrapper.like(StrUtil.isNotEmpty(orderSn), "o.sn", orderSn); //按时间查询 wrapper.ge(startDate != null, "o.create_time", startDate); wrapper.le(endDate != null, "o.create_time", DateUtil.endOfDate(endDate)); //按购买人用户名 - wrapper.like(StringUtils.isNotEmpty(buyerName), "o.member_name", buyerName); + wrapper.like(StrUtil.isNotEmpty(buyerName), "o.member_name", buyerName); //按订单类型 - if (StringUtils.isNotEmpty(orderType)) { - wrapper.and(queryWrapper -> queryWrapper.eq("o.order_type", orderType).or() - .eq("o.order_promotion_type", orderType)); - } - + wrapper.eq(StrUtil.isNotEmpty(orderType), "o.order_type", orderType); //物流查询 - wrapper.like(StringUtils.isNotEmpty(shipName), "o.consignee_name", shipName); + wrapper.like(StrUtil.isNotEmpty(shipName), "o.consignee_name", shipName); //按商品名称查询 - wrapper.like(StringUtils.isNotEmpty(goodsName), "oi.goods_name", goodsName); + wrapper.like(StrUtil.isNotEmpty(goodsName), "oi.goods_name", goodsName); //付款方式 - wrapper.like(StringUtils.isNotEmpty(paymentType), "o.payment_type", paymentType); + wrapper.like(StrUtil.isNotEmpty(paymentType), "o.payment_type", paymentType); //按支付方式 - wrapper.eq(StringUtils.isNotEmpty(paymentMethod), "o.payment_method", paymentMethod); + wrapper.eq(StrUtil.isNotEmpty(paymentMethod), "o.payment_method", paymentMethod); //订单状态 - wrapper.eq(StringUtils.isNotEmpty(orderStatus), "o.order_status", orderStatus); + wrapper.eq(StrUtil.isNotEmpty(orderStatus), "o.order_status", orderStatus); //付款状态 - wrapper.eq(StringUtils.isNotEmpty(payStatus), "o.pay_status", payStatus); + wrapper.eq(StrUtil.isNotEmpty(payStatus), "o.pay_status", payStatus); //订单来源 - wrapper.like(StringUtils.isNotEmpty(clientType), "o.client_type", clientType); + wrapper.like(StrUtil.isNotEmpty(clientType), "o.client_type", clientType); //按标签查询 diff --git a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java index e4f13ce0..f0e43af9 100644 --- a/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/page/serviceimpl/ArticleCategoryServiceImpl.java @@ -4,7 +4,6 @@ import cn.lili.common.cache.Cache; import cn.lili.common.cache.CachePrefix; import cn.lili.common.enums.ResultCode; import cn.lili.common.exception.ServiceException; -import cn.lili.common.utils.StringUtils; import cn.lili.modules.page.entity.dos.Article; import cn.lili.modules.page.entity.dos.ArticleCategory; import cn.lili.modules.page.entity.enums.ArticleCategoryEnum; @@ -54,12 +53,6 @@ public class ArticleCategoryServiceImpl extends ServiceImpl list = this.list( - new LambdaQueryWrapper().eq(ArticleCategory::getArticleCategoryName, articleCategory.getArticleCategoryName())); - if (StringUtils.isNotEmpty(list)) { - throw new ServiceException(ResultCode.ARTICLE_CATEGORY_NAME_EXIST); - } //非顶级分类 if (articleCategory.getParentId() != null && !parentId.equals(articleCategory.getParentId())) { ArticleCategory parent = this.getById(articleCategory.getParentId()); diff --git a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java index 5deb5d46..452377fc 100644 --- a/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/permission/serviceimpl/AdminUserServiceImpl.java @@ -56,7 +56,7 @@ public class AdminUserServiceImpl extends ServiceImpl adminUserPage(Page initPage, QueryWrapper initWrapper) { @@ -120,7 +120,7 @@ public class AdminUserServiceImpl extends ServiceImpl roles) { - if (!StringUtils.isNotEmpty(roles)) { + if (roles.isEmpty() || roles == null) { return; } List userRoles = new ArrayList<>(roles.size()); diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java index 72239a17..196d86e7 100644 --- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java @@ -1,5 +1,6 @@ package cn.lili.modules.search.serviceimpl; +import cn.hutool.core.convert.Convert; import cn.hutool.core.text.CharSequenceUtil; import cn.lili.common.cache.Cache; import cn.lili.common.utils.StringUtils; @@ -392,11 +393,11 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService { if(prices.length==0){ return; } - double min = StringUtils.toDouble(prices[0], 0.0); + double min = Convert.toDouble(prices[0], 0.0); double max = Integer.MAX_VALUE; if (prices.length == 2) { - max = StringUtils.toDouble(prices[1], Double.MAX_VALUE); + max = Convert.toDouble(prices[1], Double.MAX_VALUE); } filterBuilder.must(QueryBuilders.rangeQuery("price").from(min).to(max).includeLower(true).includeUpper(true)); }