Skip to content

Commit

Permalink
Merge pull request #27 from 9oormthonUniv-seoultech/feat/#22
Browse files Browse the repository at this point in the history
feat: 사진url 링크 공유 기능 추가
  • Loading branch information
sooieese00 authored Nov 6, 2024
2 parents a354284 + 69dc2f8 commit a97fd06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 14 additions & 1 deletion controllers/photoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,17 @@ const getPhoto = async (req, res) => {
}
};

module.exports = { createTemp, updateInfo, updateRecord, savePhoto, deletePhoto, getPhoto };
const sharePhoto = async (req, res) => {
const { photo_id } = req.params;
try {
const photo = await Photo.findByPk(photo_id);
if (!photo) {
res.status(404).json({ status: 'fail', message: '사진을 찾을 수 없습니다.'});
}
res.status(200).json({ status: "success",shareLink: photo.image_url });
} catch (error) {
res.status(500).json({ status: 'fail', message: " 공유 링크 생성 실패"});
}
}

module.exports = { createTemp, updateInfo, updateRecord, savePhoto, deletePhoto, getPhoto, sharePhoto };
5 changes: 4 additions & 1 deletion routes/photoRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const express = require('express');
const router = express.Router();
const { uploadOneImageUrl, uploadOneImage } = require('../middlewares/s3');
const { uploadImageByQR } = require('../middlewares/uploadPhoto');
const { createTemp, updateInfo, updateRecord, savePhoto, deletePhoto, getPhoto } = require('../controllers/photoController');
const { createTemp, updateInfo, updateRecord, savePhoto, deletePhoto, getPhoto, sharePhoto } = require('../controllers/photoController');

// 사진 등록용 라우트 1: 사용자id와 사진url 저장 (photoTemp 테이블)
router.post('/temp/upload/qr', uploadImageByQR, uploadOneImageUrl, createTemp); // 1) QR 업로드
Expand All @@ -20,6 +20,9 @@ router.post('/save/:photoTemp_id', savePhoto);
// 사진 삭제용 라우트
router.delete('/delete/:photo_id', deletePhoto);

// 사진 공유
router.get('/share/:photo_id', sharePhoto);

// 사진 조회용 라우트
router.get('/:photo_id', getPhoto);

Expand Down

0 comments on commit a97fd06

Please sign in to comment.