Add descriptions to Works
This commit is contained in:
parent
7e7608b7d1
commit
767da66f63
5 changed files with 50 additions and 18 deletions
|
@ -42,7 +42,21 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
|||
return
|
||||
}
|
||||
|
||||
w := c.MustGet("work").(*Work)
|
||||
var w *Work
|
||||
if work, ok := c.Get("work"); ok {
|
||||
w = work.(*Work)
|
||||
} else if repository.IdWork > 0 {
|
||||
var err error
|
||||
w, err = getWork(int(repository.IdWork))
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Unable to find the given work identifier."})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Unable to find the given work identifier."})
|
||||
return
|
||||
}
|
||||
|
||||
k, err := u.NewRepository(w, repository.URI)
|
||||
if err != nil {
|
||||
log.Println("Unable to NewRepository:", err)
|
||||
|
@ -158,13 +172,13 @@ func (u *User) GetRepositories() (repositories []*Repository, err error) {
|
|||
|
||||
func getRepository(id int) (r *Repository, err error) {
|
||||
r = new(Repository)
|
||||
err = DBQueryRow("SELECT id_repository, id_user, id_work, uri, lastcheck FROM user_work_repositories WHERE id_repository=?", id).Scan(&r.Id, &r.IdUser, &r.IdWork, &r.URI, &r.LastCheck)
|
||||
err = DBQueryRow("SELECT id_repository, id_user, id_work, uri, last_check FROM user_work_repositories WHERE id_repository=?", id).Scan(&r.Id, &r.IdUser, &r.IdWork, &r.URI, &r.LastCheck)
|
||||
return
|
||||
}
|
||||
|
||||
func (u *User) getRepository(id int) (r *Repository, err error) {
|
||||
r = new(Repository)
|
||||
err = DBQueryRow("SELECT id_repository, id_user, id_work, uri FROM user_work_repositories WHERE id_repository=? AND id_user=?", id, u.Id).Scan(&r.Id, &r.IdUser, &r.IdWork, &r.URI, &r.LastCheck)
|
||||
err = DBQueryRow("SELECT id_repository, id_user, id_work, uri, last_check FROM user_work_repositories WHERE id_repository=? AND id_user=?", id, u.Id).Scan(&r.Id, &r.IdUser, &r.IdWork, &r.URI, &r.LastCheck)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue