Skip to content

Commit

Permalink
BE - 기프티콘 객체에 thumbnail 멤버 변수 추가
Browse files Browse the repository at this point in the history
BE - 기프티콘 객체에 thumbnail 멤버 변수 추가
  • Loading branch information
201724554 authored Feb 10, 2023
2 parents c497098 + fb1c395 commit 4c3dac7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions amatta_server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sourceCompatibility = '11'

repositories {
mavenCentral()
google()
}

dependencies {
Expand All @@ -35,6 +36,9 @@ dependencies {
annotationProcessor('org.projectlombok:lombok')
testAnnotationProcessor('org.projectlombok:lombok')
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.24'

implementation group: 'com.google.firebase', name: 'firebase-admin', version: '9.0.0'
implementation group: 'com.google.cloud', name: 'google-cloud-storage', version: '2.17.2'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import javax.validation.Valid;

@RestController
@CrossOrigin(origins = "http://15.164.13.149:5173/", allowCredentials = "true")
@CrossOrigin(origins = "https://amatta.site/", allowCredentials = "true")
@RequestMapping("/gifticon")
public class GifticonController {
private final GifticonService gifticonService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class GifticonDto {
@NotEmpty
private String image;
@NotEmpty
private String thumbnail;
@NotEmpty
private String barcode;
@NotEmpty
private String expiresAtInString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Gifticon {
private long id;
private long uid;
private byte[] image;
private byte[] thumbnail;
private String brandname;
private String itemname;
private String barcode;
Expand All @@ -29,6 +30,10 @@ public byte[] getImage() {
return image;
}

public byte[] getThumbnail() {
return thumbnail;
}

public String getBrandName() {
return brandname;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public interface GifticonRepository extends CrudRepository<Gifticon, Long> {
"itemName, " +
"brandName, " +
"image, " +
"thumbnail, " +
"barcode, " +
"price, " +
"expiresAt, " +
Expand All @@ -33,11 +34,12 @@ public interface GifticonRepository extends CrudRepository<Gifticon, Long> {
Optional<Gifticon> findById(@Param("id") long id);

@Modifying
@Query("INSERT INTO gifticon(uid, image, brandName, itemName, barcode, expiresAt, usedAt, price)" +
" VALUES (:uid, :image, :brandName, :itemName, :barcode, :expiresAt, :usedAt, :price)")
@Query("INSERT INTO gifticon(uid, image, thumbnail, brandName, itemName, barcode, expiresAt, usedAt, price)" +
" VALUES (:uid, :image, :thumbnail, :brandName, :itemName, :barcode, :expiresAt, :usedAt, :price)")
void addGifticon(
@Param("uid") long uid,
@Param("image") byte[] image,
@Param("thumbnail") byte[] thumbnail,
@Param("brandName") String brandName,
@Param("itemName") String itemName,
@Param("barcode") String barcode,
Expand All @@ -52,6 +54,7 @@ void addGifticon(
"itemName, " +
"brandName, " +
"image, " +
"thumbnail, " +
"barcode, " +
"price, " +
"expiresAt, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public Gifticon mapTextToGifticon(GifticonTextDto dto) throws NullPointerExcepti
public void addGifticon(GifticonDto dto) throws DuplicateGifticonException {
long uid = getUserBySessionId().getId();
byte[] image = dto.getImage().getBytes();
byte[] thumbnail = dto.getThumbnail().getBytes();
String brandName = dto.getBrandName();
String itemName = dto.getItemName();
String barcode = dto.getBarcode();
Expand All @@ -75,6 +76,7 @@ public void addGifticon(GifticonDto dto) throws DuplicateGifticonException {
gifticonRepository.addGifticon(
uid,
image,
thumbnail,
brandName,
itemName,
barcode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void GifticonAddRequest() throws Exception {
"\"itemName\": \"아메리카노\", " +
"\"brandName\": \"스타벅스\", " +
"\"image\": \"adfadf\", " +
"\"thumbnail\": \"adfadfa\", " +
"\"price\": \"3000\", " +
"\"barcode\": \"12341234\", " +
"\"expiresAtInString\": \"2023/11/11\"" +
Expand All @@ -78,6 +79,7 @@ public void DuplicateBarcodeGifticonAddRequest() throws Exception {
"\"itemName\": \"아메리카노\", " +
"\"brandName\": \"스타벅스\", " +
"\"image\": \"adfadf\", " +
"\"thumbnail\": \"adfadfa\", " +
"\"price\": \"3000\", " +
"\"barcode\": \"12341234\", " +
"\"expiresAtInString\": \"2023/11/11\"" +
Expand All @@ -103,6 +105,7 @@ public void BarcodeGifticonAddRequestWithNullAttr() throws Exception {
String requestBody = "{" +
"\"itemName\": \"아메리카노\", " +
"\"image\": \"adfadf\", " +
"\"thumbnail\": \"adfadfa\", " +
"\"price\": \"3000\", " +
"\"barcode\": \"12341234\", " +
"\"expiresAtInString\": \"2023/11/11\"" +
Expand All @@ -129,6 +132,7 @@ public void GifticonListTest() throws Exception {
"\"itemName\": \"아메리카노\", " +
"\"brandName\": \"스타벅스\", " +
"\"image\": \"adfadf\", " +
"\"thumbnail\": \"adfadfa\", " +
"\"price\": \"3000\", " +
"\"barcode\": \"12341234000\", " +
"\"expiresAtInString\": \"2023/11/11\"" +
Expand All @@ -144,6 +148,7 @@ public void GifticonListTest() throws Exception {
"\"itemName\": \"아메리카노\", " +
"\"brandName\": \"스타벅스\", " +
"\"image\": \"adfadf\", " +
"\"thumbnail\": \"adfadfa\", " +
"\"price\": \"3000\", " +
"\"barcode\": \"109123124\", " +
"\"expiresAtInString\": \"2023/11/11\"" +
Expand All @@ -170,6 +175,7 @@ public void GifticonUseTest() throws Exception {
"\"itemName\": \"아메리카노\", " +
"\"brandName\": \"스타벅스\", " +
"\"image\": \"adfadf\", " +
"\"thumbnail\": \"adfadfa\", " +
"\"price\": \"3000\", " +
"\"barcode\": \"12341234000\", " +
"\"expiresAtInString\": \"2023/11/11\"" +
Expand Down

0 comments on commit 4c3dac7

Please sign in to comment.