|
@@ -0,0 +1,29 @@
|
|
|
+package controller
|
|
|
+
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+
|
|
|
+ "cris/api/v1/common"
|
|
|
+ "cris/internal/service"
|
|
|
+
|
|
|
+ "github.com/gogf/gf/v2/frame/g"
|
|
|
+)
|
|
|
+
|
|
|
+type LoginController struct {
|
|
|
+ LoginService *service.LoginService
|
|
|
+}
|
|
|
+
|
|
|
+// 登录处理方法
|
|
|
+func (c *LoginController) Login(ctx context.Context, req *common.LoginReq) (res *common.LoginRes, err error) {
|
|
|
+
|
|
|
+ r := g.RequestFromCtx(ctx) // 获取 *ghttp.Request
|
|
|
+ if err := r.Parse(req); err != nil {
|
|
|
+ r.Response.WriteJsonExit(map[string]interface{}{"error": err.Error()})
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用服务层进行业务逻辑处理
|
|
|
+ res = c.LoginService.Login(req)
|
|
|
+
|
|
|
+ r.Response.WriteJson(res)
|
|
|
+ return
|
|
|
+}
|