Skip to content

Commit

Permalink
Add user openprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
yuneg11 committed Dec 11, 2019
1 parent 2e1581e commit ff98e89
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/backend/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ module.exports.verifyEmail = async (event) => {
// Skill

module.exports.welcome = async (event) => {
if (await checkAuth(event) != null) {
const response = responseTemplate.welcome();
const auth = await checkAuth(event);
if (auth != null) {
const response = responseTemplate.welcome(auth);
console.log(response);
return response;
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/backend/handlers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ const information = async (event) => {
}
};

// Todo
const openprofile = async (event) => {
const userId = parser.getUserId(event);
const parameters = parser.getParameters(event);
const user_openprofile = parameters["user_openprofile"].origin;

const user = await database.getUser(userId);
if (user == null) {
return responseTemplate.userRegistration();
const result = await database.setOpenprofile(userId, user_openprofile);
if (result.success == true) {
return responseTemplate.userOpenprofileSuccess(user_openprofile);
} else {
const openprofile = (user.openprofile == null ? "-" : user.openprofile);
return responseTemplate.userInformation(user.nickname, user.school_name, user.school_mail, openprofile, user.reliability_score);
return responseTemplate.processFail("오픈프로필 등록 실패", "오픈프로필 등록에 실패하였습니다.");
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/backend/responses/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const builder = require("../utils/builder");
const resource = require("../utils/resource");

module.exports.welcome = () => {
module.exports.welcome = (user) => {
// Construct buyer card
const buyerThumbnail = builder.getThumbnail(resource.buyerThumbnailUrl);
const buyerSearchTextButton = builder.getButton("상품 카테고리 검색", "block", "상품 카테고리 검색", resource.buyerSearchCategoryBlockId);
Expand All @@ -13,7 +13,8 @@ module.exports.welcome = () => {

// Construct seller card
const sellerThumbnail = builder.getThumbnail(resource.sellerThumbnailUrl);
const sellerItemRegistButton = builder.getButton("상품 등록", "block", "상품 등록", resource.sellerItemRegistBlockId);
const registLink = (user.openprofile ? resource.sellerItemRegistBlockId : resource.userInfoOpenProfileBlockId);
const sellerItemRegistButton = builder.getButton("상품 등록", "block", "상품 등록", registLink);
const sellerItemListButton = builder.getButton("상품 목록", "block", "상품 목록", resource.sellerItemListBlockId, {mode: "list"});
const sellerContractButton = builder.getButton("판매자 거래 체결", "block", "판매자 거래 체결", resource.sellerItemListBlockId, {mode: "contract"});
const sellerCardBody = builder.getBasicCardBody("판매", "상품을 판매합니다.", sellerThumbnail, [sellerItemRegistButton, sellerItemListButton, sellerContractButton]);
Expand Down
4 changes: 2 additions & 2 deletions src/backend/responses/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports.itemListSuccess = (itemList, mode="search") => {
buttons.push(builder.getButton("상세정보", "block", "상세정보", resource.itemDetailBlockId, {itemId: resultItemId, mode: "list"}));
buttons.push(builder.getButton("삭제", "block", "삭제", resource.itemDeleteWarningBlockId, {itemId: resultItemId, item_image: item.item_image[0]}));
} else if (mode == "search") {
buttons.push(builder.getButton("구매", "block", "구매", resource.itemBuyBlockId, {userId: resultUserId, itemId: resultItemId}));
buttons.push(builder.getButton("판매자 연결", "webLink", (item.openprofile == null ? "" : item.openprofile)));
buttons.push(builder.getButton("상세정보", "block", "상세정보", resource.itemDetailBlockId, {userId: resultUserId, itemId: resultItemId, mode: "search"}));
} else if (mode == "contract") {
buttons.push(builder.getButton("판매", "block", "판매", resource.sellerContractBlockId, {itemId: resultItemId}));
Expand Down Expand Up @@ -83,7 +83,7 @@ module.exports.itemDetail = (item, mode="list", user=null) => {
const resultTitle = item.item_name + "(" + item.item_price + "원)";
const resultDescription = item.item_detail + "\n"+ item.item_date;
const resultMainMenuButton = (mode == "list" ? builder.getButton("삭제", "block", "삭제", resource.itemDeleteWarningBlockId, {itemId: item.itemId, item_image: item.item_image[0]})
: builder.getButton("구매", "block", "구매", resource.itemBuyBlockId, {userId: resultUserId, itemId: resultItemId}));
: builder.getButton("판매자 연결", "webLink", item.openprofile));
const resultCard1 = builder.getBasicCardBody(resultTitle, resultDescription, "", [resultMainMenuButton, resultMainMenuButton]);
const resultCard2 = builder.getBasicCardBody("", "", resultThumbnail);

Expand Down
3 changes: 2 additions & 1 deletion src/backend/responses/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ module.exports = {
itemBuyerContractSuccess: itemResponse.itemBuyerContractSuccess,
itemDeleteWarning: itemResponse.itemDeleteWarning,
itemDeleteOk: itemResponse.itemDeleteOk,
itemDeleteCancel: itemResponse.itemDeleteCancel
itemDeleteCancel: itemResponse.itemDeleteCancel,
userOpenprofileSuccess: userResponse.userOpenprofileSuccess
};
6 changes: 6 additions & 0 deletions src/backend/responses/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ module.exports.userAuthenticationSuccess = () => {
module.exports.userAuthenticationFail = () => {
return builder.buildAWSResponse("Mail authentication fail!");
};

module.exports.userOpenprofileSuccess = (openprofile) => {
const listItem = builder.getListItem(openprofile, "오픈프로필 링크");
const listCard = builder.getListCard("오픈프로필 등록 성공", "", [listItem]);
return builder.buildResponse([listCard]);
};
3 changes: 2 additions & 1 deletion src/backend/utils/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,5 +501,6 @@ module.exports = {
registNewDeal,
deleteItem,
deleteUser,
getTransaction
getTransaction,
setOpenprofile
}

0 comments on commit ff98e89

Please sign in to comment.