From 12893d3cc99bee6057cbe1d134c49cf16424d902 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Wed, 9 Feb 2022 19:45:41 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B2=8C=EC=8B=9C=EA=B8=80=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20#01?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 게시글 관리 조회 --- .gitignore | 1 + build.gradle | 24 +++---- .../controller/MinCivBoard680Controller.java | 54 ++++++++++++++++ .../xit/biz/ctgy/dto/MinCivBoard680Dto.java | 64 +++++++++++++++++++ .../dto/struct/MinCivBoard680Mapstruct.java | 12 ++++ .../xit/biz/ctgy/entity/MinCivBoard680.java | 2 - .../repository/IMinCivBoard680Repository.java | 11 ++++ .../ctgy/service/IMinCivBoard680Service.java | 11 ++++ .../service/impl/MinCivBoard680Service.java | 38 +++++++++++ .../com/xit/core/config/SecurityConfig.java | 2 +- .../config/support/SpringDocApiConfig.java | 10 +++ .../resources/config/application-local.yml | 23 +++---- src/main/resources/config/application.yml | 2 +- 13 files changed, 227 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/xit/biz/ctgy/controller/MinCivBoard680Controller.java create mode 100644 src/main/java/com/xit/biz/ctgy/dto/MinCivBoard680Dto.java create mode 100644 src/main/java/com/xit/biz/ctgy/dto/struct/MinCivBoard680Mapstruct.java create mode 100644 src/main/java/com/xit/biz/ctgy/repository/IMinCivBoard680Repository.java create mode 100644 src/main/java/com/xit/biz/ctgy/service/IMinCivBoard680Service.java create mode 100644 src/main/java/com/xit/biz/ctgy/service/impl/MinCivBoard680Service.java diff --git a/.gitignore b/.gitignore index e2f6364..88e5506 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ build/ /work/ /.gradle/ /src/main/generated/ +/LOG_PATH_IS_UNDEFINED/ diff --git a/build.gradle b/build.gradle index 96ae29c..6b865d2 100644 --- a/build.gradle +++ b/build.gradle @@ -129,23 +129,23 @@ dependencies { //compileOnly 'com.querydsl:querydsl-apt' // JPA mapstruct : lombok 과 함께 사용시 반드시 순서 지겨야 함다 - lombok이 먼저 선언된 경우 - implementation 'org.projectlombok:lombok-mapstruct-binding:0.2.0' - implementation 'org.projectlombok:lombok' - implementation 'org.mapstruct:mapstruct:1.4.2.Final' - annotationProcessor "org.projectlombok:lombok-mapstruct-binding:0.2.0" - annotationProcessor 'org.projectlombok:lombok' - annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final' +// implementation 'org.projectlombok:lombok-mapstruct-binding:0.2.0' +// implementation 'org.projectlombok:lombok' +// implementation 'org.mapstruct:mapstruct:1.4.2.Final' +// annotationProcessor "org.projectlombok:lombok-mapstruct-binding:0.2.0" +// annotationProcessor 'org.projectlombok:lombok' +// annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final' // JPA mapstruct : lombok 과 함께 사용시 반드시 순서 지겨야 함다 - ㅡmapstruct이 먼저 선언된 경우 // target class 에 @Builder 가 있어도 무시하고 생성자 + setter 를 사용하므로 정상적으로 Mapper 클래스를 Generation 하기 위해서 // @NoArgsConstructor, @Setter 가 필요 // but, 최근 Setter 사용을 지양하는 추세라 mapstruct를 먼저 오도록 해서 @Builder 방식으로 Generation -// implementation 'org.mapstruct:mapstruct:1.4.2.Final' -// implementation 'org.projectlombok:lombok-mapstruct-binding:0.2.0' -// implementation 'org.projectlombok:lombok' -// annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final' -// annotationProcessor "org.projectlombok:lombok-mapstruct-binding:0.2.0" -// annotationProcessor 'org.projectlombok:lombok' + implementation 'org.mapstruct:mapstruct:1.4.2.Final' + implementation 'org.projectlombok:lombok-mapstruct-binding:0.2.0' + implementation 'org.projectlombok:lombok' + annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final' + annotationProcessor "org.projectlombok:lombok-mapstruct-binding:0.2.0" + annotationProcessor 'org.projectlombok:lombok' //-----------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------// diff --git a/src/main/java/com/xit/biz/ctgy/controller/MinCivBoard680Controller.java b/src/main/java/com/xit/biz/ctgy/controller/MinCivBoard680Controller.java new file mode 100644 index 0000000..7dba9ac --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/controller/MinCivBoard680Controller.java @@ -0,0 +1,54 @@ +package com.xit.biz.ctgy.controller; + +import com.xit.biz.cmm.dto.CmmUserDto; +import com.xit.biz.cmm.dto.struct.CmmUserMapstruct; +import com.xit.biz.ctgy.dto.MinCivBoard680Dto; +import com.xit.biz.ctgy.dto.struct.MinCivBoard680Mapstruct; +import com.xit.biz.ctgy.service.IMinCivBoard680Service; +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.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "OAuth2LocalController", description = "인증 관리") +@RestController +@RequestMapping("/api/v1/biz/board") +@Validated +@RequiredArgsConstructor +public class MinCivBoard680Controller { + + private final IMinCivBoard680Service minCivBoard680Service; + + private MinCivBoard680Mapstruct minCivBoard680Mapstruct = Mappers.getMapper(MinCivBoard680Mapstruct.class); + + @Operation(summary = "게시판 목록 조회" , description = "게시판 목록 조회") + @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "ciTitle", description = "제목", required = false, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "ciName", description = "이름", required = false, example = " "), + @Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "1"), + @Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10") + }) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findMinCivBoard680s( + @Parameter(hidden = true) + @ModelAttribute("minCivBoard680Dto") + final MinCivBoard680Dto minCivBoard680Dto, + @Parameter(hidden = true) + final Pageable pageable) { + return RestResponse.of(minCivBoard680Service.findMinCivBoard680s(minCivBoard680Mapstruct.toEntity(minCivBoard680Dto), pageable)); + } + +} diff --git a/src/main/java/com/xit/biz/ctgy/dto/MinCivBoard680Dto.java b/src/main/java/com/xit/biz/ctgy/dto/MinCivBoard680Dto.java new file mode 100644 index 0000000..7670b4c --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/dto/MinCivBoard680Dto.java @@ -0,0 +1,64 @@ +package com.xit.biz.ctgy.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; + +@Schema(name = "MinCivBoard680Dto", description = "게시판") +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class MinCivBoard680Dto implements Serializable { + private static final long SerialVersionUID = 1L; + + @Schema(title = "게시판코드", example = " ", description = "Input Description...") + private Long ciCode; + + @Schema(title = "글번호", example = " ", description = "Input Description...") + private Long ciContentno; + + @Schema(title = "제목", example = " ", description = "Input Description...") + private String ciTitle; + + @Schema(title = "사용자 아이디", example = " ", description = "Input Description...") + private String ciId; + + @Schema(title = "사용자패스워드", example = " ", description = "Input Description...") + private String ciPwd; + + @Schema(title = "사용자 성명", example = " ", description = "Input Description...") + private String ciName; + + @Schema(required = false, title = "등록일자", example = " ", description = "Input Description...") + private String ciNalja; + + @Schema(required = false, title = "등록시간", example = " ", description = "Input Description...") + private String ciTime; + + @Schema(required = false, title = "조회수", example = " ", description = "Input Description...") + private Long ciHit; + + @Schema(required = false, title = "REF", example = " ", description = "Input Description...") + private Long ciRef; + + @Schema(required = false, title = "STEP", example = " ", description = "Input Description...") + private Long ciStep; + + @Schema(required = false, title = "LEVEL", example = " ", description = "Input Description...") + private Long ciRevel; + + @Schema(required = false, title = "패스워드", example = " ", description = "Input Description...") + private String ciPass; + + @Schema(required = false, title = "이메일", example = " ", description = "Input Description...") + private String ciEmail; + + @Schema(required = false, title = "내용", example = " ", description = "Input Description...") + private String ciContents; +} diff --git a/src/main/java/com/xit/biz/ctgy/dto/struct/MinCivBoard680Mapstruct.java b/src/main/java/com/xit/biz/ctgy/dto/struct/MinCivBoard680Mapstruct.java new file mode 100644 index 0000000..cc65816 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/dto/struct/MinCivBoard680Mapstruct.java @@ -0,0 +1,12 @@ +package com.xit.biz.ctgy.dto.struct; + +import com.xit.biz.ctgy.dto.MinCivBoard680Dto; +import com.xit.biz.ctgy.entity.MinCivBoard680; +import com.xit.core.support.jpa.mapstruct.IMapstruct; +import com.xit.core.support.jpa.mapstruct.MapStructMapperConfig; +import org.mapstruct.Mapper; + +@Mapper(config = MapStructMapperConfig.class) +public interface MinCivBoard680Mapstruct extends IMapstruct { + +} diff --git a/src/main/java/com/xit/biz/ctgy/entity/MinCivBoard680.java b/src/main/java/com/xit/biz/ctgy/entity/MinCivBoard680.java index 1999574..d39e9a3 100644 --- a/src/main/java/com/xit/biz/ctgy/entity/MinCivBoard680.java +++ b/src/main/java/com/xit/biz/ctgy/entity/MinCivBoard680.java @@ -16,8 +16,6 @@ public class MinCivBoard680 implements Serializable { private static final long SerialVersionUID = 1L; @Id - private Long id; - @Schema(required = true, title = "게시판코드", example = " ", description = "Input Description...") @Column(name = "ci_code", nullable = false) private Long ciCode; diff --git a/src/main/java/com/xit/biz/ctgy/repository/IMinCivBoard680Repository.java b/src/main/java/com/xit/biz/ctgy/repository/IMinCivBoard680Repository.java new file mode 100644 index 0000000..ec84848 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/repository/IMinCivBoard680Repository.java @@ -0,0 +1,11 @@ +package com.xit.biz.ctgy.repository; + +import com.xit.biz.cmm.entity.CmmUser; +import com.xit.biz.ctgy.entity.MinCivBoard680; +import org.springframework.data.domain.Example; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface IMinCivBoard680Repository extends JpaRepository { +} diff --git a/src/main/java/com/xit/biz/ctgy/service/IMinCivBoard680Service.java b/src/main/java/com/xit/biz/ctgy/service/IMinCivBoard680Service.java new file mode 100644 index 0000000..0c80e96 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/service/IMinCivBoard680Service.java @@ -0,0 +1,11 @@ +package com.xit.biz.ctgy.service; + +import com.xit.biz.ctgy.entity.MinCivBoard680; +import com.xit.core.support.jpa.IJpaOperation; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface IMinCivBoard680Service { + + Page findMinCivBoard680s(MinCivBoard680 minCivBoard680, Pageable pageable); +} diff --git a/src/main/java/com/xit/biz/ctgy/service/impl/MinCivBoard680Service.java b/src/main/java/com/xit/biz/ctgy/service/impl/MinCivBoard680Service.java new file mode 100644 index 0000000..75352a2 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/service/impl/MinCivBoard680Service.java @@ -0,0 +1,38 @@ +package com.xit.biz.ctgy.service.impl; + +import com.xit.biz.cmm.entity.CmmUser; +import com.xit.biz.ctgy.entity.MinCivBoard680; +import com.xit.biz.ctgy.repository.IMinCivBoard680Repository; +import com.xit.biz.ctgy.service.IMinCivBoard680Service; +import com.xit.core.support.jpa.JpaUtil; +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.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; + +@Service +public class MinCivBoard680Service implements IMinCivBoard680Service { + + private final IMinCivBoard680Repository minCivBoard680Repository; + + public MinCivBoard680Service(IMinCivBoard680Repository minCivBoard680Repository) { + this.minCivBoard680Repository = minCivBoard680Repository; + } + + @Transactional(readOnly = true) + public Page findMinCivBoard680s(MinCivBoard680 minCivBoard680, Pageable pageable) { + //Sort sort = Sort.by(Sort.Direction.ASC, "codeOrdr"); + pageable = JpaUtil.getPagingInfo(pageable); + ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll() + .withMatcher("ciTitle", contains()) + .withMatcher("ciName", contains()); + Example example = Example.of(minCivBoard680, exampleMatcher); + Page page = minCivBoard680Repository.findAll(example, pageable); + // List userList = page.getContent(); + return page; + } +} diff --git a/src/main/java/com/xit/core/config/SecurityConfig.java b/src/main/java/com/xit/core/config/SecurityConfig.java index 54bf101..cf89ef1 100644 --- a/src/main/java/com/xit/core/config/SecurityConfig.java +++ b/src/main/java/com/xit/core/config/SecurityConfig.java @@ -192,7 +192,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { "/**/*.html", "/**/*.css", "/**/*.js").permitAll() - .antMatchers("/**/auth/**", "/**/oauth2/**", "/**/users/**").permitAll() + .antMatchers("/**/auth/**", "/**/oauth2/**", "/**/users/**", "/**/biz/**").permitAll() .anyRequest().authenticated() .and() //.anyRequest().permitAll() //.hasRole(RoleType.USER.getCode()) diff --git a/src/main/java/com/xit/core/config/support/SpringDocApiConfig.java b/src/main/java/com/xit/core/config/support/SpringDocApiConfig.java index 7bcf629..982669a 100644 --- a/src/main/java/com/xit/core/config/support/SpringDocApiConfig.java +++ b/src/main/java/com/xit/core/config/support/SpringDocApiConfig.java @@ -63,6 +63,16 @@ public class SpringDocApiConfig { ; } + @Bean + public GroupedOpenApi ctgyBizApi() { + return GroupedOpenApi.builder() + .group("Ctgy-biz-API") + .pathsToMatch( + "/api/v1/biz/**" + ) + .build(); + } + @Bean public GroupedOpenApi authorizeApi() { return GroupedOpenApi.builder() diff --git a/src/main/resources/config/application-local.yml b/src/main/resources/config/application-local.yml index c183c45..3ab516e 100644 --- a/src/main/resources/config/application-local.yml +++ b/src/main/resources/config/application-local.yml @@ -17,14 +17,14 @@ spring: # database setting # ================================================================================================================== datasource: - driver-class-name: org.h2.Driver - url: jdbc:h2:mem:xitdb;MODE=Oracle;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - username: sa - password: '' -# driver-class-name: oracle.jdbc.OracleDriver -# url: jdbc:oracle:thin:@211.119.124.118:1521:bustms -# username: traffic -# password: xhdgkq0 +# driver-class-name: org.h2.Driver +# url: jdbc:h2:mem:xitdb;MODE=Oracle;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE +# username: sa +# password: '' + driver-class-name: oracle.jdbc.OracleDriver + url: jdbc:oracle:thin:@211.119.124.118:1521:bustms + username: traffic + password: xhdgkq0 hikari: driver-class-name: ${spring.datasource.driver-class-name} jdbc-url: ${spring.datasource.url} @@ -36,14 +36,15 @@ spring: # JPA setting # ================================================================================================================== jpa: - database-platform: org.hibernate.dialect.H2Dialect -# database-platform: org.hibernate.dialect.Oracle10gDialect +# database-platform: org.hibernate.dialect.H2Dialect + database-platform: org.hibernate.dialect.Oracle10gDialect #show-sql: false properties: hibernate: hbm2ddl: # create / create-drop / update / validate / none - auto: create-drop +# auto: create-drop + auto: none h2: console: diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index d93af4d..8272b10 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -77,7 +77,7 @@ spring: max-lifetime: 1800000 maximum-pool-size: 30 minimum-idle: 5 - transaction-isolation: TRANSACTION_READ_UNCOMMITTED + #transaction-isolation: TRANSACTION_READ_UNCOMMITTED # TRANSACTION_READ_UNCOMMITTED data-source-properties: rewriteBatchedStatements: true