Skip to content

Commit

Permalink
Merge pull request #40 from Team-O2/feat/#22
Browse files Browse the repository at this point in the history
[fix] mypage comment 없을 때 response body 수정 / 회원정보 수정 requeset body 수정
  • Loading branch information
xxeol2 authored Sep 22, 2021
2 parents a26a96a + 7a2e49d commit eeab424
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
9 changes: 8 additions & 1 deletion src/DTO/userDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@ namespace userDTO {
challengeNum: number;
}

// export interface userInfoReqDTO {
// nickname: string;
// interest: string[];
// isMarketing: Boolean;
// img?: File;
// }

export interface userInfoReqDTO {
nickname: string;
interest: string[];
interest: string;
isMarketing: Boolean;
img?: File;
}
Expand Down
16 changes: 8 additions & 8 deletions src/controller/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ const getMyCommentsController = async (req: Request, res: Response) => {
"잘못된 postModel 값입니다."
);
}
// 3. 작성한 댓글이 없을 때
else if (data === -3) {
response.basicResponse(
res,
returnCode.NO_CONTENT,
"작성한 댓글이 없습니다."
);
}
// // 3. 작성한 댓글이 없을 때
// else if (data === -3) {
// response.basicResponse(
// res,
// returnCode.NO_CONTENT,
// "작성한 댓글이 없습니다."
// );
// }
// 4. 내가 쓴 댓글 조회 성공
else {
response.dataResponse(
Expand Down
22 changes: 11 additions & 11 deletions src/service/userService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import period from "../library/date";
import jwt from "jsonwebtoken";
import bcrypt from "bcryptjs";
import config from "../config";
import { emailSender } from "../library";
import { emailSender, array } from "../library";
import ejs from "ejs";
import { ConnectionTimedOutError, Op, QueryTypes, Sequelize } from "sequelize";
// DTO
Expand Down Expand Up @@ -157,7 +157,7 @@ const getUserInfo = async (userID: number) => {
const user = await User.findOne({
where: {
id: userID,
},
},
attributes: ["isMarketing", "img", "id", "email", "nickname", "interest"],
});

Expand Down Expand Up @@ -724,11 +724,11 @@ const getMyComments = async (
if (!commentList) {
return -2;
}
// 3. 작성한 댓글이 없을 떄
else if (!commentList.length) {
// console.log(challengeList.length);
return -3;
}
// // 3. 작성한 댓글이 없을 떄
// else if (!commentList.length) {
// // console.log(challengeList.length);
// return -3;
// }

const commentNum = commentList.length;

Expand Down Expand Up @@ -1015,7 +1015,8 @@ const patchUserInfo = async (
body: userDTO.userInfoReqDTO,
url?
) => {
let { nickname, interest, isMarketing } = body;
let { nickname, isMarketing } = body;
let interest = array.stringToInterest(body.interest);

// 1. 요청 바디 부족
if (
Expand All @@ -1033,7 +1034,6 @@ const patchUserInfo = async (
return -2;
}

let newInterest = "";
const user = await User.findOne({
where: { id: userID },
});
Expand All @@ -1043,7 +1043,7 @@ const patchUserInfo = async (
await User.update(
{
nickname,
interest: interest.join(),
interest,
isMarketing,
img: url.img,
},
Expand All @@ -1053,7 +1053,7 @@ const patchUserInfo = async (
await User.update(
{
nickname,
interest: interest.join(),
interest: interest,
isMarketing,
},
{ where: { id: userID } }
Expand Down

0 comments on commit eeab424

Please sign in to comment.