관리자 관리 추가, 수정
This commit is contained in:
@@ -75,12 +75,7 @@ public class AuthApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PutMapping("/update/{id}")
|
||||
public ApiResponseDto<Long> update(
|
||||
@PathVariable
|
||||
Long id,
|
||||
@RequestBody
|
||||
AuthDto.SaveReq saveReq
|
||||
) {
|
||||
public ApiResponseDto<Long> update(@PathVariable Long id, @RequestBody AuthDto.SaveReq saveReq) {
|
||||
return ApiResponseDto.createOK(authService.update(id, saveReq).getId());
|
||||
}
|
||||
|
||||
@@ -103,7 +98,6 @@ public class AuthApiController {
|
||||
return ApiResponseDto.deleteOk(authService.withdrawal(id).getId());
|
||||
}
|
||||
|
||||
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
@@ -142,18 +136,16 @@ public class AuthApiController {
|
||||
})
|
||||
@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 = "관리자 이름") @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
|
||||
) {
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,10 +26,16 @@ public class AuthDto {
|
||||
private String userId;
|
||||
private String empId;
|
||||
private String userEmail;
|
||||
@JsonFormatDttm
|
||||
private ZonedDateTime createdDttm;
|
||||
@JsonFormatDttm private ZonedDateTime createdDttm;
|
||||
|
||||
public Basic(Long id, String userAuth, String userNm, String userId, String empId, String userEmail, ZonedDateTime createdDttm) {
|
||||
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;
|
||||
|
||||
@@ -7,13 +7,12 @@ 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
|
||||
@@ -32,10 +31,11 @@ public class ChangeDetectionApiController {
|
||||
|
||||
/**
|
||||
* PolygonData -> JsonNode 변환 예제
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/json-data")
|
||||
public ApiResponseDto<List<JsonNode>> getPolygonToJson(){
|
||||
public ApiResponseDto<List<JsonNode>> getPolygonToJson() {
|
||||
return ApiResponseDto.ok(changeDetectionService.getPolygonToJson());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
public class ChangeDetectionDto{
|
||||
public class ChangeDetectionDto {
|
||||
|
||||
@Schema(name = "TestDto", description = "테스트용")
|
||||
@Getter
|
||||
@@ -17,7 +17,8 @@ public class ChangeDetectionDto{
|
||||
public static class TestDto {
|
||||
private Long id;
|
||||
private Geometry polygon;
|
||||
private Double centroidX;;
|
||||
private Double centroidX;
|
||||
;
|
||||
private Double centroidY;
|
||||
}
|
||||
|
||||
@@ -26,12 +27,12 @@ public class ChangeDetectionDto{
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class PointGeometry{
|
||||
public static class PointGeometry {
|
||||
private Long geoUid;
|
||||
private String type; // "Point"
|
||||
private Geometry coordinates; //Point 값
|
||||
private String before_class; //기준 분류
|
||||
private String after_class; //비교 분류
|
||||
private Geometry coordinates; // Point 값
|
||||
private String before_class; // 기준 분류
|
||||
private String after_class; // 비교 분류
|
||||
}
|
||||
|
||||
@Schema(name = "PolygonGeometry", description = "폴리곤 리턴 객체")
|
||||
@@ -39,12 +40,12 @@ public class ChangeDetectionDto{
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class PolygonGeometry{
|
||||
public static class PolygonGeometry {
|
||||
private Long geoUid;
|
||||
private String type; // "MultiPolygon"
|
||||
private Geometry coordinates; //Polygon 값
|
||||
private Double center_latitude; //폴리곤 중심 위도
|
||||
private Double center_longitude; //폴리곤 중심 경도
|
||||
private Geometry coordinates; // Polygon 값
|
||||
private Double center_latitude; // 폴리곤 중심 위도
|
||||
private Double center_longitude; // 폴리곤 중심 경도
|
||||
}
|
||||
|
||||
@Schema(name = "CogURL", description = "COG URL")
|
||||
@@ -52,9 +53,9 @@ public class ChangeDetectionDto{
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class CogURL{
|
||||
private String before_cog_url; //기준 COG URL
|
||||
private String after_cog_url; //비교 COG URL
|
||||
public static class CogURL {
|
||||
private String before_cog_url; // 기준 COG URL
|
||||
private String after_cog_url; // 비교 COG URL
|
||||
}
|
||||
|
||||
@Schema(name = "PolygonProperties", description = "폴리곤 정보")
|
||||
@@ -62,13 +63,13 @@ public class ChangeDetectionDto{
|
||||
@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; //비교 분류
|
||||
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; // 비교 분류
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ChangeDetectionService {
|
||||
return changeDetectionCoreService.getPolygonToPoint();
|
||||
}
|
||||
|
||||
public List<JsonNode> getPolygonToJson(){
|
||||
public List<JsonNode> getPolygonToJson() {
|
||||
return changeDetectionCoreService.getPolygonToJson();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ public class AuthCoreService {
|
||||
new EntityNotFoundException("중복된 아이디가 있습니다. " + saveReq.getUserId());
|
||||
}
|
||||
|
||||
UserEntity userEntity = new UserEntity(
|
||||
UserEntity userEntity =
|
||||
new UserEntity(
|
||||
null,
|
||||
saveReq.getUserAuth(),
|
||||
saveReq.getUserNm(),
|
||||
saveReq.getUserId(),
|
||||
saveReq.getEmpId(),
|
||||
saveReq.getUserEmail(),
|
||||
saveReq.getUserPw()
|
||||
);
|
||||
saveReq.getUserPw());
|
||||
|
||||
return authRepository.save(userEntity);
|
||||
}
|
||||
@@ -48,8 +48,8 @@ public class AuthCoreService {
|
||||
* @return
|
||||
*/
|
||||
public UserEntity update(Long id, AuthDto.SaveReq saveReq) {
|
||||
UserEntity userEntity = authRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("유저가 존재하지 않습니다."));
|
||||
UserEntity userEntity =
|
||||
authRepository.findById(id).orElseThrow(() -> new RuntimeException("유저가 존재하지 않습니다."));
|
||||
|
||||
if (saveReq.getUserAuth() != null) {
|
||||
userEntity.setUserAuth(saveReq.getUserAuth());
|
||||
@@ -85,8 +85,8 @@ public class AuthCoreService {
|
||||
* @return
|
||||
*/
|
||||
public UserEntity withdrawal(Long id) {
|
||||
UserEntity userEntity = authRepository.findById(id)
|
||||
.orElseThrow(() -> new RuntimeException("유저가 존재하지 않습니다."));
|
||||
UserEntity userEntity =
|
||||
authRepository.findById(id).orElseThrow(() -> new RuntimeException("유저가 존재하지 않습니다."));
|
||||
|
||||
userEntity.setId(id);
|
||||
userEntity.setDateWithdrawal(ZonedDateTime.now());
|
||||
@@ -102,7 +102,10 @@ public class AuthCoreService {
|
||||
* @return
|
||||
*/
|
||||
public AuthDto.Basic findUserById(Long id) {
|
||||
UserEntity entity = authRepository.findUserById(id).orElseThrow(() -> new EntityNotFoundException("관리자를 찾을 수 없습니다. " + id));
|
||||
UserEntity entity =
|
||||
authRepository
|
||||
.findUserById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("관리자를 찾을 수 없습니다. " + id));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ public class ChangeDetectionCoreService {
|
||||
// 중심 좌표 계산
|
||||
Point centroid = polygon.getCentroid();
|
||||
|
||||
return new ChangeDetectionDto.TestDto(p.getId(), polygon, centroid.getX(), centroid.getY());
|
||||
return new ChangeDetectionDto.TestDto(
|
||||
p.getId(), polygon, centroid.getX(), centroid.getY());
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -10,12 +10,9 @@ import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -149,5 +146,4 @@ public class MapSheetAnalDataEntity {
|
||||
|
||||
@Column(name = "ref_map_sheet_num")
|
||||
private Long refMapSheetNum;
|
||||
|
||||
}
|
||||
|
||||
@@ -88,7 +88,14 @@ public class UserEntity {
|
||||
@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) {
|
||||
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;
|
||||
@@ -106,8 +113,6 @@ public class UserEntity {
|
||||
this.userId,
|
||||
this.empId,
|
||||
this.userEmail,
|
||||
this.createdDttm
|
||||
);
|
||||
|
||||
this.createdDttm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ public class AuthRepositoryImpl implements AuthRepositoryCustom {
|
||||
private final JPAQueryFactory queryFactory;
|
||||
private final QUserEntity userEntity = QUserEntity.userEntity;
|
||||
|
||||
|
||||
/**
|
||||
* 유저 아이디로 조회
|
||||
*
|
||||
@@ -64,24 +63,22 @@ public class AuthRepositoryImpl implements AuthRepositoryCustom {
|
||||
|
||||
List<Basic> content =
|
||||
queryFactory
|
||||
.select(Projections.constructor(AuthDto.Basic.class,
|
||||
.select(
|
||||
Projections.constructor(
|
||||
AuthDto.Basic.class,
|
||||
userEntity.id,
|
||||
userEntity.userAuth,
|
||||
userEntity.userNm,
|
||||
userEntity.userId,
|
||||
userEntity.empId,
|
||||
userEntity.userEmail,
|
||||
userEntity.createdDttm
|
||||
))
|
||||
userEntity.createdDttm))
|
||||
.from(userEntity)
|
||||
.where(
|
||||
builder
|
||||
)
|
||||
.where(builder)
|
||||
.orderBy(userEntity.userId.asc())
|
||||
.fetch();
|
||||
|
||||
long total =
|
||||
queryFactory.select(userEntity.id).from(userEntity).where(builder).fetchCount();
|
||||
long total = queryFactory.select(userEntity.id).from(userEntity).where(builder).fetchCount();
|
||||
return new PageImpl<>(content, pageable, total);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,9 @@ public class ChangeDetectionRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findPolygonJson(){
|
||||
public List<String> findPolygonJson() {
|
||||
return queryFactory
|
||||
.select(
|
||||
Expressions.stringTemplate("ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geom)
|
||||
)
|
||||
.select(Expressions.stringTemplate("ST_AsGeoJSON({0})", mapSheetAnalDataGeomEntity.geom))
|
||||
.from(mapSheetAnalDataGeomEntity)
|
||||
.orderBy(mapSheetAnalDataGeomEntity.id.desc())
|
||||
.fetch();
|
||||
|
||||
Reference in New Issue
Block a user