Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor dlr.resolvers.go: Comment & Return #68

Closed
Feyzanrs opened this issue May 17, 2024 · 0 comments
Closed

Refactor dlr.resolvers.go: Comment & Return #68

Feyzanrs opened this issue May 17, 2024 · 0 comments
Assignees
Labels
Be development Issues or tasks currently in active development refactor Improvements or restructuring of existing functionality

Comments

@Feyzanrs
Copy link
Member

Feyzanrs commented May 17, 2024

In the pkg/presentation/controller/graphql/resolver/dlr.resolvers.go file, please comment out all existing methods and update their return values to nil, nil. This adjustment is necessary to temporarily disable functionality without removing the method structures.

The new version of the code:

package presentation

// This file will be automatically regenerated based on the schema, any resolver implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen version v0.17.44

import (
	"context"

	presentation "github.com/octoposprime/op-be-graphql/pkg/presentation/dto/model"
)

// CreateDlr is the resolver for the createDlr field.
func (r *mutationResolver) CreateDlr(ctx context.Context, dlr presentation.DlrInput) (*presentation.Dlr, error) {
	// userId := ctx.Value(smodel.QueryKeyUid).(string)

	// dlrID := ""
	// if dlr.ID != nil {
	// 	dlrID = *dlr.ID
	// }

	// if authResponse, err := r.CommandHandler.CheckAuth(ctx, &pb_auth.AuthRequest{EntityType: "dlr", EntityId: dlrID, UserId: userId, Action: "create"}); !authResponse.IsAuthorized || err != nil {
	// 	return nil, mo.ErrorUnauthorized
	// }

	// dtoData := presentation.NewDlrDto(&dlr)
	// resultData, err := r.CommandHandler.CreateDlr(ctx, dtoData.ToPb())
	// if err != nil {
	// 	return nil, err
	// }
	// dtoData.PbData = resultData
	// return dtoData.ToModel(), nil
	return nil, nil
}

// UpdateDlrBase is the resolver for the updateDlrBase field.
func (r *mutationResolver) UpdateDlrBase(ctx context.Context, dlr presentation.DlrInput) (*presentation.Dlr, error) {
	// userId := ctx.Value(smodel.QueryKeyUid).(string)
	// userType := ctx.Value(smodel.QueryKeyUType).(pb_user.UserType)
	// if userType != pb_user.UserType_UserTypeADMIN {
	// 	user.ID = &userId
	// }
	// dtoData := presentation.NewDlrDto(&dlr)
	// resultData, err := r.CommandHandler.UpdateDlrBase(ctx, dtoData.ToPb())
	// if err != nil {
	// 	return nil, err
	// }
	// dtoData.PbData = resultData
	// return dtoData.ToModel(), nil
	return nil, nil
}

// UpdateDlrCore is the resolver for the updateDlrCore field.
func (r *mutationResolver) UpdateDlrCore(ctx context.Context, dlr presentation.DlrInput) (*presentation.Dlr, error) {
	// userId := ctx.Value(smodel.QueryKeyUid).(string)
	// userType := ctx.Value(smodel.QueryKeyUType).(pb_user.UserType)
	// if userType != pb_user.UserType_UserTypeADMIN {
	// 	user.ID = &userId
	// }
	// dtoData := presentation.NewDlrDto(&dlr)
	// resultData, err := r.CommandHandler.UpdateDlrCore(ctx, dtoData.ToPb())
	// if err != nil {
	// 	return nil, err
	// }
	// dtoData.PbData = resultData
	// return dtoData.ToModel(), nil
	return nil, nil
}

// UpdateDlrStatus is the resolver for the updateDlrStatus field.
func (r *mutationResolver) UpdateDlrStatus(ctx context.Context, dlr presentation.DlrInput) (*presentation.Dlr, error) {
	// userId := ctx.Value(smodel.QueryKeyUid).(string)
	// userType := ctx.Value(smodel.QueryKeyUType).(pb_user.UserType)
	// if userType != pb_user.UserType_UserTypeADMIN {
	// 	user.ID = &userId
	// }
	// dtoData := presentation.NewDlrDto(&dlr)
	// resultData, err := r.CommandHandler.UpdateDlrStatus(ctx, dtoData.ToPb())
	// if err != nil {
	// 	return nil, err
	// }
	// dtoData.PbData = resultData
	// return dtoData.ToModel(), nil
	return nil, nil
}

// DeleteDlr is the resolver for the deleteDlr field.
func (r *mutationResolver) DeleteDlr(ctx context.Context, id string) (*presentation.Dlr, error) {
	// userId := ctx.Value(smodel.QueryKeyUid).(string)
	// userType := ctx.Value(smodel.QueryKeyUType).(pb_user.UserType)
	// if userType != pb_user.UserType_UserTypeADMIN {
	// 	id = userId
	// }
	// inData := new(presentation.DlrInput)
	// inData.ID = &id
	// dtoData := presentation.NewDlrDto(inData)
	// resultData, err := r.CommandHandler.DeleteDlr(ctx, dtoData.ToPb())
	// if err != nil {
	// 	return nil, err
	// }
	// dtoData.PbData = resultData
	// return dtoData.ToModel(), nil
	return nil, nil
}

// Dlr is the resolver for the dlr field.
func (r *queryResolver) Dlr(ctx context.Context, id string) (*presentation.Dlr, error) {
	// userId := ctx.Value(smodel.QueryKeyUid).(string)
	// userType := ctx.Value(smodel.QueryKeyUType).(pb_user.UserType)
	// if userType != pb_user.UserType_UserTypeADMIN {
	// 	id = userId
	// }
	// var filter presentation.DlrFilterInput
	// filter.ID = &id
	// dtoFilter := presentation.NewDlrFilterDto(&filter)
	// dtoData := presentation.NewDlrDto(new(presentation.DlrInput))
	// resultDatas, err := r.QueryHandler.GetDlrsByFilter(ctx, dtoFilter.ToPb())
	// if err != nil {
	// 	return nil, err
	// }
	// if len(resultDatas.Dlrs) > 0 {
	// 	dtoData.PbData = resultDatas.Dlrs[0]
	// 	return dtoData.ToModel(), nil
	// } else {
	// 	return nil, mo.ErrorDlrNotFound
	// }
	return nil, nil
}

// Dlrs is the resolver for the dlrs field.
func (r *queryResolver) Dlrs(ctx context.Context, filter *presentation.DlrFilterInput) (*presentation.Dlrs, error) {
	// userId := ctx.Value(smodel.QueryKeyUid).(string)
	// userType := ctx.Value(smodel.QueryKeyUType).(pb_user.UserType)
	// if userType != pb_user.UserType_UserTypeADMIN {
	// 	filter.ID = &userId
	// }
	// var results presentation.Dlrs
	// if filter == nil {
	// 	filter = &presentation.DlrFilterInput{}
	// }
	// dtoFilter := presentation.NewDlrFilterDto(filter)

	// resultDatas, err := r.QueryHandler.GetDlrsByFilter(ctx, dtoFilter.ToPb())
	// if err != nil {
	// 	return nil, err
	// }

	// for _, resultData := range resultDatas.Dlrs {
	// 	dtoData := presentation.NewDlrDto(new(presentation.DlrInput))
	// 	dtoData.PbData = resultData
	// 	results.Dlrs = append(results.Dlrs, dtoData.ToModel())
	// }
	// results.Total = int32(resultDatas.TotalRows)

	// return &results, nil
	return nil, nil
}

And push them to the feature/hsm/58/auth-service branch.

@Feyzanrs Feyzanrs changed the title Refactor dlr.resolvers.go: Comment & Nil Refactor dlr.resolvers.go: Comment & Return May 17, 2024
@Feyzanrs Feyzanrs added refactor Improvements or restructuring of existing functionality development Issues or tasks currently in active development labels May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Be development Issues or tasks currently in active development refactor Improvements or restructuring of existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants