32 lines
543 B
Go
32 lines
543 B
Go
package logic
|
|
|
|
import (
|
|
"lone-services/pkg/utils"
|
|
ad "lone-services/rpc/ad/pb"
|
|
|
|
jsoniter "github.com/json-iterator/go"
|
|
)
|
|
|
|
func okResponse(data any) *ad.Response {
|
|
buf, _ := jsoniter.Marshal(data)
|
|
return &ad.Response{
|
|
Code: utils.Ok.Code,
|
|
Msg: utils.Ok.Msg,
|
|
Data: string(buf),
|
|
}
|
|
}
|
|
|
|
func failResponse(status utils.Status) *ad.Response {
|
|
return &ad.Response{
|
|
Code: status.Code,
|
|
Msg: status.Msg,
|
|
}
|
|
}
|
|
|
|
func outResponse(status utils.Status, msg string) *ad.Response {
|
|
return &ad.Response{
|
|
Code: status.Code,
|
|
Msg: msg,
|
|
}
|
|
}
|