Skip to content

Commit

Permalink
[BE] Todo: 게시글 등록 API
Browse files Browse the repository at this point in the history
  • Loading branch information
shkum0330 committed Sep 12, 2023
1 parent 32f7684 commit 6f1ca09
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/share/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
// implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
// implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
// runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ssafy.share.api.mapper;


import com.ssafy.share.api.request.ShareBoardWriteRequest;
import com.ssafy.share.db.entity.SharePost;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.ERROR)
public interface ShareBoardMapper {
ShareBoardMapper INSTANCE = Mappers.getMapper(ShareBoardMapper.class);

@Mappings({
@Mapping(target = "thumbnail", ignore = true),
@Mapping(target = "shareImages", ignore = true),
@Mapping(target = "shareIngredients", ignore = true),
@Mapping(target = "member", ignore = true),
@Mapping(target = "locationInfo", ignore = true)
})
SharePost postWriteRequestToPost(ShareBoardWriteRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.ssafy.share.api.request;


import com.ssafy.share.db.entity.ShareIngredient;
import lombok.Data;

import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

@Data
public class ShareBoardWriteRequest {

private Long memberId;
private Short locationId;
private String title;
private String content;
private List<ShareIngredient> shareIngredients;
private List<String> shareImages;

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,16 @@ public class SharePost extends BaseTimeEntity{

@Column(name="thumbnail",length = 255)
private String thumbnail;

public SharePost(Member member, LocationInfo locationInfo,
String title, String content, List<ShareImage> shareImages,
List<ShareIngredient> shareIngredients, String thumbnail) {
this.member = member;
this.locationInfo = locationInfo;
this.title = title;
this.content = content;
this.shareImages = shareImages;
this.shareIngredients = shareIngredients;
this.thumbnail = thumbnail;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.ssafy.share.db.repository;

import com.ssafy.share.db.entity.SharePost;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ShareBoardRepository extends JpaRepository<SharePost,Long> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.ssafy.share.service;

public interface ShareBoardService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ssafy.share.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class ShareBoardServiceImpl {
}
3 changes: 3 additions & 0 deletions backend/share/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
server:
port: 8080

spring:
config:
import: env.yml
Expand Down

0 comments on commit 6f1ca09

Please sign in to comment.