auth_controller.go 563 B

1234567891011121314151617181920212223242526272829
  1. package controller
  2. import (
  3. "context"
  4. "cris/api/v1/common"
  5. "cris/internal/service"
  6. "github.com/gogf/gf/v2/frame/g"
  7. )
  8. type LoginController struct {
  9. LoginService *service.LoginService
  10. }
  11. // 登录处理方法
  12. func (c *LoginController) Login(ctx context.Context, req *common.LoginReq) (res *common.LoginRes, err error) {
  13. r := g.RequestFromCtx(ctx)
  14. if err := r.Parse(req); err != nil {
  15. r.Response.WriteJsonExit(g.Map{"error": err.Error()})
  16. }
  17. // 调用服务层进行逻辑处理
  18. res = c.LoginService.Login(req)
  19. r.Response.WriteJson(res)
  20. return
  21. }