Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 인증사진 모아보기에 timerRecord 항목 추가 #184

Merged
merged 3 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions functions/api/routes/feed/feedGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ const { GET_WAITROOM_DATA_ALREADY } = require('../../../constants/responseMessag

/**
* @피드_조회
* @route GET /feed?lastid=&size=
* @route GET /feed?lastId=&size=
* @error
* 1. 잘못된 lastid
* 1. 잘못된 lastId
*/

module.exports = async (req, res) => {
const lastid = Number(req.query.lastid);
const lastId = Number(req.query.lastId);
const size = Number(req.query.size);
const user = req.user;

Expand All @@ -41,8 +41,8 @@ module.exports = async (req, res) => {
let responseRecords = [];
let recordIds = [];
// 최초 요청이 아닐시
if (lastid !== -1) {
const lastIndex = _.indexOf(allRecordIds, lastid);
if (lastId !== -1) {
const lastIndex = _.indexOf(allRecordIds, lastId);
// @error 1. 잘못된 last id
if (lastIndex === -1) {
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.INVALID_LASTID));
Expand Down
12 changes: 6 additions & 6 deletions functions/api/routes/myroom/myroomGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const _ = require('lodash');

/**
* @보관함_리스트_불러오기
* @route GET /myroom/:roomType?lastid=&size=
* @route GET /myroom/:roomType?lastId=&size=
* @error
* 1. 잘못된 roomType
* 2. 잘못된 lastid
* 2. 잘못된 lastId
*/

module.exports = async (req, res) => {
const lastid = Number(req.query.lastid);
const lastId = Number(req.query.lastId);
const size = Number(req.query.size);
const roomType = req.query.type;
const user = req.user;
Expand Down Expand Up @@ -55,8 +55,8 @@ module.exports = async (req, res) => {
rooms = failRooms;
}

if (lastid !== -1) {
const lastIndex = _.indexOf(roomIds, lastid);
if (lastId !== -1) {
const lastIndex = _.indexOf(roomIds, lastId);
// @error 1. 잘못된 last id
if (lastIndex === -1) {
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.INVALID_LASTID));
Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = async (req, res) => {
roomName: room.roomName,
leftDay,
thumbnail: room.thumbnail,
totalReceivedSpark: sparkCount.count ? parseInt(sparkCount.count) : 0,
totalReceivedSpark: parseInt(sparkCount[0].count) ? parseInt(sparkCount[0].count) : 0,
startDate: startDate.format('YYYY-MM-DD'),
endDate: endDate.format('YYYY-MM-DD'),
failDay: null,
Expand Down
6 changes: 4 additions & 2 deletions functions/api/routes/myroom/myroomRoomGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const _ = require('lodash');

/**
* @인증사진_모아보기
* @route GET /myroom/room/:roomId?lastid=&size=
* @route GET /myroom/room/:roomId?lastId=&size=
* @error
* 1. roomId가 없음
* 2. 존재하지 않는 습관방인 경우
* 3. 접근 권한이 없는 유저인 경우
*/

module.exports = async (req, res) => {
let lastId = Number(req.query.lastid);
let lastId = Number(req.query.lastId);
const size = Number(req.query.size);
const user = req.user;
const { roomId } = req.params;
Expand All @@ -33,6 +33,7 @@ module.exports = async (req, res) => {
client = await db.connect(req);

const room = await roomDB.getRoomById(client, roomId);
console.log(room);
// @error 2. 존재하지 않는 습관방인 경우
if (!room) {
res.status(statusCode.NO_CONTENT).send(util.fail(statusCode.NO_CONTENT, responseMessage.GET_ROOM_DATA_FAIL));
Expand Down Expand Up @@ -68,6 +69,7 @@ module.exports = async (req, res) => {
certifyingImg: record.certifyingImg,
sparkNum,
status: record.status,
timerRecord: record.timerRecord,
};
});

Expand Down
6 changes: 3 additions & 3 deletions functions/api/routes/notice/active/activeGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ const { noticeDB } = require('../../../../db');

/**
* @활동_알림_조회
* @route GET /notice/active?lastid=&size=
* @route GET /notice/active?lastId=&size=
* @error
*/

module.exports = async (req, res) => {
const user = req.user;
const userId = user.userId;
const { lastid, size } = req.query;
const { lastId, size } = req.query;

let client;

try {
client = await db.connect(req);

const actives = await noticeDB.getActivesByUserId(client, userId, parseInt(lastid), parseInt(size));
const actives = await noticeDB.getActivesByUserId(client, userId, parseInt(lastId), parseInt(size));

const notices = actives.map((a) => {
const notice = {};
Expand Down
6 changes: 3 additions & 3 deletions functions/api/routes/notice/service/serviceGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ const { noticeDB } = require('../../../../db');

/**
* @서비스_알림_조회
* @route GET /notice/service?lastid=&size=
* @route GET /notice/service?lastId=&size=
* @error
*/

module.exports = async (req, res) => {
const user = req.user;
const userId = user.userId;
const { lastid, size } = req.query;
const { lastId, size } = req.query;

let client;

try {
client = await db.connect(req);

const services = await noticeDB.getServicesByUserId(client, userId, parseInt(lastid), parseInt(size));
const services = await noticeDB.getServicesByUserId(client, userId, parseInt(lastId), parseInt(size));

const notices = services.map((s) => {
const notice = {};
Expand Down
12 changes: 6 additions & 6 deletions functions/api/routes/room/roomListGET.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ const roomPOST = require('./roomPOST');

/**
* @습관방_리스트_조회
* @route GET /room?lastid=&size=
* @route GET /room?lastId=&size=
* @error
* 1. 잘못된 lastid
* 1. 잘못된 lastId
*/

module.exports = async (req, res) => {
const lastid = Number(req.query.lastid);
const lastId = Number(req.query.lastId);
const size = Number(req.query.size);
console.log(lastid, size);
console.log(lastId, size);
const user = req.user;
console.log(user.userId);

Expand All @@ -48,8 +48,8 @@ module.exports = async (req, res) => {
let responseRoomIds = [];

// 최초 요청이 아닐시
if (lastid !== -1) {
const lastIndex = _.indexOf(roomIds, lastid);
if (lastId !== -1) {
const lastIndex = _.indexOf(roomIds, lastId);
// @error 1. 잘못된 last id
if (lastIndex === -1) {
return res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, responseMessage.INVALID_LASTID));
Expand Down
2 changes: 1 addition & 1 deletion functions/constants/responseMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
PATH_ERROR: '요청 경로가 올바르지 않습니다',
INTERNAL_SERVER_ERROR: '서버 내부 오류',
PRIV_NOT_FOUND: '권한이 없는 요청입니다',
INVALID_LASTID: '잘못된 lastid 입니다',
INVALID_LASTID: '잘못된 lastId 입니다',

// 회원가입
CREATED_USER: '회원 가입 성공',
Expand Down
12 changes: 6 additions & 6 deletions functions/db/notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ const deleteNoticeByNoticeId = async (client, noticeId) => {
return convertSnakeToCamel.keysToCamel(rows[0]);
};

const getServicesByUserId = async (client, userId, lastid, size) => {
const getServicesByUserId = async (client, userId, lastId, size) => {
const beforeAWeek = dayjs().subtract(7, 'day');
if (lastid === -1) {
if (lastId === -1) {
const { rows } = await client.query(
`
SELECT * FROM spark.notification
Expand All @@ -89,15 +89,15 @@ const getServicesByUserId = async (client, userId, lastid, size) => {
ORDER BY notification_id DESC
LIMIT $3
`,
[userId, lastid, size, beforeAWeek],
[userId, lastId, size, beforeAWeek],
);
return convertSnakeToCamel.keysToCamel(rows);
}
};

const getActivesByUserId = async (client, userId, lastid, size) => {
const getActivesByUserId = async (client, userId, lastId, size) => {
const beforeAWeek = dayjs().subtract(7, 'day');
if (lastid === -1) {
if (lastId === -1) {
const { rows } = await client.query(
`
SELECT * FROM spark.notification
Expand All @@ -123,7 +123,7 @@ const getActivesByUserId = async (client, userId, lastid, size) => {
ORDER BY notification_id DESC
LIMIT $3
`,
[userId, lastid, size, beforeAWeek],
[userId, lastId, size, beforeAWeek],
);
return convertSnakeToCamel.keysToCamel(rows);
}
Expand Down