-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/UMC-5th-Muffler/Money-Pl…
…anner-BE into release
- Loading branch information
Showing
35 changed files
with
674 additions
and
108 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
src/main/java/com/umc5th/muffler/domain/dailyplan/repository/DailyPlanJdbcRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.umc5th.muffler.domain.dailyplan.repository; | ||
|
||
import com.umc5th.muffler.entity.DailyPlan; | ||
import java.sql.Date; | ||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class DailyPlanJdbcRepository { | ||
|
||
private final JdbcTemplate jdbcTemplate; | ||
|
||
public void batchInsert(List<DailyPlan> dailyPlans) { | ||
String sql = "INSERT INTO daily_plan (date, budget, is_zero_day, total_cost, goal_id) VALUES (?, ?, ?, ?, ?)"; | ||
|
||
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { | ||
@Override | ||
public void setValues(PreparedStatement ps, int i) throws SQLException { | ||
DailyPlan dailyPlan = dailyPlans.get(i); | ||
ps.setDate(1, Date.valueOf(dailyPlan.getDate())); | ||
ps.setLong(2, dailyPlan.getBudget()); | ||
ps.setBoolean(3, dailyPlan.getIsZeroDay()); | ||
ps.setLong(4, dailyPlan.getTotalCost()); | ||
ps.setLong(5, dailyPlan.getGoal().getId()); | ||
} | ||
|
||
@Override | ||
public int getBatchSize() { | ||
return dailyPlans.size(); | ||
} | ||
}); | ||
} | ||
|
||
public void batchUpdateBudget(List<DailyPlan> dailyPlans, List<Long> dailyBudgets) { | ||
String sql = "UPDATE daily_plan SET budget = ? WHERE id = ?"; | ||
|
||
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() { | ||
@Override | ||
public void setValues(PreparedStatement ps, int i) throws SQLException { | ||
DailyPlan dailyPlan = dailyPlans.get(i); | ||
Long budget = dailyBudgets.get(i); | ||
ps.setLong(1, budget); | ||
ps.setLong(2, dailyPlan.getId()); | ||
} | ||
|
||
@Override | ||
public int getBatchSize() { | ||
return dailyPlans.size(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/umc5th/muffler/domain/goal/dto/CategoryGoalsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.umc5th.muffler.domain.goal.dto; | ||
|
||
import java.util.List; | ||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CategoryGoalsRequest { | ||
@NotNull @Valid | ||
private List<CategoryGoalRequest> categoryGoals; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/umc5th/muffler/domain/goal/dto/DailyBudgetsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.umc5th.muffler.domain.goal.dto; | ||
|
||
import java.util.List; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class DailyBudgetsRequest { | ||
@NotNull | ||
private List<Long> dailyBudgets; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.