add apis
CI / changes (push) Successful in 1m34s
CI / ad (push) Successful in 27s
CI / admin (push) Successful in 17s
CI / aiserver (push) Successful in 26s
CI / analysis (push) Successful in 22s
CI / bff (push) Successful in 21s
CI / chore (push) Successful in 20s
CI / equipment (push) Successful in 19s
CI / express (push) Successful in 19s
CI / factory (push) Successful in 19s
CI / message (push) Successful in 18s
CI / order (push) Successful in 19s
CI / payment (push) Successful in 17s
CI / percutaneous (push) Successful in 17s
CI / product (push) Successful in 19s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / store (push) Successful in 20s
CI / support (push) Successful in 19s
CI / task (push) Successful in 21s
CI / user (push) Successful in 22s
CI / water (push) Successful in 25s
CI / wecom (push) Successful in 21s
CI / ws (push) Successful in 9s

This commit is contained in:
2026-10-30 18:02:20 +08:00
parent 54b1e958df
commit cc23c30c9e
62 changed files with 3257 additions and 86 deletions
+44
View File
@@ -0,0 +1,44 @@
package logic
import (
"lone-services/pkg/utils"
"lone-services/pkg/validate"
aiserver "lone-services/rpc/aiserver/pb"
"reflect"
jsoniter "github.com/json-iterator/go"
)
type BaseLogic struct {
}
func (l *BaseLogic) checkParams(in interface{}, v validate.IValidator) *aiserver.Response {
rv := reflect.ValueOf(in)
if rv.Kind() != reflect.Ptr || rv.IsNil() {
return &aiserver.Response{
Code: utils.ErrorParams.Code,
Msg: "request must be non‑nil proto pointer",
}
}
resp := validate.ValidateFromProto(in, v)
if resp != utils.StringEmpty {
return &aiserver.Response{
Code: utils.ErrorParams.Code,
Msg: resp,
}
}
return nil
}
func (l *BaseLogic) fail(status utils.Status) (*aiserver.Response, error) {
return l.out(status, status.Msg)
}
func (l *BaseLogic) out(status utils.Status, msg string) (*aiserver.Response, error) {
return &aiserver.Response{Code: status.Code, Msg: msg}, nil
}
func (l *BaseLogic) ok(data any) (*aiserver.Response, error) {
buf, _ := jsoniter.Marshal(data)
return &aiserver.Response{Code: utils.Ok.Code, Msg: utils.Ok.Msg, Data: string(buf)}, nil
}