center.go 478 B

12345678910111213141516171819202122
  1. package query
  2. import (
  3. "context"
  4. "adm-vehicle-style/errors"
  5. v1 "adm-vehicle-style/pb/v1"
  6. )
  7. func Query(ctx context.Context, req *v1.QueryRequest) (reply *v1.QueryResponse, err error) {
  8. interfaces := map[string]func(ctx context.Context, params string) (reply *v1.QueryResponse, err error){
  9. "001": BrandList,
  10. "002": SeriesList,
  11. "003": StyleList,
  12. }
  13. if v, ok := interfaces[req.Code]; ok {
  14. return v(ctx, req.Params)
  15. }
  16. return reply, errors.InterfaceNoExistError
  17. }