사용자등록 추가, 추론결과 dashboard 수정
This commit is contained in:
@@ -1,15 +1,55 @@
|
||||
package com.kamco.cd.kamcoback.auth;
|
||||
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto;
|
||||
import com.kamco.cd.kamcoback.auth.service.AuthService;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
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 lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
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
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/auth")
|
||||
public class AuthApiController {
|
||||
|
||||
@PostMapping("/signup")
|
||||
public void signup() {
|
||||
private final AuthService authService;
|
||||
|
||||
@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("/signup")
|
||||
public ApiResponseDto<Long> signup(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "사용자 정보",
|
||||
required = true,
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = AuthDto.Signup.class)))
|
||||
@RequestBody
|
||||
@Valid
|
||||
AuthDto.Signup signup) {
|
||||
return ApiResponseDto.createOK(authService.signup(signup));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,69 @@
|
||||
package com.kamco.cd.kamcoback.auth.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class AuthDto {
|
||||
|
||||
@Getter
|
||||
public static class Signup {
|
||||
@Setter
|
||||
public static class Basic {
|
||||
|
||||
private String userAuth;
|
||||
private String userNm;
|
||||
private String userId;
|
||||
private String userPw;
|
||||
private String empId;
|
||||
private String userEmail;
|
||||
|
||||
public Basic(String userAuth, String userNm, String userId, String empId, String userEmail) {
|
||||
this.userAuth = userAuth;
|
||||
this.userNm = userNm;
|
||||
this.userId = userId;
|
||||
this.empId = empId;
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "Signup", description = "사용자 등록 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Signup {
|
||||
|
||||
@Schema(description = "구분", example = "관리자/라벨러/검수자 중 하나")
|
||||
@NotBlank
|
||||
private String userAuth;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "이름", example = "홍길동")
|
||||
private String userNm;
|
||||
|
||||
@Schema(description = "ID", example = "gildong")
|
||||
@NotBlank
|
||||
private String userId;
|
||||
|
||||
@Schema(description = "PW", example = "password")
|
||||
@NotBlank
|
||||
private String userPw;
|
||||
|
||||
@Schema(description = "사번", example = "사번")
|
||||
@NotBlank
|
||||
private String empId;
|
||||
|
||||
@Schema(description = "이메일", example = "gildong@naver.com")
|
||||
@NotBlank
|
||||
private String userEmail;
|
||||
|
||||
public Signup(
|
||||
String userAuth,
|
||||
String userNm,
|
||||
String userId,
|
||||
String userPw,
|
||||
String empId,
|
||||
String userEmail
|
||||
) {
|
||||
String userAuth,
|
||||
String userNm,
|
||||
String userId,
|
||||
String userPw,
|
||||
String empId,
|
||||
String userEmail) {
|
||||
this.userAuth = userAuth;
|
||||
this.userNm = userNm;
|
||||
this.userId = userId;
|
||||
@@ -32,4 +72,10 @@ public class AuthDto {
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class User {
|
||||
String userId;
|
||||
String userPw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.kamco.cd.kamcoback.auth.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.AuthCoreService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional(readOnly = true)
|
||||
@RequiredArgsConstructor
|
||||
public class AuthService {
|
||||
private final AuthCoreService authCoreService;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
/**
|
||||
* 사용자 등록
|
||||
*
|
||||
* @param signup
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public Long signup(AuthDto.Signup signup) {
|
||||
signup.setUserPw(passwordEncoder.encode(signup.getUserPw()));
|
||||
return authCoreService.signup(signup);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user