|
@@ -3,19 +3,13 @@ package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.GetOrgsByIdListReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.GetOrgsReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.SaveOrgReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetOrgsByIdListResp;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetOrgsResp;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.SaveOrgResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.*;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.*;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgPropertyRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.OrgService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.OrgInfo;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.impl.OrgServiceImpl;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -35,9 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* {@link StatusException} 状态码范围:010XXX<br>
|
|
@@ -54,7 +46,7 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
private static final long serialVersionUID = -7858439296389761341L;
|
|
|
|
|
|
@Autowired
|
|
|
- private OrgServiceImpl orgService;
|
|
|
+ private OrgService orgService;
|
|
|
|
|
|
@Autowired
|
|
|
private OrgRepo orgRepo;
|
|
@@ -107,16 +99,8 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
throw new StatusException("150001", "机构不存在");
|
|
|
}
|
|
|
|
|
|
- OrgBean orgBean = new OrgBean();
|
|
|
- orgBean.setId(org.getId());
|
|
|
- orgBean.setName(org.getName());
|
|
|
- orgBean.setCode(org.getCode());
|
|
|
- orgBean.setParentId(org.getParentId());
|
|
|
- orgBean.setRootId(org.getRootId());
|
|
|
- orgBean.setEnable(org.getEnable());
|
|
|
-
|
|
|
GetOrgResp resp = new GetOrgResp();
|
|
|
- resp.setOrg(orgBean);
|
|
|
+ resp.setOrg(toOrgBean(org));
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
@@ -133,14 +117,8 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
if (null == org) {
|
|
|
throw new StatusException("010001", "no org. [id=" + cur + "]");
|
|
|
}
|
|
|
- OrgBean orgBean = new OrgBean();
|
|
|
- orgBean.setId(org.getId());
|
|
|
- orgBean.setName(org.getName());
|
|
|
- orgBean.setCode(org.getCode());
|
|
|
- orgBean.setParentId(org.getParentId());
|
|
|
- orgBean.setRootId(org.getRootId());
|
|
|
- orgBean.setEnable(org.getEnable());
|
|
|
|
|
|
+ OrgBean orgBean = toOrgBean(org);
|
|
|
orgList.add(orgBean);
|
|
|
}
|
|
|
GetOrgsByIdListResp resp = new GetOrgsByIdListResp();
|
|
@@ -148,6 +126,22 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @PostMapping("getOrgMaps")
|
|
|
+ @ApiOperation(value = "根据ID列表获取机构集合")
|
|
|
+ public GetOrgMapsResp getOrgMaps(@RequestBody GetOrgMapsReq req) {
|
|
|
+ Map<Long, OrgEntity> orgs = orgService.getOrgMapsByIds(req.getOrgIds());
|
|
|
+
|
|
|
+ Map<Long, OrgBean> orgMaps = new HashMap<>();
|
|
|
+ for (Map.Entry<Long, OrgEntity> entry : orgs.entrySet()) {
|
|
|
+ orgMaps.put(entry.getKey(), toOrgBean(entry.getValue()));
|
|
|
+ }
|
|
|
+
|
|
|
+ GetOrgMapsResp resp = new GetOrgMapsResp();
|
|
|
+ resp.setOrgMaps(orgMaps);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "查询所有机构")
|
|
|
@PostMapping("getOrgs")
|
|
|
@Override
|
|
@@ -193,15 +187,9 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
boolean has = false;
|
|
|
while (iterator.hasNext()) {
|
|
|
OrgEntity org = iterator.next();
|
|
|
- OrgBean orgBean = new OrgBean();
|
|
|
- orgBean.setId(org.getId());
|
|
|
- orgBean.setName(org.getName());
|
|
|
- orgBean.setCode(org.getCode());
|
|
|
- orgBean.setParentId(org.getParentId());
|
|
|
- orgBean.setRootId(org.getRootId());
|
|
|
- orgBean.setEnable(org.getEnable());
|
|
|
-
|
|
|
next = org.getId();
|
|
|
+
|
|
|
+ OrgBean orgBean = toOrgBean(org);
|
|
|
list.add(orgBean);
|
|
|
has = true;
|
|
|
}
|
|
@@ -216,4 +204,15 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ private OrgBean toOrgBean(OrgEntity entity) {
|
|
|
+ OrgBean bean = new OrgBean();
|
|
|
+ bean.setId(entity.getId());
|
|
|
+ bean.setParentId(entity.getParentId());
|
|
|
+ bean.setRootId(entity.getRootId());
|
|
|
+ bean.setCode(entity.getCode());
|
|
|
+ bean.setName(entity.getName());
|
|
|
+ bean.setEnable(entity.getEnable());
|
|
|
+ return bean;
|
|
|
+ }
|
|
|
+
|
|
|
}
|