Skip to content
Snippets Groups Projects
Commit d378105d authored by Sumin Hong's avatar Sumin Hong
Browse files

router 및 프론트 수정

parent eb19017f
No related branches found
No related tags found
No related merge requests found
Showing
with 840 additions and 781 deletions
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ilovepet.iml" filepath="$PROJECT_DIR$/.idea/ilovepet.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="283e462c-4927-4de6-ae4c-7c4eee0fea57" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/backend/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/backend/app.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/backend/routes/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/backend/routes/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/App.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/App.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/BoardContent.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/BoardContent.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/BoardDelAdmin.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/BoardDelAdmin.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/BoardEditAdmin.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/BoardEditAdmin.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/CommentDel.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/CommentDel.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/Find.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/Find.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/FindCommentDel.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/FindCommentDel.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/FindContent.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/FindContent.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/FindDelAdmin.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/FindDelAdmin.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/FindEditAdmin.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/FindEditAdmin.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/FindWrite.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/FindWrite.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/FreeBoard.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/FreeBoard.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/Main.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/Main.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/Protect.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/Protect.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/ProtectCommentDel.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/ProtectCommentDel.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/ProtectContent.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/ProtectContent.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/ProtectDelAdmin.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/ProtectDelAdmin.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/ProtectEditAdmin.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/ProtectEditAdmin.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/ProtectWrite.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/ProtectWrite.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/Signin.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/Signin.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/Signup.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/Signup.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/component/Write.js" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/component/Write.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/css/center.css" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/css/center.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/css/content.css" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/css/content.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/css/find.css" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/css/find.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/css/footer.css" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/css/footer.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/css/freeboard.css" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/css/freeboard.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/frontend/src/css/header.css" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/src/css/header.css" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1lZ1mGHnW4Uv8GpVEw2DVO4hVST" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../../ilovepet-project/ilovepet" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="vue.rearranger.settings.migration" value="true" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="283e462c-4927-4de6-ae4c-7c4eee0fea57" name="Default Changelist" comment="" />
<created>1607789956668</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1607789956668</updated>
<workItem from="1607789957833" duration="319000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="WindowStateProjectService">
<state x="345" y="193" key="FileChooserDialogImpl" timestamp="1607789999044">
<screen x="0" y="0" width="1536" height="824" />
</state>
<state x="345" y="193" key="FileChooserDialogImpl/0.0.1536.824@0.0.1536.824" timestamp="1607789999044" />
</component>
</project>
\ No newline at end of file
......@@ -13,13 +13,7 @@ const cors =require('cors');
var bodyParser = require('body-parser');
const User = require('./models/user');
const Board =require('./models/board');
const Comment = require('./models/comment');
const FindBoard = require('./models/findboard');
const FindComment = require('./models/findcomment');
const ProtectBoard = require('./models/protectboard');
const ProtectComment = require('./models/protectcomment');
const port = 3002;
......@@ -39,6 +33,7 @@ mongoose.connect('mongodb://localhost:27017/projecttest', {
});
mongooseAutoInc.initialize(mongoose.connection);
var indexRouter = require('./routes/index');
//var db = mongoose.connection.db;
//var mongoDriver = mongoose.mongo;
//var gfs = new Gridfs(db,mongoDriver);
......@@ -53,537 +48,10 @@ app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
//============================================================
app.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
//회원가입
app.post('/Signup',function(req,res,next){
console.log("in server !!");
console.log("**************"+req.body);
const userdb= new User({
userid:req.body.userid,
userpassword:req.body.userpassword
});
userdb.save((err)=>{
res.redirect('http://localhost:3000');
})
})
//로그인
app.post('/Signin',function(req,res,next){
console.log("in 로그인 server !!");
console.log("**************"+req.body);
User.find(function(err,us){
var cnt2=-1;
us.forEach(cnt=>{
cnt2+=1;
if(us[cnt2].userid===req.body.signinID && us[cnt2].userpassword===req.body.signinPWD){
res.redirect('http://localhost:3000/')
}
});
})
})
app.use(bodyParser.urlencoded({extended: true}));
//게시판 글쓰기 (회원 여부 확인하여 존재하는 회원만 글쓰기 가능)
app.post('/Createboard',function(req,res,next){
console.log("!!!!!!!!!!!createFreemoard server");
User.find(function(err,us){
var cnt2=-1;
us.forEach(cnt=>{
cnt2+=1;
if(us[cnt2].userid===req.body.userid && us[cnt2].userpassword===req.body.userpsw){
console.log(us[cnt2].userid);
console.log(us[cnt2].userpassword);
const boarddb=new Board({
boarduserid:req.body.userid,
boarduserpsw:req.body.userpsw,
boardtitle:req.body.title,
boardcontent:req.body.content
});
boarddb.save((err)=>{
res.redirect('http://localhost:3000/freeboard');
})
}
});
})
})
//찾아주세요 게시글 작성
app.post('/Createfindboard',function(req,res,next){
console.log("!!!!!!!!!!!createfindboard server");
console.log(req.body);
User.find(function(err,us){
var cnt2=-1;
us.forEach(cnt=>{
cnt2+=1;
if(us[cnt2].userid===req.body.userid && us[cnt2].userpassword===req.body.userpsw){
console.log(us[cnt2].userid);
const boarddb=new FindBoard({
findboarduserid:req.body.userid,
findboarduserpsw:req.body.userpsw,
findboardtitle:req.body.title,
findboardcontent:req.body.content,
findboardplace:req.body.place,
findboardimg:req.body.imgfile,
});
boarddb.save((err)=>{
res.redirect('http://localhost:3000/find');
})
}
});
})
})
//보호중이에요 게시글 작성
app.post('/Createprotectboard',function(req,res,next){
console.log("!!!!!!!!!!!createprotectboard server");
console.log(req.body);
User.find(function(err,us){
var cnt7=-1;
us.forEach(cnt=>{
cnt7+=1;
if(us[cnt7].userid===req.body.userid && us[cnt7].userpassword===req.body.userpsw){
console.log(us[cnt7].userid);
const protectboarddb=new ProtectBoard({
protectboarduserid:req.body.userid,
protectboarduserpsw:req.body.userpsw,
protectboardtitle:req.body.title,
protectboardcontent:req.body.content,
protectboardplace:req.body.place,
protectboardimg:req.body.imgfile,
});
protectboarddb.save((err)=>{
res.redirect('http://localhost:3000/protect');
})
}
});
})
})
//자유게시판에서 제목을 누르면 해당 content 열람 가능
app.get('/Readboard',function(req,res,next){
console.log("!!!!@@@@@@ read board server!!!");
Board.find(function(err, board){
//console.log(board);
if(err) return res.status(500).send({error: 'database failure'});
res.send(board);
});
})
//찾아주세요 페이지의 게시글 리스트
app.get('/Readfindboard',function(req,res,next){
console.log("!!!!@@@@@@ read find board server!!!");
FindBoard.find(function(err, findboard){
//console.log(board);
if(err) return res.status(500).send({error: 'database failure'});
res.send(findboard);
});
})
//보호해주세요 페이지의 게시글 리스트
app.get('/Readprotectboard',function(req,res,next){
console.log("!!!!@@@@@@ read protect board server!!!");
ProtectBoard.find(function(err, protectboard){
//console.log(board);
if(err) return res.status(500).send({error: 'database failure'});
res.send(protectboard);
});
})
//댓글 리스트 출력
app.get('/Readcomment',function(req,res,next){
console.log("~~~~~~~~read comment server !");
Comment.find(function(err,comment){
if(err) return res.status(500).send({error: 'database failure'});
res.send(comment);
})
})
//find 댓글 리스트 출력
app.get('/Readfindcomment',function(req,res,next){
console.log("~~~~~~~~read find comment server !");
FindComment.find(function(err,fcomment){
if(err) return res.status(500).send({error: 'database failure'});
res.send(fcomment);
})
})
//protect 댓글 리스트 출력
app.get('/Readprotectcomment',function(req,res,next){
console.log("~~~~~~~~read protect comment server !");
ProtectComment.find(function(err,pcomment){
if(err) return res.status(500).send({error: 'database failure'});
res.send(pcomment);
})
})
//게시글 삭제
app.post('/Deleteboard',function(req,res,next){
console.log(req.body);
if(req.body.adminid===req.body.bduserid&&req.body.adminpwd===req.body.bdpwd ){
Board.deleteOne({_id:req.body.delid}).then((result)=>{
res.redirect('http://localhost:3000/freeboard');
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//댓글 삭제
app.post('/Deletecomment',function(req,res,next){
console.log(req.body);
if(req.body.delcmid===req.body.cmdbuserid&&req.body.delcmpwd===req.body.cmdbpwd ){
Comment.deleteOne({_id:req.body.delcm}).then((result)=>{
res.redirect('http://localhost:3000/boardcontent'+req.body.interid);
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//찾아주세요 댓글 삭제
app.post('/Deletefindcomment',function(req,res,next){
console.log(req.body);
if(req.body.delcmid===req.body.cmdbuserid&&req.body.delcmpwd===req.body.cmdbpwd ){
FindComment.deleteOne({_id:req.body.delfindcm}).then((result)=>{
res.redirect('http://localhost:3000/findcontent'+req.body.interid);
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//보호중이에요 댓글 삭제
app.post('/Deleteprotectcomment',function(req,res,next){
console.log(req.body);
if(req.body.delcmid===req.body.cmdbuserid&&req.body.delcmpwd===req.body.cmdbpwd ){
ProtectComment.deleteOne({_id:req.body.delfindcm}).then((result)=>{
res.redirect('http://localhost:3000/protectcontent'+req.body.interid);
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//찾아주세요 게시글 삭제
app.post('/Deletefindboard',function(req,res,next){
console.log(req.body);
if(req.body.adminid===req.body.bduserid&&req.body.adminpwd===req.body.bdpwd ){
FindBoard.deleteOne({_id:req.body.delid}).then((result)=>{
res.redirect('http://localhost:3000/find');
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//보호중이에요 게시글 삭제
app.post('/Deleteprotectboard',function(req,res,next){
console.log(req.body);
if(req.body.adminid===req.body.bduserid&&req.body.adminpwd===req.body.bdpwd ){
ProtectBoard.deleteOne({_id:req.body.delid}).then((result)=>{
res.redirect('http://localhost:3000/protect');
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//게시글 수정
app.post('/Editboard',function(req,res,next){
console.log(req.body);
if(req.body.editid===req.body.bduserid&&req.body.editpwd===req.body.bdpwd ){
Board.findByIdAndUpdate(req.body.edid, {$set:{boardtitle:req.body.edittitle,boardcontent:req.body.editcontent}}, (err, movies)=>{
res.redirect('http://localhost:3000/freeboard');
});
}
else{
res.status(200).send("<script>alert(\"수정 권한이 없습니다\")</script>");
}
});
//찾아주세요 게시글 수정
app.post('/Editfindboard',function(req,res,next){
console.log(req.body);
if(req.body.editid===req.body.bduserid&&req.body.editpwd===req.body.bdpwd ){
FindBoard.findByIdAndUpdate(req.body.edid, {$set:{findboardtitle:req.body.edittitle,findboardcontent:req.body.editcontent,findboardplace:req.body.editplace}}, (err, movies)=>{
res.redirect('http://localhost:3000/find');
});
}
else{
res.status(200).send("<script>alert(\"수정 권한이 없습니다\")</script>");
}
});
//보호중이에요 게시글 수정
app.post('/Editprotectboard',function(req,res,next){
console.log(req.body);
if(req.body.editid===req.body.bduserid&&req.body.editpwd===req.body.bdpwd ){
ProtectBoard.findByIdAndUpdate(req.body.edid, {$set:{protectboardtitle:req.body.edittitle,protectboardcontent:req.body.editcontent,protectboardplace:req.body.editplace}}, (err, movies)=>{
res.redirect('http://localhost:3000/protect');
});
}
else{
res.status(200).send("<script>alert(\"수정 권한이 없습니다\")</script>");
}
});
//자유 게시판 댓글 추가
app.post('/Addcomment',function(req,res,next){
//console.log(req.body);
User.find(function(err,us){
var cnt4=-1;
us.forEach(cnt9=>{
cnt4+=1;
if(us[cnt4].userid===req.body.commentid && us[cnt4].userpassword===req.body.commentpwd){
console.log(req.body);
//console.log(us[cnt4].commentpwd);
const commentdb=new Comment({
commentUserid:req.body.commentid,
commentUserpwd:req.body.commentpwd,
commentContent:req.body.commentcontent,
commentId:req.body.commentkey
});
commentdb.save((err)=>{
console.log("commentkey"+req.body.commentkey);
res.redirect('http://localhost:3000/boardcontent'+req.body.commentkey);
})
}
});
})
})
//찾아주세요 댓글 추가
app.post('/Addfindcomment',function(req,res,next){
//console.log(req.body);
User.find(function(err,us){
var cnt4=-1;
us.forEach(cnt9=>{
cnt4+=1;
if(us[cnt4].userid===req.body.commentid && us[cnt4].userpassword===req.body.commentpwd){
console.log(req.body);
//console.log(us[cnt4].commentpwd);
const findcommentdb=new FindComment({
commentUserid:req.body.commentid,
commentUserpwd:req.body.commentpwd,
commentContent:req.body.commentcontent,
commentId:req.body.commentkey
});
findcommentdb.save((err)=>{
console.log("commentkey"+req.body.commentkey);
res.redirect('http://localhost:3000/findcontent'+req.body.commentkey);
})
}
});
})
})
//보호중이에요 댓글 추가
app.post('/Addprotectcomment',function(req,res,next){
//console.log(req.body);
User.find(function(err,us){
var cnt4=-1;
us.forEach(cnt9=>{
cnt4+=1;
if(us[cnt4].userid===req.body.commentid && us[cnt4].userpassword===req.body.commentpwd){
console.log(req.body);
//console.log(us[cnt4].commentpwd);
const protectcommentdb=new ProtectComment({
commentUserid:req.body.commentid,
commentUserpwd:req.body.commentpwd,
commentContent:req.body.commentcontent,
commentId:req.body.commentkey
});
protectcommentdb.save((err)=>{
console.log("commentkey"+req.body.commentkey);
res.redirect('http://localhost:3000/protectcontent'+req.body.commentkey);
})
}
});
})
})
/*
Board.find(function(err,fboard){
var cnt3=-1;
fboard.forEach(cnt2=>{
cnt3+=1;
if(fboard[cnt3].boardtitle===req.body.beforetitle && fboard[cnt3].boardcontent===req.body.beforecontent){
console.log("foreach--title"+fboard[cnt3].boardtitle);
console.log("foreach--content"+fboard[cnt3].boardcontent);
fboard[cnt3].boardtitle=req.body.edititle;
fboard[cnt3].boardcontent=req.body.editcontent;
console.log("after"+req.body.edititle);
res.redirect('http://localhost:3000/freeboard');
}
});
})
*/
......
......@@ -3,25 +3,26 @@ var router = express.Router();
var bodyParser = require('body-parser');
router.use(bodyParser.urlencoded({extended: true}));
const User = require('../models/user');
const Board =require('../models/board');
const Comment = require('../models/comment');
const FindBoard = require('../models/findboard');
const FindComment = require('../models/findcomment');
const ProtectBoard = require('../models/protectboard');
const ProtectComment = require('../models/protectcomment');
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
//회원가입
router.post('/Signup',function(req,res,next){
console.log("in server !!");
console.log("**************"+req.body);
const userdb= new User({
usernickname:req.body.usernickname,
userid:req.body.userid,
userpassword:req.body.userpassword
});
console.log("**********************"+req.body.usernickname);
userdb.save((err)=>{
res.redirect('http://localhost:3000');
......@@ -30,4 +31,486 @@ router.post('/Signup',function(req,res,next){
})
//로그인
router.post('/Signin',function(req,res,next){
console.log("in 로그인 server !!");
console.log("**************"+req.body);
User.find(function(err,us){
var cnt2=-1;
us.forEach(cnt=>{
cnt2+=1;
if(us[cnt2].userid===req.body.signinID && us[cnt2].userpassword===req.body.signinPWD){
res.redirect('http://localhost:3000/')
}
});
})
})
router.use(bodyParser.urlencoded({extended: true}));
//게시판 글쓰기 (회원 여부 확인하여 존재하는 회원만 글쓰기 가능)
router.post('/Createboard',function(req,res,next){
console.log("!!!!!!!!!!!createFreemoard server");
User.find(function(err,us){
var cnt2=-1;
us.forEach(cnt=>{
cnt2+=1;
if(us[cnt2].userid===req.body.userid && us[cnt2].userpassword===req.body.userpsw){
console.log(us[cnt2].userid);
console.log(us[cnt2].userpassword);
const boarddb=new Board({
boarduserid:req.body.userid,
boarduserpsw:req.body.userpsw,
boardtitle:req.body.title,
boardcontent:req.body.content
});
boarddb.save((err)=>{
res.redirect('http://localhost:3000/freeboard');
})
}
});
})
})
//찾아주세요 게시글 작성
router.post('/Createfindboard',function(req,res,next){
console.log("!!!!!!!!!!!createfindboard server");
console.log(req.body);
User.find(function(err,us){
var cnt2=-1;
us.forEach(cnt=>{
cnt2+=1;
if(us[cnt2].userid===req.body.userid && us[cnt2].userpassword===req.body.userpsw){
console.log(us[cnt2].userid);
const boarddb=new FindBoard({
findboarduserid:req.body.userid,
findboarduserpsw:req.body.userpsw,
findboardtitle:req.body.title,
findboardcontent:req.body.content,
findboardplace:req.body.place,
findboardimg:req.body.imgfile,
});
boarddb.save((err)=>{
res.redirect('http://localhost:3000/find');
})
}
});
})
})
//보호중이에요 게시글 작성
router.post('/Createprotectboard',function(req,res,next){
console.log("!!!!!!!!!!!createprotectboard server");
console.log(req.body);
User.find(function(err,us){
var cnt7=-1;
us.forEach(cnt=>{
cnt7+=1;
if(us[cnt7].userid===req.body.userid && us[cnt7].userpassword===req.body.userpsw){
console.log(us[cnt7].userid);
const protectboarddb=new ProtectBoard({
protectboarduserid:req.body.userid,
protectboarduserpsw:req.body.userpsw,
protectboardtitle:req.body.title,
protectboardcontent:req.body.content,
protectboardplace:req.body.place,
protectboardimg:req.body.imgfile,
});
protectboarddb.save((err)=>{
res.redirect('http://localhost:3000/protect');
})
}
});
})
})
//자유게시판에서 제목을 누르면 해당 content 열람 가능
router.get('/Readboard',function(req,res,next){
console.log("!!!!@@@@@@ read board server!!!");
Board.find(function(err, board){
//console.log(board);
if(err) return res.status(500).send({error: 'database failure'});
res.send(board);
});
})
//찾아주세요 페이지의 게시글 리스트
router.get('/Readfindboard',function(req,res,next){
console.log("!!!!@@@@@@ read find board server!!!");
FindBoard.find(function(err, findboard){
//console.log(board);
if(err) return res.status(500).send({error: 'database failure'});
res.send(findboard);
});
})
//보호해주세요 페이지의 게시글 리스트
router.get('/Readprotectboard',function(req,res,next){
console.log("!!!!@@@@@@ read protect board server!!!");
ProtectBoard.find(function(err, protectboard){
//console.log(board);
if(err) return res.status(500).send({error: 'database failure'});
res.send(protectboard);
});
})
//댓글 리스트 출력
router.get('/Readcomment',function(req,res,next){
console.log("~~~~~~~~read comment server !");
Comment.find(function(err,comment){
if(err) return res.status(500).send({error: 'database failure'});
res.send(comment);
})
})
//find 댓글 리스트 출력
router.get('/Readfindcomment',function(req,res,next){
console.log("~~~~~~~~read find comment server !");
FindComment.find(function(err,fcomment){
if(err) return res.status(500).send({error: 'database failure'});
res.send(fcomment);
})
})
//protect 댓글 리스트 출력
router.get('/Readprotectcomment',function(req,res,next){
console.log("~~~~~~~~read protect comment server !");
ProtectComment.find(function(err,pcomment){
if(err) return res.status(500).send({error: 'database failure'});
res.send(pcomment);
})
})
//게시글 삭제
router.post('/Deleteboard',function(req,res,next){
console.log(req.body);
if(req.body.adminid===req.body.bduserid&&req.body.adminpwd===req.body.bdpwd ){
Board.deleteOne({_id:req.body.delid}).then((result)=>{
res.redirect('http://localhost:3000/freeboard');
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//댓글 삭제
router.post('/Deletecomment',function(req,res,next){
console.log(req.body);
if(req.body.delcmid===req.body.cmdbuserid&&req.body.delcmpwd===req.body.cmdbpwd ){
Comment.deleteOne({_id:req.body.delcm}).then((result)=>{
res.redirect('http://localhost:3000/boardcontent'+req.body.interid);
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//찾아주세요 댓글 삭제
router.post('/Deletefindcomment',function(req,res,next){
console.log(req.body);
if(req.body.delcmid===req.body.cmdbuserid&&req.body.delcmpwd===req.body.cmdbpwd ){
FindComment.deleteOne({_id:req.body.delfindcm}).then((result)=>{
res.redirect('http://localhost:3000/findcontent'+req.body.interid);
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//보호중이에요 댓글 삭제
router.post('/Deleteprotectcomment',function(req,res,next){
console.log(req.body);
if(req.body.delcmid===req.body.cmdbuserid&&req.body.delcmpwd===req.body.cmdbpwd ){
ProtectComment.deleteOne({_id:req.body.delfindcm}).then((result)=>{
res.redirect('http://localhost:3000/protectcontent'+req.body.interid);
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//찾아주세요 게시글 삭제
router.post('/Deletefindboard',function(req,res,next){
console.log(req.body);
if(req.body.adminid===req.body.bduserid&&req.body.adminpwd===req.body.bdpwd ){
FindBoard.deleteOne({_id:req.body.delid}).then((result)=>{
res.redirect('http://localhost:3000/find');
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//보호중이에요 게시글 삭제
router.post('/Deleteprotectboard',function(req,res,next){
console.log(req.body);
if(req.body.adminid===req.body.bduserid&&req.body.adminpwd===req.body.bdpwd ){
ProtectBoard.deleteOne({_id:req.body.delid}).then((result)=>{
res.redirect('http://localhost:3000/protect');
}).catch((err)=>{
var response={
success:false
}
res.status(401).json(response);
});
}
else{
res.status(200).send("<script>alert(\"삭제 권한이 없습니다\")</script>");
}
});
//게시글 수정
router.post('/Editboard',function(req,res,next){
console.log(req.body);
if(req.body.editid===req.body.bduserid&&req.body.editpwd===req.body.bdpwd ){
Board.findByIdAndUpdate(req.body.edid, {$set:{boardtitle:req.body.edittitle,boardcontent:req.body.editcontent}}, (err, movies)=>{
res.redirect('http://localhost:3000/freeboard');
});
}
else{
res.status(200).send("<script>alert(\"수정 권한이 없습니다\")</script>");
}
});
//찾아주세요 게시글 수정
router.post('/Editfindboard',function(req,res,next){
console.log(req.body);
if(req.body.editid===req.body.bduserid&&req.body.editpwd===req.body.bdpwd ){
FindBoard.findByIdAndUpdate(req.body.edid, {$set:{findboardtitle:req.body.edittitle,findboardcontent:req.body.editcontent,findboardplace:req.body.editplace}}, (err, movies)=>{
res.redirect('http://localhost:3000/find');
});
}
else{
res.status(200).send("<script>alert(\"수정 권한이 없습니다\")</script>");
}
});
//보호중이에요 게시글 수정
router.post('/Editprotectboard',function(req,res,next){
console.log(req.body);
if(req.body.editid===req.body.bduserid&&req.body.editpwd===req.body.bdpwd ){
ProtectBoard.findByIdAndUpdate(req.body.edid, {$set:{protectboardtitle:req.body.edittitle,protectboardcontent:req.body.editcontent,protectboardplace:req.body.editplace}}, (err, movies)=>{
res.redirect('http://localhost:3000/protect');
});
}
else{
res.status(200).send("<script>alert(\"수정 권한이 없습니다\")</script>");
}
});
//자유 게시판 댓글 추가
router.post('/Addcomment',function(req,res,next){
//console.log(req.body);
User.find(function(err,us){
var cnt4=-1;
us.forEach(cnt9=>{
cnt4+=1;
if(us[cnt4].userid===req.body.commentid && us[cnt4].userpassword===req.body.commentpwd){
console.log(req.body);
//console.log(us[cnt4].commentpwd);
const commentdb=new Comment({
commentUserid:req.body.commentid,
commentUserpwd:req.body.commentpwd,
commentContent:req.body.commentcontent,
commentId:req.body.commentkey
});
commentdb.save((err)=>{
console.log("commentkey"+req.body.commentkey);
res.redirect('http://localhost:3000/boardcontent'+req.body.commentkey);
})
}
});
})
})
//찾아주세요 댓글 추가
router.post('/Addfindcomment',function(req,res,next){
//console.log(req.body);
User.find(function(err,us){
var cnt4=-1;
us.forEach(cnt9=>{
cnt4+=1;
if(us[cnt4].userid===req.body.commentid && us[cnt4].userpassword===req.body.commentpwd){
console.log(req.body);
//console.log(us[cnt4].commentpwd);
const findcommentdb=new FindComment({
commentUserid:req.body.commentid,
commentUserpwd:req.body.commentpwd,
commentContent:req.body.commentcontent,
commentId:req.body.commentkey
});
findcommentdb.save((err)=>{
console.log("commentkey"+req.body.commentkey);
res.redirect('http://localhost:3000/findcontent'+req.body.commentkey);
})
}
});
})
})
//보호중이에요 댓글 추가
router.post('/Addprotectcomment',function(req,res,next){
//console.log(req.body);
User.find(function(err,us){
var cnt4=-1;
us.forEach(cnt9=>{
cnt4+=1;
if(us[cnt4].userid===req.body.commentid && us[cnt4].userpassword===req.body.commentpwd){
console.log(req.body);
//console.log(us[cnt4].commentpwd);
const protectcommentdb=new ProtectComment({
commentUserid:req.body.commentid,
commentUserpwd:req.body.commentpwd,
commentContent:req.body.commentcontent,
commentId:req.body.commentkey
});
protectcommentdb.save((err)=>{
console.log("commentkey"+req.body.commentkey);
res.redirect('http://localhost:3000/protectcontent'+req.body.commentkey);
})
}
});
})
})
module.exports = router;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment