service

package
v0.0.0-...-a36e7e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToUserResponse

func ToUserResponse(user *models.User) *dto.UserResponse

Types

type AccessService

type AccessService struct {
	// contains filtered or unexported fields
}

func NewAccessService

func NewAccessService(conf *config.Config, repo repository.IAccessRepository, logger logging.Logger, notificationService notification.INotificationService) *AccessService

func (*AccessService) CreateVoteVisibility

func (s *AccessService) CreateVoteVisibility(c context.Context, surveyID uint, viewerID uint, req dto.VoteVisibilityCreateRequest) (dto.VoteVisibilityResponse, error)

func (*AccessService) DeleteUserSurveyRole

func (s *AccessService) DeleteUserSurveyRole(c context.Context, surveyID uint, userID uint, roleID uint) error

func (*AccessService) DeleteVoteVisibilityById

func (s *AccessService) DeleteVoteVisibilityById(c context.Context, id uint) error
func (s *AccessService) GetVoteVisibilityById(c context.Context, id uint) (dto.VoteVisibilityResponse, error) {
	res, err := s.repo.GetVoteVisibilityById(c, id)
	if err != nil {
		return dto.VoteVisibilityResponse{}, err
	}
	return dto.VoteVisibilityResponse{
		ID:           res.ID,
		SurveyID:     res.SurveyID,
		ViewerID:     res.ViewerID,
		RespondentID: res.RespondentID,
	}, err
}
func (s *AccessService) GetVoteVisibilityBySurveyId(ctx context.Context, surveyId uint) ([]dto.VoteVisibilityResponse, error) {
	res, err := s.repo.GetVoteVisibilityBySurveyId(ctx, surveyId)
	if err != nil {
		return nil, err
	}
	var response []dto.VoteVisibilityResponse
	for _, vv := range res {
		response = append(response, dto.VoteVisibilityResponse{
			ID:           vv.ID,
			SurveyID:     vv.SurveyID,
			ViewerID:     vv.ViewerID,
			RespondentID: vv.RespondentID,
		})
	}
	return response, nil
}

func (*AccessService) GetAllPermissions

func (s *AccessService) GetAllPermissions(c context.Context) ([]models.Permission, error)

func (*AccessService) GetUserRolesForSomeSurvey

func (s *AccessService) GetUserRolesForSomeSurvey(c context.Context, userID uint, surveyID uint) (*dto.GetUserRolesForSomeSurveyResponse, error)

func (*AccessService) SetRole

type IAccessService

type IAccessService interface {
	SetRole(c context.Context, req dto.SurveyRoleAssignRequest) (*dto.SurveyRoleAssignResponse, error)
	GetUserRolesForSomeSurvey(c context.Context, userID uint, surveyID uint) (*dto.GetUserRolesForSomeSurveyResponse, error)
	GetAllPermissions(c context.Context) ([]models.Permission, error)
	DeleteUserSurveyRole(c context.Context, surveyID uint, userID uint, roleID uint) error
	CreateVoteVisibility(c context.Context, surveyID uint, viewerID uint, request dto.VoteVisibilityCreateRequest) (dto.VoteVisibilityResponse, error)
}

type IUserService

type IUserService interface {
	GetUsers(context.Context, dto.UserGetRequest) ([]*dto.UserResponse, error)
	SetMaxSurveys(ctx context.Context, userID string, maxSurveys int) error
	Login(c context.Context, req dto.LoginRequest) (string, time.Time, error)
	UpdateUserProfile(c context.Context, userID uint, req dto.UpdateUserRequest) (*dto.UserResponse, error)
	GetUser(c context.Context, id uint) (*dto.UserResponse, error)
	Deposit(ctx context.Context, userID uint, amount float64) error
	Transfer(ctx context.Context, senderID, receiverID uint, amount float64) error
	Withdraw(ctx context.Context, userID uint, amount float64) error
	BuyVote(ctx context.Context, buyerID, sellerID uint, voteID uint, amount float64) error
	SellVote(ctx context.Context, sellerID, buyerID uint, voteID uint, amount float64) error
	GetVoterID(ctx context.Context, voteID uint) (uint, error)
	GetBalance(ctx context.Context, userID uint) (float64, error)
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func New

func (*UserService) BuyVote

func (s *UserService) BuyVote(ctx context.Context, buyerID, sellerID uint, voteID uint, amount float64) error

func (*UserService) Deposit

func (s *UserService) Deposit(ctx context.Context, userID uint, amount float64) error

Deposit money to user's wallet

func (*UserService) GetBalance

func (s *UserService) GetBalance(ctx context.Context, userID uint) (float64, error)

func (*UserService) GetUser

func (s *UserService) GetUser(c context.Context, id uint) (*dto.UserResponse, error)

func (*UserService) GetUsers

func (*UserService) GetVoterID

func (s *UserService) GetVoterID(ctx context.Context, voteID uint) (uint, error)

func (*UserService) Login

func (*UserService) SellVote

func (s *UserService) SellVote(ctx context.Context, sellerID, buyerID uint, voteID uint, amount float64) error

func (*UserService) SetMaxSurveys

func (s *UserService) SetMaxSurveys(ctx context.Context, userID string, maxSurveys int) error

func (*UserService) Transfer

func (s *UserService) Transfer(ctx context.Context, senderID, receiverID uint, amount float64) error

func (*UserService) UpdateUserProfile

func (s *UserService) UpdateUserProfile(c context.Context, userID uint, req dto.UpdateUserRequest) (*dto.UserResponse, error)

func (*UserService) Withdraw

func (s *UserService) Withdraw(ctx context.Context, userID uint, amount float64) error

Withdraw money from user's wallet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL