|
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -27,6 +28,7 @@ import lombok.NonNull;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
/**
|
|
|
* 分类业务操作实现
|
|
@@ -98,16 +100,12 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
|
|
Long userId = SessionContextHolder.getId();
|
|
|
Scope scope = StringUtils.ifEmpty(SessionContextHolder.getScope(), Scope::parse);
|
|
|
if (scope == Scope.ADMIN) {
|
|
|
- param.setType("0");
|
|
|
}else {
|
|
|
List<Long> merchants = this.merchantService.getMerchantIdsByUserId(userId);
|
|
|
if (ObjectUtils.isEmpty(merchants)) {
|
|
|
return null;
|
|
|
}
|
|
|
param.setMerchantId(merchants.get(0));
|
|
|
- if (StringUtils.isEmpty(param.getType())){
|
|
|
- param.setType("1");
|
|
|
- }
|
|
|
}
|
|
|
List<Category> categories = this.lambdaQuery().eq(Category::getEnabled, true)
|
|
|
.eq(StringUtils.notEmpty(param.getType()),Category::getType,param.getType())
|
|
@@ -170,24 +168,26 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
|
|
}
|
|
|
@Override
|
|
|
public List<CategoryDTO> getRootCategories(CategoryListParam param){
|
|
|
-// Long userId = SessionContextHolder.getId();
|
|
|
-// Scope scope = StringUtils.ifEmpty(SessionContextHolder.getScope(), Scope::parse);
|
|
|
-// if (scope == Scope.ADMIN) {
|
|
|
-// param.setType("0");
|
|
|
-// }else {
|
|
|
-// List<Long> merchants = this.merchantService.getMerchantIdsByUserId(userId);
|
|
|
-// if (ObjectUtils.isEmpty(merchants)) {
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-// param.setMerchantId(merchants.get(0));
|
|
|
-// param.setType("1");
|
|
|
-// }
|
|
|
+ Long userId = SessionContextHolder.getId();
|
|
|
+ Scope scope = StringUtils.ifEmpty(SessionContextHolder.getScope(), Scope::parse);
|
|
|
+ if (scope == Scope.ADMIN) {
|
|
|
+ }else {
|
|
|
+ List<Long> merchants = this.merchantService.getMerchantIdsByUserId(userId);
|
|
|
+ if (ObjectUtils.isEmpty(merchants)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ param.setMerchantId(merchants.get(0));
|
|
|
+ }
|
|
|
List<Category> categories = this.lambdaQuery()
|
|
|
.eq(Category::getEnabled, true)
|
|
|
-// .eq(StringUtils.notEmpty(param.getType()),Category::getType,param.getType())
|
|
|
-// .eq(StringUtils.notEmpty(param.getMerchantId()),Category::getMerchantId,param.getMerchantId())
|
|
|
+ .eq(StringUtils.notEmpty(param.getType()),Category::getType,param.getType())
|
|
|
+ .eq(StringUtils.notEmpty(param.getMerchantId()),Category::getMerchantId,param.getMerchantId())
|
|
|
.orderByAsc(Category::getSort).list();
|
|
|
categories.sort(Comparator.comparing(Category::getType).thenComparing(Category::getSort));
|
|
|
+// List<String> names = categories.stream().map(Category::getName).collect(Collectors.toList());
|
|
|
+// List<Category> categoryList = this.lambdaQuery()
|
|
|
+// .in(!CollectionUtils.isEmpty(names),Category::getId,names)
|
|
|
+// .list();
|
|
|
return CategoryCopier.INSTANCE.copying(categories);
|
|
|
}
|
|
|
@Override
|