Take int instead of int64

This commit is contained in:
nemunaire 2023-03-05 03:57:37 +01:00
parent e57b7a7089
commit 91aee60bfb
2 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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)))