Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#31
Browse files Browse the repository at this point in the history
  • Loading branch information
oU-Ua authored Feb 14, 2024
2 parents 81cea34 + d9781b4 commit bb727fb
Show file tree
Hide file tree
Showing 68 changed files with 2,232 additions and 127 deletions.
Binary file modified .DS_Store
Binary file not shown.
49 changes: 42 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
buildscript {
ext {
queryDslVersion = "5.0.0"
}
}



plugins {
id 'java'
id 'org.springframework.boot' version '2.6.2'
id 'io.spring.dependency-management' version '1.1.4'

//querydsl 추가
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}

group = 'com.kbds'
Expand All @@ -28,21 +39,21 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'

//querydsl 추가
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
implementation "com.querydsl:querydsl-apt:${queryDslVersion}"


//h2 DB
runtimeOnly 'com.h2database:h2'


runtimeOnly ('mysql:mysql-connector-java') //mysql8
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

//jasypt 설정파일 암호화 라이브러리
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5'



// Security, Authentication
// 시큐리티 추가
implementation 'org.springframework.boot:spring-boot-starter-security'
Expand All @@ -52,10 +63,13 @@ dependencies {
implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation 'io.springfox:springfox-swagger-ui:3.0.0'



// 이미지 S3 업로드
//implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
//pdf view
implementation 'com.itextpdf:itext7-core:7.2.6'
// // 이미지 S3 업로드
// implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
// implementation 'com.amazonaws:aws-java-sdk-s3:1.12.476'
// implementation 'org.apache.tika:tika-core:2.5.0'
// annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"



Expand All @@ -65,3 +79,24 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}




//querydsl 추가 시작
def querydslDir = "$buildDir/generated/querydsl"

querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
configurations {
querydsl.extendsFrom compileClasspath
}
compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
//querydsl 추가 끝
Binary file modified src/.DS_Store
Binary file not shown.
Binary file added src/main/.DS_Store
Binary file not shown.
Binary file added src/main/java/.DS_Store
Binary file not shown.
Binary file added src/main/java/com/.DS_Store
Binary file not shown.
Binary file added src/main/java/com/kbds/.DS_Store
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.kbds.itamserveradmin;

import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.Bean;

import javax.persistence.EntityManager;


@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
Expand All @@ -18,4 +22,9 @@ public static void main(String[] args) {

}

@Bean
public JPAQueryFactory queryFactory(EntityManager em){
return new JPAQueryFactory(em);
}

}
Empty file.
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
package com.kbds.itamserveradmin.domain.asset.controller;
import com.kbds.itamserveradmin.domain.asset.dto.AssetRes;
import com.kbds.itamserveradmin.domain.asset.dto.ManualLogRes;
import com.kbds.itamserveradmin.domain.asset.entity.Asset;
import com.kbds.itamserveradmin.domain.asset.entity.ManualLog;
import com.kbds.itamserveradmin.domain.asset.service.AssetService;
import com.kbds.itamserveradmin.domain.asset.service.ManualLogService;
import com.kbds.itamserveradmin.domain.contract.service.ContractService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

import com.kbds.itamserveradmin.domain.asset.service.AssetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/kbitam")
public class AssetController {

public final AssetService assetService;
private final AssetService assetService;
private final ManualLogService manualLogService;
private final ContractService contractService;

@GetMapping("/{dept}/{cont-id}/info")
public ResponseEntity<AssetRes> info(@PathVariable("cont-id") String contId, @PathVariable String dept){
Expand All @@ -21,4 +42,70 @@ public ResponseEntity<AssetRes> info(@PathVariable("cont-id") String contId, @Pa
}
return ResponseEntity.ok(assetRes);
}
}


@GetMapping("/d/{corpId}")
public ResponseEntity<String> PKtest(@PathVariable("corpId")String corpId){

System.out.println(corpId+"!!!");


return ResponseEntity.ok( assetService.testSaveForcreatePk(corpId));

}


@GetMapping("/{dept}/{cont-id}/allver")
public ResponseEntity<List<ManualLogRes>> allVer(@PathVariable("cont-id") String contId, @PathVariable String dept){
Asset asset = contractService.findAstIdByContId(contId);

List<ManualLog> manualLogs = manualLogService.findByAstId(asset);
List<ManualLogRes> mnLogVersList = manualLogs.stream()
.map(ManualLogRes::allvers)
.collect(Collectors.toList());

return ResponseEntity.ok(mnLogVersList);
}

@GetMapping("/{dept}/{cont-id}/installguide")
public ResponseEntity<byte[]> installGuide(@PathVariable("cont-id") String contId, @PathVariable String dept) throws IOException {
ManualLogRes installGuideRes = assetService.getInstallGuide(contId);
if (installGuideRes == null) {
return ResponseEntity.notFound().build();
}

String pdfFilePath = installGuideRes.getMnLogInstallGuide();

// PDF 파일을 HTML로 변환
ByteArrayOutputStream htmlStream = new ByteArrayOutputStream();
PdfReader reader = new PdfReader(pdfFilePath);
PdfDocument pdfDoc = new PdfDocument(reader);
pdfDoc.copyPagesTo(1, pdfDoc.getNumberOfPages(), new PdfDocument(new com.itextpdf.kernel.pdf.PdfWriter(htmlStream)));
pdfDoc.close();
reader.close();
String htmlContent = new String(htmlStream.toByteArray());

// HTML을 바이트 배열로 변환하여 클라이언트에게 전송
byte[] htmlBytes = htmlContent.getBytes();

// HTTP 응답으로 HTML 파일 반환
return ResponseEntity.ok()
.contentType(MediaType.TEXT_HTML)
.body(htmlBytes);

}
}
// @GetMapping("/{dept}/{cont-id}/pdfView")
// public ModelAndView getPdfView(@PathVariable("cont-id") String contId, @PathVariable String dept) {
// findBycontId
// ManualLog manualLog = manualLogService.findByMnLogId(mnLogId);
// if (manualLog == null) {
// return null;
// }
//
// ModelAndView mav = new ModelAndView();
// mav.setView(new CustomPdfView());
// mav.addObject("manualLog", manualLog);
// return mav;
// }

Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ public static AssetRes assetInfo (Asset asset){
.astPrice(asset.getAstPrice())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.kbds.itamserveradmin.domain.asset.dto;

import lombok.Data;
import org.springframework.web.multipart.MultipartFile;

@Data
public class ManualLogReq {
private MultipartFile file;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.kbds.itamserveradmin.domain.asset.dto;

import com.kbds.itamserveradmin.domain.asset.entity.ManualLog;
import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class ManualLogRes {

private String mnLogId;
private String mnLogVer;
private String mnLogUserGuide;
private String mnLogInstallFile;
private String mnLogInstallGuide;
private String assetId;

public static ManualLogRes installGuideRes(ManualLog manualLog){
return ManualLogRes.builder()
.assetId(manualLog.getAsset().getAstId())
.mnLogId(manualLog.getMnLogId())
.mnLogVer(manualLog.getMnLogVer())
.mnLogInstallFile(manualLog.getMnLogInstallFile())
.mnLogInstallGuide(manualLog.getMnLogInstallGuide())
.build();
}

public static ManualLogRes allvers(ManualLog manualLog){
return ManualLogRes.builder()
.assetId(manualLog.getAsset().getAstId())
.mnLogVer(manualLog.getMnLogVer())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ public class Asset {
private String astDpd;
private String astImgUrl;





}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public class ManualLog {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ast_id")
private Asset asset;

public void updateInstallFilePath(String InsFilePath){
this.mnLogInstallFile = InsFilePath;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
package com.kbds.itamserveradmin.domain.asset.repository;

import com.kbds.itamserveradmin.domain.asset.entity.Asset;
import com.kbds.itamserveradmin.domain.corporation.entity.CorpPK;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;


@Repository
public interface AssetRepository extends JpaRepository<Asset, String> {

Asset findAssetByAstId(String astId);





// @Query("SELECT a " +
// "FROM Asset a " +
// "Where a.corp.corpId = :corp_id " +
// "order by astId desc")
// Asset findCorpCntById(@Param("corp_id") String corp_id);

@Query(value = "SELECT max(a.astId) " +
"FROM Asset a " + // 여기서 공백을 추가해야 함
"WHERE a.corp.corpId = :corp_id " + // WHERE 절에 공백을 추가하고 corp_id의 앞에 콜론(:)을 빼먹지 않아야 함
"ORDER BY a.astId DESC") // ORDER BY 구문을 추가하고 astId 앞에 a.를 빼먹지 않아야 함
String findCorpCntById(@Param("corp_id") String corp_id);

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.kbds.itamserveradmin.domain.asset.repository;

import com.kbds.itamserveradmin.domain.asset.entity.Asset;
import com.kbds.itamserveradmin.domain.asset.entity.ManualLog;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface ManualLogRepository extends JpaRepository<ManualLog, String> {
ManualLog findByAsset_AstId(String astId);
List<ManualLog> findByAsset (Asset asset);
ManualLog findByMnLogId (String mnLogId);
}
Loading

0 comments on commit bb727fb

Please sign in to comment.