|
@@ -11,13 +11,16 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
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.GetOrgListByNameLikeReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.SaveOrgReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgListByNameLikeResp;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.OrgResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.SaveOrgResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Org;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.impl.OrgService;
|
|
@@ -33,11 +36,11 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
@Autowired
|
|
|
private OrgRepo orgRepo;
|
|
|
|
|
|
- @ApiOperation(value = "保存机构", notes = "保存机构")
|
|
|
+ @ApiOperation(value = "保存机构")
|
|
|
@PostMapping("saveOrg")
|
|
|
@Override
|
|
|
- public OrgResp saveOrg(SaveOrgReq orgReq) {
|
|
|
- OrgResp orgResp = new OrgResp();
|
|
|
+ public SaveOrgResp saveOrg(SaveOrgReq orgReq) {
|
|
|
+ SaveOrgResp orgResp = new SaveOrgResp();
|
|
|
Org org = orgService.findFirstByParentIdAndCode(orgReq.getRootOrgId(), orgReq.getOrgCode());
|
|
|
if (org == null) {
|
|
|
org = new Org();
|
|
@@ -53,7 +56,7 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
return orgResp;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "按机构名称模糊查询机构列表", notes = "按机构名称模糊查询机构列表")
|
|
|
+ @ApiOperation(value = "按机构名称模糊查询机构列表")
|
|
|
@PostMapping("getOrgListByNameLike")
|
|
|
@Override
|
|
|
public GetOrgListByNameLikeResp getOrgListByNameLike(GetOrgListByNameLikeReq req) {
|
|
@@ -83,4 +86,28 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
|
|
|
return resp;
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "按机构名称模糊查询机构列表")
|
|
|
+ @PostMapping("getOrg")
|
|
|
+ @Override
|
|
|
+ public GetOrgResp getOrg(GetOrgReq req) {
|
|
|
+ Long orgId = req.getOrgId();
|
|
|
+
|
|
|
+ Org org = orgRepo.findOne(orgId);
|
|
|
+
|
|
|
+ if (null == org) {
|
|
|
+ throw new StatusException("B-150001", "机构不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ OrgBean orgBean = new OrgBean();
|
|
|
+ orgBean.setId(org.getId());
|
|
|
+ orgBean.setLevel(org.getLevel());
|
|
|
+ orgBean.setName(org.getName());
|
|
|
+ orgBean.setParentId(org.getParentId());
|
|
|
+ orgBean.setRootId(org.getRootId());
|
|
|
+
|
|
|
+ GetOrgResp resp = new GetOrgResp();
|
|
|
+ resp.setOrg(orgBean);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
}
|