|
@@ -1,23 +1,20 @@
|
|
package com.usky.system.service.impl;
|
|
package com.usky.system.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.usky.common.core.exception.BusinessException;
|
|
import com.usky.common.core.exception.BusinessException;
|
|
|
|
+import com.usky.common.mybatis.core.AbstractCrudService;
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
import com.usky.system.domain.HceArticle;
|
|
import com.usky.system.domain.HceArticle;
|
|
import com.usky.system.domain.HceCategory;
|
|
import com.usky.system.domain.HceCategory;
|
|
import com.usky.system.domain.SysUser;
|
|
import com.usky.system.domain.SysUser;
|
|
import com.usky.system.mapper.HceArticleMapper;
|
|
import com.usky.system.mapper.HceArticleMapper;
|
|
import com.usky.system.mapper.HceCategoryMapper;
|
|
import com.usky.system.mapper.HceCategoryMapper;
|
|
-import com.usky.system.service.HceArticleService;
|
|
|
|
import com.usky.system.service.HceCategoryService;
|
|
import com.usky.system.service.HceCategoryService;
|
|
-import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
|
import com.usky.system.service.ISysUserService;
|
|
import com.usky.system.service.ISysUserService;
|
|
import com.usky.system.service.vo.HceCategoryListVO;
|
|
import com.usky.system.service.vo.HceCategoryListVO;
|
|
import com.usky.system.service.vo.HceCategoryVO;
|
|
import com.usky.system.service.vo.HceCategoryVO;
|
|
-import org.apache.tomcat.jni.Local;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -47,17 +44,56 @@ public class HceCategoryServiceImpl extends AbstractCrudService<HceCategoryMappe
|
|
long userId = SecurityUtils.getUserId();
|
|
long userId = SecurityUtils.getUserId();
|
|
SysUser sysUser = userService.selectUserByIdOne(userId);
|
|
SysUser sysUser = userService.selectUserByIdOne(userId);
|
|
List<HceCategoryListVO> list = new ArrayList<>();
|
|
List<HceCategoryListVO> list = new ArrayList<>();
|
|
- if(("00").equals(sysUser.getUserType())){
|
|
|
|
- if (1L == userId)
|
|
|
|
- {
|
|
|
|
- list = baseMapper.selectMenuTreeAll(hceCategoryVO.getCategoryName(),hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime());
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- list = baseMapper.selectMenuTreeByUserId(hceCategoryVO.getCategoryName(),hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime(),userId);
|
|
|
|
|
|
+ List<Integer> categoryIdList = new ArrayList<>();
|
|
|
|
+ if(StringUtils.isNotBlank(hceCategoryVO.getCategoryName())){
|
|
|
|
+ LambdaQueryWrapper<HceCategory> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapper.like(HceCategory::getCategoryName, hceCategoryVO.getCategoryName());
|
|
|
|
+ List<HceCategory> list1 = this.list(queryWrapper);
|
|
|
|
+ if(list1.size() > 0){
|
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
|
+ categoryIdList.add(list1.get(i).getId());
|
|
|
|
+ }
|
|
|
|
+ if(("00").equals(sysUser.getUserType())){
|
|
|
|
+ if (1L == userId)
|
|
|
|
+ {
|
|
|
|
+ list = baseMapper.selectMenuTreeAll(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ list = baseMapper.selectMenuTreeByUserId(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime(),userId);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ if (1L == userId)
|
|
|
|
+ {
|
|
|
|
+ list = baseMapper.selectMenuTreeAll(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ list = baseMapper.selectMenuTreeByUserIdOne(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime(),SecurityUtils.getTenantId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
- list = baseMapper.selectMenuTreeByUserIdOne(hceCategoryVO.getCategoryName(),hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime(),SecurityUtils.getTenantId());
|
|
|
|
|
|
+ if(("00").equals(sysUser.getUserType())){
|
|
|
|
+ if (1L == userId)
|
|
|
|
+ {
|
|
|
|
+ list = baseMapper.selectMenuTreeAll(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ list = baseMapper.selectMenuTreeByUserId(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime(),userId);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ if (1L == userId)
|
|
|
|
+ {
|
|
|
|
+ list = baseMapper.selectMenuTreeAll(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ list = baseMapper.selectMenuTreeByUserIdOne(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime(),SecurityUtils.getTenantId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
List<HceCategoryListVO> finalList = list;
|
|
List<HceCategoryListVO> finalList = list;
|
|
@@ -72,7 +108,21 @@ public class HceCategoryServiceImpl extends AbstractCrudService<HceCategoryMappe
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<HceCategoryListVO> pageWhite(HceCategoryVO hceCategoryVO){
|
|
public List<HceCategoryListVO> pageWhite(HceCategoryVO hceCategoryVO){
|
|
- List<HceCategoryListVO> list = baseMapper.selectMenuTreeAll(hceCategoryVO.getCategoryName(),hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime());
|
|
|
|
|
|
+ List<HceCategoryListVO> list = new ArrayList<>();
|
|
|
|
+ List<Integer> categoryIdList = new ArrayList<>();
|
|
|
|
+ if(StringUtils.isNotBlank(hceCategoryVO.getCategoryName())){
|
|
|
|
+ LambdaQueryWrapper<HceCategory> queryWrapper = Wrappers.lambdaQuery();
|
|
|
|
+ queryWrapper.like(HceCategory::getCategoryName, hceCategoryVO.getCategoryName());
|
|
|
|
+ List<HceCategory> list2 = this.list(queryWrapper);
|
|
|
|
+ if(list2.size() > 0){
|
|
|
|
+ for (int i = 0; i < list2.size(); i++) {
|
|
|
|
+ categoryIdList.add(list2.get(i).getId());
|
|
|
|
+ }
|
|
|
|
+ list = baseMapper.selectMenuTreeAll(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime());
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ list = baseMapper.selectMenuTreeAll(categoryIdList,hceCategoryVO.getStartTime(),hceCategoryVO.getEndTime());
|
|
|
|
+ }
|
|
|
|
|
|
List<HceCategoryListVO> finalList = list;
|
|
List<HceCategoryListVO> finalList = list;
|
|
List<HceCategoryListVO> list1 = list.stream().filter(s ->s.getParentId() == 0).map(
|
|
List<HceCategoryListVO> list1 = list.stream().filter(s ->s.getParentId() == 0).map(
|
|
@@ -109,15 +159,15 @@ public class HceCategoryServiceImpl extends AbstractCrudService<HceCategoryMappe
|
|
}
|
|
}
|
|
|
|
|
|
//新增栏目时校验对应上级栏目是否存在,不存在要先新增上级栏目后再新增本栏目
|
|
//新增栏目时校验对应上级栏目是否存在,不存在要先新增上级栏目后再新增本栏目
|
|
- Integer pid = baseMapper.selectPidByMenuid(hceCategory.getMenuId());
|
|
|
|
- if(pid != null && pid != 0){
|
|
|
|
- LambdaQueryWrapper<HceCategory> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
|
- queryWrapper2.eq(HceCategory::getMenuId,pid);
|
|
|
|
- List<HceCategory> list2 = this.list(queryWrapper2);
|
|
|
|
- if(list2.size() <= 0){
|
|
|
|
- throw new BusinessException("上级栏目不存在,请先添加上级栏目");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// Integer pid = baseMapper.selectPidByMenuid(hceCategory.getMenuId());
|
|
|
|
+// if(pid != null && pid != 0){
|
|
|
|
+// LambdaQueryWrapper<HceCategory> queryWrapper2 = Wrappers.lambdaQuery();
|
|
|
|
+// queryWrapper2.eq(HceCategory::getMenuId,pid);
|
|
|
|
+// List<HceCategory> list2 = this.list(queryWrapper2);
|
|
|
|
+// if(list2.size() <= 0){
|
|
|
|
+// throw new BusinessException("上级栏目不存在,请先添加上级栏目");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
|
|
hceCategory.setCreatedate(LocalDateTime.now());
|
|
hceCategory.setCreatedate(LocalDateTime.now());
|
|
this.save(hceCategory);
|
|
this.save(hceCategory);
|
|
@@ -152,13 +202,13 @@ public class HceCategoryServiceImpl extends AbstractCrudService<HceCategoryMappe
|
|
if(list.size() > 0){
|
|
if(list.size() > 0){
|
|
throw new BusinessException("该栏目存在栏目内容不可删除");
|
|
throw new BusinessException("该栏目存在栏目内容不可删除");
|
|
}
|
|
}
|
|
- LambdaQueryWrapper<HceCategory> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
|
- queryWrapper1.eq(HceCategory::getPid,id)
|
|
|
|
- .eq(HceCategory::getStatus,1);
|
|
|
|
- List<HceCategory> list1 = this.list(queryWrapper1);
|
|
|
|
- if(list1.size()>0){
|
|
|
|
- throw new BusinessException("该栏目存在子栏目不可删除");
|
|
|
|
- }
|
|
|
|
|
|
+// LambdaQueryWrapper<HceCategory> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
|
+// queryWrapper1.eq(HceCategory::getPid,id)
|
|
|
|
+// .eq(HceCategory::getStatus,1);
|
|
|
|
+// List<HceCategory> list1 = this.list(queryWrapper1);
|
|
|
|
+// if(list1.size()>0){
|
|
|
|
+// throw new BusinessException("该栏目存在子栏目不可删除");
|
|
|
|
+// }
|
|
this.removeById(id);
|
|
this.removeById(id);
|
|
|
|
|
|
}
|
|
}
|