mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-21 01:19:58 +01:00
setRating.view implemented
This commit is contained in:
parent
d59394c653
commit
fc8bb34ae3
4 changed files with 59 additions and 0 deletions
|
|
@ -60,6 +60,14 @@ func (c *BaseAPIController) ParamTimes(param string) []time.Time {
|
|||
return times
|
||||
}
|
||||
|
||||
func (c *BaseAPIController) RequiredParamInt(param string, msg string) int {
|
||||
p := c.Input().Get(param)
|
||||
if p == "" {
|
||||
c.SendError(responses.ErrorMissingParameter, msg)
|
||||
}
|
||||
return c.ParamInt(param, 0)
|
||||
}
|
||||
|
||||
func (c *BaseAPIController) ParamInt(param string, def int) int {
|
||||
value := def
|
||||
c.Ctx.Input.Bind(&value, param)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,25 @@ func (c *MediaAnnotationController) Prepare() {
|
|||
utils.ResolveDependencies(&c.scrobbler, &c.ratings)
|
||||
}
|
||||
|
||||
func (c *MediaAnnotationController) SetRating() {
|
||||
id := c.RequiredParamString("id", "Required id parameter is missing")
|
||||
rating := c.RequiredParamInt("rating", "Required rating parameter is missing")
|
||||
|
||||
beego.Debug("Setting rating", rating, "for id", id)
|
||||
err := c.ratings.SetRating(id, rating)
|
||||
|
||||
switch {
|
||||
case err == domain.ErrNotFound:
|
||||
beego.Error(err)
|
||||
c.SendError(responses.ErrorDataNotFound, "Id not found")
|
||||
case err != nil:
|
||||
beego.Error(err)
|
||||
c.SendError(responses.ErrorGeneric, "Internal Error")
|
||||
}
|
||||
|
||||
c.SendEmptyResponse()
|
||||
}
|
||||
|
||||
func (c *MediaAnnotationController) Star() {
|
||||
ids := c.RequiredParamStrings("id", "Required id parameter is missing")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue