diff --git a/internal/logic/test503logic.go b/internal/logic/test503logic.go index 4f70217..1008f21 100644 --- a/internal/logic/test503logic.go +++ b/internal/logic/test503logic.go @@ -5,6 +5,7 @@ import ( httpresult "demo/common" "demo/internal/svc" "demo/internal/types" + "math/rand" "github.com/zeromicro/go-zero/core/logx" ) @@ -24,6 +25,14 @@ func NewTest503Logic(ctx context.Context, svcCtx *svc.ServiceContext) *Test503Lo } func (l *Test503Logic) Test503() (resp *types.Response, err error) { - // todo: add your logic here and delete this line + // 生成随机数 范围0-2 + num := rand.Intn(2) + if num == 0 { + return &types.Response{ + Success: true, + Message: "ok", + }, nil + } + return nil, httpresult.ErrorResultDefault("5031") }