package service import ( consts "assets/consts/asset" "assets/consts/public" dto "assets/model/dto/enum" "context" "gitea.com/red-future/common/beans" "github.com/gogf/gf/v2/util/gconv" ) type enum struct{} // Enum 枚举服务 var Enum = new(enum) // GetAssetType 获取资产类型 func (s *enum) GetAssetType(ctx context.Context, req *dto.GetAssetTypeReq) (res *dto.GetAssetTypeRes, err error) { _, _ = ctx, req res = new(dto.GetAssetTypeRes) err = gconv.Structs(consts.GetAllAssetTypeKeyValue(), &res.Options) return } func (s *enum) GetCategoryAttrType(ctx context.Context, req *dto.GetCategoryAttrTypeReq) (res *dto.GetCategoryAttrTypeRes, err error) { _, _ = ctx, req res = new(dto.GetCategoryAttrTypeRes) err = gconv.Structs(consts.GetAllAttrTypeKeyValue(), &res.Options) return } func (s *enum) GetSpecsUnit(ctx context.Context, req *dto.GetSpecsUnitReq) (res *dto.GetSpecsUnitRes, err error) { res = new(dto.GetSpecsUnitRes) if *req.AssetType == consts.AssetTypeVirtual { keyValue := public.GetAllDurationTypeKeyValue() err = gconv.Structs(keyValue, &res.Options) if err != nil { return } } else { // 使用简化的 RPC 调用方式 - 直接传 map 参数 //dictData := &dto.GetDictRes{} //if err = message.CallRPC(ctx, "dictService.GetDictWithDataByType", map[string]interface{}{"dictType": gconv.String(req.AssetType)}, dictData); err != nil { // return //} //for _, v := range dictData.Values { // res.Options = append(res.Options, dto.KeyValue{ // Key: v.DictValue, // Value: v.DictLabel, // }) //} } return } func (s *enum) GetTenantModuleType(ctx context.Context, req *dto.GetTenantModuleTypeReq) (res *dto.GetTenantModuleTypeRes, err error) { _ = ctx res = new(dto.GetTenantModuleTypeRes) err = gconv.Structs(beans.GetTenantModuleTypes(req.AssetId), &res.Options) return }