172 lines
7.5 KiB
Java
172 lines
7.5 KiB
Java
package com.kamco.cd.kamcoback.members;
|
|
|
|
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
|
import com.kamco.cd.kamcoback.members.dto.MembersDto;
|
|
import com.kamco.cd.kamcoback.members.dto.MembersDto.Basic;
|
|
import com.kamco.cd.kamcoback.members.service.AdminService;
|
|
import com.kamco.cd.kamcoback.members.service.MembersService;
|
|
import com.kamco.cd.kamcoback.scheduler.service.MemberInactiveJobService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.media.Content;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import jakarta.validation.Valid;
|
|
import java.util.UUID;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springdoc.core.annotations.ParameterObject;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PatchMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@Tag(name = "관리자 관리", description = "회원정보 관리 및 회원정보 API")
|
|
@RestController
|
|
@RequestMapping("/api/members")
|
|
@RequiredArgsConstructor
|
|
public class MembersApiController {
|
|
|
|
private final MembersService membersService;
|
|
private final AdminService adminService;
|
|
private final MemberInactiveJobService memberInactiveJobService;
|
|
|
|
@Operation(summary = "회원정보 목록", description = "회원정보 조회")
|
|
@ApiResponses(
|
|
value = {
|
|
@ApiResponse(
|
|
responseCode = "200",
|
|
description = "검색 성공",
|
|
content =
|
|
@Content(
|
|
mediaType = "application/json",
|
|
schema = @Schema(implementation = Page.class))),
|
|
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
|
})
|
|
@GetMapping
|
|
public ApiResponseDto<Page<Basic>> getMemberList(
|
|
@ParameterObject MembersDto.SearchReq searchReq) {
|
|
return ApiResponseDto.ok(membersService.findByMembers(searchReq));
|
|
}
|
|
|
|
@Operation(
|
|
summary = "사용자 비밀번호 변경",
|
|
description = "로그인 성공후 status가 INACTIVE일때 로그인 id를 memberId로 path 생성필요")
|
|
@ApiResponses(
|
|
value = {
|
|
@ApiResponse(
|
|
responseCode = "201",
|
|
description = "사용자 비밀번호 변경",
|
|
content =
|
|
@Content(
|
|
mediaType = "application/json",
|
|
schema = @Schema(implementation = Long.class))),
|
|
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
|
|
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
|
})
|
|
@PatchMapping("/{memberId}/password")
|
|
public ApiResponseDto<String> resetPassword(
|
|
@PathVariable String memberId, @RequestBody @Valid MembersDto.InitReq initReq) {
|
|
membersService.resetPassword(memberId, initReq);
|
|
return ApiResponseDto.createOK(memberId);
|
|
}
|
|
|
|
@Operation(summary = "관리자 계정 등록", description = "관리자 계정 등록")
|
|
@ApiResponses(
|
|
value = {
|
|
@ApiResponse(
|
|
responseCode = "201",
|
|
description = "등록 성공",
|
|
content =
|
|
@Content(
|
|
mediaType = "application/json",
|
|
schema = @Schema(implementation = Long.class))),
|
|
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
|
|
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
|
})
|
|
@PostMapping("/join")
|
|
public ApiResponseDto<Long> saveMember(
|
|
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
|
description = "관리자 계정 등록",
|
|
required = true,
|
|
content =
|
|
@Content(
|
|
mediaType = "application/json",
|
|
schema = @Schema(implementation = MembersDto.AddReq.class)))
|
|
@RequestBody
|
|
@Valid
|
|
MembersDto.AddReq addReq) {
|
|
|
|
return ApiResponseDto.createOK(adminService.saveMember(addReq));
|
|
}
|
|
|
|
@Operation(summary = "관리자 계정 수정", description = "관리자 계정 수정")
|
|
@ApiResponses(
|
|
value = {
|
|
@ApiResponse(
|
|
responseCode = "201",
|
|
description = "수정 성공",
|
|
content =
|
|
@Content(
|
|
mediaType = "application/json",
|
|
schema = @Schema(implementation = Long.class))),
|
|
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
|
|
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
|
})
|
|
@PutMapping("/{uuid}")
|
|
public ApiResponseDto<UUID> updateMembers(
|
|
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
|
description = "관리자 계정 수정",
|
|
required = true,
|
|
content =
|
|
@Content(
|
|
mediaType = "application/json",
|
|
schema = @Schema(implementation = MembersDto.UpdateReq.class)))
|
|
@PathVariable
|
|
UUID uuid,
|
|
@RequestBody @Valid MembersDto.UpdateReq updateReq) {
|
|
adminService.updateMembers(uuid, updateReq);
|
|
return ApiResponseDto.createOK(UUID.randomUUID());
|
|
}
|
|
|
|
@Operation(summary = "사번 중복 체크", description = "사번 중복 체크")
|
|
@ApiResponses(
|
|
value = {
|
|
@ApiResponse(
|
|
responseCode = "200",
|
|
description = "조회 성공",
|
|
content =
|
|
@Content(
|
|
mediaType = "application/json",
|
|
schema = @Schema(implementation = Boolean.class))),
|
|
@ApiResponse(responseCode = "400", description = "잘못된 요청 데이터", content = @Content),
|
|
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
|
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
|
})
|
|
@GetMapping("/{employeeNo}")
|
|
public ApiResponseDto<Boolean> checkEmployeeNo(
|
|
@Parameter(description = "중복 체크할 사번", required = true, example = "1234567") @PathVariable
|
|
String employeeNo) {
|
|
return ApiResponseDto.ok(adminService.existsByEmployeeNo(employeeNo));
|
|
}
|
|
|
|
@Operation(
|
|
summary = "라벨러/검수자 최종로그인 28일 경과 이후 사용중지(스케줄링 실행)",
|
|
description = "라벨러/검수자 최종로그인 28일 경과 이후 사용중지 처리")
|
|
@GetMapping("/member-inactive-job")
|
|
public ApiResponseDto<Void> memberInactiveJob() {
|
|
memberInactiveJobService.memberActive28daysToInactive();
|
|
return ApiResponseDto.ok(null);
|
|
}
|
|
}
|