Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
wellbeing-dough committed Oct 14, 2023
2 parents 93fb66a + 4e9d808 commit a330410
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package co.kr.jurumarble.drink.controller;

import co.kr.jurumarble.comment.enums.Region;
import co.kr.jurumarble.drink.controller.request.AddDrink;
import co.kr.jurumarble.drink.controller.request.AddImage;
import co.kr.jurumarble.drink.controller.request.DrinkData;
import co.kr.jurumarble.drink.controller.request.EnjoyDrinkRequest;
import co.kr.jurumarble.drink.controller.request.*;
import co.kr.jurumarble.drink.controller.response.GetDrinkResponse;
import co.kr.jurumarble.drink.controller.response.GetEnjoyedResponse;
import co.kr.jurumarble.drink.controller.response.GetHotDrinksResponse;
Expand Down Expand Up @@ -92,11 +89,19 @@ public ResponseEntity<HttpStatus> addDrinkImage(@RequestBody AddImage image) {
return ResponseEntity.ok().build();
}

@Operation(summary = "전통주 추가")
@Operation(summary = "전통주 추가 테스트")
@PostMapping("/add-test")
public ResponseEntity<Long> addDrink(@RequestBody AddDrink drink) {
Long id = drinkService.addDrink(drink);
return new ResponseEntity(id, HttpStatus.OK);
}

@Operation(summary = "전통주 수정 테스트")
@PutMapping("/update-test")
public ResponseEntity<Long> updateDrink(@RequestBody UpdateDrink drink) {
Long id = drinkService.updateDrink(drink);
return new ResponseEntity(id, HttpStatus.OK);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package co.kr.jurumarble.drink.controller.request;

import lombok.Getter;

@Getter
public class UpdateDrink {
private Long drinkId;
private String name;
private String type;
private String manufacturer;
private String alcoholicBeverage;
private String rawMaterial;
private String capacity;
private String manufactureAddress;
private String region;
private String price;
private String image;
private Double latitude;
private Double longitude;


}
16 changes: 16 additions & 0 deletions src/main/java/co/kr/jurumarble/drink/domain/entity/Drink.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.kr.jurumarble.drink.domain.entity;

import co.kr.jurumarble.drink.controller.request.UpdateDrink;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -82,4 +83,19 @@ public int hashCode() {
public boolean hasSameRegion(Drink drink) {
return region.equals(drink.getRegion());
}

public void updateDrink(UpdateDrink info) {
this.name = info.getName();
this.type = info.getType();
this.manufacturer = info.getManufacturer();
this.alcoholicBeverage = info.getAlcoholicBeverage();
this.rawMaterial = info.getRawMaterial();
this.capacity = info.getCapacity();
this.manufactureAddress = info.getManufactureAddress();
this.region = info.getRegion();
this.price = info.getPrice();
this.image = info.getImage();
this.latitude = info.getLatitude();
this.longitude = info.getLongitude();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import co.kr.jurumarble.drink.controller.request.AddDrink;
import co.kr.jurumarble.drink.controller.request.AddImage;
import co.kr.jurumarble.drink.controller.request.DrinkData;
import co.kr.jurumarble.drink.controller.request.UpdateDrink;
import co.kr.jurumarble.drink.controller.response.GetHotDrinksResponse;
import co.kr.jurumarble.drink.controller.response.GetMapInDrinksResponse;
import co.kr.jurumarble.drink.domain.dto.MapInDrinkData;
Expand Down Expand Up @@ -142,4 +143,11 @@ public Long addDrink(AddDrink drinkInfo) {
Drink drink = drinkInfo.toEntity();
return drinkRepository.save(drink).getId();
}

@Transactional
public Long updateDrink(UpdateDrink drinkInfo) {
Drink drink = drinkRepository.findById(drinkInfo.getDrinkId()).orElseThrow(RuntimeException::new);
drink.updateDrink(drinkInfo);
return drink.getId();
}
}

0 comments on commit a330410

Please sign in to comment.