servicesimpl

package
v0.0.0-...-6d3e060 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BidService

type BidService struct {
	ProjectService services.ProjectService
	PaymentService services.PaymentService
	TeamService    services.TeamService
	TxManager      transaction.TxManager
	BidRepo        repositories.BidRepo
	TeamRepo       repositories.TeamRepo
}

func NewBidService

func NewBidService(
	projectservice services.ProjectService,
	paymentservice services.PaymentService,
	teamservice services.TeamService,
	bidRepo repositories.BidRepo,
	teamRepo repositories.TeamRepo,
	txManager transaction.TxManager,
) *BidService

func (BidService) AcceptBid

func (bs BidService) AcceptBid(userID int, bidID int, projectID int)

func (BidService) GetPrivateProjectBids

func (bs BidService) GetPrivateProjectBids(userID int, projectID int) []dto.PrivateProjectBidInfo

func (BidService) GetPublicProjectBids

func (bs BidService) GetPublicProjectBids(projectID int) []dto.PublicProjectBidInfo

func (BidService) GetTeamBids

func (bs BidService) GetTeamBids(userID int, teamID int64) []dto.BidInfo

func (BidService) PutBidOnProject

func (bs BidService) PutBidOnProject(info dto.BidInfo) int

func (BidService) UpdateBid

func (bs BidService) UpdateBid(info dto.BidInfo)

type CareerService

type CareerService struct {
	TagService services.TagService
	CareerRepo repositories.CareerRepo
	TagRepo    repositories.TagRepo
	UserRepo   repositories.UserRepo
}

func NewCareerService

func NewCareerService(
	careerRepo repositories.CareerRepo,
	tagService services.TagService,
	tagRepo repositories.TagRepo,
	userRepo repositories.UserRepo,
) *CareerService

func (*CareerService) GetCareersForUser

func (cs *CareerService) GetCareersForUser(userid int, target int) []dto.SendCareerDTO

func (*CareerService) UpdateCareers

func (cs *CareerService) UpdateCareers(userid int, params []dto.CareerDTO) []dto.CareerDTO

type ChatService

type ChatService struct {
	TxManager   transaction.TxManager
	ChatRepo    repositories.ChatRepo
	UserService services.UserService
}

func NewChatService

func NewChatService(
	txManager transaction.TxManager,
	chatRepo repositories.ChatRepo,
	userService services.UserService,
) *ChatService

func (*ChatService) CreateUserRoom

func (cs *ChatService) CreateUserRoom(userID int, targetUserID int) *dto.RoomInfo

func (*ChatService) GetAllRoom

func (cs *ChatService) GetAllRoom(userID int) []dto.RoomInfo

func (*ChatService) GetRoomMessages

func (cs *ChatService) GetRoomMessages(userID, roomID int) []dto.Message

func (*ChatService) SaveMessage

func (cs *ChatService) SaveMessage(roomID int, senderID int, content string) *dto.Message

type CommentService

type CommentService struct {
	CommentRepo    repositories.CommentRepo
	ProjectRepo    repositories.ProjectRepo
	ProjectService services.ProjectService
}

func NewCommentService

func NewCommentService(
	commentRepo repositories.CommentRepo,
	projectRepo repositories.ProjectRepo,
	projectService services.ProjectService,
) *CommentService

func (CommentService) GetCommentInfo

func (cs CommentService) GetCommentInfo(id int) *dto.CommentWithUserDTO

func (CommentService) GetCommentOfProject

func (cs CommentService) GetCommentOfProject(projectID int) *dto.CommentDTO

func (CommentService) GetUserComments

func (cs CommentService) GetUserComments(userID int) []dto.CommentWithUserDTO

func (CommentService) GetUserStar

func (cs CommentService) GetUserStar(userID int) float64

func (CommentService) PutComment

func (cs CommentService) PutComment(userID, ProjectID int, content string, star int) int

type FileService

type FileService struct {
	S3Storage storage.S3Storage
}

func NewFileService

func NewFileService(s3storage storage.S3Storage) *FileService

func (*FileService) DeleteProfilePhoto

func (fs *FileService) DeleteProfilePhoto(userid int)

func (*FileService) DeleteResume

func (fs *FileService) DeleteResume(userid int)

func (*FileService) DeleteTeamProfilePhoto

func (fs *FileService) DeleteTeamProfilePhoto(teamid int64)

func (*FileService) GetProfilePhotoURL

func (fs *FileService) GetProfilePhotoURL(userid int, wantHighQual bool) string

func (*FileService) GetResumeURL

func (fs *FileService) GetResumeURL(userid int) string

func (*FileService) GetTeamProfilePhotoURL

func (fs *FileService) GetTeamProfilePhotoURL(teamid int64, wantHighQual bool) string

func (*FileService) UploadProfilePhoto

func (fs *FileService) UploadProfilePhoto(data []byte, userid int)

func (*FileService) UploadResume

func (fs *FileService) UploadResume(data []byte, userid int)

func (*FileService) UploadTeamProfilePhoto

func (fs *FileService) UploadTeamProfilePhoto(data []byte, teamid int64)

type JWT

type JWT struct {
	PrivateKey *rsa.PrivateKey
	PublicKey  *rsa.PublicKey
}

func NewJWT

func NewJWT(Const *bootstrap.Constants) *JWT

func (*JWT) GenerateToken

func (j *JWT) GenerateToken(userID int) (string, string)

func (*JWT) RefreshToken

func (j *JWT) RefreshToken(tokenString string) string

func (*JWT) VerifyToken

func (j *JWT) VerifyToken(tokenString string) (jwt.MapClaims, error)

type LabelService

type LabelService struct {
	LableRepo repositories.LabelRepo
	UserRepo  repositories.UserRepo
}

func NewLabelService

func NewLabelService(
	labelRepo repositories.LabelRepo,
	userRepo repositories.UserRepo,
) *LabelService

func (*LabelService) GetLabelInfo

func (ls *LabelService) GetLabelInfo(labelID int) *models.LabelModel

func (*LabelService) GetLabels

func (ls *LabelService) GetLabels() []byte

type PaymentService

type PaymentService struct {
	PaymentRepo repositories.PaymentRepo
	TxManager   transaction.TxManager
}

func NewPaymentService

func NewPaymentService(
	paymentRepo repositories.PaymentRepo,
	txManager transaction.TxManager,
) *PaymentService

func (*PaymentService) Deposit

func (paymentService *PaymentService) Deposit(userID int, amount int64, description string)

func (*PaymentService) GetUserBalance

func (paymentService *PaymentService) GetUserBalance(userID int) int64

func (*PaymentService) GetUserTransactions

func (paymentService *PaymentService) GetUserTransactions(userID int, offset, limit int, sortBy, order string) (int, []dto.UserTransactionDTO)

func (*PaymentService) ProjectPayment

func (paymentService *PaymentService) ProjectPayment(ctx context.Context, tx transaction.Tx, userID int, amount int64)

func (*PaymentService) TransferMoney

func (paymentService *PaymentService) TransferMoney(ctx context.Context, tx transaction.Tx, fromUserID, toUserID int, amount int64, description string)

func (*PaymentService) Withdraw

func (paymentService *PaymentService) Withdraw(userID int, amount int64, description string)

type ProjectService

type ProjectService struct {
	ProjectRepo    repositories.ProjectRepo
	PaymentService services.PaymentService
	Constants      *bootstrap.Constants
	TxManager      transaction.TxManager
	TagRepo        repositories.TagRepo
	BidRepo        repositories.BidRepo
	TagService     services.TagService
	TeamService    services.TeamService
	SearchRepo     elastic.SearchRepo
}

func NewProjectService

func NewProjectService(
	projectRepo repositories.ProjectRepo,
	paymentService services.PaymentService,
	constants *bootstrap.Constants,
	tagRepo repositories.TagRepo,
	bidRepo repositories.BidRepo,
	tagService services.TagService,
	teamService services.TeamService,
	txManager transaction.TxManager,
	searchRepo elastic.SearchRepo,
) *ProjectService

func (*ProjectService) CreateProject

func (projectService *ProjectService) CreateProject(userID int, title, description string, label int, durationInt int, price int64, tags []int) int

func (*ProjectService) DeleteProject

func (projectService *ProjectService) DeleteProject(userID, projectID int)

func (*ProjectService) EndOfProject

func (projectService *ProjectService) EndOfProject(userID, projectID int)

func (*ProjectService) GetOneManTeamProjects

func (projectService *ProjectService) GetOneManTeamProjects(userID int) []models.ProjectModel

func (*ProjectService) GetParticipatedProjectsForUser

func (ps *ProjectService) GetParticipatedProjectsForUser(userid int) []models.ProjectModel

func (*ProjectService) GetProject

func (projectService *ProjectService) GetProject(projectID int) *models.ProjectModel

func (*ProjectService) GetProjectCount

func (projectService *ProjectService) GetProjectCount(userID int) int

func (*ProjectService) GetTeamProjects

func (projectService *ProjectService) GetTeamProjects(userID int, teamID int64) []models.ProjectModel

func (*ProjectService) GetUserProjects

func (projectService *ProjectService) GetUserProjects(userID, targetuserID, offset, limit int) ([]models.ProjectModel, int)

func (*ProjectService) LandingProps

func (projectService *ProjectService) LandingProps() []dto.ProjectLanding

func (*ProjectService) SearchProjects

func (ps *ProjectService) SearchProjects(req *elasticmodel.QueryAndTagSearchReqDto) []map[string]any

func (*ProjectService) UpdateProject

func (projectService *ProjectService) UpdateProject(projectID, userID int, title, description string, label int, price int64, tags []int)

type RoleService

type RoleService struct {
	RoleRepo repositories.RoleRepo
}

func NewRoleService

func NewRoleService() *RoleService

func (*RoleService) GetAllRolesForTeam

func (rs *RoleService) GetAllRolesForTeam() []string

func (*RoleService) GetPermissionsForRole

func (rs *RoleService) GetPermissionsForRole(role string) []string

type SherlockService

type SherlockService struct {
	SearchRepo  elastic.SearchRepo
	FileService services.FileService
}

func NewSherlockService

func NewSherlockService(
	sr elastic.SearchRepo,
	fs services.FileService,
) *SherlockService

func (*SherlockService) SearchEverything

func (ss *SherlockService) SearchEverything(req *elasticmodel.SearchRequest) []elasticmodel.InnerHits

type SmsService

type SmsService struct {
	Env  *bootstrap.Env
	Cons *bootstrap.Constants
}

func NewSmsService

func NewSmsService(env *bootstrap.Env, constant *bootstrap.Constants) *SmsService

func (*SmsService) GenerateOTP

func (ss *SmsService) GenerateOTP() string

func (*SmsService) SendOTP

func (ss *SmsService) SendOTP(phonenumber string, code string)

type TagService

type TagService struct {
	TagRepo  repositories.TagRepo
	UserRepo repositories.UserRepo
}

func NewTagService

func NewTagService(
	tagRepo repositories.TagRepo,
	userRepo repositories.UserRepo,
) *TagService

func (*TagService) GetTags

func (ts *TagService) GetTags() []byte

func (*TagService) GetTagsForUser

func (ts *TagService) GetTagsForUser(userid int) []dto.GetTagDto

func (*TagService) UpdateTagsForCareerOrUser

func (ts *TagService) UpdateTagsForCareerOrUser(careerUserid int, newTags []dto.RecieveTagDTO, isForUser bool) []dto.RecieveTagDTO

func (*TagService) UpdateTagsForProject

func (ts *TagService) UpdateTagsForProject(projectid int, newTags []int)

type TeamService

type TeamService struct {
	TeamRepo           repositories.TeamRepo
	UserRepo           repositories.UserRepo
	RoleRepo           repositories.RoleRepo
	TransactionManager transaction.TxManager
	FileService        services.FileService
	SearchRepo         elastic.SearchRepo
}

func NewTeamService

func NewTeamService(
	teamRepo repositories.TeamRepo,
	userRepo repositories.UserRepo,
	roleRepo repositories.RoleRepo,
	tManager transaction.TxManager,
	fileService services.FileService,
	sp elastic.SearchRepo,
) *TeamService

func (*TeamService) AddMembers

func (ts *TeamService) AddMembers(userid int, teamid int64, members []int)

TODO: email? some sort of request must be sent and then when it is accepted, the member gets added ! this version is naive

func (*TeamService) BehindCurtainTeam

func (ts *TeamService) BehindCurtainTeam(ctx context.Context, tx transaction.Tx, userid int)

func (*TeamService) CreateTeam

func (ts *TeamService) CreateTeam(userid int, teamInfo *dto.TeamCreateDto) int64

func (*TeamService) DeleteTeam

func (ts *TeamService) DeleteTeam(commanderid int, teamid int64)

func (*TeamService) DeleteTeamProfile

func (ts *TeamService) DeleteTeamProfile(commanderid int, teamid int64)

func (*TeamService) GetAllTeamsIDs

func (ts *TeamService) GetAllTeamsIDs(userID int) []int64

func (*TeamService) GetInternalTeamInfo

func (ts *TeamService) GetInternalTeamInfo(teamid int64) *dto.GetInternalTeamInfo

func (*TeamService) GetMembers

func (ts *TeamService) GetMembers(commanderid int, teamid int64) []dto.SendMemberDto

func (*TeamService) GetOneManTeamID

func (ts *TeamService) GetOneManTeamID(userid int) int64

func (*TeamService) GetTeam

func (ts *TeamService) GetTeam(commanderid int, teamid int64) *dto.GetTeamDto

func (*TeamService) GetTeamsForBidding

func (ts *TeamService) GetTeamsForBidding(userid int) *dto.TeamListDto

func (*TeamService) GetTeamsForUser

func (ts *TeamService) GetTeamsForUser(userid int, active, dontCare int) []dto.GetTeamPreviewDto

func (*TeamService) KickMemebr

func (ts *TeamService) KickMemebr(commanderid int, poorGuysid []int, teamid int64)

func (*TeamService) LeaveTeam

func (ts *TeamService) LeaveTeam(userid int, teamid int64)

func (*TeamService) SearchTeams

func (ts *TeamService) SearchTeams(req *elasticmodel.SimpleQuerySearchReqDto) []map[string]any

func (*TeamService) UpdateMemeberRole

func (ts *TeamService) UpdateMemeberRole(commanderid int, info *dto.UpdateMemberRoleDto)

func (*TeamService) UpdatePosition

func (ts *TeamService) UpdatePosition(commanderid int, req *dto.UpdateMemberPositionDto)

func (*TeamService) UpdateTeamInfo

func (ts *TeamService) UpdateTeamInfo(userid int, info *dto.UpdateTeamInfoDto)

func (*TeamService) UpdateTeamProfile

func (ts *TeamService) UpdateTeamProfile(commanderid int, teamid int64, data []byte)

type UserService

type UserService struct {
	UserRepo       repositories.UserRepo
	CacheRepo      redis.UserCache
	TxManager      transaction.TxManager
	Constants      *bootstrap.Constants
	Env            *bootstrap.Env
	FileService    services.FileService
	TeamService    services.TeamService
	CommentService services.CommentService
	SecretSauce    *pkg.SecretSauce
	SearchRepo     elastic.SearchRepo
}

func NewUserService

func NewUserService(
	userRepo repositories.UserRepo,
	cacheRepo redis.UserCache,
	txManager transaction.TxManager,
	constants *bootstrap.Constants,
	Env *bootstrap.Env,
	fileService services.FileService,
	teamService services.TeamService,
	commentService services.CommentService,
	secretSauce *pkg.SecretSauce,
	searchRepo elastic.SearchRepo,
) *UserService

func (*UserService) AuthenticateUser

func (userService *UserService) AuthenticateUser(identifier string, password string) *models.UserModel

func (*UserService) CacheUserInfo

func (us *UserService) CacheUserInfo(phonenumber string, username string, password string, otp string) string

caches the data until otp is expired or entered.

func (*UserService) ChangePassword

func (userService *UserService) ChangePassword(user_id int, new_password string)

func (*UserService) ChangePasswordValidate

func (userService *UserService) ChangePasswordValidate(user_id int, old_password string)

func (*UserService) CheckAvailabilityForSignup

func (us *UserService) CheckAvailabilityForSignup(phonenumber string, username string) string

signup stage. checks if username or phonenumber is already taken.

func (*UserService) CheckFlagForPasswordReset

func (us *UserService) CheckFlagForPasswordReset(session string) int

func (*UserService) DeleteUser

func (us *UserService) DeleteUser(userid int)

func (*UserService) GetUserInfo

func (us *UserService) GetUserInfo(targetUserid int, userid int) *dto.UserProfileDTO

func (*UserService) Register

func (us *UserService) Register(phonenumber string, username string, password []byte, session string) int

last stage of signup

func (*UserService) SearchUsers

func (us *UserService) SearchUsers(req *elasticmodel.QueryAndTagSearchReqDto) []map[string]any

func (*UserService) SetForgetPasswordFlag

func (us *UserService) SetForgetPasswordFlag(userID string) string

func (*UserService) SetupOTP

func (us *UserService) SetupOTP(phonenumber string, code string) string

for forget password: creates uuid and otp and caches otp

func (*UserService) UpdateEmail

func (us *UserService) UpdateEmail(userid int, email string)

func (*UserService) UpdatePhone

func (us *UserService) UpdatePhone(phone string, userid string)

func (*UserService) UpdatePhoneSendOTP

func (us *UserService) UpdatePhoneSendOTP(phone string, userid int, code string) string

func (*UserService) UpdateUserData

func (us *UserService) UpdateUserData(userid int, userData *dto.UpdateUserDTO)

func (*UserService) UpdateUsername

func (us *UserService) UpdateUsername(userid int, username string)

func (*UserService) ValidateOTP

func (us *UserService) ValidateOTP(session string, otp string) (string, string, []byte)

checks the code with cache and returns the data. returns phonenumber, username, password

Jump to

Keyboard shortcuts

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