|
|
@@ -2,21 +2,15 @@ package com.zhongshu.card.server.core.service.openAPI;
|
|
|
|
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
-import com.zhongshu.card.client.model.devices.DeviceInfoSearch;
|
|
|
-import com.zhongshu.card.client.model.org.OrganizationMiniModel;
|
|
|
-import com.zhongshu.card.client.model.school.AreaSimpleModel;
|
|
|
-import com.zhongshu.card.client.openApi.model.DeviceInfoOpenApiModel;
|
|
|
-import com.zhongshu.card.client.openApi.model.DeviceInfoOpenApiSimpleModel;
|
|
|
-import com.zhongshu.card.client.openApi.params.DeviceIdParam;
|
|
|
-import com.zhongshu.card.client.openApi.params.DeviceInfoOpenApiSearch;
|
|
|
-import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
|
|
|
-import com.zhongshu.card.server.core.dao.devices.DevicePermissDao;
|
|
|
-import com.zhongshu.card.server.core.dao.payment.ExpenseFlowDao;
|
|
|
-import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationUserModel;
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationUserSearch;
|
|
|
+import com.zhongshu.card.client.openApi.model.OrganizationUserOpenApiModel;
|
|
|
+import com.zhongshu.card.client.openApi.params.OrganizationUserOpenApiSearch;
|
|
|
+import com.zhongshu.card.server.core.dao.org.OrganizationUserDao;
|
|
|
+import com.zhongshu.card.server.core.domain.org.Organization;
|
|
|
+import com.zhongshu.card.server.core.domain.org.OrganizationUser;
|
|
|
+import com.zhongshu.card.server.core.domain.org.UserAccount;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
-import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
|
|
|
-import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
|
|
|
-import com.zhongshu.card.server.core.service.school.AreaServiceImpl;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
@@ -27,10 +21,6 @@ import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
/**
|
|
|
* 机构相关的 openAPI
|
|
|
*
|
|
|
@@ -42,93 +32,54 @@ import java.util.stream.Collectors;
|
|
|
public class OrganizationUserOpenApiService extends SuperService {
|
|
|
|
|
|
@Autowired
|
|
|
- private DevicePermissDao devicePermissDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ExpenseFlowDao expenseFlowDao;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OrganizationManagerServiceImpl organizationManagerService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OrganizationServiceImpl organizationServiceImpl;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private AreaServiceImpl areaService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private DeviceInfoDao deviceInfoDao;
|
|
|
+ private OrganizationUserDao organizationUserDao;
|
|
|
|
|
|
- /**
|
|
|
- * 设备列表
|
|
|
- *
|
|
|
- * @param apiSearch
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ResultContent<Page<DeviceInfoOpenApiModel>> page(DeviceInfoOpenApiSearch apiSearch) {
|
|
|
+ public ResultContent<Page<OrganizationUserOpenApiModel>> projectUserPage(OrganizationUserOpenApiSearch apiSearch) {
|
|
|
+ OrganizationUserSearch param = new OrganizationUserSearch();
|
|
|
if (StringUtils.isEmpty(apiSearch.getProjectCode())) {
|
|
|
return ResultContent.buildFail("projectCode不能为空");
|
|
|
}
|
|
|
- DeviceInfoSearch param = new DeviceInfoSearch();
|
|
|
+ String projectOid = getOidByCode(apiSearch.getProjectCode());
|
|
|
+ if (StringUtils.isEmpty(projectOid)) {
|
|
|
+ projectOid = "unKnow";
|
|
|
+ }
|
|
|
BeanUtils.copyProperties(apiSearch, param);
|
|
|
- param.setProjectInfoCode(apiSearch.getProjectCode());
|
|
|
+ param.setProjectOid(projectOid);
|
|
|
|
|
|
Pageable pageable = PageRequest.of(apiSearch.getNumber(), apiSearch.getSize());
|
|
|
- Page<DeviceInfo> page = deviceInfoDao.page(pageable, param);
|
|
|
+ Page<OrganizationUser> page = organizationUserDao.page(pageable, param);
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设备详情
|
|
|
- *
|
|
|
- * @param param
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ResultContent<DeviceInfoOpenApiModel> getDetailByDeviceId(DeviceIdParam param) {
|
|
|
- DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(param.getDeviceId());
|
|
|
- if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
- return ResultContent.buildFail("数据不存在");
|
|
|
+ public ResultContent<OrganizationUserOpenApiModel> getUserDetailById(String id) {
|
|
|
+ OrganizationUser organizationUser = organizationUserDao.findTopById(id);
|
|
|
+ if (ObjectUtils.isEmpty(organizationUser)) {
|
|
|
+ return ResultContent.buildFail("用户存在");
|
|
|
}
|
|
|
- return ResultContent.buildSuccess(toModel(deviceInfo));
|
|
|
+ return ResultContent.buildSuccess(toModel(organizationUser));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设备基础信息
|
|
|
- *
|
|
|
- * @param entity
|
|
|
- * @return
|
|
|
- */
|
|
|
- public DeviceInfoOpenApiModel toModel(DeviceInfo entity) {
|
|
|
- DeviceInfoOpenApiModel model = null;
|
|
|
- if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
- model = new DeviceInfoOpenApiModel();
|
|
|
+ public OrganizationUserOpenApiModel toModel(OrganizationUser entity) {
|
|
|
+ OrganizationUserOpenApiModel model = new OrganizationUserOpenApiModel();
|
|
|
+ if (ObjectUtils.isNotEmpty(entity.getId())) {
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
|
|
|
- // 所属机构信息
|
|
|
- OrganizationMiniModel miniModel = organizationManagerService.toMiniModel(entity.getOrganization());
|
|
|
- model.setOrganization(miniModel);
|
|
|
-
|
|
|
- model.setProjectInfoName(organizationServiceImpl.getOrgNameByCode(entity.getProjectInfoCode()));
|
|
|
-
|
|
|
- // 所属区域信息
|
|
|
- List<AreaSimpleModel> areaModels = areaService.getParents(entity.getArea());
|
|
|
- if (ObjectUtils.isNotEmpty(areaModels)) {
|
|
|
- model.setArea(areaModels.get(0));
|
|
|
- Collections.reverse(areaModels);
|
|
|
- List<String> areaNames = areaModels.stream().map(it -> it.getName()).collect(Collectors.toList());
|
|
|
- model.setAreaAllName(String.join("/", areaNames));
|
|
|
+ Organization organization = entity.getOrganization();
|
|
|
+ UserAccount user = entity.getUser();
|
|
|
+ if (ObjectUtils.isNotEmpty(user)) {
|
|
|
+ model.setUserId(user.getUserId());
|
|
|
+ model.setPhone(user.getPhone());
|
|
|
+ model.setName(user.getName());
|
|
|
+ model.setProfilePic(user.getProfilePic());
|
|
|
+ model.setSex(user.getSex());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotEmpty(organization)) {
|
|
|
+ model.setOrgName(organization.getName());
|
|
|
+ model.setAuthType(organization.getAuthType());
|
|
|
+ model.setOrgOid(organization.getOid());
|
|
|
+ model.setLogo(organization.getLogo());
|
|
|
}
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
-
|
|
|
- public DeviceInfoOpenApiSimpleModel toDeviceSimpleModel(DeviceInfo entity) {
|
|
|
- DeviceInfoOpenApiSimpleModel model = null;
|
|
|
- if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
- model = new DeviceInfoOpenApiSimpleModel();
|
|
|
- BeanUtils.copyProperties(entity, model);
|
|
|
- }
|
|
|
- return model;
|
|
|
- }
|
|
|
-
|
|
|
}
|