package controllers

import (
	"fmt"
	"hongze/hongze_mobile_admin/utils"
	"net/url"
)

//不需要授权的基类
type BaseNotAuth struct {
	BaseCommon
}

func (this *BaseNotAuth) Prepare() {
	var requestBody string
	method := this.Ctx.Input.Method()
	if method == "GET" {
		requestBody = this.Ctx.Request.RequestURI
	} else {
		requestBody, _ = url.QueryUnescape(string(this.Ctx.Input.RequestBody))
	}
	fmt.Println("requestBody:", requestBody)
	ip := this.Ctx.Input.IP()
	fmt.Println("ip:", ip)
	//apiLog.Println("请求地址:", this.Ctx.Input.URI(), "RequestBody:", requestBody, "IP:", ip)

	authorization := this.Ctx.Input.Header("Authorization")
	if authorization == "" {
		cookie := this.Ctx.GetCookie("rddp_access_token")
		utils.FileLog.Info("authorization:%s,cookie:%s", authorization, cookie)
		authorization = cookie
	}
	uri := this.Ctx.Input.URI()
	utils.FileLog.Info("URI:%s", uri)
	//if strings.Contains(uri, "/h5adminapi/wechat/login") {
	//	authorization = ""
	//}
}