Skip to content

Commit

Permalink
Merge pull request #41 from taking/taking
Browse files Browse the repository at this point in the history
Chore: 파일 관리 기능 - minio 제거, GridFS 추가
  • Loading branch information
taking authored Oct 25, 2023
2 parents 534280e + 540893c commit 52b2c8a
Show file tree
Hide file tree
Showing 29 changed files with 398 additions and 951 deletions.
10 changes: 3 additions & 7 deletions application.properties_docker
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ server.port=8888
#server.error.include-message=always
server.servlet.encoding.charset=UTF-8
server.servlet.encoding.force=true
spring.servlet.multipart.max-file-size=3096MB
spring.servlet.multipart.max-request-size=3096MB
spring.servlet.multipart.max-file-size=${MAX_UPLOAD_SIZE:3096MB}
spring.servlet.multipart.max-request-size=${MAX_UPLOAD_SIZE:3096MB}
spring.servlet.multipart.enabled=true

# Swagger springdoc-ui Configuration
Expand Down Expand Up @@ -45,8 +45,4 @@ spring.mail.password=${SMTP_PASS:-passWord}
#echo 'lab-cherry-nw-project-secret-key' | base64
lab.cherry.nw.jwtSecret= bGFiLWNoZXJyeS1udy1wcm9qZWN0LXNlY3JldC1rZXkK
lab.cherry.nw.jwtExpirationMs= 86400000

# MinIo Properties
minio.url=${MINIO_URL:-http://nw-storage:9000}
minio.access-key=${MINIO_ACCESS_KEY:-admin}
minio.secret-key=${MINIO_SECRET_KEY:-nangmanwedding}
lab.cherry.nw.uploadPath= ${UPLOAD_PATH:/data}
28 changes: 5 additions & 23 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ services:
DATABASE_NAME: nw
DATABASE_USERID: nw
DATABASE_USERPASS: nw
UPLOAD_PATH: /data
MAX_UPLOAD_SIZE: 3096MB
#SPRING_PROFILES_ACTIVE: prod
JAVA_OPTS: "-Xms256m -Xmx512m -XX:+UseG1GC"
ports:
- "8081:8888"
depends_on:
- nw-db
- nw-redis
- nw-storage
# volumes:
# - ./log:/log/spring

volumes:
- ./nw_data:/data

nw-db:
image: 'bitnami/mongodb:latest'
Expand Down Expand Up @@ -55,22 +55,4 @@ services:
- no-new-privileges:true
volumes:
- './redis_data:/data'
- '/etc/localtime:/etc/localtime:ro'


nw-storage:
image: 'minio/minio:RELEASE.2023-09-04T19-57-37Z'
container_name: nw-storage
command: server --console-address ":9001" /data
restart: unless-stopped
logging:
driver: json-file
environment:
MINIO_ACCESS_KEY: admin
MINIO_SECRET_KEY: nangmanwedding
ports:
- "9000:9000"
- "9001:9001"
volumes:
- './storage_data:/data'

- '/etc/localtime:/etc/localtime:ro'
11 changes: 3 additions & 8 deletions docker-compose/.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ DATABASE_NAME=nw
DATABASE_USERID=admin
DATABASE_USERPASS=admin
#SPRING_PROFILES_ACTIVE=prod
MINIO_URL=http://nw-storage:9000
MINIO_ACCESS_KEY=admin
MINIO_SECRET_KEY=4FqfsKQUVWsca3MsAUVtgcf2
UPLOAD_PATH=/data
MAX_UPLOAD_SIZE=3096MB
REDIS_HOST=nw-redis
REDIS_PORT=8083
JAVA_OPTS="-Xms256m -Xmx512m -XX:+UseG1GC"
Expand All @@ -26,8 +25,4 @@ SMTP_PASS=null
# nw-db
MONGO_INITDB_DATABASE=nw
MONGO_INITDB_ROOT_USERNAME=admin
MONGO_INITDB_ROOT_PASSWORD=admin

# nw-storage
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=4FqfsKQUVWsca3MsAUVtgcf2
MONGO_INITDB_ROOT_PASSWORD=admin
16 changes: 0 additions & 16 deletions docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ services:
ports:
- "8081:8888"
depends_on:
- nw-storage
- nw-db
- nw-redis
- nw-smtp
Expand Down Expand Up @@ -42,21 +41,6 @@ services:
- './redis_data:/data'
- '/etc/localtime:/etc/localtime:ro'

nw-storage:
image: 'minio/minio:RELEASE.2023-09-04T19-57-37Z'
container_name: nw-storage
command: server --console-address ":9001" /data
restart: unless-stopped
logging:
driver: json-file
env_file:
- ./.env
ports:
- "9000:9000"
- "9001:9001"
volumes:
- './storage_data:/data'

mailhog:
image: jcalonso/mailhog
container_name: 'mailhog'
Expand Down
21 changes: 8 additions & 13 deletions nw/src/main/java/lab/cherry/nw/configuration/Initalizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import lab.cherry.nw.repository.OrgRepository;
import lab.cherry.nw.repository.RoleRepository;
import lab.cherry.nw.repository.UserRepository;
import lab.cherry.nw.service.MinioService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.security.crypto.password.PasswordEncoder;
Expand All @@ -18,20 +19,23 @@
import java.security.NoSuchAlgorithmException;
import java.time.Instant;

@Slf4j
@RequiredArgsConstructor
@Component
public class Initalizer implements ApplicationRunner {


@Value("${lab.cherry.nw.uploadPath}")
private String uploadPath;

private final UserRepository userRepository;
private final RoleRepository roleRepository;
private final OrgRepository orgRepository;
private final PasswordEncoder passwordEncoder;
private final MinioService minioService;

@Override
public void run(ApplicationArguments args) {


if(roleRepository.findByName("ROLE_ADMIN").isEmpty()) {

RoleEntity roleEntity = RoleEntity.builder()
Expand All @@ -58,6 +62,7 @@ public void run(ApplicationArguments args) {
.name("DEFAULT")
.biznum("123-45-67890")
.contact("02-0000-0000")
.address("파인에비뉴")
.enabled(true)
.created_at(instant)
.build();
Expand Down Expand Up @@ -95,15 +100,5 @@ public void run(ApplicationArguments args) {
.enabled(true)
.build());
}

// 'user' Bucket 생성
try {
minioService.createBucketIfNotExists("user");
minioService.createGlobalPolicy("user");
minioService.setBucketPolicy("user");
} catch (InvalidKeyException | NoSuchAlgorithmException | IOException e) {
// log.error("{}, e");
// e.printStackTrace();
}
}
}
84 changes: 0 additions & 84 deletions nw/src/main/java/lab/cherry/nw/configuration/bean/MinioConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse

}

private boolean checkAccessToken(AccessToken accessToken) {
private Boolean checkAccessToken(AccessToken accessToken) {
if (accessToken == null) return false;
return tokenService.validateToken(accessToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,11 @@ public ResponseEntity<?> findAllBanquets(
@ApiResponse(responseCode = "400", description = "입력 값이 잘못되었습니다.", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
public ResponseEntity<?> createBanquet(@Valid @RequestPart BanquetEntity.BanquetCreateDto banquetCreateDto,
@RequestPart List<MultipartFile> files) {
@RequestPart List<MultipartFile> images) {

log.info("[BanquetController] createBanquet...!");

log.error("이름 : {}", banquetCreateDto.getBanquetName());
log.error("조직 : {}", banquetCreateDto.getOrg());
log.error("이미지 : {}", files);

BanquetEntity banquetEntity = banquetService.createBanquet(banquetCreateDto, files);
BanquetEntity banquetEntity = banquetService.createBanquet(banquetCreateDto, images);

return new ResponseEntity<>(banquetEntity, new HttpHeaders(), HttpStatus.OK);
}
Expand Down
Loading

0 comments on commit 52b2c8a

Please sign in to comment.