Skip to content

Commit

Permalink
Refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
yuneg11 committed Dec 11, 2019
1 parent 847bb9b commit 453516c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/backend/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ module.exports.itemBuyerContract = async (event) => {
}
};

module.exports.itemDeleteWarning = async (event) => {
if (await checkAuth(event) == true) {
const response = await itemHandler.deleteWarning(event);
console.log(response);
return response;
} else {
console.log("Auth fail");
return getAuthFailResponse();
}
};

module.exports.test = async (event) => {
const body = parser.getBody(event);
const userId = parser.getUserId(event);
Expand Down
8 changes: 7 additions & 1 deletion src/backend/handlers/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,18 @@ const buyerContract = async (event) => {
}
};

const deleteWarning = async (event) => {
const userId = parser.getUserId(event);
return responseTemplate.processFail("상품 구매 실패", "상품 구매 등록에 실패했습니다.");
};

module.exports = {
registration,
list,
searchCategory,
searchKeyword,
detail,
sellerContract,
buyerContract
buyerContract,
deleteWarning
};
4 changes: 1 addition & 3 deletions src/backend/handlers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ const registration = async (event) => {
const nickname = parameters["nickname"].origin;
const school_name = parameters["school_name"].value;
const school_mail = parameters["school_mail"].origin;
const timetable_image = parameters["timetable_image"].origin;
const timetable = ""; // Todo: Process timetable_image and get JSON data

if (authenticator.authenticateUser(userId) == true) {
return responseTemplate.userRegistrationFail("이미 등록된 사용자입니다.");
} else {
const mail_success = await authenticator.sendAuthenticateMail(userId, school_mail);
if (mail_success == true) {
const result = await database.registNewUser(userId, nickname, school_name, school_mail, timetable);
const result = await database.registNewUser(userId, nickname, school_name, school_mail);
if (result.success == true) {
return responseTemplate.userRegistrationSuccess(nickname);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/responses/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports.welcome = () => {
const userInfoThumbnail = builder.getThumbnail(resource.userInfoThumbnailUrl);
const userInfoQueryButton = builder.getButton("회원 정보 조회", "block", "회원 정보 조회", resource.userInfoQueryBlockId);
const userInfoOpenProfileButton = builder.getButton("오픈프로필 링크 수정", "block", "오픈프로필 링크 수정", resource.userInfoOpenProfileBlockId);
const userInfoTimeTableButton = builder.getButton("시간표 수정", "block", "시간표 수정", resource.userInfoTimeTableBlockId);
const userInfoTimeTableButton = builder.getButton("거래기록 조회", "block", "거래기록 조회", resource.userInfoContractListBlockId);
const userInfoCardBody = builder.getBasicCardBody("회원 정보", "회원 정보를 조회하거나 수정합니다.", userInfoThumbnail, [userInfoQueryButton, userInfoOpenProfileButton, userInfoTimeTableButton]);

// Build response
Expand Down
6 changes: 6 additions & 0 deletions src/backend/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ functions:
- http:
path: item/contract/buyer
method: post
itemDeleteWarning:
handler: handler.itemDeleteWarning
events:
- http:
path: item/delete/warning
method: post
test:
handler: handler.test
events:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/utils/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
sellerContractBlockId: "5de3d4eaffa7480001988104",
userInfoQueryBlockId: "5de3d56d8192ac0001d65d18",
userInfoOpenProfileBlockId: "5de3d5958192ac0001d65d1a",
userInfoTimeTableBlockId: "5de3d59d8192ac0001d65d1c",
userInfoContractListBlockId: "5de3d59d8192ac0001d65d1c",
itemDetailBlockId: "5decfa26ffa74800014b098e",
itemDeleteBlockId: "5decfa26ffa74800014b098e", // Temp
itemBuyBlockId: "5decfa26ffa74800014b098e", // Temp
Expand Down

0 comments on commit 453516c

Please sign in to comment.