|
@@ -4,6 +4,8 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Map.Entry;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -13,23 +15,29 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
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.base.util.excel.ExcelError;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.excel.ExcelReader;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.excel.ExcelReaderHandle;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.enums.RoleMeta;
|
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.ExamSiteRepo;
|
|
|
+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.RoleRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRoleRelationRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.ExamSite;
|
|
|
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.entity.RoleEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserRoleRelationEntity;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.enums.OrgProperty;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.OrgService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.OrgDto;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.OrgInfo;
|
|
@@ -52,6 +60,9 @@ public class OrgServiceImpl implements OrgService {
|
|
|
@Autowired
|
|
|
UserRoleRelationRepo userRoleRelationRepo;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ OrgPropertyRepo orgPropertyRepo;
|
|
|
+
|
|
|
@Transactional
|
|
|
public List<ExcelError> importLearnCenter(Long orgId, InputStream inputStream) {
|
|
|
ExcelReader excelReader = new ExcelReader(OrgDto.class);
|
|
@@ -213,6 +224,7 @@ public class OrgServiceImpl implements OrgService {
|
|
|
String telephone = orgInfo.getTelephone();
|
|
|
String domainName = orgInfo.getDomainName();
|
|
|
String remark = orgInfo.getRemark();
|
|
|
+ Map<String, String> properties = orgInfo.getProperties();
|
|
|
|
|
|
if (StringUtils.isBlank(code)) {
|
|
|
throw new StatusException("B-150001", "code is null");
|
|
@@ -249,6 +261,22 @@ public class OrgServiceImpl implements OrgService {
|
|
|
|
|
|
OrgEntity saved = orgRepo.save(orgEntity);
|
|
|
|
|
|
+ Map<DynamicEnum, String> map = checkAndGetOrgProperties(properties);
|
|
|
+ for (Entry<DynamicEnum, String> entry : map.entrySet()) {
|
|
|
+ DynamicEnum de = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ OrgPropertyEntity entity = orgPropertyRepo.findByOrgIdAndKeyId(saved.getId(),
|
|
|
+ de.getId());
|
|
|
+ if (null == entity) {
|
|
|
+ entity = new OrgPropertyEntity();
|
|
|
+ entity.setOrgId(saved.getId());
|
|
|
+ entity.setKeyId(de.getId());
|
|
|
+ }
|
|
|
+ entity.setValue(value);
|
|
|
+
|
|
|
+ orgPropertyRepo.save(entity);
|
|
|
+ }
|
|
|
+
|
|
|
return saved;
|
|
|
}
|
|
|
|
|
@@ -272,6 +300,7 @@ public class OrgServiceImpl implements OrgService {
|
|
|
Long rootId = orgInfo.getRootId();
|
|
|
Long parentId = orgInfo.getParentId();
|
|
|
String remark = orgInfo.getRemark();
|
|
|
+ Map<String, String> properties = orgInfo.getProperties();
|
|
|
|
|
|
if (null == enable) {
|
|
|
enable = true;
|
|
@@ -322,7 +351,55 @@ public class OrgServiceImpl implements OrgService {
|
|
|
|
|
|
OrgEntity saved = orgRepo.save(orgEntity);
|
|
|
|
|
|
+ Map<DynamicEnum, String> map = checkAndGetOrgProperties(properties);
|
|
|
+ for (Entry<DynamicEnum, String> entry : map.entrySet()) {
|
|
|
+ DynamicEnum de = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ OrgPropertyEntity entity = orgPropertyRepo.findByOrgIdAndKeyId(saved.getId(),
|
|
|
+ de.getId());
|
|
|
+ if (null == entity) {
|
|
|
+ entity = new OrgPropertyEntity();
|
|
|
+ entity.setOrgId(saved.getId());
|
|
|
+ entity.setKeyId(de.getId());
|
|
|
+ }
|
|
|
+ entity.setValue(value);
|
|
|
+
|
|
|
+ orgPropertyRepo.save(entity);
|
|
|
+ }
|
|
|
+
|
|
|
return saved;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 方法注释
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @param properties
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<DynamicEnum, String> checkAndGetOrgProperties(Map<String, String> properties) {
|
|
|
+ DynamicEnumManager manager = OrgProperty.getDynamicEnumManager();
|
|
|
+
|
|
|
+ Map<DynamicEnum, String> map = Maps.newHashMap();
|
|
|
+ if (null == properties) {
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ for (Entry<String, String> entry : properties.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ if (StringUtils.isBlank(value)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ DynamicEnum de = null;
|
|
|
+ try {
|
|
|
+ de = manager.getByName(key);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new StatusException("E-001004", "机构属性错误");
|
|
|
+ }
|
|
|
+ map.put(de, value.trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
}
|