成功代理登录功能

This commit is contained in:
2024-04-12 10:20:29 +08:00
parent 809c0deaa2
commit 6e8a6eb7d1
7 changed files with 196 additions and 96 deletions

View File

@@ -6,6 +6,8 @@ type ErrorCode struct {
}
var (
ErrRespNotNil = &ErrorCode{Code: 10000, Message: "resp must not nil"}
ErrEncGcm = &ErrorCode{Code: 10001, Message: "gmc加密错误"}
ErrParamParse = &ErrorCode{Code: 10100, Message: "参数解析错误"}

View File

@@ -1,5 +1,49 @@
package basic
import "time"
func IntPtr(src int) *int {
return &src
}
func Int32Ptr(src int32) *int32 {
return &src
}
func Int64Ptr(src int64) *int64 {
return &src
}
func UintPtr(src uint) *uint {
return &src
}
func Uint32Ptr(src uint32) *uint32 {
return &src
}
func Uint64Ptr(src uint64) *uint64 {
return &src
}
//
func Float32Ptr(src float32) *float32 {
return &src
}
func Float64Ptr(src float64) *float64 {
return &src
}
func BytesPtr(src []byte) *[]byte {
return &src
}
func StringPtr(src string) *string {
return &src
}
func TimePtr(time time.Time) *time.Time {
return &time
}

View File

@@ -1,5 +1,7 @@
package basic
import "github.com/iapologizewhenimwrong/Vestmore_GO/utils/log"
// 全局返回的结构体
type Response struct {
Data interface{} `json:"data"`
@@ -8,23 +10,49 @@ type Response struct {
IsSuccess bool `json:"success"`
}
func (resp *Response) Error(errcode *ErrorCode, Data ...interface{}) {
func (resp *Response) Error(errcode *ErrorCode, Data ...interface{}) *Response {
if resp == nil {
resp = &Response{}
}
resp.ErrorCode = errcode.Code
resp.ErrorText = errcode.Message
resp.IsSuccess = false
resp.setData(Data)
log.Error(resp.ErrorText)
return resp
}
func (resp *Response) ErrorEx(Code int, Message string, Data ...interface{}) {
func (resp *Response) ErrorErr(Code int, err error, Data ...interface{}) *Response {
if resp == nil {
resp = &Response{}
}
resp.ErrorCode = Code
resp.ErrorText = err.Error()
resp.IsSuccess = false
resp.setData(Data)
log.Error(resp.ErrorText)
return resp
}
func (resp *Response) ErrorMsg(Code int, Message string, Data ...interface{}) *Response {
if resp == nil {
resp = &Response{}
}
resp.ErrorCode = Code
resp.ErrorText = Message
resp.IsSuccess = false
resp.setData(Data)
log.Error(resp.ErrorText)
return resp
}
func (resp *Response) Success(Data ...interface{}) {
func (resp *Response) Success(Data ...interface{}) *Response {
if resp == nil {
resp = &Response{}
}
resp.IsSuccess = true
resp.setData(Data)
return resp
}
func (resp *Response) setData(Data []interface{}) {