Skip to content

[BE/FEAT] 식사 등록 단위에 따른 식사 등록 및 분석 로직 개선 #640

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

Merged
merged 8 commits into from
Mar 25, 2025

Conversation

hwangdaesun
Copy link
Collaborator

📌관련 이슈

closes #639

🔑 주요 변경사항

MEAL_FOOD_TB에 MEAL_FOOD_UNIT_TYPE 칼럼을 추가해 단위별 측정 단위를 명확하게 구분하도록 수정 (기존에는 각 단위가 null임을 사용하여 판별)

기존에는 MealStrategy 인터페이스를 사용해 측정 전략을 관리했으나 측정 방식이 늘어남에 따라 구현체들이 많아져 관리가 힘들어짐. 따라서, UnitType Enum을 사용하여 단위별 측정 전략을 직접 관리하도록 수정

변경 전)

public interface MeasureStrategy {
    double measure(double nutrients, Unit unit, double servingSize);
}

public class GStrategy implements MeasureStrategy {
    @Override
    public double measure(double nutrients, Unit unit, double servingSize) {
        return (unit.getG() / servingSize) * nutrients;
    }
}

public class MultipleStrategy implements MeasureStrategy {
    @Override
    public double measure(double nutrients, Unit unit, double servingSize) {
        return nutrients * unit.getMultiple();
    }
}

변경 후)

public enum UnitType {
    G {
        @Override
        public double measure(double nutrients, Unit unit, double servingSize) {
            return (unit.getG() / servingSize) * nutrients;
        }
    },
    MULTIPLE {
        @Override
        public double measure(double nutrients, Unit unit, double servingSize) {
            return nutrients * unit.getMultiple();
        }
    };

    abstract double measure(double nutrients, Unit unit, double servingSize);
}

@hwangdaesun hwangdaesun added this to the BE_daesun milestone Mar 25, 2025
@hwangdaesun hwangdaesun requested a review from LJH098 March 25, 2025 07:26
@hwangdaesun hwangdaesun self-assigned this Mar 25, 2025
Copy link

Overall Project NaN% NaN% 🍏

There is no coverage information present for the Files changed

Copy link

Overall Project NaN% NaN% 🍏

There is no coverage information present for the Files changed

@hwangdaesun hwangdaesun changed the title Feat/#639 [BE/FEAT] 식사 등록 단위에 따른 식사 등록 및 분석 로직 개선 Mar 25, 2025
Copy link

Overall Project NaN% NaN% 🍏

There is no coverage information present for the Files changed

@hwangdaesun hwangdaesun merged commit 0eabe7e into develop Mar 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE/FEAT] 식사 등록 단위에 따른 식사 등록 및 분석 로직 개선
1 participant