department.go 790 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. // departments .
  9. func departments(c *bm.Context) {
  10. c.JSON(mngSvc.Departments(c))
  11. }
  12. // roles .
  13. func roles(c *bm.Context) {
  14. c.JSON(mngSvc.Roles(c))
  15. }
  16. // userByDepartment .
  17. func usersByDepartment(c *bm.Context) {
  18. ID, _ := strconv.ParseInt(c.Request.Form.Get("id"), 10, 64)
  19. if ID <= 0 {
  20. c.JSON(nil, ecode.RequestErr)
  21. log.Error("ID unnarmal (%d)", ID)
  22. return
  23. }
  24. c.JSON(mngSvc.UsersByDepartment(c, ID))
  25. }
  26. // userByRole .
  27. func usersByRole(c *bm.Context) {
  28. ID, _ := strconv.ParseInt(c.Request.Form.Get("id"), 10, 64)
  29. if ID <= 0 {
  30. c.JSON(nil, ecode.RequestErr)
  31. log.Error("ID unnarmal (%d)", ID)
  32. return
  33. }
  34. c.JSON(mngSvc.UsersByRole(c, ID))
  35. }