Skip to content

Commit

Permalink
Merge pull request #14 from UMC-5th-Hackathon-N-Team/chulsoo
Browse files Browse the repository at this point in the history
feat: 이미지
  • Loading branch information
cimaron713 authored Jan 4, 2024
2 parents 6f49a93 + f82d39a commit 2a6e261
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/main/java/com/umc/sopi/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.persistence.Id;
import lombok.*;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Entity
Expand All @@ -22,7 +23,7 @@ public class User extends BaseEntity {

private String name;

private LocalDateTime birth;
private LocalDate birth;

private String blood;

Expand All @@ -34,6 +35,8 @@ public class User extends BaseEntity {

private Integer ingredient;

private String imageUri;

public void wholeAdd(){
this.whole += 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.umc.sopi.domain.User;
import com.umc.sopi.repository.UserRepository;
import com.umc.sopi.service.userService.UserService;
import com.umc.sopi.web.dto.UserResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -56,4 +57,22 @@ public Long getIngredient(){
new IllegalStateException("해당 유저가 존재하지 않습니다."));
return user.getIngredient().longValue();
}

@Override
public UserResponse.MyPageDTO myPage(){
User user = userRepository.findById(1L).orElseThrow(()->
new IllegalStateException("해당 유저가 존재하지 않습니다."));

UserResponse.MyPageDTO result = UserResponse.MyPageDTO.builder()
.blood(user.getBlood())
.whole(user.getWhole())
.birth(user.getBirth())
.name(user.getName())
.merit(user.getMerit())
.ingredient(user.getIngredient())
.imageUri(user.getImageUri())
.build();

return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.umc.sopi.service.userService;

import com.umc.sopi.web.dto.UserResponse;

public interface UserService {
public void updateWhole();
public void updateMerit();
public void updateIngredient();
public Long getWhole();
public Long getMerit();
public Long getIngredient();
public UserResponse.MyPageDTO myPage();
}
13 changes: 8 additions & 5 deletions src/main/java/com/umc/sopi/web/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@

@RestController
@RequiredArgsConstructor
@RequestMapping("/count")
@CrossOrigin(origins = "http://localhost:3000")
public class UserController {
private final UserService userService;

@GetMapping("/whole")
@GetMapping("/count/whole")
public ApiResponse<UserResponse.CountDTO> getWhole(){
return ApiResponse.onSuccess(UserConverter.toCountResultDTO(userService.getWhole()));
}
@GetMapping("/merit")
@GetMapping("/count/merit")
public ApiResponse<UserResponse.CountDTO> getMerit(){
return ApiResponse.onSuccess(UserConverter.toCountResultDTO(userService.getMerit()));
}
@GetMapping("/ingredient")
@GetMapping("/count/ingredient")
public ApiResponse<UserResponse.CountDTO> getIngredient(){
return ApiResponse.onSuccess(UserConverter.toCountResultDTO(userService.getIngredient()));
}
@GetMapping("/year")
@GetMapping("/count/year")
public ApiResponse<UserResponse.CountDTO> getYear(){
return ApiResponse.onSuccess(UserConverter.toCountResultDTO(userService.getIngredient() + userService.getWhole()));
}

@GetMapping("/MyPage")
public ApiResponse<UserResponse.MyPageDTO> getMyPage(){
return ApiResponse.onSuccess(userService.myPage());

}
}
15 changes: 15 additions & 0 deletions src/main/java/com/umc/sopi/web/dto/UserResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.time.LocalDateTime;

public class UserResponse {
@Builder
Expand All @@ -15,4 +16,18 @@ public class UserResponse {
public static class CountDTO{
Long count;
}

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class MyPageDTO{
String name;
LocalDate birth;
String blood;
Integer merit;
Integer whole;
Integer ingredient;
String imageUri;
}
}

0 comments on commit 2a6e261

Please sign in to comment.