diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/CtgyFileMgtController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/CtgyFileMgtController.java new file mode 100644 index 0000000..c0ed87f --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/CtgyFileMgtController.java @@ -0,0 +1,165 @@ +package com.xit.biz.ctgy.v2.controller; + +import com.xit.biz.ctgy.dto.MinInfoBoard680Dto; +import com.xit.biz.ctgy.entity.MinInfoBoard680; +import com.xit.biz.ctgy.service.ICtgyFileService; +import com.xit.core.api.IRestResponse; +import com.xit.core.api.RestResponse; +import com.xit.core.constant.ErrorCode; +import com.xit.core.exception.CustomBaseException; +import com.xit.core.util.AssertUtils; +import com.xit.core.util.Checks; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.apache.commons.io.FileUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.core.io.InputStreamResource; +import org.springframework.core.io.Resource; +import org.springframework.http.*; +import org.springframework.lang.NonNull; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Nonnull; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; + +@Tag(name = "CtgyFileMgtController", description = "공지사항 / 게시판 관리") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v2/ctgy/file") +public class CtgyFileMgtController { + + private final Environment env; + + @Value("${file.cmm.upload.root:c:/data/file/upload}") + private String rootPath; + + @Value("${file.cmm.upload.path:/kangnamSIM/simUpFile/}") + private String uploadPath; + + @Value("${file.cmm.upload.url}") + private String serviceUrl; + + private final ICtgyFileService service; + + @Operation(summary = "파일 조회", description = "등록된 파일 조회") + @GetMapping("/{id}") + public ResponseEntity findFiles(@PathVariable("inCode") @NonNull final Long inCode) { + AssertUtils.isTrue(!Checks.isEmpty(inCode), "대상 게시글[inCode]을 선택해 주세요."); + return RestResponse.of(service.findFiles(inCode)); + } + + @Operation(summary = "공지사항 저장", description = "공지사항 저장") + @PostMapping(value = "/pboard", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity savePublicBoardFiles(@Nonnull MinInfoBoard680Dto dto) { + AssertUtils.isTrue(!Checks.isEmpty(dto), "파일 정보가 존재하지 않습니다."); + + return RestResponse.of(service.saveFiles(dto)); + } + + @Operation(summary = "공지사항 삭제", description = "공지사항 삭제") + @PostMapping(value = "/pboard/{inCode}") + public ResponseEntity removePublicBoardFile(@PathVariable @Nonnull final Long inCode) { + AssertUtils.isTrue(!Checks.isEmpty(inCode), "공지 사항이 선택되지 않았습니다."); + service.removePublicBoardFile(inCode); + + return RestResponse.of(HttpStatus.OK); + } + + @GetMapping("/download/{inCode}") + public void download2(@PathVariable Long inCode, HttpServletResponse response) { + + MinInfoBoard680 entity = service.findFiles(inCode); + + String absFile = ""; + + if (Arrays.asList(env.getActiveProfiles()).contains("prod")) + absFile = entity.getInFileurl() + File.separator + entity.getInFilename(); + else + absFile = rootPath + entity.getInFileurl().split(serviceUrl)[1] + File.separator + entity.getInFilename(); + + Path path = Paths.get(absFile); + String contentType = null; + try { + contentType = Files.probeContentType(path); + } catch (IOException e) { + throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); + } + + File file = new File(absFile); + byte[] fileByte = new byte[0]; + try { + fileByte = FileUtils.readFileToByteArray(file); + } catch (IOException e) { + throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); + } + + response.setContentType(contentType); + response.setHeader(HttpHeaders.CONTENT_TYPE, contentType); + response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"); + response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(entity.getInFilename(), StandardCharsets.UTF_8) + "\";"); + //response.setHeader(HttpHeaders.CONTENT_ENCODING, "binary"); + response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(entity.getInFilesize())); + try { + response.getOutputStream().write(fileByte); + response.getOutputStream().flush(); + response.getOutputStream().close(); + } catch (IOException e) { + throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); + } + } + + @GetMapping("/download2/{inCode}") + public ResponseEntity download(@PathVariable Long inCode, HttpServletResponse response) { + + MinInfoBoard680 entity = service.findFiles(inCode); + + String absFile = ""; + + if (Arrays.asList(env.getActiveProfiles()).contains("prod")) + absFile = entity.getInFileurl() + File.separator + entity.getInFilename(); + else + absFile = rootPath + entity.getInFileurl().split(serviceUrl)[1] + File.separator + entity.getInFilename(); + + Path path = Paths.get(absFile); + String contentType = null; + try { + contentType = Files.probeContentType(path); + } catch (IOException e) { + throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); + } + +// File file = new File(absFile); +// try { +// byte[] fileByte = FileUtils.readFileToByteArray(file); +// } catch (IOException e) { +// throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); +// } + + + HttpHeaders headers = new HttpHeaders(); + headers.add(HttpHeaders.CONTENT_TYPE, contentType); + headers.setContentDisposition(ContentDisposition.builder("attachment") + .filename(entity.getInFilename(), StandardCharsets.UTF_8) + //.filename(URLEncoder.encode(entity.getInFilename(), StandardCharsets.UTF_8)) + .build()); + headers.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(entity.getInFilesize())); + + Resource resource = null; + try { + resource = new InputStreamResource(Files.newInputStream(path)); + } catch (IOException e) { + throw new CustomBaseException(ErrorCode.FILE_NOT_FOUND); + } + return new ResponseEntity<>(resource, headers, HttpStatus.OK); + } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/MinUserController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/MinUserController.java new file mode 100644 index 0000000..05e9a11 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/MinUserController.java @@ -0,0 +1,91 @@ +package com.xit.biz.ctgy.v2.controller; + +import com.xit.biz.ctgy.dto.MinUserinfoDto; +import com.xit.biz.ctgy.dto.struct.MinUserinfoMapstruct; +import com.xit.biz.ctgy.service.IMinUserService; +import com.xit.core.annotation.Secured; +import com.xit.core.annotation.SecurityPolicy; +import com.xit.core.api.IRestResponse; +import com.xit.core.api.RestResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.mapstruct.factory.Mappers; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@Tag(name = "MinUserController", description = "사용자 관리") +@RestController +@RequestMapping("/api/v2/ctgy/user") +@Validated +@RequiredArgsConstructor +public class MinUserController { + + private final IMinUserService service; + + private final MinUserinfoMapstruct mapstruct = Mappers.getMapper(MinUserinfoMapstruct.class); + + // TODO :: 파라메터 정의 필요 + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "사용자 목록 조회" , description = "사용자 목록 조회") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "userid", description = "사용자ID", required = false, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "name", description = "이름", required = false, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "team", description = "팀", required = false, example = "001"), + @Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"), + @Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10") + }) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findMinUsers( + @Parameter(hidden = true) + final MinUserinfoDto minUserinfoDto, + @Parameter(hidden = true) + final Pageable pageable) { + return RestResponse.of(service.findMinUsers(mapstruct.toEntity(minUserinfoDto), pageable)); + } + + @Operation(summary = "사용자 정보 조회" , description = "사용자 정보 조회") + @GetMapping("/info") + @Secured(policy = SecurityPolicy.TOKEN) + @Transactional(readOnly = true) + public ResponseEntity getMinUser() { + return RestResponse.of(service.findMinUser()); + } + + @Operation(summary = "사용자 정보 조회" , description = "사용자 정보 조회") + @GetMapping("/{userid}") + //@Transactional(readOnly = true) + public ResponseEntity getMinUser(@PathVariable final String userid) { + return RestResponse.of(service.findMinUserByUserid(userid)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "사용자 정보 저장" , description = "사용자 정보 저장") + @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity saveMinUser( + @Valid + final MinUserinfoDto minUserinfoDto) { + service.saveMinUser(minUserinfoDto); + return RestResponse.of(HttpStatus.OK); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "사용자 삭제" , description = "사용자 삭제") + @PutMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity removeMinUser( + @Valid + final MinUserinfoDto minUserinfoDto) { + service.removeMinUser(minUserinfoDto); + return RestResponse.of(HttpStatus.OK); + } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/OAuth2MinController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/OAuth2MinController.java new file mode 100644 index 0000000..9e001b8 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/OAuth2MinController.java @@ -0,0 +1,164 @@ +package com.xit.biz.ctgy.v2.controller; + +import com.xit.biz.ctgy.auth.service.IAuthMinService; +import com.xit.biz.ctgy.dto.LoginMinRequestDto; +import com.xit.core.api.IRestResponse; +import com.xit.core.api.RestResponse; +import com.xit.core.oauth2.api.dto.TokenRequestDto; +import com.xit.core.oauth2.oauth.JwtTokenProvider; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +@Tag(name = "OAuth2MinController", description = "인증 관리") +@RestController +@RequestMapping("/api/v2/ctgy/account") +@Validated +@RequiredArgsConstructor +public class OAuth2MinController { + + + private final IAuthMinService authMinService; + + + /** + *
+     * 로그인 요청을 처리(Redis에 저장)하고 토큰(Access + Refresh) return
+     *
+     * 1. Login ID, PW 로 인증 정보 객체 UsernamePasswordAuthenticationToken 생성
+     * 2. AuthenticationManager에 authenticate 메소드의 파라미터로 넘겨, 검증 후 Authentication(사용자ID가 들어있다) return
+     *    AuthenticationManager --> 스프링 시큐리티의 실제 인증이 이루어지는 곳
+     *                              authenticate 메소드 하나만 정의되어 있는 인터페이스
+     *                              Builder 에서 UserDetails 의 유저 정보가 서로 일치하는지 검사
+     * 3. 인증정보로 JWT 토큰 생성
+     * 4. Refresh 토큰 저장 : : Redis에 저장
+     * 5. 토큰(Access + Refresh) return
+     * 
+ * @see AuthenticationManagerBuilder + * @see JwtTokenProvider + * + * @param loginRequestDto LoginMinRequestDto + * @param request HttpServletRequest + * @param response HttpServletResponse + * @param session Session + * @return ResponseEntity + */ + @Operation(summary = "login" , description = "login") + @PostMapping("/login") + @Transactional + public ResponseEntity login( + @Valid + @RequestBody + final LoginMinRequestDto loginRequestDto, + HttpServletRequest request, + HttpServletResponse response, + HttpSession session + ) { + return RestResponse.of( + authMinService.login( + loginRequestDto, + request, + response, + session + ) + ); + + } + + /** + *
+     * JWT token 재발급
+     * access token - header, refresh - TokenRequestDto 에 담아 요청
+     *
+     * 1. access token의 유효기간이 남아 있는 경우 ErrorCode.NOT_EXPIRED_TOKEN_YET
+     * 2. refresh token의 유효기간이 재 발급 기준에 부합된 경우 refresh token도 재발급
+     * 3. 2번 항묵에 미 해당시 refresh token 값은 null로
+     * 
+ * + * @param tokenRequestDto TokenRequestDto + * @param request HttpServletRequest + * @return ResponseEntity IRestResponse + */ + @Operation(summary = "token 재발급 요청(header & DTO 사용)" , description = "token 재발급 :: accessToken - header, refreshToken - dto") + @Parameter(in = ParameterIn.QUERY, name = "refreshToken", description = "refresh token", required = true, example = " ") + @PostMapping("/jwt/reissue") + public ResponseEntity reissueFromHeader( + @Parameter(hidden = true) + @NotNull + @RequestBody + final TokenRequestDto tokenRequestDto, + HttpServletRequest request) { + return RestResponse.of(authMinService.reissue(tokenRequestDto, request, null)); + } + + /** + *
+     * JWT token 재발급
+     * access token - header, refresh - cookie 에 담아 요청
+     *
+     * 1. access token의 유효기간이 남아 있는 경우 ErrorCode.NOT_EXPIRED_TOKEN_YET
+     * 2. refresh token의 유효기간이 재 발급 기준에 부합된 경우 refresh token도 재발급
+     * 3. 2번 항묵에 미 해당시 refresh token 값은 null로
+     * 
+ * + * @param request HttpServletRequest + * @param response HttpServletResponse + * @return ResponseEntity IRestResponse + */ + @Operation(summary = "token 재발급(header & cookie 사용)" , description = "토큰 재발급 :: accessToken - header, refreshToken - cookie") + //@Parameter(in = ParameterIn.HEADER, name = "Authorization", description = "access token", required = true, example = " ") + //@Parameter(in = ParameterIn.COOKIE, name = "refreshToken", description = "refresh token", required = true, example = " ") + @PostMapping("/jwt/reissue/cookie") + public ResponseEntity reissueFromCookie(HttpServletRequest request, HttpServletResponse response) { + return RestResponse.of(authMinService.reissue(null, request, response)); + } + + + + /** + *
+     * JWT token 재발급
+     * access token - TokenRequestDto, refresh - TokenRequestDto 에 담아 요청
+     *
+     * 1. access token의 유효기간이 남아 있는 경우 ErrorCode.NOT_EXPIRED_TOKEN_YET
+     * 2. refresh token의 유효기간이 재 발급 기준에 부합된 경우 refresh token도 재발급
+     * 3. 2번 항묵에 미 해당시 refresh token 값은 null로
+     * 
+ * + * @param tokenRequestDto TokenRequestDto + * @return ResponseEntity IRestResponse + */ + @Operation(summary = "token 재발급(DTO 사용)" , description = "token 재발급 :: accessToken - dto, refreshToken - dto") + @PostMapping("/jwt/reissue/dto") + public ResponseEntity reissueFromParam( + @NotNull + @RequestBody + final TokenRequestDto tokenRequestDto) { + return RestResponse.of(authMinService.reissue(tokenRequestDto, null, null)); + } + + @Operation(summary = "토큰 체크" , description = "access token 체크") + @PostMapping("/jwt/validate") + public ResponseEntity validate(@RequestParam final String accessToken, @RequestParam boolean isExceptionThrow) { + return RestResponse.of(authMinService.validationToken(accessToken, isExceptionThrow)); + } + + @Operation(summary = "토큰 정보 확인" , description = "토큰 정보 확인") + @PostMapping("/jwt/info") + public ResponseEntity findAccessTokenInfo(@RequestParam final String accessToken) { + return RestResponse.of(authMinService.findAccessTokenInfo(accessToken)); + } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java new file mode 100644 index 0000000..2d0cee3 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java @@ -0,0 +1,146 @@ +package com.xit.biz.ctgy.v2.controller; + +import com.xit.biz.ctgy.dto.JudgeListDto; +import com.xit.biz.ctgy.dto.ParkingTargetDto; +import com.xit.biz.ctgy.dto.struct.JudgeListMapstruct; +import com.xit.biz.ctgy.dto.struct.MinSimsa680Mapstruct; +import com.xit.biz.ctgy.service.IParkingService; +import com.xit.core.annotation.Secured; +import com.xit.core.annotation.SecurityPolicy; +import com.xit.core.api.IRestResponse; +import com.xit.core.api.RestResponse; +import com.xit.core.util.AssertUtils; +import com.xit.core.util.Checks; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.mapstruct.factory.Mappers; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; + +@Tag(name = "ParkingController", description = "주정차 의견진술 관리") +@RestController +@RequiredArgsConstructor +@Slf4j +@RequestMapping("/api/v2/ctgy/parking") +public class ParkingController { + + private final IParkingService service; + + private final MinSimsa680Mapstruct mapstruct = Mappers.getMapper(MinSimsa680Mapstruct.class); + private final JudgeListMapstruct groupMapstruct = Mappers.getMapper(JudgeListMapstruct.class); + + //--------------------------------------------------------------------------------- + // 관리자 + //--------------------------------------------------------------------------------- + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "주정차 의견진술 심의 목록" , description = "주정차 의견진술 심의 목록") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "msYear", description = "심사년도", required = true, example = "2021"), + @Parameter(in = ParameterIn.QUERY, name = "msChasu", description = "차수", required = false, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"), + @Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10") + + }) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findParkings( + @Valid + @Parameter(hidden = true) + final JudgeListDto dto, + @Parameter(hidden = true) + final Pageable pageable) { + return RestResponse.of(service.findParkings(dto, pageable)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "주정차 의견진술 심의 결과" , description = "주정차 의견진술 심의 결과") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "msSdate", description = "심사시작일", required = true, example = "2021-01-04"), + @Parameter(in = ParameterIn.QUERY, name = "msEdate", description = "심사종료일", required = true, example = "2021-01-05"), + @Parameter(in = ParameterIn.QUERY, name = "msChasu", description = "차수", required = false, example = "3"), + @Parameter(in = ParameterIn.QUERY, name = "msuTeam", description = "팀코드", required = true, example = "002") + }) + @GetMapping(value="/result", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findParkingResults( + @Valid + @Parameter(hidden = true) + final JudgeListDto dto) { + return RestResponse.of(service.findParkingResults(dto)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "주정차 의견진술 심의대상 조회" , description = "주정차 의견진술 심의대상 조회") + @GetMapping(value="/target", produces = MediaType.APPLICATION_JSON_VALUE) + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "rcIrTransfer", description = "전송상태(미접수-1,접수-2)", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "rcSeq1", description = "접수번호-시작", required = true, example = "2022200801"), + @Parameter(in = ParameterIn.QUERY, name = "rcSeq2", description = "접수번호-종료", required = true, example = "2022200899"), + }) + public ResponseEntity findParkingJudgeTargets(@Parameter(hidden = true) final ParkingTargetDto dto){ + return RestResponse.of(service.findParkingJudgeTargets(dto)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "주정차 의견진술 심의대상 등록" , description = "주정차 의견진술 심의대상 등록") + @PostMapping(value="/target", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity saveParkinJudgeTargets( + @Valid + @RequestBody + final ParkingTargetDto dto) { + service.saveParkingJudgeTargets(dto); + return RestResponse.of(HttpStatus.OK); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "주정차 의견진술 심의 자료 삭제" , description = "주정차 의견진술 심의 자료 삭제") + @PostMapping(value="/remove", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity removeParkinJudge( + @Valid + @RequestBody + final ParkingTargetDto dto) { + service.removeParkingJudge(dto); + return RestResponse.of(HttpStatus.OK); + } + + //--------------------------------------------------------------------------------- + // 심사자 + //--------------------------------------------------------------------------------- + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "심사자별 주정차 의견진술 심의목록 조회" , description = "심사자별 주정차 의견진술 심의목록 조회") + @GetMapping(value = "/judge", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findByUserJudges() { + return RestResponse.of(service.findByUserJudges()); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "주정차 의견진술 심의 결과 저장" , description = "주정차 의견진술 심의 결과 저장") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "msuCode", description = "심사코드", required = true, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "msuResult", description = "심사결과코드", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "msuReason", description = "심사사유", required = true, example = " ") + }) + @PostMapping(value="/judge", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity saveJudgeResult( + @Valid + @RequestBody + @Parameter(hidden = true) + final JudgeListDto dto) { + AssertUtils.isTrue(!Checks.isEmpty(dto), "필수 조건이 입력되지 않았습니다."); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsuCode()), "심사코드 값은 필수입니다(PK)"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsuResult()), "심사결과는 필수입니다(1-수용,2-미수용)"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsuReason()), "심의사유는 필수입니다"); + service.saveJudgeResult(dto); + return RestResponse.of(HttpStatus.OK); + } +} + diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/PublicBoardController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/PublicBoardController.java new file mode 100644 index 0000000..29a16ed --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/PublicBoardController.java @@ -0,0 +1,71 @@ +package com.xit.biz.ctgy.v2.controller; + +import com.xit.biz.ctgy.dto.MinInfoBoard680Dto; +import com.xit.biz.ctgy.dto.struct.MinInfoBoard680Mapstruct; +import com.xit.biz.ctgy.service.IPublicBoardService; +import com.xit.core.annotation.Secured; +import com.xit.core.annotation.SecurityPolicy; +import com.xit.core.api.IRestResponse; +import com.xit.core.api.RestResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.mapstruct.factory.Mappers; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +@Tag(name = "PublicBoardController", description = "공지사항 관리") +@RestController +@RequestMapping("/api/v2/ctgy/pboard") +@Validated +@RequiredArgsConstructor +public class PublicBoardController { + + private final IPublicBoardService service; + + private final MinInfoBoard680Mapstruct mapstruct = Mappers.getMapper(MinInfoBoard680Mapstruct.class); + + // TODO :: 파라메터 정의 필요 + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "공지사항 목록 조회" , description = "공지사항 목록 조회") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "inTitle", description = "제목", required = false, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "inName", description = "이름", required = false, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"), + @Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10") + }) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findAll( + @Parameter(hidden = true) + final MinInfoBoard680Dto dto, + @Parameter(hidden = true) + final Pageable pageable) { + return RestResponse.of(service.findAll(mapstruct.toEntity(dto), pageable)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "공지사항상세" , description = "공지사항상세") + @Parameters({ + @Parameter(in = ParameterIn.PATH, name = "inCode", description = "공지사항번호", required = true, example = "18"), + }) + @GetMapping(value = "/{inCode}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findByInCode(@PathVariable final Long inCode) { + return RestResponse.of(service.findByInCode(inCode)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "공지사항 조회수 증가" , description = "공지사항 조회수 증가") + @Parameters({ + @Parameter(in = ParameterIn.PATH, name = "inCode", description = "공지사항번호", required = true, example = "18"), + }) + @PutMapping(value = "/hit/{inCode}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity modifyByInCode(@PathVariable final Long inCode) { + return RestResponse.of(service.modifyByInCode(inCode)); + } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/ResidentAndDisabledController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/ResidentAndDisabledController.java new file mode 100644 index 0000000..32ac173 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/ResidentAndDisabledController.java @@ -0,0 +1,223 @@ +package com.xit.biz.ctgy.v2.controller; + +import com.xit.biz.ctgy.dto.GnRecallScDto; +import com.xit.biz.ctgy.dto.JudgeListDto; +import com.xit.biz.ctgy.dto.JudgeStdDto; +import com.xit.biz.ctgy.dto.JudgeTargetDto; +import com.xit.biz.ctgy.dto.struct.GnRecallScMapstruct; +import com.xit.biz.ctgy.service.IResidentAndDisabledService; +import com.xit.core.annotation.Secured; +import com.xit.core.annotation.SecurityPolicy; +import com.xit.core.api.IRestResponse; +import com.xit.core.api.RestResponse; +import com.xit.core.util.AssertUtils; +import com.xit.core.util.Checks; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.mapstruct.factory.Mappers; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Nonnull; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + +/** + * 거주자 / 장애인 의견 진술 + * 거주자 : scDatagb = "1" + * 장애인 : scDatagb = "2" + */ +@Tag(name = "ResidentAndDisabledController", description = "거주자/장애인 의견진술 관리") +@RestController +@RequestMapping("/api/v2/ctgy") +@Validated +@RequiredArgsConstructor +public class ResidentAndDisabledController { + + private final IResidentAndDisabledService service; + + private final GnRecallScMapstruct mapstruct = Mappers.getMapper(GnRecallScMapstruct.class); + + //--------------------------------------------------------------------------------- + // 관리자 + //--------------------------------------------------------------------------------- + + // TODO :: 파라메터 정의 필요 + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/장애인 의견지술자료 목록 조회" , description = "거주자/장애인 의견진술자료 목록 조회") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "scDatagb", description = "데이타구분", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"), + @Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10") + }) + @GetMapping(value="/admin/data", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findJudgeDatas( + @NotNull final String scDatagb, + @Parameter(hidden = true) + final Pageable pageable) { + return RestResponse.of(service.findJudgeDatas(scDatagb, pageable)); } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/장애인 의견진술 자료 등록", description = "거주자/장애인 의견진술 자료 등록") + @PostMapping(value = "/admin/data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity saveJudgeData(@Nonnull GnRecallScDto dto) { + AssertUtils.isTrue(!Checks.isEmpty(dto), "등록할 거주자 의견진술 자료가 없습니다"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getScDatagb()), "데이타구분 값은 필수입니다(1-거주자,2-장애인)"); + + service.saveJudgeData(dto); + return RestResponse.of(HttpStatus.OK); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/장애인 의견진술 자료 상세" , description = "거주자/장애인 의견진술 자료 상세") + @Parameters({ + @Parameter(in = ParameterIn.PATH, name = "scCode", description = "의견진술번호", required = true, example = "3778"), + }) + @GetMapping(value = "/admin/data/{scCode}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findJudgeData(@PathVariable final Long scCode) { + return RestResponse.of(service.findJudgeData(scCode)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/장애인 의견진술 자료 삭제" , description = "거주자/장애인 의견진술 자료 삭제") + @PostMapping(value="/admin/data/remove", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity removeJudgeData(final Long scCode) { + service.removeJudgeData(scCode); + return RestResponse.of(HttpStatus.OK); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/장애인 의견진술 심의대상 조회" , description = "거주자/장애인 의견진술 심의대상 조회") + @GetMapping(value="/admin/target", produces = MediaType.APPLICATION_JSON_VALUE) + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "scDatagb", description = "데이타구분(1-거주자, 2-장애인)", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "scTransfer", description = "전송상태(미접수-1,접수-2)", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "scSeq1", description = "접수번호-시작", required = true, example = "2022000001"), + @Parameter(in = ParameterIn.QUERY, name = "scSeq2", description = "접수번호-종료", required = true, example = "2022999999"), + }) + public ResponseEntity findResidentJudgeTargets(@Parameter(hidden = true) final JudgeTargetDto dto){ + AssertUtils.isTrue(!Checks.isEmpty(dto), "필수 검색 조건이 입력되지 않았습니다."); + AssertUtils.isTrue(!Checks.isEmpty(dto.getScDatagb()), "데이타구분 값은 필수입니다(1-거주자,2-장애인)"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getScTransfer()), "전송상태를 선택하지 않았습니다(1-미전송,2-전송)"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getScSeq1()), "조회할 접수번호(시작)가 입력되지 않았습니다"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getScSeq2()), "조회할 접수번호(종료)가 입력되지 않았습니다"); + return RestResponse.of(service.findJudgeTargets(dto)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/징애인 의견진술 심의대상 등록" , description = "거주자/장애인 의견진술 심의대상 등록") + @PostMapping(value="/admin/target", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity saveJudgeTargets( + @Valid + @RequestBody + final JudgeTargetDto dto) { + service.saveJudgeTargets(dto); + //service.saveParkingSimsaJudgeTargets(dto); + return RestResponse.of(HttpStatus.OK); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/장애인 의견진술 심의목록 조회" , description = "거주자/장애인 의견진술 심의목록 조회") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "scDatagb", description = "데이타구분(1-거주자, 2-장애인)", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "scYear", description = "심사년도", required = true, example = "2021"), + @Parameter(in = ParameterIn.QUERY, name = "scChasu", description = "차수", required = false, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"), + @Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10") + + }) + @GetMapping(value = "/admin", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findJudges( + @Valid + @Parameter(hidden = true) + final JudgeListDto dto, + @Parameter(hidden = true) + final Pageable pageable) { + AssertUtils.isTrue(!Checks.isEmpty(dto), "필수 검색 조건이 입력되지 않았습니다."); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsDatagb()), "데이타구분 값은 필수입니다(1-거주자,2-장애인)"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsYear()), "심사년도를 선택하셔야 합니다"); + return RestResponse.of(service.findJudges(dto, pageable)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/장애인 의견진술 심의 결과 목록" , description = "거주자/장애인 의견진술 심의 결과 목록") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "msDatagb", description = "데이타구분(1-거주자, 2-장애인)", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "msSdate", description = "심사시작일", required = true, example = "2021-09-10"), + @Parameter(in = ParameterIn.QUERY, name = "msEdate", description = "심사종료일", required = true, example = "2021-09-11"), + @Parameter(in = ParameterIn.QUERY, name = "msChasu", description = "차수", required = true, example = "12"), + @Parameter(in = ParameterIn.QUERY, name = "msuTeam", description = "팀코드", required = false, example = "003") + }) + @GetMapping(value="/admin/result", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findJudgeResults( + @Valid + @Parameter(hidden = true) + final JudgeListDto dto) { + AssertUtils.isTrue(!Checks.isEmpty(dto), "필수 검색 조건이 입력되지 않았습니다."); + return RestResponse.of(service.findJudgeResults(dto)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "관리자 심사기준 적용 심사 처리" , description = "관리자 심사기준 적용 심사 처리") + @PostMapping(value="/admin/judge", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity saveJudgeStds( + @Valid + @RequestBody + final JudgeStdDto dto) { + service.saveJudgeStds(dto); + return RestResponse.of(HttpStatus.OK); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "dashboard" , description = "dashboard") + @GetMapping(value="/dashboard", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity getDashboard() { + return RestResponse.of(service.findDashboard()); + } + //--------------------------------------------------------------------------------- + // 심사자 + //--------------------------------------------------------------------------------- + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "심사자별 거주자/장애인 의견진술 심의목록 조회" , description = "심사자별 거주자/장애인 의견진술 심의목록 조회") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "msDatagb", description = "데이타구분(1-거주자, 2-장애인)", required = true, example = "1") + }) + @GetMapping(value = "/judge", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findByUserJudges( + @Valid + @Parameter(hidden = true) + final JudgeListDto dto) { + AssertUtils.isTrue(!Checks.isEmpty(dto), "필수 검색 조건이 입력되지 않았습니다."); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsDatagb()), "데이타구분 값은 필수입니다(1-거주자,2-장애인)"); + return RestResponse.of(service.findByUserJudges(dto)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "거주자/장애인 의견진술 심의 결과 저장" , description = "거주자/장애인 의견진술 심의 결과 저장") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "msuCode", description = "심사코드", required = true, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "msuResult", description = "심사결과코드", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "msuReason", description = "심사사유", required = true, example = " ") + }) + @PostMapping(value="/judge", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity saveJudgeResult( + @Valid + @RequestBody + @Parameter(hidden = true) + final JudgeListDto dto) { + AssertUtils.isTrue(!Checks.isEmpty(dto), "필수 조건이 입력되지 않았습니다."); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsuCode()), "심사코드 값은 필수입니다(PK)"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsuResult()), "심사결과는 필수입니다(1-수용,2-미수용)"); + AssertUtils.isTrue(!Checks.isEmpty(dto.getMsuReason()), "심의사유는 필수입니다"); + service.saveJudgeResult(dto); + return RestResponse.of(HttpStatus.OK); + } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java index 0ece33b..2ec4e23 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java @@ -10,7 +10,7 @@ import java.util.List; public interface IBoardService { - List findAll(final BoardDto dto, Pageable pageable); + Page findAll(final BoardDto dto, Pageable pageable); // Page findAll2(final MinCivBoard680 entity, Pageable pageable); // diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/ICtgyFileService.java b/src/main/java/com/xit/biz/ctgy/v2/service/ICtgyFileService.java new file mode 100644 index 0000000..d58b5f1 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/ICtgyFileService.java @@ -0,0 +1,19 @@ +package com.xit.biz.ctgy.v2.service; + +import com.xit.biz.ctgy.dto.MinInfoBoard680Dto; +import com.xit.biz.ctgy.entity.MinInfoBoard680; + +import javax.annotation.Nonnull; +import java.util.List; + +/** + * @author Lim, Jong Uk (minuk926) + * @since 2021-07-16 + */ +public interface ICtgyFileService { + MinInfoBoard680 findFiles(Long inCode); + +// List saveFiles(@Nonnull MinInfoBoard680Dto dto); +// +// void removePublicBoardFile(Long inCode); +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IMinUserService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IMinUserService.java new file mode 100644 index 0000000..09915f5 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IMinUserService.java @@ -0,0 +1,19 @@ +package com.xit.biz.ctgy.v2.service; + +import com.xit.biz.ctgy.dto.MinUserinfoDto; +import com.xit.biz.ctgy.entity.MinUserinfo; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface IMinUserService { + + Page findMinUsers(final MinUserinfo minUserinfo, Pageable pageable); + +// MinUserinfo findMinUser(); +// +// MinUserinfo findMinUserByUserid(final String userId); +// +// void saveMinUser(MinUserinfoDto dto); +// +// void removeMinUser(MinUserinfoDto dto); +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java new file mode 100644 index 0000000..3643cff --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java @@ -0,0 +1,37 @@ +package com.xit.biz.ctgy.v2.service; + +import com.xit.biz.ctgy.dto.JudgeListDto; +import com.xit.biz.ctgy.dto.ParkingTargetDto; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import java.util.List; +import java.util.Map; + +public interface IParkingService { + + Page findParkings(final JudgeListDto dto, Pageable pageable); + +// /** +// * 주정차 의견진술 심의 결과 목록 +// * @param dto JudgeListDto +// * @return Map +// */ +// Map findParkingResults(final JudgeListDto dto); +// +// List findParkingJudgeTargets(final ParkingTargetDto dto) ; +// +// // Page findAll(final MinSimsa680 minSimsa680, Pageable pageable); +// +// void saveParkingJudgeTargets(ParkingTargetDto dto); +// +// void removeParkingJudge(final ParkingTargetDto dto); +// +// //--------------------------------------------------------------------------------- +// // 심사자 +// //--------------------------------------------------------------------------------- +// List findByUserJudges(); +// +// void saveJudgeResult(JudgeListDto dto); + +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IPublicBoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IPublicBoardService.java new file mode 100644 index 0000000..1def95f --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IPublicBoardService.java @@ -0,0 +1,13 @@ +package com.xit.biz.ctgy.v2.service; + +import com.xit.biz.ctgy.entity.MinInfoBoard680; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface IPublicBoardService { + + Page findAll(final MinInfoBoard680 entity, Pageable pageable); +// MinInfoBoard680 findByInCode(final Long inCode); +// +// int modifyByInCode(Long inCode); +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IResidentAndDisabledService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IResidentAndDisabledService.java new file mode 100644 index 0000000..a73618b --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IResidentAndDisabledService.java @@ -0,0 +1,92 @@ +package com.xit.biz.ctgy.v2.service; + +import com.xit.biz.ctgy.dto.GnRecallScDto; +import com.xit.biz.ctgy.dto.JudgeListDto; +import com.xit.biz.ctgy.dto.JudgeStdDto; +import com.xit.biz.ctgy.dto.JudgeTargetDto; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Map; + +/** + * 거주자 / 장애인 의견 진술 + * 거주자 : scDatagb = "1" + * 장애인 : scDatagb = "2" + */ +public interface IResidentAndDisabledService { + //--------------------------------------------------------------------------------- + // 관리자 + //--------------------------------------------------------------------------------- + + /** + * 거주자 / 장애인 심의자료 목록 조회 + * @param pageable Pageable + * @return Page + */ + Page findJudgeDatas(@NotNull final String scDatagb, Pageable pageable); +// +// /** +// * 거주자 / 장애인 심의자료 정보 조회 +// * @param scCode Long +// * @return GnRecallScDto +// */ +// GnRecallScDto findJudgeData(final Long scCode); +// +// //Page findAll(final GnRecallSc entity, Pageable pageable); +// +// // 심의자료 저장 +// +// /** +// * 거주자 / 장애인 심의자료 저장 +// * @param entity GnRecallScDto +// */ +// void saveJudgeData(GnRecallScDto entity); +// +// void removeJudgeData(Long scCode); +// +// /** +// * 거주자 / 장애인 의견진술 심의 목록 조회 +// * @param dto JudgeListDto +// * @param pageable Pageable +// * @return Page +// */ +// Page findJudges(JudgeListDto dto, Pageable pageable); +// +// /** +// * 거주자 / 장애인 의견진술 심의 결과 목록 +// * @param dto JudgeListDto +// * @return Map +// */ +// Map findJudgeResults(final JudgeListDto dto); +// Map findJudgeResults2(final JudgeListDto dto); +// +// /** +// * 거주자 / 장애인 심의대상 목록 조회 +// * @param dto JufgeTargetDto +// * @return List +// */ +// List findJudgeTargets(final JudgeTargetDto dto) ; +// +// /** +// * 거주자 / 장애인 심의대상 목록 저장 +// * @param dto JudgeTargetDto +// */ +// void saveJudgeTargets(JudgeTargetDto dto); +// +// void removeJudge(final JudgeListDto dto); +// +// void saveJudgeStds(final JudgeStdDto dto); +// +// Map findDashboard(); +// +// //--------------------------------------------------------------------------------- +// // 심사자 +// //--------------------------------------------------------------------------------- +// List findByUserJudges(JudgeListDto dto); +// +// void saveJudgeResult(JudgeListDto dto); + +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java index f236e12..c88c173 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java @@ -28,15 +28,13 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.dom4j.DocumentException; import org.mapstruct.factory.Mappers; import org.mybatis.spring.SqlSessionTemplate; -import org.springframework.data.domain.Example; -import org.springframework.data.domain.ExampleMatcher; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.*; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.nio.charset.Charset; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -51,26 +49,30 @@ public class BoardService implements IBoardService { @Transactional(readOnly = true) - public List findAll(final BoardDto dto, Pageable pageable) { - //String sql = DBUtils.getXmlSql("sql/board2-mapper", "selectBoardList"); - //String sql = DBUtils.getMybatisSql(sqlSessionTemplate, "board.selectBoardList", dto); + public Page findAll(final BoardDto dto, Pageable pageable) { + String cntSql = getSql("selectBoardListCnt", dto, pageable); + String listSql = getSql("selectBoardList", dto, pageable); + MpowerUtils listQuery = new MpowerUtils(); + listQuery.setFeilds("ciCode, ciName, ciContentno, ciTitle, ciContents, ciNalja, ciStep, ciRevel, ciRef, ciHit, ciPass, ciId"); + listQuery.setQuery(listSql); - String sql = QueryGenerator.createNamedQuery("board", "selectBoardList") + Map map = listQuery.getPagingMap(BoardDto.class, cntSql); + if(Long.parseLong(map.get("totalCount").toString()) <= 0) + return new PageImpl<>(new ArrayList<>(), pageable, 0); + else + return new PageImpl<>((List)map.get("list"), pageable, Long.parseLong(map.get("totalCount").toString())); + } + + private String getSql(String sqlId, BoardDto dto, Pageable pageable){ + return QueryGenerator.createNamedQuery("board", sqlId) .setParameter("ciTitle", dto.getCiTitle()) .setParameter("ciName", dto.getCiName()) .setParameter("ciContents", dto.getCiContents()) + .setParameter("page", pageable.getPageNumber()) + .setParameter("size", pageable.getPageSize()) .getQueryString(); - System.out.println(sql); - - MpowerUtils sendXml = new MpowerUtils(); - sendXml.setFeilds("ciCode, ciName, ciContentno, ciTitle, ciContents, ciNalja, ciStep, ciRevel, ciRef, ciHit, ciPass, ciId"); - sendXml.setQuery(sql); - - return sendXml.selectCustomQuery(BoardDto.class); - //return DBUtils.convertToValueObjects(sendXml.selectCustomQuery(), BoardDto.class); } - // @Transactional(readOnly = true) // public Page findAll2(final MinCivBoard680 entity, Pageable pageable) { // pageable = JpaUtil.getPagingInfo(pageable); diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/CtgyFileService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/CtgyFileService.java new file mode 100644 index 0000000..4471b69 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/CtgyFileService.java @@ -0,0 +1,177 @@ +package com.xit.biz.ctgy.v2.service.impl; + +import com.xit.biz.ctgy.dto.MinInfoBoard680Dto; +import com.xit.biz.ctgy.entity.MinInfoBoard680; +import com.xit.biz.ctgy.v2.service.ICtgyFileService; +import com.xit.core.constant.ErrorCode; +import com.xit.core.exception.CustomBaseException; +import com.xit.core.util.AssertUtils; +import com.xit.core.util.Checks; +import io.jsonwebtoken.lang.Assert; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.mapstruct.factory.Mappers; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Nonnull; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +@Slf4j +@Service +@RequiredArgsConstructor +public class CtgyFileService implements ICtgyFileService { + + @Value("${file.cmm.upload.root:c:/data/file/upload}") + private String rootPath; + + @Value("${file.cmm.upload.path:/kangnamSIM/simUpFile/}") + private String uploadPath; + + @Value("${file.cmm.upload.url}") + private String serviceUrl; + + @Value("${file.cmm.upload.allow.ext:}") + private String allowExt; + + @Value("${file.cmm.upload.max.size:1024}") + private long maxSize; + + @Override + public MinInfoBoard680 findFiles(Long inCode) { + Assert.notNull(inCode, "대상 게시글[inCode]을 선택해 주세요."); + return null; +// return repository.findById(inCode).orElse(null); + } +// +// /** +// * 파일 등록 +// * 신규등록시는 CmmFileMst.fileMstId가 null, 변경시 not null +// * 변경시 동일한 파일 이름이 존재하면 DB 및 해당 파일 삭제후 신규로 생성 +// * +// * @param dto MinInfoBoard680Dto +// * @return CmmFileMst +// */ +// @Override +// @Transactional +// public List saveFiles(@Nonnull MinInfoBoard680Dto dto) { +// List entityList = new ArrayList<>(); +// MultipartFile[] files = dto.getFiles(); +// String makePath = ""; +// +// if(files != null && files.length > 0){ +// //makePath = File.separator + DateUtil.getToday(""); +// +// // 파일 경로 : upload root 제외 +// String urlPath = this.uploadPath + makePath; +// // 물리적인 파일 저장 위치 +// String fileUploadPath = this.rootPath + urlPath; +// File file = new File(fileUploadPath); +// if(!file.exists()) file.mkdirs(); +// +// for(MultipartFile mf : files) { +// if (!mf.isEmpty()) { +// String orgFileName = ""; +// try { +// orgFileName = StringUtils.cleanPath(Objects.requireNonNull(mf.getOriginalFilename())); +// MinInfoBoard680 savedEntity = null; +// +// // 파일 저장 && 전송 +// if(Checks.isEmpty(dto.getInCode())) { +// dto.setInCode(repository.getInCodeByInBgubun()); +// dto.setInContentno(dto.getInCode()); +// dto.setInFilename(orgFileName); +// dto.setInFilesize(mf.getSize()); +// dto.setInFileurl(serviceUrl + urlPath); +// savedEntity = mapstruct.toEntity(dto); //MinInfoBoard680.builder().build(); +// }else { +// savedEntity = repository.findById(dto.getInCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); +// savedEntity.setInFilename(orgFileName); +// savedEntity.setInFilesize(mf.getSize()); +// savedEntity.setInFileurl(serviceUrl + urlPath); +// setEntity(savedEntity, dto); +// } +// repository.save(savedEntity); +// +// entityList.add(savedEntity); +// mf.transferTo(new File(fileUploadPath + File.separator + orgFileName)); +// +// // inputStream을 가져와 +// // copyOfLocation (저장위치)로 파일을 쓴다. +// // copy의 옵션은 기존에 존재하면 REPLACE(대체한다), 오버라이딩 한다 +// //Files.copy(multipartFile.getInputStream(), copyOfLocation, StandardCopyOption.REPLACE_EXISTING); +// +// } catch (IOException e) { +// String errMsg = String.format("File Upload Error :: %s", orgFileName); +// //TODO : 에러처리 +// //return RestError.of(String.format("File Upload Error :: %s", orgFileName)); +// AssertUtils.isTrue(false, String.format("File Upload Error :: %s", orgFileName)); +// } +// } +// } +// }else{ +// MinInfoBoard680 savedEntity = null; +// if(Checks.isEmpty(dto.getInCode())) { +// dto.setInCode(repository.getInCodeByInBgubun()); +// dto.setInContentno(dto.getInCode()); +// savedEntity = mapstruct.toEntity(dto); +// }else { +// savedEntity = repository.findById(dto.getInCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); +// setEntity(savedEntity, dto); +// } +// repository.save(savedEntity); +// //JpaUtil.saveIfNullId(dto.getInCode(), repository, savedEntity); +// } +// return entityList; +// } +// +// @Override +// @Transactional +// public void removePublicBoardFile(Long inCode) { +// +// MinInfoBoard680 savedEntity = repository.findById(inCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); +// repository.delete(savedEntity); +// +// // 정보 삭제후 파일 삭제 : 에러 발생시 skip +// if(Checks.isNotEmpty(savedEntity.getInFilename())){ +// String absFile = rootPath + savedEntity.getInFileurl().split(serviceUrl)[1]+File.separator + savedEntity.getInFilename(); +// try { +// File file = new File(absFile); +// if (Checks.isNotEmpty(file) && file.exists()) file.delete(); +// }catch(Exception e){ +// // +// } +// } +// +// } +// +// private void setEntity(MinInfoBoard680 savedEntity, MinInfoBoard680Dto dto){ +// savedEntity.setInDept(dto.getInDept()); +// savedEntity.setInTitle(dto.getInTitle()); +// savedEntity.setInContents(dto.getInContents()); +// } +} + + + +/* + // File.seperator 는 OS종속적이다. + // Spring에서 제공하는 cleanPath()를 통해서 ../ 내부 점들에 대해서 사용을 억제한다 + Path copyOfLocation = Paths.get(uploadDir + File.separator + StringUtils.cleanPath(multipartFile.getOriginalFilename())); + try { + // inputStream을 가져와서 + // copyOfLocation (저장위치)로 파일을 쓴다. + // copy의 옵션은 기존에 존재하면 REPLACE(대체한다), 오버라이딩 한다 + Files.copy(multipartFile.getInputStream(), copyOfLocation, StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + e.printStackTrace(); + throw new FileStorageException("Could not store file : " + multipartFile.getOriginalFilename()); + } +*/ diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/MinUserService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/MinUserService.java new file mode 100644 index 0000000..2d65213 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/MinUserService.java @@ -0,0 +1,67 @@ +package com.xit.biz.ctgy.v2.service.impl; + +import com.xit.biz.ctgy.dto.MinUserinfoDto; +import com.xit.biz.ctgy.entity.MinUserinfo; +import com.xit.biz.ctgy.v2.service.IMinUserService; +import com.xit.core.constant.ErrorCode; +import com.xit.core.exception.CustomBaseException; +import com.xit.core.oauth2.utils.HeaderUtil; +import lombok.AllArgsConstructor; +import org.mapstruct.factory.Mappers; +import org.springframework.data.domain.*; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; + +@AllArgsConstructor +@Service +public class MinUserService implements IMinUserService { + + private final PasswordEncoder passwordEncoder; + + @Transactional//(readOnly = true) + public Page findMinUsers(final MinUserinfo minUserinfo, Pageable pageable) { + Sort sort = Sort.by(Sort.Direction.ASC, "team", "name"); + pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort); + ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll() + .withMatcher("userid", contains()) + .withMatcher("name", contains()); + Example example = Example.of(minUserinfo, exampleMatcher); + return null; + +// Page page = repository.findAll(example, pageable); +// return page; + } + +// @Override +// @Transactional(readOnly = true) +// public MinUserinfo findMinUser() { +// //cmmUserRepos +// //return Optional.empty(); //cmmUserRepository.findOneWithAuthorities(SecurityUtil.getCurrentMemberId()); +// return repository.findMinUserinfoByUserid(HeaderUtil.getUserId()); +// } +// +// @Override +// @Transactional(readOnly = true) +// public MinUserinfo findMinUserByUserid(final String userid) { +// return repository.findMinUserinfoByUserid(userid); +// } +// +// @Override +// @Transactional +// public void saveMinUser(MinUserinfoDto dto) { +// if("Y".equals(dto.getNewYn()) && repository.findByUserid(dto.getUserid()).isPresent()) throw new CustomBaseException(ErrorCode.MEMBER_EXISTS); +// dto.setPasswd(passwordEncoder.encode(dto.getPasswd())); +// repository.save(mapstruct.toEntity(dto)); +// } +// +// @Override +// @Transactional +// public void removeMinUser(MinUserinfoDto dto) { +// MinUserinfo entity = repository.findByUserid(dto.getUserid()).orElseThrow(()-> new CustomBaseException(ErrorCode.USER_NOT_FOUND)); +// entity.setIsenable("0"); +// repository.save(entity); +// } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java new file mode 100644 index 0000000..a4068ee --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java @@ -0,0 +1,183 @@ +package com.xit.biz.ctgy.v2.service.impl; + +import com.xit.biz.ctgy.CtgyConstants; +import com.xit.biz.ctgy.dto.JudgeListDto; +import com.xit.biz.ctgy.dto.ParkingTargetDto; +import com.xit.biz.ctgy.entity.MinSimsaUser680; +import com.xit.biz.ctgy.entity.MinUserinfo; +import com.xit.biz.ctgy.entity.Tf680Recall; +import com.xit.biz.ctgy.v2.service.IParkingService; +import com.xit.core.constant.ErrorCode; +import com.xit.core.exception.CustomBaseException; +import com.xit.core.support.jpa.JpaUtil; +import com.xit.core.util.Checks; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class ParkingService implements IParkingService { + + @Override + @Transactional(readOnly = true) + public Page findParkings(final JudgeListDto dto, Pageable pageable) { + return null; +// return repository.findParkings(dto, pageable); + } + +// @Override +// public Map findParkingResults(JudgeListDto dto) { +// Map resultMap = new HashMap<>(); +// +// // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 +//// Map teamMap = mapper.selectTotParkingJudgeResultGroupByTeamAndChasu(dto); +//// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); +//// List> totJudgeUserList = mapper.selectTotParkingJudgeResultGroupByUser(dto); +//// totJudgeUserList.add(teamMap); +// +// List> teamList = mapper.selectParkingJudgeTeamGroupByChasuAndTeamList(dto); +// if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); +// +// // 차수별 심사자별 심사결과 합산 +// dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); +// List> totJudgeUserList = mapper.selectTotParkingJudgeResultGroupByUser(dto); +// totJudgeUserList.add(teamList.get(0)); +// +// // 심사대상 차량 목록 +// List> judgeCarList = mapper.selectParkingJurgeResultGroupByCarnum(dto); +// +// // 차량별 심사자 심사결과 목록 +// Map paramMap = new HashMap<>(); +// paramMap.put("msDatagb", dto.getMsDatagb()); +// paramMap.put("msChasu", dto.getMsChasu()); +// paramMap.put("msSdate", dto.getMsSdate()); +// paramMap.put("msEdate", dto.getMsEdate()); +// paramMap.put("msuTeam", dto.getMsuTeam()); +// paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); +// paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); +// +// List> jurgeUserList = mapper.selectParkingJudgeResultList(paramMap); +//// List> resultList = judgeCarList.stream().peek((m) -> { +//// paramMap.put("msSeq", m.get("msSeq")); +//// paramMap.put("msCarnum", m.get("msCarnum")); +//// m.put("simsa", mapper.selectParkingJudgeResultList(paramMap)); +//// }).collect(Collectors.toList()); +// +// resultMap.put("teamList", teamList); +// // 차수별 심사자별 심사결과 합산 +// resultMap.put("totJudgeUserData", totJudgeUserList); +// // 심사대상 차량 목록 +// resultMap.put("judgeCarData", judgeCarList); +// // 차량별 심사자 심사결과 목록 +// resultMap.put("judgeUserData", jurgeUserList); +// +// return resultMap; +// } +// +// @Override +// @Transactional(readOnly = true) +// public List findParkingJudgeTargets(ParkingTargetDto dto) { +// return repository.findParkingJudgeTargets(dto); +// } +// +// @Override +// @Transactional +// public void saveParkingJudgeTargets(ParkingTargetDto dto) { +// boolean isFirst = true; +// +// for(Long rcCode : dto.getRcCodes()) { +// +// //--------------------------------------------------------- +// // 심사대상 등록 +// //--------------------------------------------------------- +// dto.setRcCode(rcCode); +// +// if (isFirst) { +// dto.setMsYear(dto.getMsSdate().toString().substring(0, 4)); +// dto.setMsResult("0"); +// isFirst = false; +// } +// if(mapper.insertParkingJudgeTargetIntoSelect(dto) == 0) throw new CustomBaseException(String.format("처리된 데이타가 있습니다[ %s ]", dto.getMmOcarno())); +// +// //--------------------------------------------------------- +// // 등록한 심사대상 데이타 등록 상태 변경 : 미접수 -> 접수 +// //--------------------------------------------------------- +// Tf680Recall recallEntity = recallRepository.findById(dto.getRcCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); +// recallEntity.setRcIrTransfer(CtgyConstants.Judge.TRANSFER_ACCEPT.getCode()); +// JpaUtil.saveIfNullId(recallEntity.getRcCode(), recallRepository, recallEntity); +// +// //--------------------------------------------------------- +// // 심사자 등록 +// //--------------------------------------------------------- +// List userinfoList = userRepository.findAllByTeamAndIsenableAndAccesstype( +// dto.getMsuTeam(), +// CtgyConstants.UserInfo.ISENABLED_USE.getCode(), +// CtgyConstants.UserInfo.ACCESSTYPE_SIMSA.getCode()); +// +// List simsaUserList = userinfoList.stream().map(u -> +// MinSimsaUser680.builder() +// .msuMaincode(rcCode) +// .msuUserid(u.getUserid()) +// .msuResult(CtgyConstants.SimsaUserInfo.MSU_RESULT_NONE.getCode()) +// //.msuReaso +// // n() +// .msuTeam(dto.getMsuTeam()) +// //.msuIndate() +// .build() +// ).collect(Collectors.toList()); +// parkingJudgeUserRepository.saveAll(simsaUserList); +// } +// } +// +// +// /** +// * 심사자료 삭제 +// * 1. 삭제 대상 조회 : min_simsa680 테이블 : ms_chasu, ms_sdate, ms_edate 조건으로 ms_maincode 삭제 대상 조회 +// * 2. 심사자 삭제 : min_simsa_user680 테이블 : msu_maincode = ms_maincode +// * 3. 단속데이타 정보 변경 : tf680_recall 테이블 : rc_ir_transfer = '1', rc_code = ms_maincode +// * 4. 심사자료 삭제 : min_simsa680 테이블 ms_maincode = ms_maincode +// * @param dto ParkingTargetDto +// */ +// @Override +// @Transactional +// public void removeParkingJudge(final ParkingTargetDto dto) { +// +// List msMaincodes = repository.findAllMsMaincode(dto.getMsChasu(), dto.getMsSdate(), dto.getMsEdate()); +// +// msMaincodes.forEach(msMaincode -> { +// parkingJudgeUserRepository.deleteByMsuMaincode(msMaincode); +// // 전송상태 -> 미접수(1), 심의결과 -> 심의전(0) +// recallRepository.updateRcIrTransferAndRcState(msMaincode); +// repository.deleteById(msMaincode); +// }); +// } +// +// //--------------------------------------------------------------------------------- +// // 심사자 +// //--------------------------------------------------------------------------------- +// @Override +// @Transactional(readOnly = true) +// public List findByUserJudges() { +// return repository.findByUserJudges(); +// } +// +// @Override +// @Transactional +// public void saveJudgeResult(JudgeListDto dto){ +// parkingJudgeUserRepository.updateMsuResonAndMsuResultByMsuCode(dto.getMsuCode(), +// dto.getMsuResult(), +// dto.getMsuReason(), +// LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); +// } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/PublicBoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/PublicBoardService.java new file mode 100644 index 0000000..35402fb --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/PublicBoardService.java @@ -0,0 +1,45 @@ +package com.xit.biz.ctgy.v2.service.impl; + +import com.xit.biz.ctgy.entity.MinInfoBoard680; +import com.xit.biz.ctgy.v2.service.IPublicBoardService; +import com.xit.core.support.jpa.JpaUtil; +import lombok.AllArgsConstructor; +import org.springframework.data.domain.*; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; + +@Service +@AllArgsConstructor +public class PublicBoardService implements IPublicBoardService { + + @Override + @Transactional(readOnly = true) + public Page findAll(final MinInfoBoard680 entity, Pageable pageable) { + // Sort sort = Sort.by(Sort.Direction.DESC, "inCode"); + pageable = JpaUtil.getPagingInfo(pageable); + // pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("inCode").descending()) + ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll() + .withMatcher("inTitle", contains()) + .withMatcher("inName", contains()); + Example example = Example.of(entity, exampleMatcher); + return null; +// Page page = repository.findAll( +// example, +// PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("inCode").descending())); +// return page; + } + +// @Override +// @Transactional(readOnly = true) +// public MinInfoBoard680 findByInCode(final Long inCode) { +// return repository.findByInCode(inCode); +// } +// +// @Override +// @Transactional +// public int modifyByInCode(Long inCode) { +// return repository.updateInHitForMinInfoBoard680(inCode); +// } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java new file mode 100644 index 0000000..721db0c --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java @@ -0,0 +1,390 @@ +package com.xit.biz.ctgy.v2.service.impl; + +import com.xit.biz.cmm.service.ICmmFileService; +import com.xit.biz.ctgy.CtgyConstants; +import com.xit.biz.ctgy.dto.GnRecallScDto; +import com.xit.biz.ctgy.dto.JudgeListDto; +import com.xit.biz.ctgy.dto.JudgeStdDto; +import com.xit.biz.ctgy.dto.JudgeTargetDto; +import com.xit.biz.ctgy.entity.GnRecallSc; +import com.xit.biz.ctgy.entity.MinInfoBoard680; +import com.xit.biz.ctgy.entity.MinSimsaUser680Sc; +import com.xit.biz.ctgy.entity.MinUserinfo; +import com.xit.biz.ctgy.mapper.IParkingMapper; +import com.xit.biz.ctgy.service.IPublicBoardService; +import com.xit.biz.ctgy.v2.service.IResidentAndDisabledService; +import com.xit.core.constant.ErrorCode; +import com.xit.core.exception.CustomBaseException; +import com.xit.core.support.jpa.JpaUtil; +import com.xit.core.util.Checks; +import com.xit.core.util.DateUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.mapstruct.factory.Mappers; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.persistence.EntityManager; +import javax.validation.constraints.NotNull; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +@Slf4j +public class ResidentAndDisabledService implements IResidentAndDisabledService { + + @Value("${file.cmm.upload.root:c:/data/file/upload}") + private String rootPath; + + @Value("${file.cmm.upload.simsaPath:[simUpFile_sc1]}") + private String[] uploadPath; + + private final ICmmFileService fileService; + private final IPublicBoardService pBoardService; + private final IParkingMapper parkingMapper; + + private final EntityManager entityManager; + + //--------------------------------------------------------------------------------- + // 관리자 + //--------------------------------------------------------------------------------- + @Override + @Transactional(readOnly = true) + public Page findJudgeDatas(@NotNull final String scDatagb, Pageable pageable) { + // Sort sort = Sort.by(Sort.Direction.DESC, "inCode"); + pageable = JpaUtil.getPagingInfo(pageable); + return null; +// return gnReacallRepository.findJudgeDatas( +// scDatagb, +// PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("scCode").descending())); + } + +// @Override +// @Transactional(readOnly = true) +// public GnRecallScDto findJudgeData(final Long scCode) { +// return gnReacallRepository.findJudgeData(scCode); +// } +// +// @Override +// @Transactional +// public void saveJudgeData(GnRecallScDto dto) { +// boolean isNew = Checks.isEmpty(dto.getScCode()) || dto.getScCode() == 0L; +// +// if(dto.getPicadFiles() != null) { +// if(!isNew) changeFileUpload(dto, dto.getPicadFiles()); +// else setFileInfoAndFileUpload(dto, dto.getPicadFiles(), "setScPicad"); +// } +// +// if(dto.getFrecadFiles() != null) { +// if(!isNew) changeFileUpload(dto, dto.getFrecadFiles()); +// else setFileInfoAndFileUpload(dto, dto.getFrecadFiles(), "setScFrecad"); +// } +// +// if(dto.getContadFiles() != null) { +// if(!isNew) changeFileUpload(dto, dto.getContadFiles()); +// else setFileInfoAndFileUpload(dto, dto.getContadFiles(), "setScContad"); +// } +// +// GnRecallSc entity = null; +// // 신규 +// if (isNew) { +// // 접수번호 채번 : 년도 + seq 10자리 +// dto.setScSeq(gnReacallRepository.getGnRecallScMaxScSeq(String.valueOf(DateUtil.getCurrentYear()), CtgyConstants.Judge.DATAGB_RESIDENT.getCode())); +// entity = mapstruct.toEntity(dto); +// }else{ +// entity = mapstruct.toEntity(dto); +// } +// gnReacallRepository.save(entity); +// +// } +// +// +// @Override +// @Transactional +// public void removeJudgeData(final Long scCode){ +// gnReacallRepository.deleteById(scCode); +// } +// +// @Override +// @Transactional(readOnly = true) +// public List findJudgeTargets(JudgeTargetDto dto) { +// return gnReacallRepository.findJudgeTargets(dto); +// } +// +// @Override +// @Transactional +// public void saveJudgeTargets(JudgeTargetDto dto) { +// boolean isFirst = true; +// +// for(Long scCode : dto.getScCodes()) { +// +// //--------------------------------------------------------- +// // 심사대상 등록 +// //--------------------------------------------------------- +// dto.setScCode(scCode); +// +// if (isFirst) { +// dto.setMsYear(dto.getMsSdate().toString().substring(0, 4)); +// dto.setMsResult("0"); +// isFirst = false; +// } +// if(residentAndDisabledMapper.insertJudgeTargetIntoSelect(dto) == 0) throw new CustomBaseException(String.format("처리된 데이타가 있습니다[ %s ]", dto.getScCarnum())); +// +// //--------------------------------------------------------- +// // 등록한 심사대상 데이타 등록 상태 변경 : 미접수 -> 접수, 심의결과 : 접수 -> 심사중 +// //--------------------------------------------------------- +// GnRecallSc entity = gnReacallRepository.findById(dto.getScCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); +// entity.setScTransfer(CtgyConstants.Judge.TRANSFER_ACCEPT.getCode()); +// // entity.setScState(CtgyConstants.Judge.DATA_STATE_JUDGE.getCode()); +// //JpaUtil.saveIfNullId(dto.getScCode(), repository, entity); +// gnReacallRepository.save(entity); +// +// //--------------------------------------------------------- +// // 심사자 등록 +// //--------------------------------------------------------- +// List userinfoList = userRepository.findAllByTeamAndIsenableAndAccesstype( +// dto.getMsuTeam(), +// CtgyConstants.UserInfo.ISENABLED_USE.getCode(), +// CtgyConstants.UserInfo.ACCESSTYPE_SIMSA.getCode()); +// +// List simsaUserList = userinfoList.stream().map(u -> +// MinSimsaUser680Sc.builder() +// .msuMaincode(scCode) +// .msuUserid(u.getUserid()) +// .msuResult(CtgyConstants.SimsaUserInfo.MSU_RESULT_NONE.getCode()) +// //.msuReason() +// .msuTeam(dto.getMsuTeam()) +// //.msuIndate() +// .build() +// ).collect(Collectors.toList()); +// judgeUserRepository.saveAll(simsaUserList); +// } +// } +// +// @Override +// @Transactional(readOnly = true) +// public Page findJudges(JudgeListDto dto, Pageable pageable) { +// +// pageable = JpaUtil.getPagingInfo(pageable); +// return gnReacallRepository.findJudges(dto, pageable); +// } +// +// @Override +// @Transactional(readOnly = true) +// public Map findJudgeResults(JudgeListDto dto) { +// Map resultMap = new HashMap<>(); +// +// // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 +//// Map teamMap = residentAndDisabledMapper.selectTotJudgeResultGroupByTeamAndChasu(dto); +//// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); +//// List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); +//// totJudgeUserList.add(teamMap); +// +// List> teamList = residentAndDisabledMapper.selectJudgeTeamGroupByChasuAndTeamList(dto); +// if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); +// +// // 차수별 심사자별 심사결과 합산 +// dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); +// List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); +// totJudgeUserList.add(teamList.get(0)); +// +// // 심사대상 차량 목록 +// List> judgeCarList = residentAndDisabledMapper.selectJudgeResultGroupByCarnum(dto); +// +// // 차량별 심사자 심사결과 목록 +// Map paramMap = new HashMap<>(); +// paramMap.put("msDatagb", dto.getMsDatagb()); +// paramMap.put("msChasu", dto.getMsChasu()); +// paramMap.put("msSdate", dto.getMsSdate()); +// paramMap.put("msEdate", dto.getMsEdate()); +// paramMap.put("msuTeam", dto.getMsuTeam()); +// +// paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); +// paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); +// List> jurgeUserList = residentAndDisabledMapper.selectJudgeResultList(paramMap); +// +//// List> resultList = judgeCarList.stream().peek((m) -> { +//// paramMap.put("msSeq", m.get("msSeq")); +//// paramMap.put("msCarnum", m.get("msCarnum")); +//// m.put("simsa", residentAndDisabledMapper.selectJudgeResultList(paramMap)); +//// }).collect(Collectors.toList()); +// +// +// resultMap.put("teamList", teamList); +// // 차수별 심사자별 심사결과 합산 +// resultMap.put("totJudgeUserData", totJudgeUserList); +// // 심사대상 차량 목록 +// resultMap.put("judgeCarData", judgeCarList); +// // 차량별 심사자 심사결과 목록 +// resultMap.put("judgeUserData", jurgeUserList); +// return resultMap; +// } +// +// @Override +// @Transactional(readOnly = true) +// public Map findJudgeResults2(JudgeListDto dto) { +// Map resultMap = new HashMap<>(); +// +// // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 +//// Map teamMap = residentAndDisabledMapper.selectTotJudgeResultGroupByTeamAndChasu(dto); +//// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); +//// List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); +//// totJudgeUserList.add(teamMap); +// +// List> teamList = residentAndDisabledMapper.selectJudgeTeamGroupByChasuAndTeamList(dto); +// if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); +// +// // 차수별 심사자별 심사결과 합산 +// dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); +// List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); +// totJudgeUserList.add(teamList.get(0)); +// +// // 심사대상 차량 목록 +// List> judgeCarList = residentAndDisabledMapper.selectJudgeResultGroupByCarnum(dto); +// +// // 차량별 심사자 심사결과 목록 +// Map paramMap = new HashMap<>(); +// paramMap.put("msDatagb", dto.getMsDatagb()); +// paramMap.put("msChasu", dto.getMsChasu()); +// paramMap.put("msSdate", dto.getMsSdate()); +// paramMap.put("msEdate", dto.getMsEdate()); +// paramMap.put("msuTeam", dto.getMsuTeam()); +// +// paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); +// paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); +// List> jurgeUserList = residentAndDisabledMapper.selectJudgeResultList(paramMap); +// +//// List> resultList = judgeCarList.stream().peek((m) -> { +//// paramMap.put("msSeq", m.get("msSeq")); +//// paramMap.put("msCarnum", m.get("msCarnum")); +//// m.put("simsa", residentAndDisabledMapper.selectJudgeResultList(paramMap)); +//// }).collect(Collectors.toList()); +// +// +// resultMap.put("teamList", teamList); +// // 차수별 심사자별 심사결과 합산 +// resultMap.put("totJudgeUserData", totJudgeUserList); +// // 심사대상 차량 목록 +// resultMap.put("judgeCarData", judgeCarList); +// // 차량별 심사자 심사결과 목록 +// resultMap.put("judgeUserData", jurgeUserList); +// return resultMap; +// } +// +// /** +// * 심사자료 삭제 +// * 1. 삭제 대상 조회 : min_simsa680_sc 테이블 : ms_datagb, ms_chasu, ms_sdate, ms_edate 조건으로 ms_maincode 삭제 대상 조회 +// * 2. 심사자 삭제 : min_simsa_user680_sc 테이블 : msu_maincode = ms_maincode +// * 3. 단속데이타 정보 변경 : gn_recall_sc 테이블 : sc_transfer = '1', sc_state = '1', sc_code = ms_maincode +// * 4. 심사자료 삭제 : min_simsa680_sc 테이블 ms_maincode = ms_maincode +// * @param dto ParkingTargetDto +// */ +// @Override +// @Transactional +// public void removeJudge(final JudgeListDto dto) { +// +// List msMaincodes = judgeRepository.findAllMsMaincode(dto.getMsDatagb(), dto.getMsChasu(), dto.getMsSdate(), dto.getMsEdate()); +// +// msMaincodes.forEach(msMaincode -> { +// //List judgeUsers = judgeUserRepository.findByMsuMaincode() +// judgeUserRepository.deleteByMsuMaincode(msMaincode); +// // 전송상태 -> 미접수(1), 심의결과 -> 접수(1) +// gnReacallRepository.updateScTransferAndScState(dto.getMsDatagb(), msMaincode); +// judgeRepository.deleteById(msMaincode); +// }); +// } +// +// @Override +// @Transactional +// public void saveJudgeStds(final JudgeStdDto dto) { +// int stdCnt = dto.getJudgeStdCnt(); +// +// dto.getJudgeDataKeys().forEach(map -> { +// int cnt = 0; +// Long msMaincode = Long.valueOf(map.get("msMaincode").toString()); +// String msSeq = map.get("msSeq").toString(); +// +// // 미부과 +// String msResult = CtgyConstants.Judge.RESULT_JUDGE_NON_IMPOSE.getCode(); +// // 주정차 심사 +// if (Checks.isEmpty(dto.getDataGb())) { +// cnt = parkingRepository.getJudgeStdCnt(msMaincode); +// if(cnt >= stdCnt) msResult = CtgyConstants.Judge.RESULT_JUDGE_IMPOSE.getCode(); +// +// parkingRepository.updateMsResult(msMaincode, msSeq, msResult); +// +// // 거주자 장애인 심사 +// } else { +// cnt = gnReacallRepository.getJudgeStdCnt(msMaincode); +// if(cnt >= stdCnt) msResult = CtgyConstants.Judge.RESULT_JUDGE_IMPOSE.getCode(); +// +// judgeRepository.updateMsResult(msMaincode, msSeq, msResult); +// } +// }); +// } +// +// @Transactional(readOnly = true) +// public Map findDashboard(){ +// Map resultMap = new HashMap<>(); +// resultMap.put("pBoardList", pBoardService.findAll(MinInfoBoard680.builder().build(), PageRequest.of(0, 7))); +// resultMap.put("parkJudgeList", parkingMapper.selectDashboardJudgeList()); +// resultMap.put("residentJudgeList", residentAndDisabledMapper.selectDashboardJudgeList(CtgyConstants.Judge.DATAGB_RESIDENT.getCode())); +// resultMap.put("disabledJudgeList", residentAndDisabledMapper.selectDashboardJudgeList(CtgyConstants.Judge.DATAGB_DISABLED.getCode())); +// +// return resultMap; +// } +// +// private void setFileInfoAndFileUpload(GnRecallScDto dto, MultipartFile[] mfs, String setMethodName) { +// String makePath = fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); +// //makePath = makePath + File.separator; +// +// for(int idx = 0; idx < mfs.length; idx++){ +// MultipartFile mf = mfs[idx]; +// try { +// Method method = GnRecallScDto.class.getMethod(setMethodName + (idx+1), String.class); +// method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); +// //method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); +// } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { +// e.printStackTrace(); +// } +// } +// } +// +// private void changeFileUpload(GnRecallScDto dto, MultipartFile[] mfs) { +// fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); +// } +// +// +// //--------------------------------------------------------------------------------- +// // 심사자 +// //--------------------------------------------------------------------------------- +// @Override +// @Transactional(readOnly = true) +// public List findByUserJudges(JudgeListDto dto) { +// return gnReacallRepository.findByUserJudges(dto); +// } +// +// @Override +// @Transactional +// public void saveJudgeResult(JudgeListDto dto){ +// judgeUserRepository.updateMsuResonAndMsuResultByMsuCode(dto.getMsuCode(), +// dto.getMsuResult(), +// dto.getMsuReason(), +// LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); +// } +} diff --git a/src/main/java/com/xit/core/oauth2/api/dao/RefreshTokenDao.java b/src/main/java/com/xit/core/oauth2/api/dao/RefreshTokenDao.java index 6480036..ab0ac2b 100644 --- a/src/main/java/com/xit/core/oauth2/api/dao/RefreshTokenDao.java +++ b/src/main/java/com/xit/core/oauth2/api/dao/RefreshTokenDao.java @@ -20,10 +20,10 @@ public class RefreshTokenDao { //String sql = DBUtils.getXmlSql(sqlXmlFile, "selectRefreshToken"); //sql = sql.replaceFirst(":userId", key); - MpowerUtils sendXml = new MpowerUtils(); - sendXml.setFeilds("key, value"); - sendXml.setQuery(sql); - return Optional.ofNullable(sendXml.selectCustomQuery(RefreshToken.class).get(0)); + MpowerUtils selectQuery = new MpowerUtils(); + selectQuery.setFeilds("key, value"); + selectQuery.setQuery(sql); + return Optional.ofNullable(selectQuery.getListObject(RefreshToken.class).get(0)); } public void save(RefreshToken refreshToken){ @@ -37,7 +37,7 @@ public class RefreshTokenDao { .getQueryString(); - MpowerUtils sendXml = new MpowerUtils(); + MpowerUtils saveQuery = new MpowerUtils(); //sendXml.setFeilds("key, value"); //sendXml.setQuery(sql); //return Optional.ofNullable(sendXml.selectCustomQuery(RefreshToken.class).get(0)); @@ -54,7 +54,7 @@ public class RefreshTokenDao { .getQueryString(); - MpowerUtils sendXml = new MpowerUtils(); + MpowerUtils updateQuery = new MpowerUtils(); //sendXml.setFeilds("key, value"); //sendXml.setQuery(sql); //return Optional.ofNullable(sendXml.selectCustomQuery(RefreshToken.class).get(0)); diff --git a/src/main/java/com/xit/core/util/mpower/MpowerUtils.java b/src/main/java/com/xit/core/util/mpower/MpowerUtils.java index 39047bf..5b8f690 100644 --- a/src/main/java/com/xit/core/util/mpower/MpowerUtils.java +++ b/src/main/java/com/xit/core/util/mpower/MpowerUtils.java @@ -33,7 +33,7 @@ public class MpowerUtils { static int port = 9999; static String query = ""; static ArrayList feilds = new ArrayList(); - static String feild = ""; + //static String feild = ""; static String tmpFeilds = ""; static Boolean RowNum = false; static String tableNm = ""; @@ -142,7 +142,7 @@ public class MpowerUtils { Params = ""; psFinalFarams = ""; recordCountPerPage = 10; - feild = ""; + //feild = ""; } @@ -267,11 +267,11 @@ public class MpowerUtils { } String finalQuery = ""; String Cquery = beforeXml + "select count(*) from " + tableNm +" "+ WhereStr +afterXml; - if(!"".equals(feild) && feild != null){ - finalQuery = query; - }else{ +// if(!"".equals(feild) && feild != null){ +// finalQuery = query; +// }else{ finalQuery = "select " + fileList +" from " + tableNm +" "+ WhereStr; - } + //} if(RowNum == true){ feilds = new ArrayList(); this.setFeilds("RN, "+tmpFeilds); @@ -314,12 +314,7 @@ public class MpowerUtils { if(!chpoint) { for(int j=0;j> selectCustomQuery() { - //EgovMap mListMap = new EgovMap(); - Map mListMap = new HashMap<>(); - //배열로 넘어온 필드를 String 오브젝트로 변형 - String fileList = ""; - for(int cnt = 0;cnt mList = new ArrayList(); + public List> getListMap() { List> mList = new ArrayList<>(); - int mListCount = 0; + + query = beforeXml+query+afterXml; try { mpower = new Client(hostip,port); mpower.setCryptEnable(false); @@ -374,29 +353,21 @@ public class MpowerUtils { mpower.Request(); String result = mpower.getString("result", 0, 0); -// System.out.println("#######message = "+mpower.getMessage()); -// System.out.println("#######message charset = "+CommUtil.detectCharset(mpower.getMessage().getBytes())); -// System.out.println("#######message = "+new String(mpower.getMessage().getBytes(), CommUtil.detectCharset(mpower.getMessage().getBytes()))); - int row; if (result.equals("true")){ row = mpower.getMaxRow("list1"); if(row>0){ for(int i=0;i m = new HashMap<>(); - if(!"".equals(feild) && feild != null){ - m.put("cbContent", mpower.getString("list1", i, 4)); - }else{ - for(int j=0;j List selectCustomQuery(Class type) { + public List getListObject(Class type) { List list = new ArrayList<>(); - String fileList = ""; - for(int cnt = 0;cnt0){ + for(int i=0;i mList = new ArrayList(); + public Map getPagingMap(Class type, String cntQuery) { + Map rtnMap = new HashMap<>(); + List list = new ArrayList<>(); + String cntSql = beforeXml + cntQuery +afterXml; + long totalCnt = 0L; + try{ + mpower = new Client(hostip,port); + mpower.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower.setInput("SQLXML", cntSql); + mpower.Request(); - int mListCount = 0; + totalCnt = Long.parseLong(mpower.getString("list1", 0, 0)); + rtnMap.put("totalCount", totalCnt); + mpower.disconnect(); + } catch (Exception e) { + e.printStackTrace(); + } + if(totalCnt <= 0) return rtnMap; + + query = beforeXml+query+afterXml; try { mpower = new Client(hostip,port); mpower.setCryptEnable(false); @@ -438,52 +461,41 @@ public class MpowerUtils { row = mpower.getMaxRow("list1"); if(row>0){ for(int i=0;i m = new HashMap<>(); T instance = null; try { instance = type.getConstructor().newInstance(); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new RuntimeException(e); } - if(!"".equals(feild) && feild != null){ - //m.put("cbContent", mpower.getString("list1", i, 4)); - continue; - }else{ - Field[] clsFields = type.getDeclaredFields(); - for(int j=0;j /* board-mapper|selectBoardList|julim */ - SELECT MCB.ci_code, - MU.name, - MCB.ci_contentno, - MCB.ci_title, - MCB.ci_contents, - MCB.ci_nalja, - MCB.ci_step, - MCB.ci_revel, - MCB.ci_ref, - MCB.ci_hit, - MCB.ci_pass, - MCB.ci_id - FROM min_civ_board680 MCB - LEFT OUTER JOIN min_userinfo MU - ON MCB.ci_id = MU.userid - - - AND INSTR(MCB.ci_title, #{ciTitle}) > 0 - - - AND MCB.ci_name like #{ciName}||'%' - - - AND INSTR(MCB.ci_contents, #{ciContents}) > 0 - - - ORDER BY MCB.ci_ref DESC, - MCB.ci_step ASC, - MCB.ci_code DESC + SELECT ci_code, + name, + ci_contentno, + ci_title, + ci_contents, + ci_nalja, + ci_step, + ci_revel, + ci_ref, + ci_hit, + ci_pass, + ci_id, + ROWNUM AS rn + FROM ( + SELECT ROWNUM AS rn, + MCB.*, + MU.name + FROM min_civ_board680 MCB + LEFT OUTER JOIN min_userinfo MU + ON MCB.ci_id = MU.userid + + + AND INSTR(MCB.ci_title, #{ciTitle}) > 0 + + + AND MCB.ci_name like #{ciName}||'%' + + + AND INSTR(MCB.ci_contents, #{ciContents}) > 0 + + + ORDER BY MCB.ci_ref DESC, MCB.ci_step ASC, MCB.ci_code DESC + ) + WHERE rn BETWEEN (#{page} * #{size} + 1) AND (#{page} + 1) * #{size} - + + /* board-mapper|selectBoardListCnt|julim */ + SELECT count(MCB.ci_code) AS totalCount + FROM min_civ_board680 MCB + LEFT OUTER JOIN min_userinfo MU + ON MCB.ci_id = MU.userid + + + AND INSTR(MCB.ci_title, #{ciTitle}) > 0 + + + AND MCB.ci_name like #{ciName}||'%' + + + AND INSTR(MCB.ci_contents, #{ciContents}) > 0 + + + \ No newline at end of file