staff.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package http
  2. import (
  3. "encoding/json"
  4. "go-common/app/admin/main/videoup/model/archive"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. func staffs(c *bm.Context) {
  10. v := new(struct {
  11. AID int64 `form:"aid" validate:"required"`
  12. })
  13. if err := c.Bind(v); err != nil {
  14. return
  15. }
  16. log.Info("staffs data(%v)", v)
  17. c.JSON(vdaSvc.Staffs(c, v.AID))
  18. }
  19. //batchStaff .
  20. func batchStaff(c *bm.Context) {
  21. v := new(struct {
  22. AID int64 `form:"aid" validate:"required"`
  23. DelAll int8 `form:"del_all"`
  24. Staffs string `form:"staffs"`
  25. })
  26. if err := c.Bind(v); err != nil {
  27. return
  28. }
  29. log.Info("batchStaff data(%v)", v)
  30. var err error
  31. var aps = &archive.StaffBatchParam{}
  32. if err = json.Unmarshal([]byte(v.Staffs), &aps.Staffs); err != nil {
  33. log.Error("http batchStaff Staffs json.Unmarshal(%s) error(%v)", v.Staffs, err)
  34. c.JSON(nil, ecode.RequestErr)
  35. return
  36. }
  37. if v.AID == 0 {
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. if len(aps.Staffs) == 0 && v.DelAll != 1 {
  42. log.Info("batchStaff del_all data is wrong(%v) staffs(%+v)", v, aps)
  43. c.JSON(nil, ecode.RequestErr)
  44. return
  45. }
  46. if aps.Staffs == nil {
  47. aps.Staffs = []*archive.StaffParam{}
  48. }
  49. if ok := vdaSvc.CheckStaff(aps.Staffs); !ok {
  50. c.JSON(nil, ecode.RequestErr)
  51. return
  52. }
  53. aps.AID = v.AID
  54. c.JSON(nil, vdaSvc.StaffApplyBatchSubmit(c, aps))
  55. }