添加配置Auth的相关自动生成

This commit is contained in:
eson 2023-06-12 17:35:43 +08:00
parent 0f31e298d4
commit 2ed11613a1
2 changed files with 6 additions and 41 deletions

View File

@ -2,3 +2,7 @@ Name: {{.serviceName}}
Host: {{.host}}
Port: {{.port}}
SourceMysql: ""
Auth:
AccessSecret: fusen2023
AccessExpire: 604800
RefreshAfter: 345600

View File

@ -2,7 +2,7 @@
package types
import (
"fusenapi/utils/basic"
)
type Request struct {
@ -126,42 +126,3 @@ type Auth struct {
RefreshAfter int64 `json:"refreshAfter"`
}
// Set 设置Response的Code和Message值
func (resp *Response) Set(Code int, Message string) *Response {
return &Response{
Code: Code,
Message: Message,
}
}
// Set 设置整个Response
func (resp *Response) SetWithData(Code int, Message string, Data interface{}) *Response {
return &Response{
Code: Code,
Message: Message,
Data: Data,
}
}
// SetStatus 设置默认StatusResponse(内部自定义) 默认msg, 可以带data, data只使用一个参数
func (resp *Response) SetStatus(sr *basic.StatusResponse, data ...interface{}) *Response {
newResp := &Response{
Code: sr.Code,
}
if len(data) == 1 {
newResp.Data = data[0]
}
return newResp
}
// SetStatusWithMessage 设置默认StatusResponse(内部自定义) 非默认msg, 可以带data, data只使用一个参数
func (resp *Response) SetStatusWithMessage(sr *basic.StatusResponse, msg string, data ...interface{}) *Response {
newResp := &Response{
Code: sr.Code,
Message: msg,
}
if len(data) == 1 {
newResp.Data = data[0]
}
return newResp
}