Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE/FEAT] redis autocomplete 데이터 셋 변경 #561

Closed
wants to merge 8 commits into from
12,943 changes: 12,152 additions & 791 deletions BE/exceed/food_data.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
@RequestMapping("/v1")
@SecurityRequirement(name = "access-token")
@Tag(name = SwaggerTag.ACCOUNT_MANAGEMENT)
public class UpdatePasswordController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class GStrategy implements MeasureStrategy {
@Override
public double measure(double value, Unit unit) {
return value * unit.getG();
public double measure(double nutrients, Unit unit, double servingSize) {
return (nutrients / servingSize) * unit.getG();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ public static List<MealFoodEntity> createMealFoods(
return mealFoodEntities;
}

public double getAdjustedCalorie() {
return this.unit
.getStrategy()
.measure(this.foodEntity.getCalorie(), unit, this.foodEntity.getServingSize());
}

public double getAdjustedCarbohydrate() {
return unit.getStrategy()
.measure(this.foodEntity.getCarbohydrate(), unit, this.foodEntity.getServingSize());
}

public double getAdjustedProtein() {
return unit.getStrategy()
.measure(this.foodEntity.getProtein(), unit, this.foodEntity.getServingSize());
}

public double getAdjustedFat() {
return unit.getStrategy()
.measure(this.foodEntity.getFat(), unit, this.foodEntity.getServingSize());
}
@Override
public String toString() {
return "MealFoodEntity{"
Expand All @@ -76,19 +96,4 @@ public String toString() {
+ '}';
}

public double getAdjustedCalorie() {
return this.unit.getStrategy().measure(this.foodEntity.getCalorie(), unit);
}

public double getAdjustedCarbohydrate() {
return unit.getStrategy().measure(this.foodEntity.getCarbohydrate(), unit);
}

public double getAdjustedProtein() {
return unit.getStrategy().measure(this.foodEntity.getProtein(), unit);
}

public double getAdjustedFat() {
return unit.getStrategy().measure(this.foodEntity.getFat(), unit);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.gaebaljip.exceed.application.domain.meal;

public interface MeasureStrategy {
double measure(double value, Unit unit);
double measure(double nutrients, Unit unit, double servingSize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class MultipleStrategy implements MeasureStrategy {
@Override
public double measure(double value, Unit unit) {
return value * unit.getMultiple();
public double measure(double nutrients, Unit unit, double servingSize) {
return nutrients * unit.getMultiple();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public void run(ApplicationArguments args) throws Exception {
List<String[]> allRows = reader.readAll();
int pk = 1;
for (String[] row : allRows) {
if (row != null && row.length > 0 && !row[4].isEmpty()) {
String foodName = row[4].trim();
if (row != null && row.length > 0 && !row[0].isEmpty()) {
String foodName = row[0].trim();
addFoodToAutocomplete(foodName, pk);
}
pk++;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.gaebaljip.exceed.common.security.config;

import java.util.Arrays;

import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
Expand All @@ -11,10 +9,7 @@
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.CorsUtils;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import com.gaebaljip.exceed.common.security.domain.JwtManager;
import com.gaebaljip.exceed.common.security.domain.JwtResolver;
Expand Down Expand Up @@ -51,9 +46,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.cors()
.configurationSource(corsConfigurationSource())
.and()
.exceptionHandling()
.authenticationEntryPoint(jwtAuthenticationPoint)
.and()
Expand Down Expand Up @@ -94,24 +86,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.build();
}

@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();

configuration.setAllowedOrigins(Arrays.asList("http://localhost:3000"));
configuration.setAllowedMethods(
Arrays.asList("HEAD", "POST", "GET", "DELETE", "PUT", "PATCH", "OPTIONS"));
configuration.setAllowedHeaders(
Arrays.asList("Authorization", "Cache-Control", "Content-Type"));
configuration.setExposedHeaders(Arrays.asList("Authorization"));
configuration.setMaxAge(3600L);
configuration.setAllowCredentials(true);

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}

@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) ->
Expand Down
Loading