Преглед на файлове

代码优化,废弃API修改

macro преди 2 години
родител
ревизия
dd4bc8f115
променени са 16 файла, в които са добавени 55 реда и са изтрити 31 реда
  1. 2 0
      mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java
  2. 5 0
      mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java
  3. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/CmsSubjectServiceImpl.java
  4. 4 3
      mall-admin/src/main/java/com/macro/mall/service/impl/PmsBrandServiceImpl.java
  5. 5 4
      mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductServiceImpl.java
  6. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/PmsSkuStockServiceImpl.java
  7. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/SmsCouponHistoryServiceImpl.java
  8. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/SmsCouponServiceImpl.java
  9. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/SmsFlashPromotionServiceImpl.java
  10. 3 2
      mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeAdvertiseServiceImpl.java
  11. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeBrandServiceImpl.java
  12. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeNewProductServiceImpl.java
  13. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeRecommendProductServiceImpl.java
  14. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeRecommendSubjectServiceImpl.java
  15. 16 12
      mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java
  16. 2 1
      mall-admin/src/main/java/com/macro/mall/service/impl/UmsRoleServiceImpl.java

+ 2 - 0
mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java

@@ -3,6 +3,8 @@ package com.macro.mall.service;
 import com.macro.mall.dto.PmsProductCategoryParam;
 import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
 import com.macro.mall.model.PmsProductCategory;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;

+ 5 - 0
mall-admin/src/main/java/com/macro/mall/service/UmsAdminService.java

@@ -84,4 +84,9 @@ public interface UmsAdminService {
      * 获取用户信息
      */
     UserDetails loadUserByUsername(String username);
+
+    /**
+     * 获取缓存服务
+     */
+    UmsAdminCacheService getCacheService();
 }

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/CmsSubjectServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.mapper.CmsSubjectMapper;
 import com.macro.mall.model.CmsSubject;
@@ -30,7 +31,7 @@ public class CmsSubjectServiceImpl implements CmsSubjectService {
         PageHelper.startPage(pageNum, pageSize);
         CmsSubjectExample example = new CmsSubjectExample();
         CmsSubjectExample.Criteria criteria = example.createCriteria();
-        if (!StringUtils.isEmpty(keyword)) {
+        if (!StrUtil.isEmpty(keyword)) {
             criteria.andTitleLike("%" + keyword + "%");
         }
         return subjectMapper.selectByExample(example);

+ 4 - 3
mall-admin/src/main/java/com/macro/mall/service/impl/PmsBrandServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.dto.PmsBrandParam;
 import com.macro.mall.mapper.PmsBrandMapper;
@@ -37,7 +38,7 @@ public class PmsBrandServiceImpl implements PmsBrandService {
         PmsBrand pmsBrand = new PmsBrand();
         BeanUtils.copyProperties(pmsBrandParam, pmsBrand);
         //如果创建时首字母为空,取名称的第一个为首字母
-        if (StringUtils.isEmpty(pmsBrand.getFirstLetter())) {
+        if (StrUtil.isEmpty(pmsBrand.getFirstLetter())) {
             pmsBrand.setFirstLetter(pmsBrand.getName().substring(0, 1));
         }
         return brandMapper.insertSelective(pmsBrand);
@@ -49,7 +50,7 @@ public class PmsBrandServiceImpl implements PmsBrandService {
         BeanUtils.copyProperties(pmsBrandParam, pmsBrand);
         pmsBrand.setId(id);
         //如果创建时首字母为空,取名称的第一个为首字母
-        if (StringUtils.isEmpty(pmsBrand.getFirstLetter())) {
+        if (StrUtil.isEmpty(pmsBrand.getFirstLetter())) {
             pmsBrand.setFirstLetter(pmsBrand.getName().substring(0, 1));
         }
         //更新品牌时要更新商品中的品牌名称
@@ -79,7 +80,7 @@ public class PmsBrandServiceImpl implements PmsBrandService {
         PmsBrandExample pmsBrandExample = new PmsBrandExample();
         pmsBrandExample.setOrderByClause("sort desc");
         PmsBrandExample.Criteria criteria = pmsBrandExample.createCriteria();
-        if (!StringUtils.isEmpty(keyword)) {
+        if (!StrUtil.isEmpty(keyword)) {
             criteria.andNameLike("%" + keyword + "%");
         }
         return brandMapper.selectByExample(pmsBrandExample);

+ 5 - 4
mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductServiceImpl.java

@@ -1,6 +1,7 @@
 package com.macro.mall.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.dao.*;
 import com.macro.mall.dto.PmsProductParam;
@@ -98,7 +99,7 @@ public class PmsProductServiceImpl implements PmsProductService {
         if(CollectionUtils.isEmpty(skuStockList))return;
         for(int i=0;i<skuStockList.size();i++){
             PmsSkuStock skuStock = skuStockList.get(i);
-            if(StringUtils.isEmpty(skuStock.getSkuCode())){
+            if(StrUtil.isEmpty(skuStock.getSkuCode())){
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
                 StringBuilder sb = new StringBuilder();
                 //日期
@@ -215,10 +216,10 @@ public class PmsProductServiceImpl implements PmsProductService {
         if (productQueryParam.getVerifyStatus() != null) {
             criteria.andVerifyStatusEqualTo(productQueryParam.getVerifyStatus());
         }
-        if (!StringUtils.isEmpty(productQueryParam.getKeyword())) {
+        if (!StrUtil.isEmpty(productQueryParam.getKeyword())) {
             criteria.andNameLike("%" + productQueryParam.getKeyword() + "%");
         }
-        if (!StringUtils.isEmpty(productQueryParam.getProductSn())) {
+        if (!StrUtil.isEmpty(productQueryParam.getProductSn())) {
             criteria.andProductSnEqualTo(productQueryParam.getProductSn());
         }
         if (productQueryParam.getBrandId() != null) {
@@ -293,7 +294,7 @@ public class PmsProductServiceImpl implements PmsProductService {
         PmsProductExample productExample = new PmsProductExample();
         PmsProductExample.Criteria criteria = productExample.createCriteria();
         criteria.andDeleteStatusEqualTo(0);
-        if(!StringUtils.isEmpty(keyword)){
+        if(!StrUtil.isEmpty(keyword)){
             criteria.andNameLike("%" + keyword + "%");
             productExample.or().andDeleteStatusEqualTo(0).andProductSnLike("%" + keyword + "%");
         }

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/PmsSkuStockServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.macro.mall.dao.PmsSkuStockDao;
 import com.macro.mall.mapper.PmsSkuStockMapper;
 import com.macro.mall.model.PmsSkuStock;
@@ -26,7 +27,7 @@ public class PmsSkuStockServiceImpl implements PmsSkuStockService {
     public List<PmsSkuStock> getList(Long pid, String keyword) {
         PmsSkuStockExample example = new PmsSkuStockExample();
         PmsSkuStockExample.Criteria criteria = example.createCriteria().andProductIdEqualTo(pid);
-        if (!StringUtils.isEmpty(keyword)) {
+        if (!StrUtil.isEmpty(keyword)) {
             criteria.andSkuCodeLike("%" + keyword + "%");
         }
         return skuStockMapper.selectByExample(example);

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/SmsCouponHistoryServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.mapper.SmsCouponHistoryMapper;
 import com.macro.mall.model.SmsCouponHistory;
@@ -30,7 +31,7 @@ public class SmsCouponHistoryServiceImpl implements SmsCouponHistoryService {
         if(useStatus!=null){
             criteria.andUseStatusEqualTo(useStatus);
         }
-        if(!StringUtils.isEmpty(orderSn)){
+        if(!StrUtil.isEmpty(orderSn)){
             criteria.andOrderSnEqualTo(orderSn);
         }
         return historyMapper.selectByExample(example);

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/SmsCouponServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.dao.SmsCouponDao;
 import com.macro.mall.dao.SmsCouponProductCategoryRelationDao;
@@ -108,7 +109,7 @@ public class SmsCouponServiceImpl implements SmsCouponService {
     public List<SmsCoupon> list(String name, Integer type, Integer pageSize, Integer pageNum) {
         SmsCouponExample example = new SmsCouponExample();
         SmsCouponExample.Criteria criteria = example.createCriteria();
-        if(!StringUtils.isEmpty(name)){
+        if(!StrUtil.isEmpty(name)){
             criteria.andNameLike("%"+name+"%");
         }
         if(type!=null){

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/SmsFlashPromotionServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.mapper.SmsFlashPromotionMapper;
 import com.macro.mall.model.SmsFlashPromotion;
@@ -55,7 +56,7 @@ public class SmsFlashPromotionServiceImpl implements SmsFlashPromotionService {
     public List<SmsFlashPromotion> list(String keyword, Integer pageSize, Integer pageNum) {
         PageHelper.startPage(pageNum, pageSize);
         SmsFlashPromotionExample example = new SmsFlashPromotionExample();
-        if (!StringUtils.isEmpty(keyword)) {
+        if (!StrUtil.isEmpty(keyword)) {
             example.createCriteria().andTitleLike("%" + keyword + "%");
         }
         return flashPromotionMapper.selectByExample(example);

+ 3 - 2
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeAdvertiseServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.mapper.SmsHomeAdvertiseMapper;
 import com.macro.mall.model.SmsHomeAdvertise;
@@ -61,13 +62,13 @@ public class SmsHomeAdvertiseServiceImpl implements SmsHomeAdvertiseService {
         PageHelper.startPage(pageNum, pageSize);
         SmsHomeAdvertiseExample example = new SmsHomeAdvertiseExample();
         SmsHomeAdvertiseExample.Criteria criteria = example.createCriteria();
-        if (!StringUtils.isEmpty(name)) {
+        if (!StrUtil.isEmpty(name)) {
             criteria.andNameLike("%" + name + "%");
         }
         if (type != null) {
             criteria.andTypeEqualTo(type);
         }
-        if (!StringUtils.isEmpty(endTime)) {
+        if (!StrUtil.isEmpty(endTime)) {
             String startStr = endTime + " 00:00:00";
             String endStr = endTime + " 23:59:59";
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeBrandServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.mapper.SmsHomeBrandMapper;
 import com.macro.mall.model.SmsHomeBrand;
@@ -58,7 +59,7 @@ public class SmsHomeBrandServiceImpl implements SmsHomeBrandService {
         PageHelper.startPage(pageNum,pageSize);
         SmsHomeBrandExample example = new SmsHomeBrandExample();
         SmsHomeBrandExample.Criteria criteria = example.createCriteria();
-        if(!StringUtils.isEmpty(brandName)){
+        if(!StrUtil.isEmpty(brandName)){
             criteria.andBrandNameLike("%"+brandName+"%");
         }
         if(recommendStatus!=null){

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeNewProductServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.mapper.SmsHomeNewProductMapper;
 import com.macro.mall.model.SmsHomeNewProduct;
@@ -58,7 +59,7 @@ public class SmsHomeNewProductServiceImpl implements SmsHomeNewProductService {
         PageHelper.startPage(pageNum,pageSize);
         SmsHomeNewProductExample example = new SmsHomeNewProductExample();
         SmsHomeNewProductExample.Criteria criteria = example.createCriteria();
-        if(!StringUtils.isEmpty(productName)){
+        if(!StrUtil.isEmpty(productName)){
             criteria.andProductNameLike("%"+productName+"%");
         }
         if(recommendStatus!=null){

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeRecommendProductServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.mapper.SmsHomeRecommendProductMapper;
 import com.macro.mall.model.SmsHomeRecommendProduct;
@@ -58,7 +59,7 @@ public class SmsHomeRecommendProductServiceImpl implements SmsHomeRecommendProdu
         PageHelper.startPage(pageNum,pageSize);
         SmsHomeRecommendProductExample example = new SmsHomeRecommendProductExample();
         SmsHomeRecommendProductExample.Criteria criteria = example.createCriteria();
-        if(!StringUtils.isEmpty(productName)){
+        if(!StrUtil.isEmpty(productName)){
             criteria.andProductNameLike("%"+productName+"%");
         }
         if(recommendStatus!=null){

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/SmsHomeRecommendSubjectServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.mapper.SmsHomeRecommendSubjectMapper;
 import com.macro.mall.model.SmsHomeRecommendSubject;
@@ -58,7 +59,7 @@ public class SmsHomeRecommendSubjectServiceImpl implements SmsHomeRecommendSubje
         PageHelper.startPage(pageNum,pageSize);
         SmsHomeRecommendSubjectExample example = new SmsHomeRecommendSubjectExample();
         SmsHomeRecommendSubjectExample.Criteria criteria = example.createCriteria();
-        if(!StringUtils.isEmpty(subjectName)){
+        if(!StrUtil.isEmpty(subjectName)){
             criteria.andSubjectNameLike("%"+subjectName+"%");
         }
         if(recommendStatus!=null){

+ 16 - 12
mall-admin/src/main/java/com/macro/mall/service/impl/UmsAdminServiceImpl.java

@@ -14,6 +14,7 @@ import com.macro.mall.mapper.UmsAdminMapper;
 import com.macro.mall.mapper.UmsAdminRoleRelationMapper;
 import com.macro.mall.model.*;
 import com.macro.mall.security.util.JwtTokenUtil;
+import com.macro.mall.security.util.SpringUtil;
 import com.macro.mall.service.UmsAdminCacheService;
 import com.macro.mall.service.UmsAdminService;
 import org.slf4j.Logger;
@@ -56,19 +57,17 @@ public class UmsAdminServiceImpl implements UmsAdminService {
     private UmsAdminRoleRelationDao adminRoleRelationDao;
     @Autowired
     private UmsAdminLoginLogMapper loginLogMapper;
-    @Autowired
-    private UmsAdminCacheService adminCacheService;
 
     @Override
     public UmsAdmin getAdminByUsername(String username) {
-        UmsAdmin admin = adminCacheService.getAdmin(username);
+        UmsAdmin admin = getCacheService().getAdmin(username);
         if(admin!=null) return  admin;
         UmsAdminExample example = new UmsAdminExample();
         example.createCriteria().andUsernameEqualTo(username);
         List<UmsAdmin> adminList = adminMapper.selectByExample(example);
         if (adminList != null && adminList.size() > 0) {
             admin = adminList.get(0);
-            adminCacheService.setAdmin(admin);
+            getCacheService().setAdmin(admin);
             return admin;
         }
         return null;
@@ -159,7 +158,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
         PageHelper.startPage(pageNum, pageSize);
         UmsAdminExample example = new UmsAdminExample();
         UmsAdminExample.Criteria criteria = example.createCriteria();
-        if (!StringUtils.isEmpty(keyword)) {
+        if (!StrUtil.isEmpty(keyword)) {
             criteria.andUsernameLike("%" + keyword + "%");
             example.or(example.createCriteria().andNickNameLike("%" + keyword + "%"));
         }
@@ -182,15 +181,15 @@ public class UmsAdminServiceImpl implements UmsAdminService {
             }
         }
         int count = adminMapper.updateByPrimaryKeySelective(admin);
-        adminCacheService.delAdmin(id);
+        getCacheService().delAdmin(id);
         return count;
     }
 
     @Override
     public int delete(Long id) {
-        adminCacheService.delAdmin(id);
+        getCacheService().delAdmin(id);
         int count = adminMapper.deleteByPrimaryKey(id);
-        adminCacheService.delResourceList(id);
+        getCacheService().delResourceList(id);
         return count;
     }
 
@@ -212,7 +211,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
             }
             adminRoleRelationDao.insertList(list);
         }
-        adminCacheService.delResourceList(adminId);
+        getCacheService().delResourceList(adminId);
         return count;
     }
 
@@ -223,13 +222,13 @@ public class UmsAdminServiceImpl implements UmsAdminService {
 
     @Override
     public List<UmsResource> getResourceList(Long adminId) {
-        List<UmsResource> resourceList = adminCacheService.getResourceList(adminId);
+        List<UmsResource> resourceList = getCacheService().getResourceList(adminId);
         if(CollUtil.isNotEmpty(resourceList)){
             return  resourceList;
         }
         resourceList = adminRoleRelationDao.getResourceList(adminId);
         if(CollUtil.isNotEmpty(resourceList)){
-            adminCacheService.setResourceList(adminId,resourceList);
+            getCacheService().setResourceList(adminId,resourceList);
         }
         return resourceList;
     }
@@ -253,7 +252,7 @@ public class UmsAdminServiceImpl implements UmsAdminService {
         }
         umsAdmin.setPassword(passwordEncoder.encode(param.getNewPassword()));
         adminMapper.updateByPrimaryKey(umsAdmin);
-        adminCacheService.delAdmin(umsAdmin.getId());
+        getCacheService().delAdmin(umsAdmin.getId());
         return 1;
     }
 
@@ -267,4 +266,9 @@ public class UmsAdminServiceImpl implements UmsAdminService {
         }
         throw new UsernameNotFoundException("用户名或密码错误");
     }
+
+    @Override
+    public UmsAdminCacheService getCacheService() {
+        return SpringUtil.getBean(UmsAdminCacheService.class);
+    }
 }

+ 2 - 1
mall-admin/src/main/java/com/macro/mall/service/impl/UmsRoleServiceImpl.java

@@ -1,5 +1,6 @@
 package com.macro.mall.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.github.pagehelper.PageHelper;
 import com.macro.mall.dao.UmsRoleDao;
 import com.macro.mall.mapper.UmsRoleMapper;
@@ -63,7 +64,7 @@ public class UmsRoleServiceImpl implements UmsRoleService {
     public List<UmsRole> list(String keyword, Integer pageSize, Integer pageNum) {
         PageHelper.startPage(pageNum, pageSize);
         UmsRoleExample example = new UmsRoleExample();
-        if (!StringUtils.isEmpty(keyword)) {
+        if (!StrUtil.isEmpty(keyword)) {
             example.createCriteria().andNameLike("%" + keyword + "%");
         }
         return roleMapper.selectByExample(example);