Take int instead of int64
This commit is contained in:
parent
e57b7a7089
commit
91aee60bfb
@ -125,7 +125,7 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
||||
w = work.(*Work)
|
||||
} else if repository.IdWork > 0 {
|
||||
var err error
|
||||
w, err = getWork(int(repository.IdWork))
|
||||
w, err = getWork(repository.IdWork)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Unable to find the given work identifier."})
|
||||
return
|
||||
@ -187,7 +187,7 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
||||
repositoriesRoutes.DELETE("", func(c *gin.Context) {
|
||||
loggeduser := c.MustGet("LoggedUser").(*User)
|
||||
repository := c.MustGet("repository").(*Repository)
|
||||
work, err := getWork(int(repository.IdWork))
|
||||
work, err := getWork(repository.IdWork)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to find related work."})
|
||||
return
|
||||
@ -219,7 +219,7 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
||||
u = loggeduser
|
||||
}
|
||||
repo := c.MustGet("repository").(*Repository)
|
||||
work, err := getWork(int(repo.IdWork))
|
||||
work, err := getWork(repo.IdWork)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to find related work."})
|
||||
return
|
||||
@ -309,7 +309,7 @@ func declareAPIAuthRepositoriesRoutes(router *gin.RouterGroup) {
|
||||
u = loggeduser
|
||||
}
|
||||
repo := c.MustGet("repository").(*Repository)
|
||||
work, err := getWork(int(repo.IdWork))
|
||||
work, err := getWork(repo.IdWork)
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to find related work."})
|
||||
return
|
||||
@ -361,7 +361,7 @@ func declareCallbacksRoutes(router *gin.RouterGroup) {
|
||||
return
|
||||
}
|
||||
|
||||
work, err := getWork(int(repo.IdWork))
|
||||
work, err := getWork(repo.IdWork)
|
||||
if err != nil {
|
||||
log.Println("Unable to getWork:", err.Error())
|
||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to find related work."})
|
||||
@ -387,7 +387,7 @@ func declareCallbacksRoutes(router *gin.RouterGroup) {
|
||||
// Allow to use a secret for another tag
|
||||
if len(repos) > 1 {
|
||||
for _, r := range repos {
|
||||
w, err := getWork(int(r.IdWork))
|
||||
w, err := getWork(r.IdWork)
|
||||
if err != nil {
|
||||
log.Println("Unable to getWork:", err.Error())
|
||||
continue
|
||||
|
4
works.go
4
works.go
@ -228,7 +228,7 @@ func workHandler(c *gin.Context) {
|
||||
if wid, err := strconv.Atoi(string(c.Param("wid"))); err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Bad work identifier."})
|
||||
return
|
||||
} else if work, err := getWork(wid); err != nil {
|
||||
} else if work, err := getWork(int64(wid)); err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusNotFound, gin.H{"errmsg": "Work not found."})
|
||||
return
|
||||
} else {
|
||||
@ -331,7 +331,7 @@ func getWorks(cnd string, param ...interface{}) (items []*Work, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func getWork(id int) (w *Work, err error) {
|
||||
func getWork(id int64) (w *Work, err error) {
|
||||
w = new(Work)
|
||||
err = DBQueryRow("SELECT id_work, id_category, title, promo, grp, shown, description, tag, submission_url, gradation_repo, corrected, start_availability, end_availability FROM works WHERE id_work=?", id).Scan(&w.Id, &w.IdCategory, &w.Title, &w.Promo, &w.Group, &w.Shown, &w.DescriptionRaw, &w.Tag, &w.SubmissionURL, &w.GradationRepo, &w.Corrected, &w.StartAvailability, &w.EndAvailability)
|
||||
w.Description = string(blackfriday.Run([]byte(w.DescriptionRaw)))
|
||||
|
Reference in New Issue
Block a user