fixes
This commit is contained in:
parent
9fcc33b0ba
commit
e3117f1475
@ -31,6 +31,7 @@ func Listen(address string, path string) {
|
||||
{
|
||||
apiAdmin.POST("task/add", task.Add)
|
||||
apiAdmin.POST("task/remove/:id", task.Remove)
|
||||
apiAdmin.GET("task/list/:neptun", task.ListUser)
|
||||
}
|
||||
|
||||
apiUser := api.Group("user").Use(auth.LoggedIn)
|
||||
|
@ -100,3 +100,20 @@ func List(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func ListUser(c *gin.Context) {
|
||||
recipient := c.Param("neptun")
|
||||
|
||||
tasks, err := task.List(recipient)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"status": http.StatusInternalServerError,
|
||||
"error": err.Error(),
|
||||
})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": http.StatusOK,
|
||||
"tasks": tasks,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ func Remove(id int) error {
|
||||
db := database.GetDB()
|
||||
|
||||
_, err := db.NamedExec(
|
||||
`delete from "task" where "id" = :id`, map[string]interface{}{
|
||||
`delete from "task" where "id" = :id`,
|
||||
map[string]interface{}{
|
||||
"id": id,
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user