30 lines
901 B
Go
30 lines
901 B
Go
package account
|
|
|
|
import (
|
|
"context"
|
|
"example.com/errorCatalog/internal/types"
|
|
apierrors "git.yuntuo.hk/k2safe/go-omni/errors"
|
|
)
|
|
|
|
func check(kind string) (*types.CheckResponse, error) {
|
|
switch kind {
|
|
case "success":
|
|
return &types.CheckResponse{OK: true}, nil
|
|
case "long":
|
|
return nil, apierrors.ByCode("TEXT_TOO_LONG").WithParams(map[string]any{"label": "企业名称", "max": 100})
|
|
case "unknown":
|
|
return nil, apierrors.ByCode("NOT_REGISTERED")
|
|
default:
|
|
return nil, apierrors.ByCode("USERNAME_INVALID")
|
|
}
|
|
}
|
|
func (s *Logic) Plain(ctx context.Context, req *types.CheckRequest) (*types.CheckResponse, error) {
|
|
return check(req.Kind)
|
|
}
|
|
func (s *Logic) Raw(ctx context.Context, req *types.CheckRequest) (*types.CheckResponse, error) {
|
|
return check(req.Kind)
|
|
}
|
|
func (s *Logic) Cleared(ctx context.Context, req *types.CheckRequest) (*types.CheckResponse, error) {
|
|
return check(req.Kind)
|
|
}
|