version.go 931 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package http
  2. import (
  3. "go-common/app/admin/main/vip/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func updateVersion(c *bm.Context) {
  8. var (
  9. err error
  10. )
  11. arg := new(struct {
  12. ID int64 `form:"id" validate:"required"`
  13. Version string `form:"version" `
  14. Tip string `form:"tip"`
  15. Link string `form:"link"`
  16. })
  17. if err = c.Bind(arg); err != nil {
  18. return
  19. }
  20. operator, ok := c.Get("username")
  21. if !ok {
  22. c.JSON(nil, ecode.AccessDenied)
  23. return
  24. }
  25. if err = vipSvc.UpdateVersion(c, &model.VipAppVersion{
  26. ID: arg.ID,
  27. Version: arg.Version,
  28. Tip: arg.Tip,
  29. Operator: operator.(string),
  30. Link: arg.Link,
  31. }); err != nil {
  32. c.JSON(nil, err)
  33. return
  34. }
  35. c.JSON(nil, nil)
  36. }
  37. func versions(c *bm.Context) {
  38. var (
  39. res []*model.VipAppVersion
  40. err error
  41. )
  42. if res, err = vipSvc.AllVersion(c); err != nil {
  43. c.JSON(nil, err)
  44. return
  45. }
  46. c.JSON(res, nil)
  47. }