|
@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
@@ -20,19 +21,29 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnum;
|
|
|
+import cn.com.qmth.examcloud.commons.base.helpers.DynamicEnumManager;
|
|
|
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.GetAllOrgPropertiesReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgPropertyReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
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.GetAllOrgPropertiesResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgPropertyResp;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
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.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.dao.entity.OrgPropertyEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.enums.OrgProperty;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.OrgInfo;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.impl.OrgServiceImpl;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -57,6 +68,9 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
@Autowired
|
|
|
private OrgRepo orgRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ OrgPropertyRepo orgPropertyRepo;
|
|
|
+
|
|
|
@ApiOperation(value = "保存机构")
|
|
|
@PostMapping("saveOrg")
|
|
|
@Override
|
|
@@ -162,4 +176,55 @@ public class OrgCloudServiceProvider extends ControllerSupport implements OrgClo
|
|
|
|
|
|
return resp;
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取所有机构属性")
|
|
|
+ @PostMapping("getAllOrgProperties")
|
|
|
+ @Override
|
|
|
+ public GetAllOrgPropertiesResp getAllOrgProperties(@RequestBody GetAllOrgPropertiesReq req) {
|
|
|
+ Long orgId = req.getOrgId();
|
|
|
+
|
|
|
+ OrgEntity orgEntity = orgRepo.findOne(orgId);
|
|
|
+ if (null == orgEntity) {
|
|
|
+ throw new StatusException("B-001250", "orgId is wrong");
|
|
|
+ }
|
|
|
+ validateRootOrgIsolation(orgEntity.getRootId());
|
|
|
+
|
|
|
+ Map<String, String> map = Maps.newHashMap();
|
|
|
+ List<OrgPropertyEntity> list = orgPropertyRepo.findByOrgId(orgId);
|
|
|
+ DynamicEnumManager manager = OrgProperty.getDynamicEnumManager();
|
|
|
+ for (OrgPropertyEntity cur : list) {
|
|
|
+ DynamicEnum de = manager.getById(cur.getKeyId());
|
|
|
+ map.put(de.getName(), cur.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ GetAllOrgPropertiesResp resp = new GetAllOrgPropertiesResp();
|
|
|
+ resp.setProps(map);
|
|
|
+
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取机构属性")
|
|
|
+ @PostMapping("getOrgProperty")
|
|
|
+ @Override
|
|
|
+ public GetOrgPropertyResp getOrgProperty(@RequestBody GetOrgPropertyReq req) {
|
|
|
+ Long orgId = req.getOrgId();
|
|
|
+ String key = req.getKey();
|
|
|
+ OrgEntity orgEntity = orgRepo.findOne(orgId);
|
|
|
+ if (null == orgEntity) {
|
|
|
+ throw new StatusException("B-001250", "orgId is wrong");
|
|
|
+ }
|
|
|
+ validateRootOrgIsolation(orgEntity.getRootId());
|
|
|
+
|
|
|
+ DynamicEnumManager manager = OrgProperty.getDynamicEnumManager();
|
|
|
+ DynamicEnum de = manager.getByName(key);
|
|
|
+ OrgPropertyEntity one = orgPropertyRepo.findByOrgIdAndKeyId(orgId, de.getId());
|
|
|
+ if (null == one) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String value = one.getValue();
|
|
|
+
|
|
|
+ GetOrgPropertyResp resp = new GetOrgPropertyResp();
|
|
|
+ resp.setValue(value);
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
}
|