|
|
@@ -12,6 +12,9 @@ import org.springframework.stereotype.Service;
|
|
|
import com.xintong.visualinspection.bean.FeeStation;
|
|
|
import com.xintong.visualinspection.bean.Menu;
|
|
|
import com.xintong.visualinspection.bean.Organ;
|
|
|
+import com.xintong.visualinspection.bean.Permission;
|
|
|
+import com.xintong.visualinspection.bean.Role;
|
|
|
+import com.xintong.visualinspection.bean.User;
|
|
|
import com.xintong.visualinspection.dao.cluster.DepartmentDao;
|
|
|
import com.xintong.visualinspection.service.BaseService;
|
|
|
import com.xintong.visualinspection.service.DepartmentService;
|
|
|
@@ -23,7 +26,6 @@ import lombok.Data;
|
|
|
* 版权所有.
|
|
|
*/
|
|
|
@Service
|
|
|
-@Data
|
|
|
public class DepartmentServiceImpl extends BaseService implements DepartmentService {
|
|
|
|
|
|
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(DepartmentService.class);
|
|
|
@@ -32,7 +34,7 @@ public class DepartmentServiceImpl extends BaseService implements DepartmentServ
|
|
|
private DepartmentDao departmentDao;
|
|
|
|
|
|
@Override
|
|
|
- public List<Organ> getOrgans(Organ organ) {
|
|
|
+ public List<Organ> getOrgans(Organ organ,User u) {
|
|
|
|
|
|
List<Organ> organs = departmentDao.getOrgan(organ);
|
|
|
List<Organ> olist = new ArrayList<>();
|
|
|
@@ -60,7 +62,7 @@ public class DepartmentServiceImpl extends BaseService implements DepartmentServ
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return olist;
|
|
|
+ return getOragnsByPermison(olist,u);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -87,7 +89,7 @@ public class DepartmentServiceImpl extends BaseService implements DepartmentServ
|
|
|
|
|
|
@Override
|
|
|
public List<Organ> getAll() {
|
|
|
- // TODO Auto-generated method stub
|
|
|
+
|
|
|
return departmentDao.getAll();
|
|
|
}
|
|
|
|
|
|
@@ -95,5 +97,50 @@ public class DepartmentServiceImpl extends BaseService implements DepartmentServ
|
|
|
public FeeStation getFSByDeptId(Integer id) {
|
|
|
return departmentDao.getFsBydeptId(id);
|
|
|
}
|
|
|
+
|
|
|
+ private List<Organ> getOragnsByPermison(List<Organ> oragns,User user){
|
|
|
+ if(user == null ) return oragns;
|
|
|
+ boolean hasrole = false;
|
|
|
+ for(Role r:user.getRoles()){
|
|
|
+ if(r.getName().equals("ROLE_ADMIN")){
|
|
|
+ hasrole = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(hasrole){
|
|
|
+ return oragns;
|
|
|
+ }
|
|
|
+
|
|
|
+ //找出自己
|
|
|
+ Organ temp = null;
|
|
|
+ for(Organ o :oragns){
|
|
|
+ temp = findOrgan(o,user.getOrganid());
|
|
|
+ if(temp!=null) break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(temp!=null){
|
|
|
+ oragns = new ArrayList<>();
|
|
|
+ oragns.add(temp);
|
|
|
+ }
|
|
|
+
|
|
|
+ return oragns;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Organ findOrgan(Organ o,Integer organid)
|
|
|
+ {
|
|
|
+ if(o.getId().intValue() == organid.intValue()){
|
|
|
+ return o;
|
|
|
+ }else{
|
|
|
+ if(o.getChilds()!=null && o.getChilds().size()>0){
|
|
|
+ for(Organ s:o.getChilds()){
|
|
|
+ Organ oo = findOrgan(s, organid);
|
|
|
+ if(oo!=null) return oo;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|