Skip to content

Commit

Permalink
[FIX]#16 - fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
yoon1013 committed Jun 9, 2022
1 parent 07d1830 commit 320fe53
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 71 deletions.
84 changes: 44 additions & 40 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const { Op, where } = require('sequelize');
const Member = require('./models/members');
const ProjectInfo = require('./models/projectinfo');
const Recruit = require("./models/recruit");
const Stack = require('./models/stack');
const Feed = require('./models/feed');
const Zzim = require('./models/zzim');
//const { where } = require('sequelize/types');
Expand Down Expand Up @@ -139,6 +138,7 @@ app.post('/login', function(req, res) {
'message': message,
})
}
/*
else if(members[0].mApproval == 2) {
members = null;
message = "탈퇴한 계정입니다.";
Expand All @@ -147,11 +147,11 @@ app.post('/login', function(req, res) {
'member': members,
'message': message,
})
}
}*/
else if(members[0].mApproval == 1) {
message = members[0].mName + "님 환영합니다.";
res.json({
'code': 205,
'code': 204,
'member': members,
'message': message,
})
Expand Down Expand Up @@ -359,7 +359,7 @@ app.post('/detailProject', async function(req, res){
isApproval = false;
}
else {
switch(approve[0].rApproval) {
switch(approve.rApproval) {
case 0:
isApproval = false;
break;
Expand All @@ -374,8 +374,10 @@ app.post('/detailProject', async function(req, res){
where: {pNum: pNum}
});
//스택 파싱
var stacks = projectInfo.pStack.split(',');
projectInfo.pStack = stacks;
if(projectInfo.pStack != null) {
var stacks = projectInfo.pStack.split(',');
projectInfo.pStack = stacks;
}

//작성자 정보
var writer = projectInfo.mNum;
Expand Down Expand Up @@ -461,34 +463,44 @@ app.post('/delProject', function(req, res) {
});

//프로젝트 지원
app.post('/apply', function(req, res) {
app.post('/apply', async function(req, res) {
var mNum = req.body.mNum;
var pNum = req.body.pNum;
var rPosition = req.body.rPosition;

Recruit.create({
mNum: mNum,
pNum: pNum,
rApproval: 0,
rPosition: rPosition
})
.then(()=> {
var message = "지원이 완료되었습니다";
res.json({
"code": 201,
"message": message
var alreadyApply = await Recruit.findAll({
where: {
mNum: mNum,
pNum: pNum,
rPosition : rPosition
}
});
if(alreadyApply == null) {
Recruit.create({
mNum: mNum,
pNum: pNum,
rApproval: 0,
rPosition: rPosition
})
})
.catch((SequelizeUniqueConstraintError)=> {
var message = "이미 지원한 프로젝트입니다"
.then(()=> {
var message = "지원이 완료되었습니다";
res.json({
"code": 202,
"code": 201,
"message": message
})
})
.catch((err)=>{
console.log(err);
})
})
.catch((err)=>{
console.log(err);
});
}
else{
var message = "이미 지원한 프로젝트입니다";
res.json({
"code": 202,
"message": message
});
}

});

//홈
Expand Down Expand Up @@ -749,24 +761,17 @@ app.post('/myPage', async function(req, res){
}
});

var stacksArr = await Stack.findAll({
attributes: ['sStack'],
where:{
mNum: mNum
}
});

const stacks = [];
for(var i = 0; i<stacksArr.length; i++) {
stacks.push(stacksArr[i].sStack);
//스택 파싱
if(mInfo.mStacks != null) {
var stacks = mInfo.mStacks.split(',');
mInfo.mStacks = stacks;
}

//const stack = stacks.reverse().join();

res.json({
"code": 201,
"mInfo": mInfo,
"stacks": stacks
"mInfo": mInfo
});
});

Expand Down Expand Up @@ -864,7 +869,7 @@ app.post('/updateProfile', upload.single('file'), async function(req, res){
});
});

//마이페이지: 참여한 프로젝트 개수
//마이페이지: 프로젝트 개수
app.post('/countProject', async function(req, res) {
var mNum = req.body.mNum;

Expand Down Expand Up @@ -938,7 +943,6 @@ app.post('/addFeed', upload.single('file'), async function(req, res){
var pNum = req.body.pNum;


console.log('./uploads/'+req.file.filename);
//이미지 파일 db에 넣기
var imgData = readImageFile('./uploads/'+req.file.filename);

Expand Down
4 changes: 0 additions & 4 deletions models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const Sequelize = require('sequelize');
const Member = require('./members');
const ProjectInfo = require('./projectinfo');
const Zzim = require('./zzim');
const Stack = require('./stack');
const Feed = require('./feed');
const Recruit = require('./recruit');
const Todo = require('./todo');
Expand All @@ -22,7 +21,6 @@ db.sequelize = sequelize;
db.Member = Member;
db.ProjectInfo = ProjectInfo;
db.Zzim = Zzim;
db.Stack = Stack;
db.Feed = Feed;
db.Recruit = Recruit;
db.Todo = Todo;
Expand All @@ -31,7 +29,6 @@ db.Evaluation = Evaluation;
Member.init(sequelize);
ProjectInfo.init(sequelize);
Zzim.init(sequelize);
Stack.init(sequelize);
Feed.init(sequelize);
Recruit.init(sequelize);
Todo.init(sequelize);
Expand All @@ -40,7 +37,6 @@ Evaluation.init(sequelize);
Member.associate(db);
ProjectInfo.associate(db);
Zzim.associate(db);
Stack.associate(db);
Feed.associate(db);
Recruit.associate(db);
Todo.associate(db);
Expand Down
4 changes: 3 additions & 1 deletion models/members.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ module.exports = class Member extends Sequelize.Model {
allowNull: false,
defaultValue: 0
},
mStacks: {
type: Sequelize.TEXT
}
},
{
sequelize,
Expand All @@ -80,7 +83,6 @@ module.exports = class Member extends Sequelize.Model {
}
static associate(db) {
db.Member.hasMany(db.ProjectInfo, {foreignKey: 'mNum', sourceKey: 'mNum'});
db.Member.hasMany(db.Stack, {foreignKey: 'mNum', sourcekey: 'mNum'});
//db.Member.belongsToMany(db.ProjectInfo, {through: 'Zzim'});
//db.Member.belongsToMany(db.ProjectInfo, {through: 'Recruit'});
db.Member.hasMany(db.Zzim, {foreignKey: 'mNum', sourceKey: 'mNum'});
Expand Down
26 changes: 0 additions & 26 deletions models/stack.js

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed uploads/metamong1654790917452.jpg
Binary file not shown.

0 comments on commit 320fe53

Please sign in to comment.