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