dao

package
v0.0.0-...-171028a Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2016 License: Apache-2.0, BSD-3-Clause, CC-BY-3.0, + 3 more Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const NonExistUserID = 0

NonExistUserID : if a user does not exist, the ID of the user will be 0.

Variables

This section is empty.

Functions

func AccessLog

func AccessLog(username, projectName, repoName, action string) error

AccessLog ...

func AddAccessLog

func AddAccessLog(accessLog models.AccessLog) error

AddAccessLog persists the access logs

func AddProject

func AddProject(project models.Project) error

AddProject adds a project to the database along with project roles information and access log records.

func AddProjectRole

func AddProjectRole(projectRole models.ProjectRole) (int64, error)

AddProjectRole ...

func AddUserProjectRole

func AddUserProjectRole(userID int, projectID int64, roleID int) error

AddUserProjectRole inserts role information to table project_role and user_project_role.

func ChangeUserPassword

func ChangeUserPassword(u models.User, oldPassword ...string) error

ChangeUserPassword ...

func CheckUserPassword

func CheckUserPassword(query models.User) (*models.User, error)

CheckUserPassword checks whether the password is correct.

func DeleteUser

func DeleteUser(userID int) error

DeleteUser ...

func DeleteUserProjectRoles

func DeleteUserProjectRoles(userID int, projectID int64) error

DeleteUserProjectRoles ...

func GenerateRandomString

func GenerateRandomString() (string, error)

GenerateRandomString generates a random string

func GetAccessLogs

func GetAccessLogs(accessLog models.AccessLog) ([]models.AccessLog, error)

GetAccessLogs gets access logs according to different conditions

func GetPermission

func GetPermission(username, projectName string) (string, error)

GetPermission gets roles that the user has according to the project.

func GetProjectByID

func GetProjectByID(projectID int64) (*models.Project, error)

GetProjectByID ...

func GetProjectByName

func GetProjectByName(projectName string) (*models.Project, error)

GetProjectByName ...

func GetUser

func GetUser(query models.User) (*models.User, error)

GetUser ...

func GetUserByProject

func GetUserByProject(projectID int64, queryUser models.User) ([]models.User, error)

GetUserByProject gets all members of the project.

func GetUserProjectRoles

func GetUserProjectRoles(userQuery models.User, projectID int64) ([]models.Role, error)

GetUserProjectRoles returns roles that the user has according to the project.

func InitDB

func InitDB()

InitDB initializes the database

func IsAdminRole

func IsAdminRole(userID int) (bool, error)

IsAdminRole returns whether the user is admin.

func IsProjectPublic

func IsProjectPublic(projectName string) bool

IsProjectPublic ...

func ListUsers

func ListUsers(query models.User) ([]models.User, error)

ListUsers lists all users according to different conditions.

func LoginByDb

func LoginByDb(auth models.AuthModel) (*models.User, error)

LoginByDb is used for user to login with database auth mode.

func ProjectExists

func ProjectExists(nameOrID interface{}) (bool, error)

ProjectExists returns whether the project exists according to its name of ID.

func QueryProject

func QueryProject(query models.Project) ([]models.Project, error)

QueryProject querys the projects based on publicity and user, disregarding the names etc.

func QueryRelevantProjects

func QueryRelevantProjects(userID int) ([]models.Project, error)

QueryRelevantProjects returns all projects that the user is a member of.

func Register

func Register(user models.User) (int64, error)

Register is used for user to register, the password is encrypted before the record is inserted into database.

func ResetUserPassword

func ResetUserPassword(u models.User) error

ResetUserPassword ...

func ToggleProjectPublicity

func ToggleProjectPublicity(projectID int64, publicity int) error

ToggleProjectPublicity toggles the publicity of the project.

func ToggleUserAdminRole

func ToggleUserAdminRole(u models.User) error

ToggleUserAdminRole gives a user admim role.

func UpdateUserResetUUID

func UpdateUserResetUUID(u models.User) error

UpdateUserResetUUID ...

func UserExists

func UserExists(user models.User, target string) (bool, error)

UserExists returns whether a user exists according username or Email.

Types

This section is empty.

Jump to

Keyboard shortcuts

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