#167 added router to return projects where user non watcher

parent cabc6242
......@@ -225,4 +225,27 @@ router.put('/change-project-role/:userId',authAdminProject, async (req: Request
})
/** return projects where user's member.role not equal 'watcher' */
router.get('/task_create/:userId', async (req : Request, res : Response): Promise<Response>=>{
try{
const userId:string = req.params.userId
const userProjects = await dataSource
.createQueryBuilder()
.select('project')
.from(Project, "project")
.leftJoinAndSelect('project.members', 'member')
.leftJoinAndSelect('member.user', 'user' )
.where("user.id = :id", { id: userId })
.andWhere("member.roleProject != :role", {role:MemberRole.WATCHER})
.getMany();
return res.send({userProjects})
} catch(e) {
return res.status(502).send({message:(e as Error).message})
}
})
export default router;
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