-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from KOA-TF/feature/notice-improved
Feature/notice update & delete / improved response type
- Loading branch information
Showing
17 changed files
with
311 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
-- notice 테이블 sample datas | ||
INSERT INTO member (member_id, name, email, profile_image_url, password, authority) | ||
values (1, '안정후', '[email protected]', 'picture.com', '20001215', 'MEMBER'); | ||
INSERT INTO member (member_id, name, email, password, fcm_token, authority) | ||
values (1, '안정후', '[email protected]', '20001215', 'fcm_token', 'MEMBER'); | ||
|
||
INSERT INTO member_info (member_info_id, member_id, major, part, phone_number, description) | ||
values (1, 1, '전자공학과', '개발팀', '010-6570-8852', '설명입니다.'); | ||
|
||
INSERT INTO curriculum (curriculum_id, curriculum_name) | ||
values (1, '기업프로젝트'); | ||
|
||
INSERT INTO notice (notice_id, member_id, curriculum_id, title, content) | ||
values (1, 1, 1, '제목입니다.', '내용입니다.'); | ||
INSERT INTO notice (notice_id, member_id, curriculum_id, title, content, is_deleted) | ||
values (1, 1, 1, '제목입니다.', '내용입니다.', false); | ||
|
||
INSERT INTO notice (notice_id, member_id, curriculum_id, title, content) | ||
values (2, 1, 1, '제목입니다.2', '내용입니다.2'); | ||
INSERT INTO notice (notice_id, member_id, curriculum_id, title, content, is_deleted) | ||
values (2, 1, 1, '제목입니다.2', '내용입니다.2', false); | ||
|
||
INSERT INTO notice_team (notice_team_id, notice_id, team_name) | ||
values (1, 1, '경영총괄팀'); | ||
|
||
INSERT INTO notice_image (notice_image_id, notice_id, image_url) | ||
values (1, 1, 'image.png'); | ||
INSERT INTO notice_image (notice_image_id, notice_id, image_url, is_deleted) | ||
values (1, 1, 'image.png', false); | ||
|
||
INSERT INTO notice_view (notice_view_id, member_id, notice_id, view) | ||
values (1, 1, 1, 1); |
108 changes: 108 additions & 0 deletions
108
common-module/src/main/java/com/koa/commonmodule/common/ApplicationResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package com.koa.commonmodule.common; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.extern.jackson.Jacksonized; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Jacksonized | ||
public class ApplicationResponse<T> { | ||
private ApplicationResult result; | ||
private T payload; | ||
|
||
public static <T> ApplicationResponse<T> ok(T payload) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(HttpStatus.OK.value()) | ||
.message("API 호출 성공") | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
|
||
public static <T> ApplicationResponse<T> ok(T payload, String message) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(HttpStatus.OK.value()) | ||
.message(message) | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
|
||
public static <T> ApplicationResponse<T> badRequest(T payload) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(HttpStatus.BAD_REQUEST.value()) | ||
.message("잘못된 요청입니다.") | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
|
||
public static <T> ApplicationResponse<T> badRequest(T payload, String message) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(HttpStatus.BAD_REQUEST.value()) | ||
.message(message) | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
|
||
public static <T> ApplicationResponse<T> notAuthenticated(T payload) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(HttpStatus.UNAUTHORIZED.value()) | ||
.message("잘못된 접근입니다.") | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
|
||
public static <T> ApplicationResponse<T> notAuthenticated(T payload, String message) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(HttpStatus.UNAUTHORIZED.value()) | ||
.message(message) | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
|
||
public static <T> ApplicationResponse<T> server(T payload) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||
.message("API 호출 실패") | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
|
||
public static <T> ApplicationResponse<T> server(T payload, String message) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||
.message(message) | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
|
||
public static <T> ApplicationResponse<T> custom(T payload, Integer code, String message) { | ||
return ApplicationResponse.<T>builder() | ||
.result(ApplicationResult.builder() | ||
.code(code) | ||
.message(message) | ||
.build()) | ||
.payload(payload) | ||
.build(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
common-module/src/main/java/com/koa/commonmodule/common/ApplicationResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.koa.commonmodule.common; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Jacksonized | ||
public class ApplicationResult { | ||
private Integer code; | ||
private String message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.