Skip to content
Open
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
1 change: 1 addition & 0 deletions config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = function () {
require("../src/app/Alert/alertRoute")(app);
require("../src/app/Report/reportRoute")(app);
require("../src/app/datamap/dmRoute")(app);
require("../src/app/PinView/pinViewRoute")(app);

return app;
};
12 changes: 10 additions & 2 deletions config/responseStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ module.exports = {
message: "이미 신고한 핀리뷰입니다.",
},



//핀지도 관련 오류
PINVIEW_LONGITUDE_EMPTY : {"isSuccess": false, "code": 4000, "message": "경도를 입력해주세요."},
PINVIEW_LATITUDE_EMPTY : {"isSuccess": false, "code": 4000, "message": "위도를 입력해주세요."},
PINVIEW_ADDRESS_EMPTY : {"isSuccess": false, "code": 4000, "message": "주소를 입력해주세요."},
PINVIEW_PINCONGEST_EMPTY : {"isSuccess": false, "code": 4000, "message": "핀 혼잡도를 입력해주세요."},
PINVIEW_PINFEELING_EMPTY : {"isSuccess": false, "code": 4000, "message": "핀 기분을 입력해주세요."},
PINVIEW_USERID_EMPTY : {"isSuccess": false, "code": 4000, "message": "userId를 입력해주세요."},
PINVIEW_PINID_EMPTY : {"isSuccess": false, "code": 4000, "message": "pinId를 입력해주세요."},

PINVIEW_CONTENTS_LENGTH : {"isSuccess": false, "code": 4000, "message": "내용을 300자 이내로 입력해주세요."}
};
2 changes: 1 addition & 1 deletion src/app/Alert/alertController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const schedule = require("node-schedule");
const baseResponse = require("../../../config/responseStatus");
const { response, errResponse } = require("../../../config/response");
const admin = require("../../../config/pushConnect");
// const admin = require("../../../config/pushConnect");
const alertService = require("../../app/Alert/alertService");
const alertProvider = require("../../app/Alert/alertProvider");

Expand Down
14 changes: 7 additions & 7 deletions src/app/PinView/pinViewController.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports.postPin = async function (req, res){
* Body: longitude, latitude, address, pinCongest, pinFeeling, contents
*/
const {longitude, latitude, address, pinCongest, pinFeeling, contents} = req.body;
const userId = req.params.userId;
const userId = req.verifiedToken.userId;


// 빈 값 체크
Expand Down Expand Up @@ -84,7 +84,7 @@ exports.getPinById = async function (req, res) {
* Path Variable: pinId
*/
const pinId = req.params.pinId;
const userId = req.params.userId;
const userId = req.verifiedToken.userId;

if (!pinId) return res.send(errResponse(baseResponse.PINVIEW_PINID_EMPTY));

Expand All @@ -102,7 +102,7 @@ exports.getPinById = async function (req, res) {

exports.deletePin= async function(req, res){

const userId = req.params.userId
const userId = req.verifiedToken.userId;
const pinId=req.params.pinId;

if (!pinId) return res.send(errResponse(baseResponse.PINVIEW_PINID_EMPTY));
Expand All @@ -122,7 +122,7 @@ exports.postPinLike= async function(req, res){


const pinId=req.params.pinId;
const userId = req.params.userId;
const userId = req.verifiedToken.userId;

if (!userId) return res.send(errResponse(baseResponse.PINVIEW_USERID_EMPTY));
if (!pinId) return res.send(errResponse(baseResponse.PINVIEW_PINID_EMPTY));
Expand All @@ -140,7 +140,7 @@ exports.postPinLike= async function(req, res){

exports.deletePinLike= async function(req, res){

const userId = req.params.userId;
const userId = req.verifiedToken.userId;
const pinId=req.params.pinId;

if (!userId) return res.send(errResponse(baseResponse.PINVIEW_USERID_EMPTY));
Expand All @@ -159,7 +159,7 @@ exports.deletePinLike= async function(req, res){

exports.getMyPin = async function (req, res) {

const userId = req.params.userId;
const userId = req.verifiedToken.userId;

if (!userId) return res.send(errResponse(baseResponse.PINVIEW_USERID_EMPTY));

Expand All @@ -175,7 +175,7 @@ exports.getMyPin = async function (req, res) {

exports.deleteMyPin = async function (req, res) {

const userId = req.params.userId;
const userId = req.verifiedToken.userId;
Comment thread
jyjyjy25 marked this conversation as resolved.
const pinId = req.params.pinId;

if (!userId) return res.send(errResponse(baseResponse.PINVIEW_USERID_EMPTY));
Expand Down
14 changes: 6 additions & 8 deletions src/app/PinView/pinViewDao.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@
}

//공공 데이터 장소와 핀지도 거리계산(인근 핀 생성)
// -> 핀지도에 넣을지 공공데이터에 넣을지 고민중입니다!
// -> 거리계산값이 정확한지 확인중입니다!
async function insertNearByPin(connection, pinId) {
async function insertNearByPin(connection) {
const insertNearByPinQuery = `
INSERT into nearByPin(pinId, placeId, pinCongest)
SELECT p.pinId, c.placeId, p.pinCongest
INSERT into nearByPin(pinId, placeId, pinCongest, pinCreatedAt)
SELECT p.pinId, c.placeId, p.pinCongest, p.createdAt
FROM cityData c, pinView p
WHERE (6371*acos(cos(radians(p.latitude))*cos(radians(c.lat))*cos(radians(c.lng)
-radians(p.longitude))+sin(radians(p.latitude))*sin(radians(c.lat)))) < 1),
-radians(p.longitude))+sin(radians(p.latitude))*sin(radians(c.lat)))) < 1
AND pinId = (SELECT MAX(pinId) from pinView);
`;
const insertNearByPinRows = await connection.query(
insertNearByPinQuery,
pinId
insertNearByPinQuery
);

return insertNearByPinRows;
Expand Down Expand Up @@ -197,6 +194,7 @@
insertPin,
selectPin,
selectPinById,
insertNearByPin,
deleteRecentPin,
insertRecentPin,
selectRecentPin,
Expand Down
16 changes: 8 additions & 8 deletions src/app/PinView/pinViewRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@ module.exports = function(app) {
const pinView = require('./pinViewController');

// 1. 핀지도 작성 API
app.post('/app/pinView', pinView.postPin);
app.post('/app/pinView', jwtMiddleware, pinView.postPin);


// 2. 핀지도 전체 조회 API
app.get('/app/pinView', pinView.getPins);
app.get('/app/pinView', jwtMiddleware, pinView.getPins);


// 3. 특정 핀지도 조회 API
app.get('/app/pinView/:pinId', pinView.getPinById);
app.get('/app/pinView/:pinId', jwtMiddleware, pinView.getPinById);


// 4. 특정 핀지도 삭제 API
app.patch('/app/pinView/:pinId', pinView.deletePin);
app.patch('/app/pinView/:pinId', jwtMiddleware, pinView.deletePin);


// 5. 도움이 되었어요 API
app.patch('/app/pinview/:pinId/likes', pinView.postPinLike);
app.patch('/app/pinview/:pinId/likes', jwtMiddleware, pinView.postPinLike);


// 6. 도움이 되었어요 취소 API
app.patch('/app/pinview/:pinId/liked', pinView.deletePinLike);
app.patch('/app/pinview/:pinId/liked', jwtMiddleware, pinView.deletePinLike);


// @. my pin 조회 API -> 추후 myPage로 이동
app.get('/app/myPage/myPin/:userId', pinView.getMyPin);
app.get('/app/myPage/myPin', jwtMiddleware, pinView.getMyPin);


// @. my pin 삭제 API -> 추후 myPage로 이동
app.delete('/app/myPage/myPin/:pinId', pinView.deleteMyPin);
app.delete('/app/myPage/myPin/:pinId', jwtMiddleware, pinView.deleteMyPin);

}
2 changes: 1 addition & 1 deletion src/app/PinView/pinViewService.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.createPin = async function (userId, longitude, latitude, address, pinCon
const connection = await pool.getConnection(async (conn) => conn);

const pinIdResult = await pinViewDao.insertPin(connection, insertPinParams);
const nearByPinIdResult = await pinViewDao.insertNearByPin(connection, pinId, pinCongest);
const nearByPinIdResult = await pinViewDao.insertNearByPin(connection);
// console.log(`추가된 핀지도 : ${pinIdResult[0]}`)
connection.release();
return response(baseResponse.SUCCESS);
Expand Down