From b7ecb6e33eefcb71d06423fb6dcd1328bcb8fdcd Mon Sep 17 00:00:00 2001 From: jusung-c Date: Wed, 15 Nov 2023 21:28:09 +0900 Subject: [PATCH 1/5] =?UTF-8?q?chore(#111):=20API=20Response=20Example=20v?= =?UTF-8?q?alue=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heachi/auth/api/controller/auth/AuthController.java | 8 ++++++++ .../api/controller/group/info/GroupInfoController.java | 7 +++++++ .../controller/group/member/GroupMemberController.java | 5 +++++ .../housework/category/HouseworkCategoryController.java | 6 ++++++ .../api/controller/housework/todo/TodoController.java | 7 +++++++ 5 files changed, 33 insertions(+) diff --git a/heachi-core/auth-api/src/main/java/com/heachi/auth/api/controller/auth/AuthController.java b/heachi-core/auth-api/src/main/java/com/heachi/auth/api/controller/auth/AuthController.java index aefc698e..591a4fdf 100644 --- a/heachi-core/auth-api/src/main/java/com/heachi/auth/api/controller/auth/AuthController.java +++ b/heachi-core/auth-api/src/main/java/com/heachi/auth/api/controller/auth/AuthController.java @@ -13,6 +13,10 @@ import com.heachi.auth.api.service.state.LoginStateService; import com.heachi.mysql.define.user.User; import com.heachi.mysql.define.user.constant.UserPlatformType; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -40,6 +44,7 @@ public JsonResult loginPage( return JsonResult.successOf(loginPage); } + @ApiResponse(responseCode = "200", description = "로그인 성공", content = @Content(schema = @Schema(implementation = AuthServiceLoginResponse.class))) @GetMapping("/{platformType}/login") public JsonResult login( @PathVariable("platformType") UserPlatformType platformType, @@ -53,6 +58,7 @@ public JsonResult login( return JsonResult.successOf(loginResponse); } + @ApiResponse(responseCode = "200", description = "회원가입 성공", content = @Content(schema = @Schema(implementation = AuthServiceLoginResponse.class))) @PostMapping("/register") public JsonResult register( @Valid @RequestBody AuthRegisterRequest request) { @@ -62,6 +68,7 @@ public JsonResult register( return JsonResult.successOf(registerResponse); } + @ApiResponse(responseCode = "200", description = "회원 정보 불러오기 성공", content = @Content(schema = @Schema(implementation = UserSimpleInfoResponse.class))) @GetMapping("/info") public JsonResult userInfo(@AuthenticationPrincipal User user) { @@ -90,6 +97,7 @@ public JsonResult userDelete(@AuthenticationPrincipal User user) { return JsonResult.successOf(); } + @ApiResponse(responseCode = "200", description = "토큰 재발급 성공", content = @Content(schema = @Schema(implementation = ReissueAccessTokenResponse.class))) @PostMapping("/reissue") public JsonResult reissueAccessToken(@RequestHeader(name = "Authorization") String token) { List tokens = Arrays.asList(token.split(" ")); diff --git a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/info/GroupInfoController.java b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/info/GroupInfoController.java index 7a886577..8e69dde8 100644 --- a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/info/GroupInfoController.java +++ b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/info/GroupInfoController.java @@ -5,6 +5,10 @@ import com.heachi.housework.api.controller.group.info.request.GroupInfoRegisterRequest; import com.heachi.housework.api.service.auth.AuthExternalService; import com.heachi.housework.api.service.group.info.GroupInfoService; +import com.heachi.housework.api.service.group.info.response.GroupInfoUserGroupServiceResponse; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; @@ -19,6 +23,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; +import java.util.List; + @Slf4j @RestController @RequiredArgsConstructor @@ -47,6 +53,7 @@ public JsonResult createGroupInfo(@RequestHeader(name = "Authorization") Stri } // User가 가입한 Group 정보를 리턴한다. + @ApiResponse(responseCode = "200", description = "그룹 리스트 조회 성공", content = @Content(schema = @Schema(implementation = GroupInfoUserGroupServiceResponse.class, type = "array"))) @GetMapping("/list") public JsonResult userGroupInfoList(@RequestHeader(name = "Authorization") String authorization) { UserInfoResponse userInfo = authExternalService.userAuthenticate(authorization); diff --git a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/member/GroupMemberController.java b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/member/GroupMemberController.java index f67a5868..03d88db7 100644 --- a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/member/GroupMemberController.java +++ b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/member/GroupMemberController.java @@ -4,6 +4,10 @@ import com.heachi.housework.api.controller.group.member.response.GroupMemberResponse; import com.heachi.housework.api.service.auth.AuthExternalService; import com.heachi.housework.api.service.group.member.GroupMemberService; +import com.heachi.redis.define.housework.todo.TodoList; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; @@ -18,6 +22,7 @@ public class GroupMemberController { private final AuthExternalService authExternalService; private final GroupMemberService groupMemberService; + @ApiResponse(responseCode = "200", description = "Group Member 리스트 조회 성공", content = @Content(schema = @Schema(implementation = GroupMemberResponse.class, type = "array"))) @GetMapping("/{groupId}") public JsonResult groupMemberList(@RequestHeader(name = "Authorization") String authorization, @PathVariable(name = "groupId") Long groupId) { diff --git a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/category/HouseworkCategoryController.java b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/category/HouseworkCategoryController.java index 9252cead..dffe6824 100644 --- a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/category/HouseworkCategoryController.java +++ b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/category/HouseworkCategoryController.java @@ -1,7 +1,12 @@ package com.heachi.housework.api.controller.housework.category; import com.heachi.admin.common.response.JsonResult; +import com.heachi.housework.api.controller.group.member.response.GroupMemberResponse; import com.heachi.housework.api.service.housework.category.HouseworkCategoryService; +import com.heachi.housework.api.service.housework.category.response.HouseworkCategoryResponse; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; @@ -16,6 +21,7 @@ public class HouseworkCategoryController { private final HouseworkCategoryService houseworkCategoryService; + @ApiResponse(responseCode = "200", description = "카테고리 리스트 조회 성공", content = @Content(schema = @Schema(implementation = HouseworkCategoryResponse.class, type = "array"))) @GetMapping("/") public JsonResult selectCategory() { diff --git a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.java b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.java index c3127e64..ec736e3f 100644 --- a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.java +++ b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.java @@ -4,10 +4,16 @@ import com.heachi.external.clients.auth.response.UserInfoResponse; import com.heachi.housework.api.controller.housework.todo.request.VerifyTodoRequest; import com.heachi.housework.api.service.auth.AuthExternalService; +import com.heachi.housework.api.service.group.info.response.GroupInfoUserGroupServiceResponse; import com.heachi.housework.api.service.housework.todo.TodoService; import com.heachi.housework.api.service.housework.todo.request.TodoSelectRequest; import com.heachi.housework.api.service.housework.todo.request.VerifyTodoServiceRequest; +import com.heachi.redis.define.housework.todo.TodoList; import com.heachi.s3.api.service.AwsS3Service; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -26,6 +32,7 @@ public class TodoController { private final AwsS3Service awsS3Service; // Todo List 가져오기 + @ApiResponse(responseCode = "200", description = "Todo List 조회 성공", content = @Content(schema = @Schema(implementation = TodoList.class))) @GetMapping("/{groupId}") public JsonResult selectTodo(@RequestHeader(name = "Authorization") String authorization, @PathVariable(name = "groupId") Long groupId, From 14ede550f3256bc823809e2e5c55fcdaa422d3df Mon Sep 17 00:00:00 2001 From: jusung-c Date: Wed, 15 Nov 2023 22:21:54 +0900 Subject: [PATCH 2/5] =?UTF-8?q?chore(#111):=20Response=20List=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=9D=98=20=EC=98=88=EC=8B=9C=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=95=88=EB=90=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/group/member/GroupMemberController.java | 3 ++- .../housework/category/HouseworkCategoryController.java | 3 ++- .../api/controller/housework/todo/TodoController.java | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/member/GroupMemberController.java b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/member/GroupMemberController.java index 03d88db7..f7011573 100644 --- a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/member/GroupMemberController.java +++ b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/group/member/GroupMemberController.java @@ -5,6 +5,7 @@ import com.heachi.housework.api.service.auth.AuthExternalService; import com.heachi.housework.api.service.group.member.GroupMemberService; import com.heachi.redis.define.housework.todo.TodoList; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -22,7 +23,7 @@ public class GroupMemberController { private final AuthExternalService authExternalService; private final GroupMemberService groupMemberService; - @ApiResponse(responseCode = "200", description = "Group Member 리스트 조회 성공", content = @Content(schema = @Schema(implementation = GroupMemberResponse.class, type = "array"))) + @ApiResponse(responseCode = "200", description = "Group Member 리스트 조회 성공", content = @Content(array = @ArraySchema(schema = @Schema(implementation = GroupMemberResponse.class)))) @GetMapping("/{groupId}") public JsonResult groupMemberList(@RequestHeader(name = "Authorization") String authorization, @PathVariable(name = "groupId") Long groupId) { diff --git a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/category/HouseworkCategoryController.java b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/category/HouseworkCategoryController.java index dffe6824..bb5a2f82 100644 --- a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/category/HouseworkCategoryController.java +++ b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/category/HouseworkCategoryController.java @@ -4,6 +4,7 @@ import com.heachi.housework.api.controller.group.member.response.GroupMemberResponse; import com.heachi.housework.api.service.housework.category.HouseworkCategoryService; import com.heachi.housework.api.service.housework.category.response.HouseworkCategoryResponse; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,7 +22,7 @@ public class HouseworkCategoryController { private final HouseworkCategoryService houseworkCategoryService; - @ApiResponse(responseCode = "200", description = "카테고리 리스트 조회 성공", content = @Content(schema = @Schema(implementation = HouseworkCategoryResponse.class, type = "array"))) + @ApiResponse(responseCode = "200", description = "Group Member 리스트 조회 성공", content = @Content(array = @ArraySchema(schema = @Schema(implementation = HouseworkCategoryResponse.class)))) @GetMapping("/") public JsonResult selectCategory() { diff --git a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.java b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.java index ec736e3f..887d57ea 100644 --- a/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.java +++ b/heachi-core/housework-api/src/main/java/com/heachi/housework/api/controller/housework/todo/TodoController.java @@ -10,9 +10,12 @@ import com.heachi.housework.api.service.housework.todo.request.VerifyTodoServiceRequest; import com.heachi.redis.define.housework.todo.TodoList; import com.heachi.s3.api.service.AwsS3Service; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -32,7 +35,7 @@ public class TodoController { private final AwsS3Service awsS3Service; // Todo List 가져오기 - @ApiResponse(responseCode = "200", description = "Todo List 조회 성공", content = @Content(schema = @Schema(implementation = TodoList.class))) + @ApiResponse(responseCode = "200", description = "성공적으로 Todo List를 조회함", content = @Content(schema = @Schema(implementation = TodoList.class))) @GetMapping("/{groupId}") public JsonResult selectTodo(@RequestHeader(name = "Authorization") String authorization, @PathVariable(name = "groupId") Long groupId, From 070f79a13ccbd88f548f8408566ad8b3c9e3ca06 Mon Sep 17 00:00:00 2001 From: jusung-c Date: Thu, 16 Nov 2023 14:16:36 +0900 Subject: [PATCH 3/5] =?UTF-8?q?test(#114):=20=EB=8D=94=EB=AF=B8=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20insert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/heachi/mysql/define/Initializer.java | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java diff --git a/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java b/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java new file mode 100644 index 00000000..4c5573f7 --- /dev/null +++ b/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java @@ -0,0 +1,127 @@ +package com.heachi.mysql.define; + +import com.heachi.mysql.define.group.info.GroupInfo; +import com.heachi.mysql.define.group.info.repository.GroupInfoRepository; +import com.heachi.mysql.define.group.member.GroupMember; +import com.heachi.mysql.define.group.member.constant.GroupMemberRole; +import com.heachi.mysql.define.group.member.constant.GroupMemberStatus; +import com.heachi.mysql.define.group.member.repository.GroupMemberRepository; +import com.heachi.mysql.define.housework.category.HouseworkCategory; +import com.heachi.mysql.define.housework.category.repository.HouseworkCategoryRepository; +import com.heachi.mysql.define.housework.info.HouseworkInfo; +import com.heachi.mysql.define.housework.info.constant.HouseworkPeriodType; +import com.heachi.mysql.define.housework.info.repository.HouseworkInfoRepository; +import com.heachi.mysql.define.housework.member.HouseworkMember; +import com.heachi.mysql.define.housework.member.repository.HouseworkMemberRepository; +import com.heachi.mysql.define.housework.todo.HouseworkTodo; +import com.heachi.mysql.define.housework.todo.repository.HouseworkTodoRepository; +import com.heachi.mysql.define.user.User; +import com.heachi.mysql.define.user.constant.UserPlatformType; +import com.heachi.mysql.define.user.constant.UserRole; +import com.heachi.mysql.define.user.repository.UserRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +import java.time.LocalDate; +import java.time.LocalTime; + +@Component +public class Initializer implements ApplicationRunner { + @Autowired private UserRepository userRepository; + @Autowired private GroupInfoRepository groupInfoRepository; + @Autowired private GroupMemberRepository groupMemberRepository; + @Autowired private HouseworkCategoryRepository houseworkCategoryRepository; + @Autowired private HouseworkInfoRepository houseworkInfoRepository; + @Autowired private HouseworkMemberRepository houseworkMemberRepository; + @Autowired private HouseworkTodoRepository houseworkTodoRepository; + + @Override + public void run(ApplicationArguments args) throws Exception { + User user = userRepository.save(generateCustomUser("김준영", "kjy@naver.com", "010-0000-0000")); + User user2 = userRepository.save(generateCustomUser("구지원", "itkoo@naver.com", "010-1111-1111")); + GroupInfo groupInfo = groupInfoRepository.save(generateGroupInfo(user)); + GroupMember groupMember = groupMemberRepository.save(generateGroupMember(user, groupInfo)); + GroupMember groupMember2 = groupMemberRepository.save(generateGroupMember(user2, groupInfo)); + + HouseworkCategory houseworkCategory = houseworkCategoryRepository.save(generateCustomHouseworkCategory("집안일")); + HouseworkCategory houseworkCategory2 = houseworkCategoryRepository.save(generateCustomHouseworkCategory("집 밖의 일")); + HouseworkInfo houseworkInfo = houseworkInfoRepository.save(generateCustomHouseworkInfo(houseworkCategory, groupInfo, "청소기 돌리기", HouseworkPeriodType.HOUSEWORK_PERIOD_EVERYDAY)); + HouseworkInfo houseworkInfo2 = houseworkInfoRepository.save(generateCustomHouseworkInfo(houseworkCategory2, groupInfo, "쓰레기 버리기", HouseworkPeriodType.HOUSEWORK_PERIOD_EVERYDAY)); + + houseworkMemberRepository.save(generateHouseworkMember(groupMember, houseworkInfo)); + houseworkMemberRepository.save(generateHouseworkMember(groupMember2, houseworkInfo)); + houseworkMemberRepository.save(generateHouseworkMember(groupMember2, houseworkInfo2)); + + HouseworkTodo houseworkTodo = houseworkTodoRepository.save(generateHouseworkTodo(houseworkInfo, groupInfo, LocalDate.now())); + HouseworkTodo houseworkTodo2 = houseworkTodoRepository.save(generateHouseworkTodo(houseworkInfo2, groupInfo, LocalDate.now())); + } + + public static User generateCustomUser(String name, String email, String phoneNumber) { + return User.builder() + .platformId("1111") + .platformType(UserPlatformType.KAKAO) + .role(UserRole.USER) + .name(name) + .email(email) + .phoneNumber(phoneNumber) + .profileImageUrl("https://google.com") + .pushAlarmYn(true) + .build(); + } + + public static GroupInfo generateGroupInfo(User user) { + + return GroupInfo.builder() + .user(user) + .bgColor("bbbbbb") + .colorCode("111111") + .gradient("csscssscss") + .name("준영하우스") + .info("hello!") + .build(); + } + + public static GroupMember generateGroupMember(User user, GroupInfo groupInfo) { + + return GroupMember.builder() + .groupInfo(groupInfo) + .user(user) + .role(GroupMemberRole.GROUP_MEMBER) + .status(GroupMemberStatus.ACCEPT) + .build(); + } + + public static HouseworkCategory generateCustomHouseworkCategory(String name) { + + return HouseworkCategory.builder() + .name(name) + .build(); + } + + public static HouseworkInfo generateCustomHouseworkInfo(HouseworkCategory category, GroupInfo groupInfo, String title, HouseworkPeriodType type) { + + return HouseworkInfo.builder() + .houseworkCategory(category) + .groupInfo(groupInfo) + .title(title) + .detail("빨래 돌리기") + .type(type) + .endTime(LocalTime.of(18,0)) + .build(); + } + + public static HouseworkMember generateHouseworkMember(GroupMember groupMember, HouseworkInfo houseworkInfo) { + + return HouseworkMember.builder() + .houseworkInfo(houseworkInfo) + .groupMember(groupMember) + .build(); + } + + public static HouseworkTodo generateHouseworkTodo(HouseworkInfo houseworkInfo, GroupInfo groupInfo, LocalDate date) { + + return HouseworkTodo.makeTodoReferInfo(houseworkInfo, groupInfo, date); + } +} From e2436b1aa9e8b40137e6f36c638afec901661515 Mon Sep 17 00:00:00 2001 From: jusung-c Date: Thu, 16 Nov 2023 14:19:11 +0900 Subject: [PATCH 4/5] =?UTF-8?q?test(#114):=20=EB=B0=B0=ED=8F=AC=20DB=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=97=90=EB=A7=8C=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94=20=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/heachi/mysql/define/Initializer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java b/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java index 4c5573f7..b4f57c3c 100644 --- a/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java +++ b/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java @@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; +import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; import java.time.LocalDate; @@ -38,6 +39,7 @@ public class Initializer implements ApplicationRunner { @Autowired private HouseworkTodoRepository houseworkTodoRepository; @Override + @Profile("prod") public void run(ApplicationArguments args) throws Exception { User user = userRepository.save(generateCustomUser("김준영", "kjy@naver.com", "010-0000-0000")); User user2 = userRepository.save(generateCustomUser("구지원", "itkoo@naver.com", "010-1111-1111")); From 0cfbe8cfb941a809e3e434e220bd5d237061e6c0 Mon Sep 17 00:00:00 2001 From: jusung-c Date: Thu, 16 Nov 2023 15:19:43 +0900 Subject: [PATCH 5/5] =?UTF-8?q?test(#111):=20502=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=83=9D=EA=B2=A8=EC=84=9C=20=EB=A1=A4=EB=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/heachi/mysql/define/Initializer.java | 129 ------------------ 1 file changed, 129 deletions(-) delete mode 100644 heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java diff --git a/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java b/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java deleted file mode 100644 index b4f57c3c..00000000 --- a/heachi-domain-mysql/src/main/java/com/heachi/mysql/define/Initializer.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.heachi.mysql.define; - -import com.heachi.mysql.define.group.info.GroupInfo; -import com.heachi.mysql.define.group.info.repository.GroupInfoRepository; -import com.heachi.mysql.define.group.member.GroupMember; -import com.heachi.mysql.define.group.member.constant.GroupMemberRole; -import com.heachi.mysql.define.group.member.constant.GroupMemberStatus; -import com.heachi.mysql.define.group.member.repository.GroupMemberRepository; -import com.heachi.mysql.define.housework.category.HouseworkCategory; -import com.heachi.mysql.define.housework.category.repository.HouseworkCategoryRepository; -import com.heachi.mysql.define.housework.info.HouseworkInfo; -import com.heachi.mysql.define.housework.info.constant.HouseworkPeriodType; -import com.heachi.mysql.define.housework.info.repository.HouseworkInfoRepository; -import com.heachi.mysql.define.housework.member.HouseworkMember; -import com.heachi.mysql.define.housework.member.repository.HouseworkMemberRepository; -import com.heachi.mysql.define.housework.todo.HouseworkTodo; -import com.heachi.mysql.define.housework.todo.repository.HouseworkTodoRepository; -import com.heachi.mysql.define.user.User; -import com.heachi.mysql.define.user.constant.UserPlatformType; -import com.heachi.mysql.define.user.constant.UserRole; -import com.heachi.mysql.define.user.repository.UserRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -import java.time.LocalDate; -import java.time.LocalTime; - -@Component -public class Initializer implements ApplicationRunner { - @Autowired private UserRepository userRepository; - @Autowired private GroupInfoRepository groupInfoRepository; - @Autowired private GroupMemberRepository groupMemberRepository; - @Autowired private HouseworkCategoryRepository houseworkCategoryRepository; - @Autowired private HouseworkInfoRepository houseworkInfoRepository; - @Autowired private HouseworkMemberRepository houseworkMemberRepository; - @Autowired private HouseworkTodoRepository houseworkTodoRepository; - - @Override - @Profile("prod") - public void run(ApplicationArguments args) throws Exception { - User user = userRepository.save(generateCustomUser("김준영", "kjy@naver.com", "010-0000-0000")); - User user2 = userRepository.save(generateCustomUser("구지원", "itkoo@naver.com", "010-1111-1111")); - GroupInfo groupInfo = groupInfoRepository.save(generateGroupInfo(user)); - GroupMember groupMember = groupMemberRepository.save(generateGroupMember(user, groupInfo)); - GroupMember groupMember2 = groupMemberRepository.save(generateGroupMember(user2, groupInfo)); - - HouseworkCategory houseworkCategory = houseworkCategoryRepository.save(generateCustomHouseworkCategory("집안일")); - HouseworkCategory houseworkCategory2 = houseworkCategoryRepository.save(generateCustomHouseworkCategory("집 밖의 일")); - HouseworkInfo houseworkInfo = houseworkInfoRepository.save(generateCustomHouseworkInfo(houseworkCategory, groupInfo, "청소기 돌리기", HouseworkPeriodType.HOUSEWORK_PERIOD_EVERYDAY)); - HouseworkInfo houseworkInfo2 = houseworkInfoRepository.save(generateCustomHouseworkInfo(houseworkCategory2, groupInfo, "쓰레기 버리기", HouseworkPeriodType.HOUSEWORK_PERIOD_EVERYDAY)); - - houseworkMemberRepository.save(generateHouseworkMember(groupMember, houseworkInfo)); - houseworkMemberRepository.save(generateHouseworkMember(groupMember2, houseworkInfo)); - houseworkMemberRepository.save(generateHouseworkMember(groupMember2, houseworkInfo2)); - - HouseworkTodo houseworkTodo = houseworkTodoRepository.save(generateHouseworkTodo(houseworkInfo, groupInfo, LocalDate.now())); - HouseworkTodo houseworkTodo2 = houseworkTodoRepository.save(generateHouseworkTodo(houseworkInfo2, groupInfo, LocalDate.now())); - } - - public static User generateCustomUser(String name, String email, String phoneNumber) { - return User.builder() - .platformId("1111") - .platformType(UserPlatformType.KAKAO) - .role(UserRole.USER) - .name(name) - .email(email) - .phoneNumber(phoneNumber) - .profileImageUrl("https://google.com") - .pushAlarmYn(true) - .build(); - } - - public static GroupInfo generateGroupInfo(User user) { - - return GroupInfo.builder() - .user(user) - .bgColor("bbbbbb") - .colorCode("111111") - .gradient("csscssscss") - .name("준영하우스") - .info("hello!") - .build(); - } - - public static GroupMember generateGroupMember(User user, GroupInfo groupInfo) { - - return GroupMember.builder() - .groupInfo(groupInfo) - .user(user) - .role(GroupMemberRole.GROUP_MEMBER) - .status(GroupMemberStatus.ACCEPT) - .build(); - } - - public static HouseworkCategory generateCustomHouseworkCategory(String name) { - - return HouseworkCategory.builder() - .name(name) - .build(); - } - - public static HouseworkInfo generateCustomHouseworkInfo(HouseworkCategory category, GroupInfo groupInfo, String title, HouseworkPeriodType type) { - - return HouseworkInfo.builder() - .houseworkCategory(category) - .groupInfo(groupInfo) - .title(title) - .detail("빨래 돌리기") - .type(type) - .endTime(LocalTime.of(18,0)) - .build(); - } - - public static HouseworkMember generateHouseworkMember(GroupMember groupMember, HouseworkInfo houseworkInfo) { - - return HouseworkMember.builder() - .houseworkInfo(houseworkInfo) - .groupMember(groupMember) - .build(); - } - - public static HouseworkTodo generateHouseworkTodo(HouseworkInfo houseworkInfo, GroupInfo groupInfo, LocalDate date) { - - return HouseworkTodo.makeTodoReferInfo(houseworkInfo, groupInfo, date); - } -}