Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
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
Hide 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) => {
return
data
;
}
//동혁
export
const
getSurveys
=
async
()
=>
{
const
{
data
}
=
await
axios
.
get
(
`
${
baseUrl
}
/surveys/`
);
return
data
;
...
...
src/controllers/survey.controller.ts
View file @
117bbc7e
import
{
NextFunction
,
Request
,
Response
}
from
"
express
"
;
import
{
surveyDb
}
from
"
../db
"
;
import
{
asyncWrap
}
from
"
../helpers/asyncWrap
"
;
// import jwt, { JwtPayload } from "jsonwebtoken";
// import { cookieConfig, envConfig, jwtCofig } from "../config";
export
interface
TypedRequestAuth
<
T
>
extends
Request
{
auth
:
T
;
...
...
@@ -26,7 +28,6 @@ export const getSurveyById = asyncWrap(async (req, res) => {
return
res
.
json
(
survey
);
});
//동혁
export
const
getSurveys
=
asyncWrap
(
async
(
reqExp
:
Request
,
res
:
Response
)
=>
{
const
req
=
reqExp
as
TypedRequestAuth
<
{
userId
:
string
}
>
;
const
{
userId
}
=
req
.
auth
;
...
...
@@ -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) => {
const
survey
=
await
Survey
.
findOneAndDelete
({
_id
:
surveyId
});
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