diff --git a/constant/constant.go b/constant/constant.go index 22f5518..05a785e 100644 --- a/constant/constant.go +++ b/constant/constant.go @@ -19,6 +19,9 @@ const ( TypeAdd = 1 TypeMinus = -1 + + StartTime = "00:00:00" + EndTime = "23:59:59" ) const ( @@ -58,3 +61,15 @@ var WeekDayMap = map[string]string{ "Saturday": "周六", "Sunday": "周日", } + +const ( + DayVIP = "日会员" + MonthVIP = "月会员" + QuarterVIP = "季会员" + YearVIP = "年会员" + + DayAllVIP = "日大会员" + MonthAllVIP = "月大会员" + QuarterAllVIP = "季大会员" + YearAllVIP = "年大会员" +) diff --git a/constant/error.go b/constant/error.go index 1c99c53..cd3756f 100644 --- a/constant/error.go +++ b/constant/error.go @@ -26,8 +26,9 @@ const ( const ( StrconvAtoiError = 30000 // 类型转换错误(主要是string转int) ParseTimeError = 30001 // 日期类型的错误 - ReadFileError = 30002 - UnknowError = 30003 + ReadFileError = 30002 // 读取文件错误 + UnknowError = 30003 // 未知错误 + UnknowOwner = 30004 // 不是球馆管理员返回码 ) // 返回4xxxx -> json错误 diff --git a/http/http.go b/http/http.go index 9e230df..aa6160b 100644 --- a/http/http.go +++ b/http/http.go @@ -1,6 +1,10 @@ package http import ( + "crypto/tls" + "encoding/json" + "io/ioutil" + "log" "net/http" "github.com/gin-gonic/gin" @@ -25,3 +29,32 @@ func Cors() gin.HandlerFunc { c.Next() } } + +// DoGet get请求 +func DoGet(req *http.Request) (map[string]string, error) { + req.Header.Set("Content-Type", "application/json") + client := &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: true, + }, + }, + } + + rsp, err := client.Do(req) + if err != nil { + log.Printf("getToken client.Do err: [%+v]", err) + return nil, err + } + defer rsp.Body.Close() + + body, _ := ioutil.ReadAll(rsp.Body) + rspMap := make(map[string]string) + err = json.Unmarshal(body, &rspMap) + if err != nil { + log.Printf("Unmarshal rsp body err:[%+v]", err) + return nil, nil + } + + return rspMap, nil +}