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