package service import ( "slices" "yintai-api/app/api/request" "yintai-api/app/common/dao" err2 "yintai-api/app/common/err" "yintai-api/app/common/model" "github.com/spf13/cast" ) type Category struct{} func (r *Category) List(req request.CategoryList) (any, int64) { if !slices.Contains(model.CategoryTypes, req.Type) { err2.ParamErr() } req.Pagination() lists, count, err := dao.NewCategory().List(cast.ToInt64(req.Pid), req.Name, req.NameEn, req.Type, req.Page, req.Size, req.Sort) if err != nil { err2.DbErr(err) } res := make([]map[string]any, 0) for _, list := range lists { res = append(res, list.Format()) } return res, count }