|
|
@@ -1,5 +1,10 @@
|
|
|
package com.zhongshu.card.server.core.service.org;
|
|
|
|
|
|
+import com.github.microservice.auth.client.content.ResultState;
|
|
|
+import com.github.microservice.auth.client.service.OrganizationUserService;
|
|
|
+import com.github.microservice.auth.client.service.RoleService;
|
|
|
+import com.github.microservice.auth.client.service.UserService;
|
|
|
+import com.github.microservice.auth.security.type.AuthType;
|
|
|
import com.zhongshu.card.client.model.org.OrganizationAddParam;
|
|
|
import com.zhongshu.card.client.model.org.OrganizationModel;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
@@ -10,11 +15,13 @@ import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
|
* 机构管理
|
|
|
+ *
|
|
|
* @author TRX
|
|
|
* @date 2024/5/31
|
|
|
*/
|
|
|
@@ -25,6 +32,18 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
@Autowired
|
|
|
OrganizationDao organizationDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ com.github.microservice.auth.client.service.OrganizationService organizationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrganizationUserService organizationUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RoleService roleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ UserService userService;
|
|
|
+
|
|
|
public ResultContent addOrganization(OrganizationAddParam param) {
|
|
|
Organization organization = new Organization();
|
|
|
|
|
|
@@ -32,7 +51,37 @@ public class OrganizationServiceImpl implements OrganizationService {
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
- public OrganizationModel toModel(Organization entity){
|
|
|
+ @Override
|
|
|
+ public ResultContent initSuperOrganization() {
|
|
|
+ String oid = "";
|
|
|
+ Organization organization = organizationDao.findByAuthType(AuthType.Platform);
|
|
|
+ if (ObjectUtils.isEmpty(organization)) {
|
|
|
+ log.info("initSuperOrganization 开始初始平台结构信息");
|
|
|
+ com.github.microservice.auth.client.model.OrganizationModel organizationModel = new com.github.microservice.auth.client.model.OrganizationModel();
|
|
|
+ organizationModel.setName("全卡项目平台");
|
|
|
+ organizationModel.setAuthType(AuthType.Platform);
|
|
|
+ organizationModel.setRemark("系统自动初始化");
|
|
|
+ com.github.microservice.auth.client.content.ResultContent<String>
|
|
|
+ resultContent = organizationService.add(organizationModel);
|
|
|
+
|
|
|
+ if (resultContent.getState() == ResultState.Success) {
|
|
|
+ log.info("平台初始成功: {}", resultContent.getContent());
|
|
|
+ oid = resultContent.getContent();
|
|
|
+ } else {
|
|
|
+ String msg = resultContent.getMsg();
|
|
|
+ if (StringUtils.isEmpty(msg) && resultContent.getException() != null) {
|
|
|
+ msg = resultContent.getException().getMessage();
|
|
|
+ }
|
|
|
+ log.info("initSuperOrganization {}", msg);
|
|
|
+ return ResultContent.buildFail(msg);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ oid = organization.getOid();
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(oid);
|
|
|
+ }
|
|
|
+
|
|
|
+ public OrganizationModel toModel(Organization entity) {
|
|
|
OrganizationModel model = new OrganizationModel();
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
BeanUtils.copyProperties(entity, model);
|