Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
117bbc7e
Commit
117bbc7e
authored
Jul 20, 2022
by
Lee SeoYeon
Browse files
0720
parent
69a26550
Changes
3
Show whitespace changes
Inline
Side-by-side
frontend/src/apis/survey.api.ts
View file @
117bbc7e
...
@@ -17,7 +17,6 @@ export const ansSurvey = async (surveyId: string) => {
...
@@ -17,7 +17,6 @@ export const ansSurvey = async (surveyId: string) => {
return
data
;
return
data
;
}
}
//동혁
export
const
getSurveys
=
async
()
=>
{
export
const
getSurveys
=
async
()
=>
{
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/surveys/`
);
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/surveys/`
);
return
data
;
return
data
;
...
...
src/controllers/survey.controller.ts
View file @
117bbc7e
import
{
NextFunction
,
Request
,
Response
}
from
"
express
"
;
import
{
NextFunction
,
Request
,
Response
}
from
"
express
"
;
import
{
surveyDb
}
from
"
../db
"
;
import
{
surveyDb
}
from
"
../db
"
;
import
{
asyncWrap
}
from
"
../helpers/asyncWrap
"
;
import
{
asyncWrap
}
from
"
../helpers/asyncWrap
"
;
// import jwt, { JwtPayload } from "jsonwebtoken";
// import { cookieConfig, envConfig, jwtCofig } from "../config";
export
interface
TypedRequestAuth
<
T
>
extends
Request
{
export
interface
TypedRequestAuth
<
T
>
extends
Request
{
auth
:
T
;
auth
:
T
;
...
@@ -26,7 +28,6 @@ export const getSurveyById = asyncWrap(async (req, res) => {
...
@@ -26,7 +28,6 @@ export const getSurveyById = asyncWrap(async (req, res) => {
return
res
.
json
(
survey
);
return
res
.
json
(
survey
);
});
});
//동혁
export
const
getSurveys
=
asyncWrap
(
async
(
reqExp
:
Request
,
res
:
Response
)
=>
{
export
const
getSurveys
=
asyncWrap
(
async
(
reqExp
:
Request
,
res
:
Response
)
=>
{
const
req
=
reqExp
as
TypedRequestAuth
<
{
userId
:
string
}
>
;
const
req
=
reqExp
as
TypedRequestAuth
<
{
userId
:
string
}
>
;
const
{
userId
}
=
req
.
auth
;
const
{
userId
}
=
req
.
auth
;
...
@@ -69,3 +70,29 @@ export const userBySurveyId = async (
...
@@ -69,3 +70,29 @@ export const userBySurveyId = async (
);
);
}
}
};
};
// export const checksurvey = asyncWrap(async(req, res)=> {
// const {_id} = req.body
// const surveyExist = await surveyDb.isSurvey(_id);
// if (surveyExist) {
// return res.status(422).send("이미 제출된 설문조사입니다")
// }
// });
// export const surveynotexist = asyncWrap(async (req, res) => {
// const { _id } = req.body;
// console.log(`surveyId: ${_id}`);
// const checksurveyId = await surveyDb.findUserBySurveyId(_id);
// const surveytoken = jwt.sign({existsurveyId: checksurveyId?.id}, jwtCofig.secret, {
// expiresIn:jwtCofig.expires,
// });
// res.cookie(cookieConfig.name, surveytoken, {
// maxAge:cookieConfig.maxAge,
// path:"/",
// httpOnly: envConfig.mode === "production",
// secure: envConfig.mode === "production",
// })
// res.json({
// surveyId: checksurveyId?._id
// })
// });
\ No newline at end of file
src/db/survey.db.ts
View file @
117bbc7e
...
@@ -36,3 +36,12 @@ export const deleteSurvey = async (surveyId: string) => {
...
@@ -36,3 +36,12 @@ export const deleteSurvey = async (surveyId: string) => {
const
survey
=
await
Survey
.
findOneAndDelete
({
_id
:
surveyId
});
const
survey
=
await
Survey
.
findOneAndDelete
({
_id
:
surveyId
});
return
survey
;
return
survey
;
};
};
// export const isSurvey = async (surveyId: string) =>{
// const survey = await Survey.findOne({surveyId});
// if (survey) {
// return true;
// } else {
// return false;
// }
// }
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment