team-delight / delight-server Goto Github PK
View Code? Open in Web Editor NEWHanghae99 2nd Team Delight BackEnd Server
Hanghae99 2nd Team Delight BackEnd Server
작업
음식 카테고리 DB 입력
Food Data 입력
PS -
음식 Category 추상화 레벨 이슈로 가장 큰 추상화 레벨로 Category 생성
이미지는 네이버 음식백과를 기준으로 최대한 가져온다.
Tag Table Add Column String TagType
User, Recommendation Table N:M 연관관계 설정
Recommendation Table count 컬럼 드랍
CategoryId = 0
일 경우 카테고리에 상관없는 전체 조회, CategoryId != 0
일 경우 해당 카테고리별 조회00시~12시
까지는 전날에 대한 카테고리별 랭킹 Top10, 12시~24시
는 당일에 대한 카테고리별 랭킹 Top10@Override
public List<RecommendationRankResponse> findAllTopTenByCategoryId(Long id) {
JPAQuery<RecommendationRankResponse> query = queryFactory
.select(Projections.constructor(RecommendationRankResponse.class,
foodRecommendation.recommendation.count,
foodRecommendation.food.name,
foodRecommendation.food.imgUrl,
foodRecommendation.food.category.id))
.from(foodRecommendation)
.innerJoin(foodRecommendation.recommendation, recommendation)
.innerJoin(foodRecommendation.food, food)
.innerJoin(food.category, category);
BooleanBuilder booleanBuilder = new BooleanBuilder();
/*
현재시간이 오전인지 오후인지 판별
오전 : 전날 추천받은 게시물 , 오후 : 당일 추천받은 게시물
*/
whetherAmPm(booleanBuilder);
/*
CategoryId = 0 이면 전체 추천랭킹 게시물 조회
CategoryId != 0 이면 해당 카테고리별 게시물 조회
*/
whetherCategoryId(id, booleanBuilder);
return query.where(booleanBuilder)
.orderBy(countDesc())
.limit(10)
.fetch();
}
private void whetherAmPm(BooleanBuilder booleanBuilder) {
LocalDateTime nowTime = LocalDateTime.now();
LocalDateTime startAmToday = LocalDateTime.now().toLocalDate().atStartOfDay();
LocalDateTime endAmToday = LocalDateTime.now().toLocalDate().atStartOfDay().plusHours(12);
LocalDateTime endPmToday = LocalDateTime.now().toLocalDate().atStartOfDay().plusDays(1);
if (nowTime.isBefore(startAmToday) && nowTime.isAfter(endAmToday)) {
booleanBuilder.and(foodRecommendation.recommendation.createdAt.goe(startAmToday)
.and(foodRecommendation.recommendation.createdAt.lt(startAmToday)));
}
if (nowTime.isEqual(endAmToday) && nowTime.isBefore(endAmToday)) {
booleanBuilder.and(foodRecommendation.recommendation.createdAt.goe(endAmToday)
.and(foodRecommendation.recommendation.createdAt.lt(endPmToday)));
}
}
private void whetherCategoryId(Long id, BooleanBuilder booleanBuilder) {
if (id != null && id != 0) {
booleanBuilder.and(categoryIdEq(id));
}
}
private OrderSpecifier<Integer> countDesc() {
return foodRecommendation.recommendation.count.desc();
}
private BooleanExpression categoryIdEq(Long id) {
return id != null ? foodRecommendation.food.category.id.eq(id) : null;
}
못고치면 롤백해
Tasks
자주 호출 되는 API에 캐싱을 적용한다.
결과에서 "tags":["매운","단백"] 로 나와서 tags:[{ "id":"1", "name":"매운" }, { "id":"2", "name":"단백" }] 같이 수정합니다.
이름으로 저장 가능하게 구현합니다.
카테고리를 분류하는데 필요합니다.
대장님의 요청
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.