Merge pull request '관리자 관리 추가, 수정' (#16) from feat/demo-20251205 into develop
Reviewed-on: https://kamco.gitea.gs.dabeeo.com/dabeeo/kamco-dabeeo-backoffice/pulls/16
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.kamco.cd.kamcoback.auth;
|
||||
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto;
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto.Basic;
|
||||
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.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;
|
||||
@@ -11,12 +13,17 @@ 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.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "사용자 관리", description = "사용자 관리 API")
|
||||
@Tag(name = "관리자 관리", description = "관리자 관리 API")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/auth")
|
||||
@@ -24,32 +31,129 @@ public class AuthApiController {
|
||||
|
||||
private final AuthService authService;
|
||||
|
||||
@Operation(summary = "사용자 등록", description = "사용자를 등록 합니다.")
|
||||
@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));
|
||||
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("/save")
|
||||
public ApiResponseDto<Long> save(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "관리자 정보",
|
||||
required = true,
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = AuthDto.SaveReq.class)))
|
||||
@RequestBody
|
||||
@Valid
|
||||
AuthDto.SaveReq saveReq) {
|
||||
return ApiResponseDto.createOK(authService.save(saveReq).getId());
|
||||
}
|
||||
|
||||
@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("/update/{id}")
|
||||
public ApiResponseDto<Long> update(
|
||||
@PathVariable
|
||||
Long id,
|
||||
@RequestBody
|
||||
AuthDto.SaveReq saveReq
|
||||
) {
|
||||
return ApiResponseDto.createOK(authService.update(id, saveReq).getId());
|
||||
}
|
||||
|
||||
@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("/withdrawal/{id}")
|
||||
public ApiResponseDto<Long> withdrawal(@PathVariable Long id) {
|
||||
return ApiResponseDto.deleteOk(authService.withdrawal(id).getId());
|
||||
}
|
||||
|
||||
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = AuthDto.Basic.class))),
|
||||
@ApiResponse(responseCode = "404", description = "코드를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@Operation(summary = "관리자 상세조회", description = "관리자 정보를 조회 합니다.")
|
||||
@GetMapping("/detail")
|
||||
public ApiResponseDto<AuthDto.Basic> getDetail(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||
description = "관리자 목록 id",
|
||||
required = true)
|
||||
@RequestParam
|
||||
Long id) {
|
||||
return ApiResponseDto.ok(authService.getFindUserById(id));
|
||||
}
|
||||
|
||||
@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("/list")
|
||||
public ApiResponseDto<Page<Basic>> getUserList(
|
||||
@Parameter(description = "관리자 이름")
|
||||
@RequestParam(required = false) String userNm,
|
||||
@Parameter(description = "페이지 번호 (0부터 시작)", example = "0")
|
||||
@RequestParam(defaultValue = "0") int page,
|
||||
@Parameter(description = "페이지 크기", example = "20")
|
||||
@RequestParam(defaultValue = "20") int size,
|
||||
@Parameter(description = "정렬 조건 (형식: 필드명,방향)", example = "name,asc")
|
||||
@RequestParam(required = false) String sort
|
||||
) {
|
||||
AuthDto.SearchReq searchReq = new AuthDto.SearchReq(userNm, page, size, sort);
|
||||
Page<AuthDto.Basic> userList = authService.getUserList(searchReq);
|
||||
return ApiResponseDto.ok(userList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
package com.kamco.cd.kamcoback.auth.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class AuthDto {
|
||||
@@ -13,25 +20,30 @@ public class AuthDto {
|
||||
@Setter
|
||||
public static class Basic {
|
||||
|
||||
private Long id;
|
||||
private String userAuth;
|
||||
private String userNm;
|
||||
private String userId;
|
||||
private String empId;
|
||||
private String userEmail;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime createdDttm;
|
||||
|
||||
public Basic(String userAuth, String userNm, String userId, String empId, String userEmail) {
|
||||
public Basic(Long id, String userAuth, String userNm, String userId, String empId, String userEmail, ZonedDateTime createdDttm) {
|
||||
this.id = id;
|
||||
this.userAuth = userAuth;
|
||||
this.userNm = userNm;
|
||||
this.userId = userId;
|
||||
this.empId = empId;
|
||||
this.userEmail = userEmail;
|
||||
this.createdDttm = createdDttm;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "Signup", description = "사용자 등록 정보")
|
||||
@Schema(name = "save request", description = "사용자 등록 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Signup {
|
||||
public static class SaveReq {
|
||||
|
||||
@Schema(description = "구분", example = "관리자/라벨러/검수자 중 하나")
|
||||
@NotBlank
|
||||
@@ -57,13 +69,64 @@ public class AuthDto {
|
||||
@NotBlank
|
||||
private String userEmail;
|
||||
|
||||
public Signup(
|
||||
String userAuth,
|
||||
String userNm,
|
||||
String userId,
|
||||
String userPw,
|
||||
String empId,
|
||||
String userEmail) {
|
||||
public SaveReq(
|
||||
String userAuth,
|
||||
String userNm,
|
||||
String userId,
|
||||
String userPw,
|
||||
String empId,
|
||||
String userEmail) {
|
||||
this.userAuth = userAuth;
|
||||
this.userNm = userNm;
|
||||
this.userId = userId;
|
||||
this.userPw = userPw;
|
||||
this.empId = empId;
|
||||
this.userEmail = userEmail;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "update request", description = "사용자 수정 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
public static class UpdateReq {
|
||||
|
||||
@Schema(description = "id", example = "1")
|
||||
@NotBlank
|
||||
private Long id;
|
||||
|
||||
@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 UpdateReq(
|
||||
Long id,
|
||||
String userAuth,
|
||||
String userNm,
|
||||
String userId,
|
||||
String userPw,
|
||||
String empId,
|
||||
String userEmail) {
|
||||
this.id = id;
|
||||
this.userAuth = userAuth;
|
||||
this.userNm = userNm;
|
||||
this.userId = userId;
|
||||
@@ -75,7 +138,35 @@ public class AuthDto {
|
||||
|
||||
@Getter
|
||||
public static class User {
|
||||
|
||||
String userId;
|
||||
String userPw;
|
||||
}
|
||||
|
||||
@Schema(name = "UserSearchReq", description = "관리자 목록 요청 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SearchReq {
|
||||
|
||||
// 검색 조건
|
||||
private String userNm;
|
||||
|
||||
// 페이징 파라미터
|
||||
private int page = 0;
|
||||
private int size = 20;
|
||||
private String sort;
|
||||
|
||||
public Pageable toPageable() {
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||
}
|
||||
return PageRequest.of(page, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.kamco.cd.kamcoback.auth.service;
|
||||
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto;
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto.Basic;
|
||||
import com.kamco.cd.kamcoback.postgres.core.AuthCoreService;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.UserEntity;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -11,18 +14,63 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Transactional(readOnly = true)
|
||||
@RequiredArgsConstructor
|
||||
public class AuthService {
|
||||
|
||||
private final AuthCoreService authCoreService;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
/**
|
||||
* 사용자 등록
|
||||
* 관리자 등록
|
||||
*
|
||||
* @param signup
|
||||
* @param saveReq
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public Long signup(AuthDto.Signup signup) {
|
||||
signup.setUserPw(passwordEncoder.encode(signup.getUserPw()));
|
||||
return authCoreService.signup(signup);
|
||||
public UserEntity save(AuthDto.SaveReq saveReq) {
|
||||
saveReq.setUserPw(passwordEncoder.encode(saveReq.getUserPw()));
|
||||
return authCoreService.save(saveReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 정보 수정
|
||||
*
|
||||
* @param id
|
||||
* @param saveReq
|
||||
* @return
|
||||
*/
|
||||
public UserEntity update(Long id, AuthDto.SaveReq saveReq) {
|
||||
if (saveReq.getUserPw() != null) {
|
||||
saveReq.setUserPw(passwordEncoder.encode(saveReq.getUserPw()));
|
||||
}
|
||||
return authCoreService.update(id, saveReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 삭제
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public UserEntity withdrawal(Long id) {
|
||||
return authCoreService.withdrawal(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 시퀀스 id로 관리자 조회
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public AuthDto.Basic getFindUserById(Long id) {
|
||||
return authCoreService.findUserById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 목록 조회
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
public Page<Basic> getUserList(AuthDto.SearchReq searchReq) {
|
||||
return authCoreService.getUserList(searchReq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
package com.kamco.cd.kamcoback.changedetection;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto;
|
||||
import com.kamco.cd.kamcoback.changedetection.service.ChangeDetectionService;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "변화탐지", description = "변화탐지 API")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@@ -20,8 +23,19 @@ public class ChangeDetectionApiController {
|
||||
|
||||
private final ChangeDetectionService changeDetectionService;
|
||||
|
||||
@Hidden
|
||||
@Deprecated
|
||||
@GetMapping
|
||||
public ApiResponseDto<List<ChangeDetectionDto>> getPolygonToPoint() {
|
||||
public ApiResponseDto<List<ChangeDetectionDto.TestDto>> getPolygonToPoint() {
|
||||
return ApiResponseDto.ok(changeDetectionService.getPolygonToPoint());
|
||||
}
|
||||
|
||||
/**
|
||||
* PolygonData -> JsonNode 변환 예제
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/json-data")
|
||||
public ApiResponseDto<List<JsonNode>> getPolygonToJson(){
|
||||
return ApiResponseDto.ok(changeDetectionService.getPolygonToJson());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,74 @@
|
||||
package com.kamco.cd.kamcoback.changedetection.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
public record ChangeDetectionDto(Long id, Geometry polygon, double centroidX, double centroidY) {}
|
||||
public class ChangeDetectionDto{
|
||||
|
||||
@Schema(name = "TestDto", description = "테스트용")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class TestDto {
|
||||
private Long id;
|
||||
private Geometry polygon;
|
||||
private Double centroidX;;
|
||||
private Double centroidY;
|
||||
}
|
||||
|
||||
@Schema(name = "PolygonGeometry", description = "폴리곤 리턴 객체")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class PointGeometry{
|
||||
private Long geoUid;
|
||||
private String type; // "Point"
|
||||
private Geometry coordinates; //Point 값
|
||||
private String before_class; //기준 분류
|
||||
private String after_class; //비교 분류
|
||||
}
|
||||
|
||||
@Schema(name = "PolygonGeometry", description = "폴리곤 리턴 객체")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class PolygonGeometry{
|
||||
private Long geoUid;
|
||||
private String type; // "MultiPolygon"
|
||||
private Geometry coordinates; //Polygon 값
|
||||
private Double center_latitude; //폴리곤 중심 위도
|
||||
private Double center_longitude; //폴리곤 중심 경도
|
||||
}
|
||||
|
||||
@Schema(name = "CogURL", description = "COG URL")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class CogURL{
|
||||
private String before_cog_url; //기준 COG URL
|
||||
private String after_cog_url; //비교 COG URL
|
||||
}
|
||||
|
||||
@Schema(name = "PolygonProperties", description = "폴리곤 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class PolygonProperties{
|
||||
private Double area; //면적
|
||||
private String before_year; //기준년도
|
||||
private Double before_confidence; //기준 신뢰도(확률)
|
||||
private String before_class; //기준 분류
|
||||
private String after_year; //비교년도
|
||||
private Double after_confidence; //비교 신뢰도(확률)
|
||||
private String after_class; //비교 분류
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.changedetection.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.ChangeDetectionCoreService;
|
||||
import java.util.List;
|
||||
@@ -12,7 +13,11 @@ public class ChangeDetectionService {
|
||||
|
||||
private final ChangeDetectionCoreService changeDetectionCoreService;
|
||||
|
||||
public List<ChangeDetectionDto> getPolygonToPoint() {
|
||||
public List<ChangeDetectionDto.TestDto> getPolygonToPoint() {
|
||||
return changeDetectionCoreService.getPolygonToPoint();
|
||||
}
|
||||
|
||||
public List<JsonNode> getPolygonToJson(){
|
||||
return changeDetectionCoreService.getPolygonToJson();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ public class InferenceResultDto {
|
||||
@Getter
|
||||
public static class AnalResSummary {
|
||||
private Long id;
|
||||
private String analTitle;
|
||||
private String modelInfo;
|
||||
private Integer targetYyyy;
|
||||
private Integer compareYyyy;
|
||||
@@ -108,6 +109,7 @@ public class InferenceResultDto {
|
||||
|
||||
public AnalResSummary(
|
||||
Long id,
|
||||
String analTitle,
|
||||
String modelInfo,
|
||||
Integer targetYyyy,
|
||||
Integer compareYyyy,
|
||||
@@ -122,6 +124,7 @@ public class InferenceResultDto {
|
||||
String analState,
|
||||
String analStateNm) {
|
||||
this.id = id;
|
||||
this.analTitle = analTitle;
|
||||
this.modelInfo = modelInfo;
|
||||
this.targetYyyy = targetYyyy;
|
||||
this.compareYyyy = compareYyyy;
|
||||
|
||||
@@ -1,26 +1,118 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto;
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto.SaveReq;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.UserEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.auth.AuthRepository;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AuthCoreService {
|
||||
|
||||
private final AuthRepository authRepository;
|
||||
|
||||
/**
|
||||
* 사용자 등록
|
||||
* 관리자 등록
|
||||
*
|
||||
* @param signup
|
||||
* @param saveReq
|
||||
* @return
|
||||
*/
|
||||
public Long signup(AuthDto.Signup signup) {
|
||||
if (authRepository.findByUserId(signup.getUserId()).isPresent()) {
|
||||
new EntityNotFoundException("중복된 아이디가 있습니다. " + signup.getUserId());
|
||||
public UserEntity save(SaveReq saveReq) {
|
||||
if (authRepository.findByUserId(saveReq.getUserId()).isPresent()) {
|
||||
new EntityNotFoundException("중복된 아이디가 있습니다. " + saveReq.getUserId());
|
||||
}
|
||||
return authRepository.signup(signup);
|
||||
|
||||
UserEntity userEntity = new UserEntity(
|
||||
null,
|
||||
saveReq.getUserAuth(),
|
||||
saveReq.getUserNm(),
|
||||
saveReq.getUserId(),
|
||||
saveReq.getEmpId(),
|
||||
saveReq.getUserEmail(),
|
||||
saveReq.getUserPw()
|
||||
);
|
||||
|
||||
return authRepository.save(userEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 정보 수정
|
||||
*
|
||||
* @param id
|
||||
* @param saveReq
|
||||
* @return
|
||||
*/
|
||||
public UserEntity update(Long id, AuthDto.SaveReq saveReq) {
|
||||
UserEntity userEntity = authRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("유저가 존재하지 않습니다."));
|
||||
|
||||
if (saveReq.getUserAuth() != null) {
|
||||
userEntity.setUserAuth(saveReq.getUserAuth());
|
||||
}
|
||||
|
||||
if (saveReq.getUserNm() != null) {
|
||||
userEntity.setUserNm(saveReq.getUserNm());
|
||||
}
|
||||
|
||||
if (saveReq.getUserId() != null) {
|
||||
userEntity.setUserId(saveReq.getUserId());
|
||||
}
|
||||
|
||||
if (saveReq.getEmpId() != null) {
|
||||
userEntity.setEmpId(saveReq.getEmpId());
|
||||
}
|
||||
|
||||
if (saveReq.getUserEmail() != null) {
|
||||
userEntity.setUserEmail(saveReq.getUserEmail());
|
||||
}
|
||||
|
||||
if (saveReq.getUserPw() != null) {
|
||||
userEntity.setUserPw(saveReq.getUserPw());
|
||||
}
|
||||
|
||||
return authRepository.save(userEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 삭제
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public UserEntity withdrawal(Long id) {
|
||||
UserEntity userEntity = authRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("유저가 존재하지 않습니다."));
|
||||
|
||||
userEntity.setId(id);
|
||||
userEntity.setDateWithdrawal(ZonedDateTime.now());
|
||||
userEntity.setState("WITHDRAWAL");
|
||||
|
||||
return authRepository.save(userEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 시퀀스 id로 관리자 조회
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public AuthDto.Basic findUserById(Long id) {
|
||||
UserEntity entity = authRepository.findUserById(id).orElseThrow(() -> new EntityNotFoundException("관리자를 찾을 수 없습니다. " + id));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 목록 조회
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
public Page<AuthDto.Basic> getUserList(AuthDto.SearchReq searchReq) {
|
||||
return authRepository.getUserList(searchReq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.kamco.cd.kamcoback.postgres.core;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.kamcoback.changedetection.dto.ChangeDetectionDto;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.repository.changedetection.ChangeDetectionRepository;
|
||||
@@ -16,7 +19,7 @@ public class ChangeDetectionCoreService {
|
||||
|
||||
private final ChangeDetectionRepository changeDetectionRepository;
|
||||
|
||||
public List<ChangeDetectionDto> getPolygonToPoint() {
|
||||
public List<ChangeDetectionDto.TestDto> getPolygonToPoint() {
|
||||
List<MapSheetAnalDataGeomEntity> list = changeDetectionRepository.findAll();
|
||||
|
||||
return list.stream()
|
||||
@@ -26,8 +29,24 @@ public class ChangeDetectionCoreService {
|
||||
// 중심 좌표 계산
|
||||
Point centroid = polygon.getCentroid();
|
||||
|
||||
return new ChangeDetectionDto(p.getId(), polygon, centroid.getX(), centroid.getY());
|
||||
return new ChangeDetectionDto.TestDto(p.getId(), polygon, centroid.getX(), centroid.getY());
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<JsonNode> getPolygonToJson() {
|
||||
List<String> list = changeDetectionRepository.findPolygonJson();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
return list.stream()
|
||||
.map(
|
||||
s -> {
|
||||
try {
|
||||
return mapper.readTree(s);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import jakarta.persistence.Id;
|
||||
import jakarta.persistence.SequenceGenerator;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
@@ -72,8 +73,7 @@ public class MapSheetAnalDataEntity {
|
||||
private Integer targetYyyy;
|
||||
|
||||
@Column(name = "data_json")
|
||||
@JdbcTypeCode(SqlTypes.JSON)
|
||||
private Map<String, Object> dataJson;
|
||||
private String dataJson;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "data_state", length = 20)
|
||||
@@ -99,9 +99,55 @@ public class MapSheetAnalDataEntity {
|
||||
@Column(name = "anal_uid")
|
||||
private Long analUid;
|
||||
|
||||
@Column(name = "map_sheep_num")
|
||||
private Long mapSheepNum;
|
||||
@Column(name = "map_sheet_num")
|
||||
private Long mapSheetNum;
|
||||
|
||||
@Column(name = "detecting_cnt")
|
||||
private Long detectingCnt;
|
||||
|
||||
@ColumnDefault("0")
|
||||
@Column(name = "pnu")
|
||||
private Long pnu;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "down_state", length = 20)
|
||||
private String downState;
|
||||
|
||||
@Column(name = "down_state_dttm")
|
||||
private OffsetDateTime downStateDttm;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "fit_state", length = 20)
|
||||
private String fitState;
|
||||
|
||||
@Column(name = "fit_state_dttm")
|
||||
private OffsetDateTime fitStateDttm;
|
||||
|
||||
@Column(name = "labeler_uid")
|
||||
private Long labelerUid;
|
||||
|
||||
@Size(max = 20)
|
||||
@ColumnDefault("NULL")
|
||||
@Column(name = "label_state", length = 20)
|
||||
private String labelState;
|
||||
|
||||
@Column(name = "label_state_dttm")
|
||||
private OffsetDateTime labelStateDttm;
|
||||
|
||||
@Column(name = "tester_uid")
|
||||
private Long testerUid;
|
||||
|
||||
@Size(max = 20)
|
||||
@Column(name = "test_state", length = 20)
|
||||
private String testState;
|
||||
|
||||
@Column(name = "test_state_dttm")
|
||||
private OffsetDateTime testStateDttm;
|
||||
|
||||
@Column(name = "fit_state_cmmnt", length = Integer.MAX_VALUE)
|
||||
private String fitStateCmmnt;
|
||||
|
||||
@Column(name = "ref_map_sheet_num")
|
||||
private Long refMapSheetNum;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
@@ -11,24 +12,27 @@ import jakarta.persistence.UniqueConstraint;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@Table(
|
||||
name = "tb_user",
|
||||
uniqueConstraints = {@UniqueConstraint(name = "ux_tb_user_user_id", columnNames = "user_id")})
|
||||
name = "tb_user",
|
||||
uniqueConstraints = {@UniqueConstraint(name = "ux_tb_user_user_id", columnNames = "user_id")})
|
||||
public class UserEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tb_user_id_gen")
|
||||
@SequenceGenerator(
|
||||
name = "tb_user_id_gen",
|
||||
sequenceName = "tb_user_user_uid_seq",
|
||||
allocationSize = 1)
|
||||
name = "tb_user_id_gen",
|
||||
sequenceName = "tb_user_user_uid_seq",
|
||||
allocationSize = 1)
|
||||
@Column(name = "user_uid", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@@ -51,7 +55,7 @@ public class UserEntity {
|
||||
@NotNull
|
||||
@ColumnDefault("'ACTIVE'")
|
||||
@Column(name = "state", nullable = false)
|
||||
private String state;
|
||||
private String state = "ACTIVE";
|
||||
|
||||
@Column(name = "date_withdrawal")
|
||||
private ZonedDateTime dateWithdrawal;
|
||||
@@ -83,4 +87,27 @@ public class UserEntity {
|
||||
@NotNull
|
||||
@Column(name = "emp_id", nullable = false)
|
||||
private String empId;
|
||||
|
||||
public UserEntity(Long id, String userAuth, String userNm, String userId, String empId, String userEmail, String userPw) {
|
||||
this.id = id;
|
||||
this.userAuth = userAuth;
|
||||
this.userNm = userNm;
|
||||
this.userId = userId;
|
||||
this.empId = empId;
|
||||
this.userEmail = userEmail;
|
||||
this.userPw = userPw;
|
||||
}
|
||||
|
||||
public AuthDto.Basic toDto() {
|
||||
return new AuthDto.Basic(
|
||||
this.id,
|
||||
this.userAuth,
|
||||
this.userNm,
|
||||
this.userId,
|
||||
this.empId,
|
||||
this.userEmail,
|
||||
this.createdDttm
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ public class InferenceResultRepositoryImpl implements InferenceResultRepositoryC
|
||||
Projections.constructor(
|
||||
InferenceResultDto.AnalResSummary.class,
|
||||
mapSheetAnal.id,
|
||||
mapSheetAnal.analTitle,
|
||||
tmm.modelNm.concat(" ").concat(tmv.modelVer).as("modelInfo"),
|
||||
mapSheetAnal.targetYyyy,
|
||||
mapSheetAnal.compareYyyy,
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.auth;
|
||||
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto;
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto.Basic;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.UserEntity;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
public interface AuthRepositoryCustom {
|
||||
Long signup(AuthDto.Signup signup);
|
||||
|
||||
Optional<UserEntity> findByUserId(String userId);
|
||||
|
||||
Optional<UserEntity> findUserById(Long id);
|
||||
|
||||
Page<Basic> getUserList(AuthDto.SearchReq searchReq);
|
||||
}
|
||||
|
||||
@@ -1,48 +1,31 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.auth;
|
||||
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto;
|
||||
import com.kamco.cd.kamcoback.auth.dto.AuthDto.Basic;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.QUserEntity;
|
||||
import com.kamco.cd.kamcoback.postgres.entity.UserEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class AuthRepositoryImpl implements AuthRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final QUserEntity userEntity = QUserEntity.userEntity;
|
||||
|
||||
/**
|
||||
* 사용자 등록
|
||||
*
|
||||
* @param signup
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Long signup(AuthDto.Signup signup) {
|
||||
return queryFactory
|
||||
.insert(userEntity)
|
||||
.columns(
|
||||
userEntity.userAuth,
|
||||
userEntity.userId,
|
||||
userEntity.userNm,
|
||||
userEntity.userPw,
|
||||
userEntity.userEmail,
|
||||
userEntity.empId)
|
||||
.values(
|
||||
signup.getUserAuth(),
|
||||
signup.getUserId(),
|
||||
signup.getUserNm(),
|
||||
signup.getUserPw(),
|
||||
signup.getUserEmail(),
|
||||
signup.getEmpId())
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* 유저 아이디 조회
|
||||
* 유저 아이디로 조회
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
@@ -50,6 +33,63 @@ public class AuthRepositoryImpl implements AuthRepositoryCustom {
|
||||
@Override
|
||||
public Optional<UserEntity> findByUserId(String userId) {
|
||||
return Optional.ofNullable(
|
||||
queryFactory.selectFrom(userEntity).where(userEntity.userId.eq(userId)).fetchOne());
|
||||
queryFactory.selectFrom(userEntity).where(userEntity.userId.eq(userId)).fetchOne());
|
||||
}
|
||||
|
||||
/**
|
||||
* 유저 시퀀스 id로 조회
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Optional<UserEntity> findUserById(Long id) {
|
||||
return Optional.ofNullable(
|
||||
queryFactory.selectFrom(userEntity).where(userEntity.id.eq(id)).fetchOne());
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 목록 조회
|
||||
*
|
||||
* @param searchReq
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Page<Basic> getUserList(AuthDto.SearchReq searchReq) {
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
if (searchReq.getUserNm() != null && !searchReq.getUserNm().isEmpty()) {
|
||||
builder.and(likeName(userEntity, searchReq.getUserNm()));
|
||||
}
|
||||
|
||||
List<Basic> content =
|
||||
queryFactory
|
||||
.select(Projections.constructor(AuthDto.Basic.class,
|
||||
userEntity.id,
|
||||
userEntity.userAuth,
|
||||
userEntity.userNm,
|
||||
userEntity.userId,
|
||||
userEntity.empId,
|
||||
userEntity.userEmail,
|
||||
userEntity.createdDttm
|
||||
))
|
||||
.from(userEntity)
|
||||
.where(
|
||||
builder
|
||||
)
|
||||
.orderBy(userEntity.userId.asc())
|
||||
.fetch();
|
||||
|
||||
long total =
|
||||
queryFactory.select(userEntity.id).from(userEntity).where(builder).fetchCount();
|
||||
return new PageImpl<>(content, pageable, total);
|
||||
}
|
||||
|
||||
private BooleanExpression likeName(QUserEntity entity, String nameStr) {
|
||||
if (nameStr == null || nameStr.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
// ex) WHERE LOWER(name) LIKE LOWER('%입력값%')
|
||||
return entity.userNm.containsIgnoreCase(nameStr.trim());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.kamco.cd.kamcoback.postgres.repository.changedetection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ChangeDetectionRepositoryCustom {
|
||||
|
||||
String getPolygonToPoint();
|
||||
|
||||
List<String> findPolygonJson();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kamco.cd.kamcoback.postgres.repository.changedetection;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetAnalDataGeomEntity.mapSheetAnalDataGeomEntity;
|
||||
|
||||
import com.kamco.cd.kamcoback.postgres.entity.MapSheetAnalDataGeomEntity;
|
||||
import com.querydsl.core.types.dsl.Expressions;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
@@ -23,10 +24,14 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<MapSheetAnalDataGeomEntity> findAll() {
|
||||
@Override
|
||||
public List<String> findPolygonJson(){
|
||||
return queryFactory
|
||||
.selectFrom(mapSheetAnalDataGeomEntity)
|
||||
.orderBy(mapSheetAnalDataGeomEntity.id.desc())
|
||||
.fetch();
|
||||
.select(
|
||||
Expressions.stringTemplate("ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geom)
|
||||
)
|
||||
.from(mapSheetAnalDataGeomEntity)
|
||||
.orderBy(mapSheetAnalDataGeomEntity.id.desc())
|
||||
.fetch();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user