refactor(open-api): 重构安保人员花名册接口

- 修改接口名称,支持事业单位和服务项目的安保人员花名册查询
- 新增枚举类 EnterPrisesUnitOrServiceProjectType 表示查询类型
- 更新 mapper 和 service层相应方法
- 重命名相关 DTO 类
This commit is contained in:
luozhun 2024-11-21 10:55:12 +08:00
parent 67d19a0885
commit 5bb44b0dc2
8 changed files with 55 additions and 45 deletions

View File

@ -2,7 +2,6 @@ package com.changhu.controller;
import cn.hutool.core.annotation.AnnotationUtil;
import cn.hutool.core.lang.Dict;
import com.alibaba.fastjson2.JSON;
import com.changhu.common.annotation.CheckUserType;
import com.changhu.common.annotation.JsonBody;
import com.changhu.common.db.enums.UserType;
@ -67,23 +66,4 @@ public class AccessKeysController {
return accessKeysService.list();
}
public static void main(String[] args) {
Class<OpenController> openControllerClass = OpenController.class;
RequestMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(openControllerClass, RequestMapping.class);
String controllerPath = requestMapping.value()[0];
List<SelectNodeVo<String>> method = Arrays.stream(openControllerClass.getMethods())
.filter(m -> AnnotationUtil.hasAnnotation(m, RequestMapping.class))
.map(m -> {
Operation operation = m.getAnnotation(Operation.class);
RequestMapping mReq = AnnotatedElementUtils.findMergedAnnotation(m, RequestMapping.class);
return SelectNodeVo.<String>builder()
.value(controllerPath + mReq.value()[0])
.label(operation.summary())
.extData(Dict.of("method", mReq.method()))
.build();
})
.toList();
method.forEach(i -> System.out.println(JSON.toJSONString(i)));
}
}

View File

@ -5,7 +5,8 @@ import com.changhu.common.pojo.vo.SelectNodeVo;
import com.changhu.pojo.dto.DataViewDTO;
import com.changhu.pojo.dto.EnterprisesUnitDetailDTO;
import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO;
import com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO;
import com.changhu.pojo.dto.SecurityUserRosterDTO;
import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType;
import com.changhu.service.OpenApiService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
@ -56,10 +57,11 @@ public class OpenController {
return openApiService.securityUnitUseStatistics(code, level);
}
@Operation(summary = "服务项目安保人员花名册")
@GetMapping("/serviceProjectUserRoster")
public List<ServiceProjectSecurityUserRosterDTO> serviceProjectUserRoster(@Schema(description = "服务项目id") Long serviceProjectId) {
return openApiService.serviceProjectUserRoster(serviceProjectId);
@Operation(summary = "安保人员花名册")
@GetMapping("/securityUserRoster")
public List<SecurityUserRosterDTO> securityUserRoster(@Schema(description = "事业单位或服务项目id") Long id,
@Schema(description = "类型") EnterprisesUnitOrServiceProjectType type) {
return openApiService.securityUserRoster(id, type);
}
}

View File

@ -2,7 +2,8 @@ package com.changhu.mapper;
import com.changhu.common.pojo.vo.SelectNodeVo;
import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO;
import com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO;
import com.changhu.pojo.dto.SecurityUserRosterDTO;
import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -38,9 +39,7 @@ public interface OpenApiMapper {
/**
* 获取服务人员花名册
*
* @param serviceProjectId 服务项目id
* @return 结果
*/
List<ServiceProjectSecurityUserRosterDTO> serviceProjectUserRoster(@Param("serviceProjectId") Long serviceProjectId);
List<SecurityUserRosterDTO> securityUserRoster(@Param("id") Long id,
@Param("type") EnterprisesUnitOrServiceProjectType type);
}

View File

@ -9,10 +9,10 @@ import lombok.Data;
/**
* @author 20252
* @createTime 2024/11/18 上午10:43
* @desc ServiceProjectSecurityUserRosterDTO...
* @desc SecurityUserRosterDTO...
*/
@Data
public class ServiceProjectSecurityUserRosterDTO {
public class SecurityUserRosterDTO {
@Schema(description = "id")
private Long snowFlakeId;
@Schema(description = "名称")

View File

@ -0,0 +1,16 @@
package com.changhu.pojo.params;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author 20252
* @createTime 2024/11/21 上午10:35
* @desc EnterprisesUnitOrServiceProjectType...
*/
@Getter
@AllArgsConstructor
public enum EnterprisesUnitOrServiceProjectType {
ENTERPRISES_UNIT,
SERVICE_PROJECT
}

View File

@ -4,7 +4,8 @@ import com.changhu.common.pojo.vo.SelectNodeVo;
import com.changhu.pojo.dto.DataViewDTO;
import com.changhu.pojo.dto.EnterprisesUnitDetailDTO;
import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO;
import com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO;
import com.changhu.pojo.dto.SecurityUserRosterDTO;
import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType;
import java.util.List;
@ -50,8 +51,9 @@ public interface OpenApiService {
/**
* 服务项目安保人员花名册
*
* @param serviceProjectId 服务项目id
* @param id 事业单位服务项目id
* @param type 类型
* @return 花名册
*/
List<ServiceProjectSecurityUserRosterDTO> serviceProjectUserRoster(Long serviceProjectId);
List<SecurityUserRosterDTO> securityUserRoster(Long id, EnterprisesUnitOrServiceProjectType type);
}

View File

@ -12,7 +12,8 @@ import com.changhu.module.miniProgram.pojo.entity.SecurityUser;
import com.changhu.pojo.dto.DataViewDTO;
import com.changhu.pojo.dto.EnterprisesUnitDetailDTO;
import com.changhu.pojo.dto.SecurityUnitUseStatisticsDTO;
import com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO;
import com.changhu.pojo.dto.SecurityUserRosterDTO;
import com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType;
import com.changhu.service.OpenApiService;
import com.changhu.support.mybatisplus.pojo.entity.BaseEntity;
import lombok.SneakyThrows;
@ -103,7 +104,7 @@ public class OpenApiServiceImpl implements OpenApiService {
}
@Override
public List<ServiceProjectSecurityUserRosterDTO> serviceProjectUserRoster(Long serviceProjectId) {
return openApiMapper.serviceProjectUserRoster(serviceProjectId);
public List<SecurityUserRosterDTO> securityUserRoster(Long id, EnterprisesUnitOrServiceProjectType type) {
return openApiMapper.securityUserRoster(id, type);
}
}

View File

@ -105,8 +105,8 @@
group by eu.snow_flake_id
order by eu.create_time desc
</select>
<select id="serviceProjectUserRoster"
resultType="com.changhu.pojo.dto.ServiceProjectSecurityUserRosterDTO">
<select id="securityUserRoster"
resultType="com.changhu.pojo.dto.SecurityUserRosterDTO">
select su.snow_flake_id,
su.name,
su.sex,
@ -116,12 +116,22 @@
eu.name as 'enterprisesUnitName',
suu.name as 'securityUnitName',
su.security_number
from enterprises_unit eu
left join service_project sp on sp.enterprises_unit_id = eu.snow_flake_id and sp.delete_flag = 0
left join security_user su on su.service_project_id = sp.snow_flake_id and su.delete_flag = 0
left join security_unit suu on su.security_unit_id = suu.snow_flake_id and suu.delete_flag = 0
from enterprises_unit eu
LEFT JOIN service_project sp ON sp.enterprises_unit_id = eu.snow_flake_id AND sp.delete_flag = 0
JOIN security_user su ON su.service_project_id = sp.snow_flake_id AND su.delete_flag = 0
LEFT JOIN security_unit suu ON su.security_unit_id = suu.snow_flake_id AND suu.delete_flag = 0
where eu.delete_flag = 0
and sp.snow_flake_id = #{serviceProjectId}
<choose>
<when test="type==@com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType@ENTERPRISES_UNIT">
and eu.snow_flake_id = #{id}
</when>
<when test="type==@com.changhu.pojo.params.EnterprisesUnitOrServiceProjectType@SERVICE_PROJECT">
and sp.snow_flake_id = #{id}
</when>
<otherwise>
and eu.snow_flake_id = -1
</otherwise>
</choose>
order by su.create_time desc
</select>
</mapper>