user.go 834 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package http
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "go-common/library/net/http/blademaster/binding"
  7. )
  8. func queryUser(c *bm.Context) {
  9. // 验证登录sessionID
  10. session, err := c.Request.Cookie("_AJSESSIONID")
  11. if err != nil {
  12. c.JSON(nil, ecode.AccessKeyErr)
  13. return
  14. }
  15. token, _ := srv.QueryServiceTreeToken(c, session.Value)
  16. if token == "" {
  17. c.JSON(nil, ecode.AccessKeyErr)
  18. return
  19. }
  20. // 获取用户名
  21. userName, err := c.Request.Cookie("username")
  22. if err != nil {
  23. c.JSON(nil, ecode.AccessKeyErr)
  24. return
  25. }
  26. c.JSON(srv.QueryUser(userName.Value))
  27. }
  28. func updateUser(c *bm.Context) {
  29. user := model.User{}
  30. if err := c.BindWith(&user, binding.JSON); err != nil {
  31. c.JSON(nil, err)
  32. return
  33. }
  34. c.JSON(nil, srv.UpdateUser(&user))
  35. }