|
@@ -49,12 +49,17 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
|
|
Long userId = SessionContextHolder.getId();
|
|
|
Scope scope = StringUtils.ifEmpty(SessionContextHolder.getScope(), Scope::parse);
|
|
|
if (scope == Scope.ADMIN) {
|
|
|
+ category.setType("0");
|
|
|
}else {
|
|
|
List<Long> merchants = this.merchantService.getMerchantIdsByUserId(userId);
|
|
|
if (ObjectUtils.isEmpty(merchants)) {
|
|
|
return null;
|
|
|
}
|
|
|
- param.setMerchantId(merchants.get(0));
|
|
|
+ category.setMerchantId(merchants.get(0));
|
|
|
+ category.setType("1");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(category.getParentId())){
|
|
|
+ category.setParentId(0l);
|
|
|
}
|
|
|
this.save(category);
|
|
|
return category.getId();
|
|
@@ -93,12 +98,14 @@ 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));
|
|
|
+ param.setType("1");
|
|
|
}
|
|
|
List<Category> categories = this.lambdaQuery().eq(Category::getEnabled, true)
|
|
|
.eq(StringUtils.notEmpty(param.getType()),Category::getType,param.getType())
|
|
@@ -136,9 +143,20 @@ 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");
|
|
|
+ }
|
|
|
List<Category> categories = this.lambdaQuery()
|
|
|
.eq(Category::getEnabled, true)
|
|
|
- .eq(Category::getParentId,0)
|
|
|
.eq(StringUtils.notEmpty(param.getType()),Category::getType,param.getType())
|
|
|
.eq(StringUtils.notEmpty(param.getMerchantId()),Category::getMerchantId,param.getMerchantId())
|
|
|
.orderByAsc(Category::getSort).list();
|