Skip to content

Commit

Permalink
Merge pull request #75 from Tea-Bliss/dev
Browse files Browse the repository at this point in the history
완성차 수정안되는 로직 수정
  • Loading branch information
lemonticsoul authored Jun 21, 2024
2 parents 49bc24a + 639f7e2 commit 8d857d5
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 42 deletions.
1 change: 0 additions & 1 deletion src/main/java/store/teabliss/basket/dto/BasketDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

public class BasketDto {



private String product;

Expand Down
17 changes: 8 additions & 9 deletions src/main/java/store/teabliss/tea/controller/TeaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public ResponseEntity<?> lowcost(@RequestParam("page") int page,@RequestParam("l

}

@GetMapping("all")
@GetMapping("/all")
@Operation(summary = "모두 조회", description = "모든 차를 조회하는 로직입니다.")
public ResponseEntity<?> all(@RequestParam("page") int page,@RequestParam("limit") int limit ){

Expand All @@ -117,9 +117,9 @@ public ResponseEntity<?> all(@RequestParam("page") int page,@RequestParam("limit


}
@GetMapping("findtea")
@GetMapping("/findtea/{id}")
@Operation(summary = "티 상세 조회", description = "차 하나만 조회하는 로직")
public ResponseEntity<TeaSearchDto> responseid(@RequestParam("id") int id){
public ResponseEntity<TeaSearchDto> responseid(@PathVariable(name="id") int id){


TeaSearchDto tea=teaService.find(id);
Expand All @@ -129,7 +129,7 @@ public ResponseEntity<TeaSearchDto> responseid(@RequestParam("id") int id){

}

@GetMapping("category")
@GetMapping("/category")
@Operation(summary = "카테고리 조회", description = "차 하나만 조회하는 로직")
public ResponseEntity<?> category(@RequestParam("page") int page,@RequestParam("limit") int limit,@RequestParam("category") String categroy){

Expand All @@ -144,7 +144,7 @@ public ResponseEntity<?> category(@RequestParam("page") int page,@RequestParam("
return ResponseEntity.ok(response);
}

@GetMapping("season")
@GetMapping("/season")
@Operation(summary = "시즌별 조회", description = "차 하나만 조회하는 로직")
public ResponseEntity<?> season(@RequestParam("page") int page,@RequestParam("limit") int limit,@RequestParam("season") String season){

Expand All @@ -160,7 +160,7 @@ public ResponseEntity<?> season(@RequestParam("page") int page,@RequestParam("li

}

@GetMapping("caffeine")
@GetMapping("/caffeine")
@Operation(summary = "카페인 조회", description = "차 하나만 조회하는 로직")
public ResponseEntity<?> caffeine(@RequestParam("page") int page,@RequestParam("limit") int limit,@RequestParam("caffeine") boolean caffeine){

Expand All @@ -174,7 +174,7 @@ public ResponseEntity<?> caffeine(@RequestParam("page") int page,@RequestParam("

}

@DeleteMapping("delete/{id}")
@DeleteMapping("/delete/{id}")
@Operation(summary = "완성차 삭제 ", description = "차 하나만 조회하는 로직")
public ResponseEntity<?> teaDelete(@PathVariable(name="id") int id){

Expand All @@ -188,8 +188,7 @@ public ResponseEntity<?> teaDelete(@PathVariable(name="id") int id){

@PatchMapping("patch/{id}")
@Operation(summary = "완성차 수정 ", description = "차 하나만 조회하는 로직")
public ResponseEntity<?> teaPatch(@PathVariable(name="id") Long id,TeaPatchDto teaPatchDto){

public ResponseEntity<?> teaPatch(@PathVariable(name="id") Long id,@RequestBody TeaPatchDto teaPatchDto){


boolean patch=teaService.patchtea(id,teaPatchDto);
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/store/teabliss/tea/dto/TeaDto.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package store.teabliss.tea.dto;


import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;

import lombok.Getter;
import lombok.Setter;

import java.sql.Timestamp;

import java.util.ArrayList;
import java.util.Date;


@Getter
@Setter
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/store/teabliss/tea/dto/TeaPatchDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
@Setter
public class TeaPatchDto {

private Long id ;

private Long price;
private String category ;

Expand All @@ -19,6 +17,7 @@ public class TeaPatchDto {
private boolean caffeine;
private String description;
private String img;

private Long inventory ;

private ArrayList<Long> ingredient;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/store/teabliss/tea/entity/TeaFlavor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package store.teabliss.tea.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

Expand All @@ -9,6 +10,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TeaFlavor {

private Long teaId;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/store/teabliss/tea/entity/TeaIngredient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

Expand All @@ -10,6 +11,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TeaIngredient {

private Long teaId;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/store/teabliss/tea/mapper/TeaMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public interface TeaMapper {
List<Tea> caffeinesort(boolean caffeine);

boolean deletetea(int id);
boolean patchtea(Long id, Tea tea);
boolean patchtea(Tea tea);

void updateIngredient(Long id,TeaIngredient teaIngredient);
void updateIngredient(TeaIngredient teaIngredient);

void updateFlavor(Long id,TeaFlavor teaFlavor);
void updateFlavor(TeaFlavor teaFlavor);



Expand Down
24 changes: 14 additions & 10 deletions src/main/java/store/teabliss/tea/service/TeaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public boolean deletetea(int id){
public boolean patchtea(Long id,TeaPatchDto teaPatchDto){

Tea updatetea = Tea.builder()
.id(teaPatchDto.getId())
.id(id)
.price(teaPatchDto.getPrice())
.category(teaPatchDto.getCategory())
.name(teaPatchDto.getName())
Expand All @@ -362,24 +362,28 @@ public boolean patchtea(Long id,TeaPatchDto teaPatchDto){
.build();

List<Long> temp1=teaPatchDto.getIngredient();

for (Long t1:temp1){
TeaIngredient teaingredient =new TeaIngredient();
teaingredient.setIngredientId(t1);
teaingredient.setTeaId(id);
teaMapper.updateIngredient(id,teaingredient);
TeaIngredient teaingredient =TeaIngredient.builder()
.ingredientId(t1)
.teaId(id)
.build();

teaMapper.updateIngredient(teaingredient);
}

List<Long> temp2=teaPatchDto.getFlavor();

for (Long t2:temp2){
TeaFlavor teaflavor =new TeaFlavor();
teaflavor.setFlavor(t2);
teaflavor.setTeaId(id);
teaMapper.updateFlavor(id,teaflavor);
TeaFlavor teaflavor =TeaFlavor.builder()
.flavor(t2)
.teaId(id)
.build();
teaMapper.updateFlavor(teaflavor);
}


boolean result=teaMapper.patchtea(id,updatetea);
boolean result=teaMapper.patchtea(updatetea);

return result;
}
Expand Down
23 changes: 11 additions & 12 deletions src/main/resources/mapper/TeaMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@
<select id="recommend">
SELECT *
FROM TEA
ORDER BY rate DESC, createDt
ORDER BY rate DESC, create_dt
</select>

<select id="sale">
SELECT *
FROM TEA
ORDER BY sale DESC, createDt
ORDER BY sale DESC, create_dt
</select>

<select id="topcost">
SELECT *
FROM TEA
ORDER BY price DESC, createDt
ORDER BY price DESC, create_dt
</select>

<select id="lowcost">
SELECT *
FROM TEA
ORDER BY price, createDt
ORDER BY price, create_dt
</select>

<select id="all">
Expand Down Expand Up @@ -121,7 +121,7 @@
price=IFNULL(#{price}, price),
category=IFNULL(#{category}, category),
name=IFNULL(#{name}, name),
nameEng=IFNULL(#{nameEng}, nameEng),
name_eng=IFNULL(#{nameEng}, name_eng),
caffeine=IFNULL(#{caffeine}, caffeine),
description=IFNULL(#{description}, description),
img=IFNULL(#{img}, img),
Expand All @@ -132,19 +132,18 @@
<update id="updateIngredient" >
UPDATE TEAINGREDIENT
SET
ingredient_id=IFNULL(#{ingredientId},ingredientId)
ingredient_id=IFNULL(#{ingredientId},ingredient_id)
WHERE tea_id= #{teaId}

WHERE 1=1
AND id= #{id}
</update>

<update id="updateFlavor" >
UPDATE TEAINGREDIENT
<update id="updateFlavor" >
UPDATE TEAFLAVOR
SET
flavor_id=IFNULL(#{flavorId},flavorId)
flavor_id=IFNULL(#{flavor},flavor_id)

WHERE 1=1
AND id= #{id}
AND tea_id= #{teaId}
</update>


Expand Down

0 comments on commit 8d857d5

Please sign in to comment.