Commit 91a3ef91 authored by “Yevgeniy's avatar “Yevgeniy

#36 put resolved

parent 010f4453
...@@ -68,14 +68,6 @@ router.get('/my', async (req: Request, res: Response):Promise<Response>=>{ ...@@ -68,14 +68,6 @@ router.get('/my', async (req: Request, res: Response):Promise<Response>=>{
}) })
router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>{ router.delete('/:taskId',async (req: Request, res: Response):Promise<Response>=>{
// const token = req.get('Authorization');
// const user = await dataSource
// .createQueryBuilder()
// .select("user")
// .from(User, "user")
// .where("user.token = :token", { token: token })
// .getOne()
// if(!user) return res.status(404).send({Message:'user not found'})
const taskId = req.params.taskId; const taskId = req.params.taskId;
await myDataSource await myDataSource
.createQueryBuilder() .createQueryBuilder()
...@@ -96,29 +88,12 @@ router.put('/',async(req:Request, res:Response)=> { ...@@ -96,29 +88,12 @@ router.put('/',async(req:Request, res:Response)=> {
.where("user.token = :token", { token: token }) .where("user.token = :token", { token: token })
.getOne() .getOne()
if (!user) return res.status(404).send({Message:'user not found'}) if (!user) return res.status(404).send({Message:'user not found'})
const {id,title,description,project,dateTimeDue,dateTimeStart,executors,accomplish,priority} = req.body;
const {id,title,description,project,dateTimeDue,dateTimeStart,accomplish,priority} = req.body;
// await dataSource
// .createQueryBuilder()
// .update(Task)
// .set({
// title: title,
// description: description,
// project: project,
// dateTimeDue: dateTimeDue,
// dateTimeStart: dateTimeStart,
// author:user,
// accomplish: accomplish,
// priority: priority
// })
// .where("id = :id", { id: id })
// .execute()
const task = await dataSource const task = await dataSource
.createQueryBuilder() .createQueryBuilder()
.select("task") .select("task")
.from(Task, "task") .from(Task, "task")
.where("task.id = :id", { id }) .where("task.id = :id", { id })
// .addSelect('password')
.getOne() .getOne()
if (!task) return res.status(404).send({Message:'task not found'}) if (!task) return res.status(404).send({Message:'task not found'})
task.title= title task.title= title
...@@ -127,9 +102,9 @@ router.put('/',async(req:Request, res:Response)=> { ...@@ -127,9 +102,9 @@ router.put('/',async(req:Request, res:Response)=> {
task.dateTimeDue= dateTimeDue task.dateTimeDue= dateTimeDue
task.dateTimeStart= dateTimeStart task.dateTimeStart= dateTimeStart
task.author=user task.author=user
task.executors=executors
task.accomplish= accomplish task.accomplish= accomplish
task.priority= priority task.priority= priority
await task.save() await task.save()
res.send({message:'update task successfully'}) res.send({message:'update task successfully'})
// res.send({task})
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment