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

Hodu back #31

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f12b405
1/19 feat: module.css 수정중
Hadan2 Jan 19, 2024
e5e36fd
24.01.21 complete-module-css
Hadan2 Jan 21, 2024
8872254
24.01.26 add react-router
Hadan2 Jan 26, 2024
f4e5f75
24.02.07 commit
minahkim03 Feb 7, 2024
60c2347
24.02.07 add-scholarship MVC
minahkim03 Feb 7, 2024
8395a6b
24.02.09 solve-mojib
Hadan2 Feb 8, 2024
252a297
24.02.09 delete .env
minahkim03 Feb 9, 2024
0ec482a
24.02.12 add: MVC로 변경 완료
minahkim03 Feb 11, 2024
06db1f3
Merge remote-tracking branch 'origin/hodu-front' into hodu-back
minahkim03 Feb 11, 2024
2c666cb
24.02.12 react-calendar testing
Hadan2 Feb 12, 2024
030f7ac
24.02.12 fix: scholarshipController async
minahkim03 Feb 12, 2024
68cbdde
24.02.12 add Routes
Hadan2 Feb 12, 2024
5358a6b
24.02.13 File uploading
Hadan2 Feb 13, 2024
0bc5952
24.02.17 img preview&calendar modify
Hadan2 Feb 17, 2024
0c4cf46
24.02.19 error solve-dropbox
Hadan2 Feb 19, 2024
21cc706
Merge remote-tracking branch 'origin/hodu-front' into hodu-back
minahkim03 Feb 20, 2024
cdc212e
24.02.20 add: image,video,file upload
minahkim03 Feb 20, 2024
6ba8b8e
24.02.21
Hadan2 Feb 21, 2024
208b15e
Merge branch 'hodu-back' of https://github.com/WebScrumProject/KHUCSE…
Hadan2 Feb 21, 2024
67d901c
24.02.21 image/video/file upload asynchronus
Hadan2 Feb 21, 2024
0ac6499
24.02.23 chore
minahkim03 Feb 23, 2024
e17e4f5
24.02.23 fix: project/write mongoDB upload
minahkim03 Feb 23, 2024
84e0712
24.02.26 Date success & categori delete
Hadan2 Feb 26, 2024
bdce869
24.02.26 writer add but login error
Hadan2 Feb 26, 2024
b55b8e8
24.02.26 wrtier add but login error2
Hadan2 Feb 26, 2024
963d5db
Merge branch 'master' into hodu-front
Hadan2 Feb 26, 2024
6858e4a
24.02.27 add click effect
Hadan2 Feb 27, 2024
e457884
24.02.27 fix: multer 한글 깨짐 현상
minahkim03 Feb 27, 2024
41ab3d9
24.02.27 merge
minahkim03 Feb 27, 2024
a0484ae
Merge remote-tracking branch 'origin/hodu-front' into hodu-back
minahkim03 Feb 27, 2024
c058d4f
24.02.27 fix: /authorization
minahkim03 Feb 27, 2024
26f0902
24.02.27 modify stroe
Hadan2 Feb 27, 2024
04a6d00
24.02.27 merge&p_list
Hadan2 Feb 27, 2024
15ab465
24.03.14 fix: project/write
minahkim03 Mar 14, 2024
0bd378d
24.03.14 add: 프로젝트 페이지 조회, 프로젝트 상세 조회, 프로젝트 수정
minahkim03 Mar 14, 2024
550fe67
commit before merge
Hadan2 Mar 15, 2024
e2806d9
Merge branch 'hodu-back' of https://github.com/WebScrumProject/KHUCSE…
Hadan2 Mar 15, 2024
92867d8
24.03.16 feat: axios p_list
Hadan2 Mar 15, 2024
cfa4489
03.16.
Hadan2 Mar 16, 2024
9d17ffd
03.17 middle test
Hadan2 Mar 16, 2024
0872775
03.17. feat: 비동기 SUCCESS!!!
Hadan2 Mar 16, 2024
5547189
3.17 feat: edit middle test
Hadan2 Mar 17, 2024
ebf76a2
3.17 feat: edit mongo error
Hadan2 Mar 17, 2024
67b5b70
03.18 sort&edit page&video success
Hadan2 Mar 18, 2024
4f1f46c
24.03.20 add: 프로젝트 삭제, 프로젝트 마감, fix: 프로젝트 수정
minahkim03 Mar 19, 2024
ba95fd4
03.21 feat: exception
Hadan2 Mar 21, 2024
029fe3e
24.03.22 add: nodemailer, project apply
minahkim03 Mar 22, 2024
ffa3fac
24.03.22 add: 메일 발송 기능
minahkim03 Mar 22, 2024
11cc1b5
03.22 type 수정
Hadan2 Mar 22, 2024
684be94
Merge branch 'hodu-back' of https://github.com/WebScrumProject/KHUCSE…
Hadan2 Mar 22, 2024
9a8f6e7
03.22 project end
Hadan2 Mar 22, 2024
e23686e
03.22 apply error
Hadan2 Mar 22, 2024
368406e
24.03.22 merge
minahkim03 Mar 22, 2024
9587d8c
Merge remote-tracking branch 'origin/hodu-front' into hodu-back
minahkim03 Mar 22, 2024
98b6715
24.03.25 fix: 이메일 사진 html 제거
minahkim03 Mar 25, 2024
2a8e457
24.03.25 fix: /project/edit 수정
minahkim03 Mar 25, 2024
b94eef4
daf
minahkim03 Mar 25, 2024
0e27b00
Merge remote-tracking branch 'origin/main' into hodu-back
minahkim03 Mar 25, 2024
3ce311f
24.03.25 백 합침
minahkim03 Mar 25, 2024
774e67f
24.03.25 백 pr
minahkim03 Mar 25, 2024
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
6 changes: 5 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ DB_URL = "mongodb+srv://chaen328:scrumproject1@cluster0.coq8qi7.mongodb.net/?ret
S3_ACCESS_KEY = AKIAQSPQBH2DMWG3ZWPC
S3_SECRET_KEY = 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
BUCKET_NAME = khu-cse-page00
EMAIL_SERVICE=gmail
NODEMAILER_USER= a64494293@gmail.com
NODEMAILER_PW= bbni zfjg yltu jebk
JWT_SECRET = 'khu_jwt_secret_key'
REFRESH_JWT_SECRET = 'khu_jwt_refresh_secret_key'
REFRESH_JWT_SECRET = 'khu_jwt_refresh_secret_key'

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.env

/node_modules
/dist
/dist
209 changes: 209 additions & 0 deletions DTO/projectDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
import mongoose from 'mongoose'
const projectModel = require('../models/projectSchema');
const {alertUsers} = require('../middlewares/alertUsers')
const client = require ('../models/connectRedis')

interface np {
title: String,
writer: String,
id : String,
date: String,
content:{
image:[String],
video: [String],
text: String,
file: [String]
}
recruit: Array<object>,
deadline : String,
is_done: boolean,
apply : Array<applier>
}

interface applier {
id: string;
date: string;
field: string;
fieldDetail: string;
memo: string;
}

interface project{
link: string,
name: string,
reason: string
}

export async function writeProject(newProject:np, userid:string, username:string){
try{
const project = await projectModel.create({
title: newProject.title,
writer: username,
id : userid,
date: newProject.date,
content: {
image: newProject.content.image,
video: newProject.content.video,
text : newProject.content.text,
file : newProject.content.file
},
recruit: newProject.recruit,
deadline : newProject.deadline,
is_done: false,
apply : []
})
}
catch(err){
console.log(err)
}
}

export async function editProject(newProject:np, projectId:string){
const objectId: mongoose.Types.ObjectId = new mongoose.Types.ObjectId(projectId)
let applier:Array<applier>;
let project:project
const oldProject = await projectModel.findOne({_id:objectId})
oldProject.title= newProject.title;
oldProject.content.image=newProject.content.image;
oldProject.content.video= newProject.content.video;
oldProject.content.text= newProject.content.text;
oldProject.content.file= newProject.content.file;
oldProject.recruit= newProject.recruit;
oldProject.deadline = newProject.deadline;
oldProject.apply = newProject.apply;
applier=oldProject.apply
project={name: oldProject.title, link:`localhost8080/project/detail/${oldProject._id}`, reason: ''}
await oldProject.save()
try{
console.log('프로젝트가 성공적으로 수정되었습니다.');
for(let i=0; i<applier.length; i++){
let useremail='', username='';
client.hget(applier[i].id, 'useremail', (err: any, email: any)=>{
useremail=email;
client.hget(applier[i].id, 'username', (err: any, name: any)=>{
username=name;
alertUsers(useremail, 'edit', username, project)
})
})
}
}
catch(error) {
console.error('프로젝트 수정 중 오류 발생:', error);
};
}

export async function getList(page: string) {
let itemsPerPage = 10;
let page_int = parseInt(page, 10);
let skip = (page_int - 1) * itemsPerPage;
try {
const result = await projectModel
.find({})
.sort({ _id: -1 })
.skip(skip)
.limit(itemsPerPage)
.exec();
return result;
} catch (err) {
console.error(err);
throw new Error('프로젝트 목록 데이터 가져오기에 실패했습니다.');
}
}

export async function getDetail(projectId:string) {
const objectId: mongoose.Types.ObjectId = new mongoose.Types.ObjectId(projectId)
try {
const result = await projectModel
.find({_id:objectId})
.exec();
return result;
} catch (err) {
console.error(err);
throw new Error('프로젝트 목록 데이터 가져오기에 실패했습니다.');
}
}

export async function endProject(projectId: string){
let applier:Array<applier>;
let project:project
const objectId: mongoose.Types.ObjectId = new mongoose.Types.ObjectId(projectId)
const oldProject=await projectModel.findOne({_id:objectId})
oldProject.is_done=true
applier=oldProject.apply
project={name: oldProject.title, link:`localhost8080/project/detail/${oldProject._id}`, reason: ''}
await oldProject.save()
try{
console.log('프로젝트가 성공적으로 마감되었습니다.');
for(let i=0; i<applier.length; i++){
let useremail='', username='';
client.hget(applier[i].id, 'useremail', (err: any, email: any)=>{
useremail=email;
client.hget(applier[i].id, 'username', (err: any, name: any)=>{
username=name;
alertUsers(useremail, applier[i].memo, username, project)
})
})
}
}
catch(error) {
console.error('프로젝트 마감 중 오류 발생:', error);
};
}
export async function applyProject(projectId: string, newApply:applier){
const objectId: mongoose.Types.ObjectId = new mongoose.Types.ObjectId(projectId)
projectModel.findOne({_id:objectId})
.then((res:any)=>{
console.log(newApply)
if(!res){
throw new Error('프로젝트를 찾을 수 없습니다.');
}
let cnt =0;
for (let i=0; i<res.apply.length; i++){
if(res.apply[i].field==newApply.field){
cnt+=1;
}
}
if(cnt<=res.recruit.apply_cnt){
res.apply.push(newApply)
console.log('성공적으로 지원되었습니다.')
return res.save()
}
else{
return false
}
})
.catch((error: any) => {
console.error('지원 중 오류 발생:', error);
});
}

export async function deleteProject(projectId: string, reason: string){
let applier:Array<applier>;
let project:project
const objectId: mongoose.Types.ObjectId = new mongoose.Types.ObjectId(projectId)
projectModel.findOne({_id:objectId})
.then((res:any)=>{
if(!res){
throw new Error('프로젝트를 찾을 수 없습니다.');
}
applier=res.apply
project={name: res.title, link:`localhost8080/project/detail/${res._id}`, reason: reason}
})
.then(() => {
for(let i=0; i<applier.length; i++){
let useremail='', username='';
client.hget(applier[i].id, 'useremail', (err: any, email: any)=>{
useremail=email;
client.hget(applier[i].id, 'username', (err: any, name: any)=>{
username=name;
alertUsers(useremail,'deletion', username, project)
})
})
}
})
.catch((error: any) => {
console.error('프로젝트 마감 중 오류 발생:', error);
});
const result = await projectModel.deleteOne({ _id: objectId });
console.log('프로젝트가 성공적으로 삭제되었습니다')
}
48 changes: 48 additions & 0 deletions DTO/scholarshipoDTO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// const scholarshipModel = require('../models/scholarshipSchema');

// export async function getList(page: string) {
// let itemsPerPage = 10;
// let page_int = parseInt(page, 10);
// let skip = (page_int - 1) * itemsPerPage;
// try {
// const result = await scholarshipModel
// .find({})
// .sort({ _id: -1 })
// .skip(skip)
// .limit(itemsPerPage)
// .exec();
// return result;
// } catch (err) {
// console.error(err);
// throw new Error('장학 목록 데이터 가져오기에 실패했습니다.');
// }
// }


// export async function getDetail(id:number) {
// var skip_number:number, limit_number:number
// if(id==0){
// skip_number = id
// limit_number = 2
// }
// else if (id==499){
// skip_number = id-1
// limit_number = 2
// }
// else{
// skip_number = id-1
// limit_number = 3
// }
// try {
// const result = await scholarshipModel
// .find({})
// .sort({_id:-1})
// .skip(skip_number)
// .limit(limit_number)
// .exec()
// return result;
// } catch (err) {
// console.error(err);
// throw new Error('장학 상세 데이터 가져오기에 실패했습니다.');
// }
// }
Loading