|
@@ -1,15 +1,22 @@
|
|
package com.cdf.service.impl;
|
|
package com.cdf.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.cdf.common.ResultData;
|
|
import com.cdf.entity.Dept;
|
|
import com.cdf.entity.Dept;
|
|
|
|
+import com.cdf.entity.User;
|
|
import com.cdf.mapper.IDeptMapper;
|
|
import com.cdf.mapper.IDeptMapper;
|
|
import com.cdf.response.DeptVo;
|
|
import com.cdf.response.DeptVo;
|
|
import com.cdf.service.IDeptService;
|
|
import com.cdf.service.IDeptService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.cdf.service.IUserService;
|
|
|
|
+import com.cdf.util.JwtUtil;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.lang.model.element.TypeElement;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -24,6 +31,8 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class DeptServiceImpl extends ServiceImpl<IDeptMapper, Dept> implements IDeptService {
|
|
public class DeptServiceImpl extends ServiceImpl<IDeptMapper, Dept> implements IDeptService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ IUserService userService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<DeptVo> getDeptList(Integer parentId) {
|
|
public List<DeptVo> getDeptList(Integer parentId) {
|
|
@@ -79,4 +88,24 @@ public class DeptServiceImpl extends ServiceImpl<IDeptMapper, Dept> implements I
|
|
getDeptSonListDg(deptList,dept.getId());
|
|
getDeptSonListDg(deptList,dept.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<DeptVo> getListByType(Integer type,String token) {
|
|
|
|
+ Integer id = JwtUtil.getId(token);
|
|
|
|
+ User user = userService.getById(id);
|
|
|
|
+ if(user == null){
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ Dept dept = this.getById(user.getDeptId());
|
|
|
|
+ if(dept == null){
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ DeptVo vo = new DeptVo();
|
|
|
|
+ BeanUtils.copyProperties(dept,vo);
|
|
|
|
+ if(type == 1){
|
|
|
|
+ vo.setChildren(this.getDeptList(user.getDeptId()));
|
|
|
|
+ }
|
|
|
|
+ return Arrays.asList(vo);
|
|
|
|
+ }
|
|
}
|
|
}
|