diff --git a/api/base.go b/api/base.go index 85f579a36..37c74c2de 100644 --- a/api/base.go +++ b/api/base.go @@ -52,7 +52,7 @@ func (b *BaseAPI) ValidateUser() int { b.CustomAbort(http.StatusUnauthorized, "") } userID := sessionUserID.(int) - u, err := dao.GetUser(models.User{UserId: userID}) + u, err := dao.GetUser(models.User{UserID: userID}) if err != nil { beego.Error("Error occurred in GetUser:", err) b.CustomAbort(http.StatusInternalServerError, "Internal error.") diff --git a/api/member.go b/api/member.go index 77d453b22..1f3751577 100644 --- a/api/member.go +++ b/api/member.go @@ -72,7 +72,7 @@ func (pma *ProjectMemberAPI) Prepare() { } func (pma *ProjectMemberAPI) Get() { - pid := pma.project.ProjectId + pid := pma.project.ProjectID if !CheckProjectPermission(pma.currentUserID, pid) { beego.Warning("Current user, user id :", pma.currentUserID, "does not have permission for project, id:", pid) pma.RenderError(http.StatusForbidden, "") @@ -89,14 +89,14 @@ func (pma *ProjectMemberAPI) Get() { } pma.Data["json"] = userList } else { //return detail of a member - roleList, err := dao.GetUserProjectRoles(models.User{UserId: pma.memberID}, pid) + roleList, err := dao.GetUserProjectRoles(models.User{UserID: pma.memberID}, pid) if err != nil { beego.Error("Error occurred in GetUserProjectRoles:", err) pma.CustomAbort(http.StatusInternalServerError, "Internal error.") } //return empty role list to indicate if a user is not a member result := make(map[string]interface{}) - user, err := dao.GetUser(models.User{UserId: pma.memberID}) + user, err := dao.GetUser(models.User{UserID: pma.memberID}) if err != nil { beego.Error("Error occurred in GetUser:", err) pma.CustomAbort(http.StatusInternalServerError, "Internal error.") @@ -110,8 +110,8 @@ func (pma *ProjectMemberAPI) Get() { } func (pma *ProjectMemberAPI) Post() { - pid := pma.project.ProjectId - userQuery := models.User{UserId: pma.currentUserID, RoleId: models.PROJECTADMIN} + pid := pma.project.ProjectID + userQuery := models.User{UserID: pma.currentUserID, RoleID: models.PROJECTADMIN} rolelist, err := dao.GetUserProjectRoles(userQuery, pid) if err != nil { beego.Error("Error occurred in GetUserProjectRoles:", err) @@ -131,7 +131,7 @@ func (pma *ProjectMemberAPI) Post() { pma.RenderError(http.StatusNotFound, "User does not exist") return } - rolelist, err = dao.GetUserProjectRoles(models.User{UserId: userID}, pid) + rolelist, err = dao.GetUserProjectRoles(models.User{UserID: userID}, pid) if err != nil { beego.Error("Error occurred in GetUserProjectRoles:", err) pma.CustomAbort(http.StatusInternalServerError, "Internal error.") @@ -153,9 +153,9 @@ func (pma *ProjectMemberAPI) Post() { } func (pma *ProjectMemberAPI) Put() { - pid := pma.project.ProjectId + pid := pma.project.ProjectID mid := pma.memberID - userQuery := models.User{UserId: pma.currentUserID, RoleId: models.PROJECTADMIN} + userQuery := models.User{UserID: pma.currentUserID, RoleID: models.PROJECTADMIN} rolelist, err := dao.GetUserProjectRoles(userQuery, pid) if err != nil { beego.Error("Error occurred in GetUserProjectRoles:", err) @@ -168,7 +168,7 @@ func (pma *ProjectMemberAPI) Put() { } var req memberReq pma.DecodeJSONReq(&req) - roleList, err := dao.GetUserProjectRoles(models.User{UserId: mid}, pid) + roleList, err := dao.GetUserProjectRoles(models.User{UserID: mid}, pid) if len(roleList) == 0 { beego.Warning("User is not in project, user id:", mid, ", project id:", pid) pma.RenderError(http.StatusNotFound, "user not exist in project") @@ -194,9 +194,9 @@ func (pma *ProjectMemberAPI) Put() { } func (pma *ProjectMemberAPI) Delete() { - pid := pma.project.ProjectId + pid := pma.project.ProjectID mid := pma.memberID - userQuery := models.User{UserId: pma.currentUserID, RoleId: models.PROJECTADMIN} + userQuery := models.User{UserID: pma.currentUserID, RoleID: models.PROJECTADMIN} rolelist, err := dao.GetUserProjectRoles(userQuery, pid) if len(rolelist) == 0 { beego.Warning("Current user, id:", pma.currentUserID, ", does not have project admin role for project, id:", pid) diff --git a/api/project.go b/api/project.go index 068611143..069d77a07 100644 --- a/api/project.go +++ b/api/project.go @@ -84,7 +84,7 @@ func (p *ProjectAPI) Post() { p.RenderError(http.StatusConflict, "") return } - project := models.Project{OwnerId: p.userID, Name: projectName, CreationTime: time.Now(), Public: public} + project := models.Project{OwnerID: p.userID, Name: projectName, CreationTime: time.Now(), Public: public} err = dao.AddProject(project) if err != nil { beego.Error("Failed to add project, error: %v", err) @@ -107,7 +107,7 @@ func (p *ProjectAPI) Head() { } func (p *ProjectAPI) Get() { - queryProject := models.Project{UserId: p.userID} + queryProject := models.Project{UserID: p.userID} projectName := p.GetString("project_name") if len(projectName) > 0 { queryProject.Name = "%" + projectName + "%" @@ -121,7 +121,7 @@ func (p *ProjectAPI) Get() { p.CustomAbort(http.StatusInternalServerError, "Internal error.") } for i := 0; i < len(projectList); i++ { - if isProjectAdmin(p.userID, projectList[i].ProjectId) { + if isProjectAdmin(p.userID, projectList[i].ProjectID) { projectList[i].Togglable = true } } @@ -167,7 +167,7 @@ func (p *ProjectAPI) FilterAccessLog() { beginTime := time.Unix(filter.BeginTimestamp, 0) endTime := time.Unix(filter.EndTimestamp, 0) - query := models.AccessLog{ProjectId: p.projectID, Username: "%" + username + "%", Keywords: keywords, BeginTime: beginTime, BeginTimestamp: filter.BeginTimestamp, EndTime: endTime, EndTimestamp: filter.EndTimestamp} + query := models.AccessLog{ProjectID: p.projectID, Username: "%" + username + "%", Keywords: keywords, BeginTime: beginTime, BeginTimestamp: filter.BeginTimestamp, EndTime: endTime, EndTimestamp: filter.EndTimestamp} log.Printf("Query AccessLog: begin: %v, end: %v, keywords: %s", query.BeginTime, query.EndTime, query.Keywords) @@ -181,7 +181,7 @@ func (p *ProjectAPI) FilterAccessLog() { } func isProjectAdmin(userID int, pid int64) bool { - userQuery := models.User{UserId: userID, RoleId: models.PROJECTADMIN} + userQuery := models.User{UserID: userID, RoleID: models.PROJECTADMIN} rolelist, err := dao.GetUserProjectRoles(userQuery, pid) if err != nil { beego.Error("Error occurred in GetUserProjectRoles:", err, ", returning false") diff --git a/api/search.go b/api/search.go index 314da749a..d7bc50819 100644 --- a/api/search.go +++ b/api/search.go @@ -57,7 +57,7 @@ func (n *SearchAPI) Get() { } if match { entry := make(map[string]interface{}) - entry["id"] = p.ProjectId + entry["id"] = p.ProjectID entry["name"] = p.Name entry["public"] = p.Public projectResult = append(projectResult, entry) @@ -93,7 +93,7 @@ func filterRepositories(repositories []string, projects []models.Project, keywor entry := make(map[string]interface{}) entry["repository_name"] = r.Name entry["project_name"] = projects[j].Name - entry["project_id"] = projects[j].ProjectId + entry["project_id"] = projects[j].ProjectID entry["project_public"] = projects[j].Public result = append(result, entry) } else { diff --git a/api/user.go b/api/user.go index be595e044..002cd0140 100644 --- a/api/user.go +++ b/api/user.go @@ -43,7 +43,7 @@ func (ua *UserAPI) Prepare() { beego.Error("Invalid user id, error:", err) ua.CustomAbort(http.StatusBadRequest, "Invalid user Id") } - userQuery := models.User{UserId: ua.userID} + userQuery := models.User{UserID: ua.userID} u, err := dao.GetUser(userQuery) if err != nil { beego.Error("Error occurred in GetUser:", err) @@ -83,7 +83,7 @@ func (ua *UserAPI) Get() { ua.Data["json"] = userList } else if ua.userID == ua.currentUserID || exist { - userQuery := models.User{UserId: ua.userID} + userQuery := models.User{UserID: ua.userID} u, err := dao.GetUser(userQuery) if err != nil { beego.Error("Error occurred in GetUser:", err) @@ -109,7 +109,7 @@ func (ua *UserAPI) Put() { //currently only for toggle admin, so no request body ua.RenderError(http.StatusForbidden, "User does not have admin role") return } - userQuery := models.User{UserId: ua.userID} + userQuery := models.User{UserID: ua.userID} dao.ToggleUserAdminRole(userQuery) } diff --git a/api/utils.go b/api/utils.go index fddd3066d..8d753096c 100644 --- a/api/utils.go +++ b/api/utils.go @@ -30,7 +30,7 @@ func CheckProjectPermission(userID int, projectID int64) bool { if exist { return true } - roleList, err := dao.GetUserProjectRoles(models.User{UserId: userID}, projectID) + roleList, err := dao.GetUserProjectRoles(models.User{UserID: userID}, projectID) if err != nil { beego.Error("Error occurred in GetUserProjectRoles:", err) return false @@ -45,7 +45,7 @@ func CheckUserExists(name string) int { return 0 } if u != nil { - return u.UserId + return u.UserID } return 0 } diff --git a/auth/ldap/ldap.go b/auth/ldap/ldap.go index f07999091..cc0c7a98d 100644 --- a/auth/ldap/ldap.go +++ b/auth/ldap/ldap.go @@ -107,7 +107,7 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) { if err != nil { return nil, err } - u.UserId = currentUser.UserId + u.UserID = currentUser.UserID } else { u.Password = "12345678AbC" u.Comment = "registered from LDAP." @@ -115,7 +115,7 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) { if err != nil { return nil, err } - u.UserId = int(userID) + u.UserID = int(userID) } return &u, nil } diff --git a/controllers/item_detail.go b/controllers/item_detail.go index d51ee123f..3b596854d 100644 --- a/controllers/item_detail.go +++ b/controllers/item_detail.go @@ -63,7 +63,7 @@ func (idc *ItemDetailController) Get() { idc.Data["Username"] = idc.GetSession("username") idc.Data["UserId"] = sessionUserID.(int) - roleList, err := dao.GetUserProjectRoles(models.User{UserId: sessionUserID.(int)}, projectID) + roleList, err := dao.GetUserProjectRoles(models.User{UserID: sessionUserID.(int)}, projectID) if err != nil { beego.Error("Error occurred in GetUserProjectRoles:", err) idc.CustomAbort(http.StatusInternalServerError, "Internal error.") @@ -75,14 +75,14 @@ func (idc *ItemDetailController) Get() { } if len(roleList) > 0 { - idc.Data["RoleId"] = roleList[0].RoleId + idc.Data["RoleId"] = roleList[0].RoleID } } - idc.Data["ProjectId"] = project.ProjectId + idc.Data["ProjectId"] = project.ProjectID idc.Data["ProjectName"] = project.Name idc.Data["OwnerName"] = project.OwnerName - idc.Data["OwnerId"] = project.OwnerId + idc.Data["OwnerId"] = project.OwnerID idc.Data["HarborRegUrl"] = os.Getenv("HARBOR_REG_URL") idc.Data["RepoName"] = idc.GetString("repo_name") diff --git a/controllers/login.go b/controllers/login.go index a036ee587..c276eb801 100644 --- a/controllers/login.go +++ b/controllers/login.go @@ -54,7 +54,7 @@ func (c *CommonController) Login() { c.CustomAbort(http.StatusUnauthorized, "") } - c.SetSession("userId", user.UserId) + c.SetSession("userId", user.UserID) c.SetSession("username", user.Username) } diff --git a/controllers/password.go b/controllers/password.go index 1de8ebbb9..fb512a0d0 100644 --- a/controllers/password.go +++ b/controllers/password.go @@ -57,7 +57,7 @@ func (cc *CommonController) UpdatePassword() { cc.CustomAbort(http.StatusBadRequest, "Old password is blank") } - queryUser := models.User{UserId: sessionUserID.(int), Password: oldPassword} + queryUser := models.User{UserID: sessionUserID.(int), Password: oldPassword} user, err := dao.CheckUserPassword(queryUser) if err != nil { beego.Error("Error occurred in CheckUserPassword:", err) @@ -71,7 +71,7 @@ func (cc *CommonController) UpdatePassword() { password := cc.GetString("password") if password != "" { - updateUser := models.User{UserId: sessionUserID.(int), Password: password, Salt: user.Salt} + updateUser := models.User{UserID: sessionUserID.(int), Password: password, Salt: user.Salt} err = dao.ChangeUserPassword(updateUser, oldPassword) if err != nil { beego.Error("Error occurred in ChangeUserPassword:", err) @@ -163,7 +163,7 @@ func (cc *CommonController) SendEmail() { cc.CustomAbort(http.StatusInternalServerError, "send_email_failed") } - user := models.User{ResetUuid: uuid, Email: email} + user := models.User{ResetUUID: uuid, Email: email} dao.UpdateUserResetUuid(user) } @@ -183,7 +183,7 @@ func (rpc *ResetPasswordController) Get() { return } - queryUser := models.User{ResetUuid: resetUUID} + queryUser := models.User{ResetUUID: resetUUID} user, err := dao.GetUser(queryUser) if err != nil { beego.Error("Error occurred in GetUser:", err) @@ -191,7 +191,7 @@ func (rpc *ResetPasswordController) Get() { } if user != nil { - rpc.Data["ResetUuid"] = user.ResetUuid + rpc.Data["ResetUuid"] = user.ResetUUID rpc.ForwardTo("page_title_reset_password", "reset-password") } else { rpc.Redirect("/", http.StatusFound) @@ -205,7 +205,7 @@ func (cc *CommonController) ResetPassword() { cc.CustomAbort(http.StatusBadRequest, "Reset uuid is blank.") } - queryUser := models.User{ResetUuid: resetUUID} + queryUser := models.User{ResetUUID: resetUUID} user, err := dao.GetUser(queryUser) if err != nil { beego.Error("Error occurred in GetUser:", err) diff --git a/dao/access_log.go b/dao/access_log.go index 5860a30c3..08c09ec4b 100644 --- a/dao/access_log.go +++ b/dao/access_log.go @@ -32,7 +32,7 @@ func AddAccessLog(accessLog models.AccessLog) error { } defer p.Close() - _, err = p.Exec(accessLog.UserId, accessLog.ProjectId, accessLog.RepoName, accessLog.Guid, accessLog.Operation) + _, err = p.Exec(accessLog.UserID, accessLog.ProjectID, accessLog.RepoName, accessLog.GUID, accessLog.Operation) return err } @@ -44,11 +44,11 @@ func GetAccessLogs(accessLog models.AccessLog) ([]models.AccessLog, error) { from access_log a left join user u on a.user_id = u.user_id where a.project_id = ? ` queryParam := make([]interface{}, 1) - queryParam = append(queryParam, accessLog.ProjectId) + queryParam = append(queryParam, accessLog.ProjectID) - if accessLog.UserId != 0 { + if accessLog.UserID != 0 { sql += ` and a.user_id = ? ` - queryParam = append(queryParam, accessLog.UserId) + queryParam = append(queryParam, accessLog.UserID) } if accessLog.Operation != "" { sql += ` and a.operation = ? ` diff --git a/dao/dao_test.go b/dao/dao_test.go index 8d08903ac..f3b4ee367 100644 --- a/dao/dao_test.go +++ b/dao/dao_test.go @@ -266,12 +266,12 @@ func TestResetUserPassword(t *testing.T) { t.Errorf("Error occurred in GenerateRandomString: %v", err) } - err = UpdateUserResetUuid(models.User{ResetUuid: uuid, Email: currentUser.Email}) + err = UpdateUserResetUuid(models.User{ResetUUID: uuid, Email: currentUser.Email}) if err != nil { t.Errorf("Error occurred in UpdateUserResetUuid: %v", err) } - err = ResetUserPassword(models.User{UserId: currentUser.UserId, Password: "HarborTester12345", ResetUuid: uuid, Salt: currentUser.Salt}) + err = ResetUserPassword(models.User{UserID: currentUser.UserID, Password: "HarborTester12345", ResetUUID: uuid, Salt: currentUser.Salt}) if err != nil { t.Errorf("Error occurred in ResetUserPassword: %v", err) } @@ -287,7 +287,7 @@ func TestResetUserPassword(t *testing.T) { } func TestChangeUserPassword(t *testing.T) { - err := ChangeUserPassword(models.User{UserId: currentUser.UserId, Password: "NewHarborTester12345", Salt: currentUser.Salt}) + err := ChangeUserPassword(models.User{UserID: currentUser.UserID, Password: "NewHarborTester12345", Salt: currentUser.Salt}) if err != nil { t.Errorf("Error occurred in ChangeUserPassword: %v", err) } @@ -303,7 +303,7 @@ func TestChangeUserPassword(t *testing.T) { } func TestChangeUserPasswordWithOldPassword(t *testing.T) { - err := ChangeUserPassword(models.User{UserId: currentUser.UserId, Password: "NewerHarborTester12345", Salt: currentUser.Salt}, "NewHarborTester12345") + err := ChangeUserPassword(models.User{UserID: currentUser.UserID, Password: "NewerHarborTester12345", Salt: currentUser.Salt}, "NewHarborTester12345") if err != nil { t.Errorf("Error occurred in ChangeUserPassword: %v", err) } @@ -317,7 +317,7 @@ func TestChangeUserPasswordWithOldPassword(t *testing.T) { } func TestChangeUserPasswordWithIncorrectOldPassword(t *testing.T) { - err := ChangeUserPassword(models.User{UserId: currentUser.UserId, Password: "NNewerHarborTester12345", Salt: currentUser.Salt}, "WrongNewerHarborTester12345") + err := ChangeUserPassword(models.User{UserID: currentUser.UserID, Password: "NNewerHarborTester12345", Salt: currentUser.Salt}, "WrongNewerHarborTester12345") if err == nil { t.Errorf("Error does not occurred due to old password is incorrect.") } @@ -331,7 +331,7 @@ func TestChangeUserPasswordWithIncorrectOldPassword(t *testing.T) { } func TestQueryRelevantProjectsWhenNoProjectAdded(t *testing.T) { - projects, err := QueryRelevantProjects(currentUser.UserId) + projects, err := QueryRelevantProjects(currentUser.UserID) if err != nil { t.Errorf("Error occurred in QueryRelevantProjects: %v", err) } @@ -346,7 +346,7 @@ func TestQueryRelevantProjectsWhenNoProjectAdded(t *testing.T) { func TestAddProject(t *testing.T) { project := models.Project{ - OwnerId: currentUser.UserId, + OwnerID: currentUser.UserID, Name: PROJECT_NAME, CreationTime: time.Now(), OwnerName: currentUser.Username, @@ -396,12 +396,12 @@ func getProjectRole(projectId int64) []models.Role { } func TestCheckProjectRoles(t *testing.T) { - r := getProjectRole(currentProject.ProjectId) + r := getProjectRole(currentProject.ProjectID) if len(r) != 3 { t.Errorf("The length of project roles is not 3") } - if r[1].RoleId != 3 { - t.Errorf("The role id does not match, expected: 3, acutal: %d", r[1].RoleId) + if r[1].RoleID != 3 { + t.Errorf("The role id does not match, expected: 3, acutal: %d", r[1].RoleID) } if r[1].Name != "developer" { t.Errorf("The name of role id: 3 should be developer, actual:%s", r[1].Name) @@ -410,8 +410,8 @@ func TestCheckProjectRoles(t *testing.T) { func TestGetAccessLog(t *testing.T) { queryAccessLog := models.AccessLog{ - UserId: currentUser.UserId, - ProjectId: currentProject.ProjectId, + UserID: currentUser.UserID, + ProjectID: currentProject.ProjectID, } accessLogs, err := GetAccessLogs(queryAccessLog) if err != nil { @@ -428,12 +428,12 @@ func TestGetAccessLog(t *testing.T) { func TestProjectExists(t *testing.T) { var exists bool var err error - exists, err = ProjectExists(currentProject.ProjectId) + exists, err = ProjectExists(currentProject.ProjectID) if err != nil { t.Errorf("Error occurred in ProjectExists: %v", err) } if !exists { - t.Errorf("The project with id: %d, does not exist", currentProject.ProjectId) + t.Errorf("The project with id: %d, does not exist", currentProject.ProjectID) } exists, err = ProjectExists(currentProject.Name) if err != nil { @@ -445,7 +445,7 @@ func TestProjectExists(t *testing.T) { } func TestGetProjectById(t *testing.T) { - id := currentProject.ProjectId + id := currentProject.ProjectID p, err := GetProjectById(id) if err != nil { t.Errorf("Error in GetProjectById: %v, id: %d", err, id) @@ -456,7 +456,7 @@ func TestGetProjectById(t *testing.T) { } func TestGetUserByProject(t *testing.T) { - pid := currentProject.ProjectId + pid := currentProject.ProjectID u1 := models.User{ Username: "%%Tester%%", } @@ -481,7 +481,7 @@ func TestGetUserByProject(t *testing.T) { } func TestToggleProjectPublicity(t *testing.T) { - err := ToggleProjectPublicity(currentProject.ProjectId, PUBLICITY_ON) + err := ToggleProjectPublicity(currentProject.ProjectID, PUBLICITY_ON) if err != nil { t.Errorf("Error occurred in ToggleProjectPublicity: %v", err) } @@ -491,9 +491,9 @@ func TestToggleProjectPublicity(t *testing.T) { t.Errorf("Error occurred in GetProjectByName: %v", err) } if currentProject.Public != PUBLICITY_ON { - t.Errorf("project, id: %d, its publicity is not on", currentProject.ProjectId) + t.Errorf("project, id: %d, its publicity is not on", currentProject.ProjectID) } - err = ToggleProjectPublicity(currentProject.ProjectId, PUBLICITY_OFF) + err = ToggleProjectPublicity(currentProject.ProjectID, PUBLICITY_OFF) if err != nil { t.Errorf("Error occurred in ToggleProjectPublicity: %v", err) } @@ -504,7 +504,7 @@ func TestToggleProjectPublicity(t *testing.T) { } if currentProject.Public != PUBLICITY_OFF { - t.Errorf("project, id: %d, its publicity is not off", currentProject.ProjectId) + t.Errorf("project, id: %d, its publicity is not off", currentProject.ProjectID) } } @@ -512,13 +512,13 @@ func TestToggleProjectPublicity(t *testing.T) { func TestIsProjectPublic(t *testing.T) { if isPublic := IsProjectPublic(PROJECT_NAME); isPublic { - t.Errorf("project, id: %d, its publicity is not false after turning off", currentProject.ProjectId) + t.Errorf("project, id: %d, its publicity is not false after turning off", currentProject.ProjectID) } } func TestQueryProject(t *testing.T) { query1 := models.Project{ - UserId: 1, + UserID: 1, } projects, err := QueryProject(query1) if err != nil { @@ -538,7 +538,7 @@ func TestQueryProject(t *testing.T) { t.Errorf("Expecting get 1 project, but actual: %d, the list: %+v", len(projects), projects) } query3 := models.Project{ - UserId: 9, + UserID: 9, } projects, err = QueryProject(query3) if err != nil { @@ -565,28 +565,28 @@ func getUserProjectRole(projectId int64, userId int) []models.Role { func TestGetUserProjectRoles(t *testing.T) { user := *currentUser - r, err := GetUserProjectRoles(user, currentProject.ProjectId) + r, err := GetUserProjectRoles(user, currentProject.ProjectID) if err != nil { - t.Errorf("Error happened in GetUserProjectRole: %v, user: %+v, project Id: %d", err, user, currentProject.ProjectId) + t.Errorf("Error happened in GetUserProjectRole: %v, user: %+v, project Id: %d", err, user, currentProject.ProjectID) } //Get the size of current user project role. if len(r) != 1 { - t.Errorf("The user, id: %d, should only have one role in project, id: %d, but actual: %d", currentUser.UserId, currentProject.ProjectId, len(r)) + t.Errorf("The user, id: %d, should only have one role in project, id: %d, but actual: %d", currentUser.UserID, currentProject.ProjectID, len(r)) } if r[0].Name != "projectAdmin" { t.Errorf("the expected rolename is: projectAdmin, actual: %s", r[0].Name) } - user.RoleId = 1 + user.RoleID = 1 - r, err = GetUserProjectRoles(user, currentProject.ProjectId) + r, err = GetUserProjectRoles(user, currentProject.ProjectID) if err != nil { - t.Errorf("Error happened in GetUserProjectRole: %v, user: %+v, project Id: %d", err, user, currentProject.ProjectId) + t.Errorf("Error happened in GetUserProjectRole: %v, user: %+v, project Id: %d", err, user, currentProject.ProjectID) } //Get the size of current user project role. if len(r) != 0 { - t.Errorf("The user, id: %d, should not have role id: 1 in project id: %d, actual role list: %v", currentUser.UserId, currentProject.ProjectId, r) + t.Errorf("The user, id: %d, should not have role id: 1 in project id: %d, actual role list: %v", currentUser.UserID, currentProject.ProjectID, r) } } @@ -601,7 +601,7 @@ func TestProjectPermission(t *testing.T) { } func TestQueryRelevantProjects(t *testing.T) { - projects, err := QueryRelevantProjects(currentUser.UserId) + projects, err := QueryRelevantProjects(currentUser.UserID) if err != nil { t.Errorf("Error occurred in QueryRelevantProjects: %v", err) } @@ -614,30 +614,30 @@ func TestQueryRelevantProjects(t *testing.T) { } func TestAssignUserProjectRole(t *testing.T) { - err := AddUserProjectRole(currentUser.UserId, currentProject.ProjectId, DEVELOPER) + err := AddUserProjectRole(currentUser.UserID, currentProject.ProjectID, DEVELOPER) if err != nil { t.Errorf("Error occurred in AddUserProjectRole: %v", err) } - r := getUserProjectRole(currentProject.ProjectId, currentUser.UserId) + r := getUserProjectRole(currentProject.ProjectID, currentUser.UserID) //Get the size of current user project role info. if len(r) != 2 { t.Errorf("Expected length of role list is 2, actual: %d", len(r)) } - if r[1].RoleId != 3 { - t.Errorf("Expected role id of the second role in list is 3, actual: %d", r[1].RoleId) + if r[1].RoleID != 3 { + t.Errorf("Expected role id of the second role in list is 3, actual: %d", r[1].RoleID) } } func TestDeleteUserProjectRole(t *testing.T) { - err := DeleteUserProjectRoles(currentUser.UserId, currentProject.ProjectId) + err := DeleteUserProjectRoles(currentUser.UserID, currentProject.ProjectID) if err != nil { t.Errorf("Error occurred in DeleteUserProjectRoles: %v", err) } - r := getUserProjectRole(currentProject.ProjectId, currentUser.UserId) + r := getUserProjectRole(currentProject.ProjectID, currentUser.UserID) //Get the size of current user project role. if len(r) != 0 { t.Errorf("Expected role list length is 0, actual: %d, role list: %+v", len(r), r) @@ -649,28 +649,28 @@ func TestToggleAdminRole(t *testing.T) { if err != nil { t.Errorf("Error in toggle ToggleUserAdmin role: %v, user: %+v", err, currentUser) } - isAdmin, err := IsAdminRole(currentUser.UserId) + isAdmin, err := IsAdminRole(currentUser.UserID) if err != nil { - t.Errorf("Error in IsAdminRole: %v, user id: %d", err, currentUser.UserId) + t.Errorf("Error in IsAdminRole: %v, user id: %d", err, currentUser.UserID) } if !isAdmin { - t.Errorf("User is not admin after toggled, user id: %d", currentUser.UserId) + t.Errorf("User is not admin after toggled, user id: %d", currentUser.UserID) } err = ToggleUserAdminRole(*currentUser) if err != nil { t.Errorf("Error in toggle ToggleUserAdmin role: %v, user: %+v", err, currentUser) } - isAdmin, err = IsAdminRole(currentUser.UserId) + isAdmin, err = IsAdminRole(currentUser.UserID) if err != nil { - t.Errorf("Error in IsAdminRole: %v, user id: %d", err, currentUser.UserId) + t.Errorf("Error in IsAdminRole: %v, user id: %d", err, currentUser.UserID) } if isAdmin { - t.Errorf("User is still admin after toggled, user id: %d", currentUser.UserId) + t.Errorf("User is still admin after toggled, user id: %d", currentUser.UserID) } } func TestDeleteUser(t *testing.T) { - err := DeleteUser(currentUser.UserId) + err := DeleteUser(currentUser.UserID) if err != nil { t.Errorf("Error occurred in DeleteUser: %v", err) } diff --git a/dao/project.go b/dao/project.go index 4e9adc051..cbbdcc057 100644 --- a/dao/project.go +++ b/dao/project.go @@ -42,7 +42,7 @@ func AddProject(project models.Project) error { return err } - r, err := p.Exec(project.OwnerId, project.Name, project.Deleted, project.Public) + r, err := p.Exec(project.OwnerID, project.Name, project.Deleted, project.Public) if err != nil { return err } @@ -52,31 +52,31 @@ func AddProject(project models.Project) error { return err } - projectAdminRole := models.ProjectRole{ProjectId: projectId, RoleId: models.PROJECTADMIN} + projectAdminRole := models.ProjectRole{ProjectID: projectId, RoleID: models.PROJECTADMIN} _, err = AddProjectRole(projectAdminRole) if err != nil { return err } - projectDeveloperRole := models.ProjectRole{ProjectId: projectId, RoleId: models.DEVELOPER} + projectDeveloperRole := models.ProjectRole{ProjectID: projectId, RoleID: models.DEVELOPER} _, err = AddProjectRole(projectDeveloperRole) if err != nil { return err } - projectGuestRole := models.ProjectRole{ProjectId: projectId, RoleId: models.GUEST} + projectGuestRole := models.ProjectRole{ProjectID: projectId, RoleID: models.GUEST} _, err = AddProjectRole(projectGuestRole) if err != nil { return err } //Add all project roles, after that when assigning a user to a project just update the upr table - err = AddUserProjectRole(project.OwnerId, projectId, models.PROJECTADMIN) + err = AddUserProjectRole(project.OwnerID, projectId, models.PROJECTADMIN) if err != nil { return err } - accessLog := models.AccessLog{UserId: project.OwnerId, ProjectId: projectId, RepoName: project.Name + "/", Guid: "N/A", Operation: "create", OpTime: time.Now()} + accessLog := models.AccessLog{UserID: project.OwnerID, ProjectID: projectId, RepoName: project.Name + "/", GUID: "N/A", Operation: "create", OpTime: time.Now()} err = AddAccessLog(accessLog) return err @@ -111,10 +111,10 @@ func QueryProject(query models.Project) ([]models.Project, error) { if query.Public == 1 { sql += ` and p.public = ?` queryParam = append(queryParam, query.Public) - } else if isAdmin, _ := IsAdminRole(query.UserId); isAdmin == false { + } else if isAdmin, _ := IsAdminRole(query.UserID); isAdmin == false { sql += ` and (p.owner_id = ? or u.user_id = ?) ` - queryParam = append(queryParam, query.UserId) - queryParam = append(queryParam, query.UserId) + queryParam = append(queryParam, query.UserID) + queryParam = append(queryParam, query.UserID) } if query.Name != "" { diff --git a/dao/project_role.go b/dao/project_role.go index bbc9217e0..8e08e63d2 100644 --- a/dao/project_role.go +++ b/dao/project_role.go @@ -27,7 +27,7 @@ func AddProjectRole(projectRole models.ProjectRole) (int64, error) { return 0, err } defer p.Close() - r, err := p.Exec(projectRole.ProjectId, projectRole.RoleId) + r, err := p.Exec(projectRole.ProjectID, projectRole.RoleID) if err != nil { return 0, err } @@ -65,7 +65,7 @@ func AddUserProjectRole(userId int, projectId int64, roleId int) error { } prId = int(id) } else if n > 0 { - prId = pr[0].PrId + prId = pr[0].PrID } p, err := o.Raw("insert into user_project_role (user_id, pr_id) values (?, ?)").Prepare() if err != nil { diff --git a/dao/role.go b/dao/role.go index 2379b149b..724698c25 100644 --- a/dao/role.go +++ b/dao/role.go @@ -32,15 +32,15 @@ func GetUserProjectRoles(userQuery models.User, projectId int64) ([]models.Role, where u.deleted = 0 and u.user_id = ? ` queryParam := make([]interface{}, 1) - queryParam = append(queryParam, userQuery.UserId) + queryParam = append(queryParam, userQuery.UserID) if projectId > 0 { sql += ` and pr.project_id = ? ` queryParam = append(queryParam, projectId) } - if userQuery.RoleId > 0 { + if userQuery.RoleID > 0 { sql += ` and r.role_id = ? ` - queryParam = append(queryParam, userQuery.RoleId) + queryParam = append(queryParam, userQuery.RoleID) } var roleList []models.Role @@ -54,7 +54,7 @@ func GetUserProjectRoles(userQuery models.User, projectId int64) ([]models.Role, func IsAdminRole(userId int) (bool, error) { //role_id == 1 means the user is system admin - userQuery := models.User{UserId: userId, RoleId: models.SYSADMIN} + userQuery := models.User{UserID: userId, RoleID: models.SYSADMIN} adminRoleList, err := GetUserProjectRoles(userQuery, 0) if err != nil { return false, err diff --git a/dao/user.go b/dao/user.go index a0a259cc5..a886eaac2 100644 --- a/dao/user.go +++ b/dao/user.go @@ -38,9 +38,9 @@ func GetUser(query models.User) (*models.User, error) { from user u where deleted = 0 ` queryParam := make([]interface{}, 1) - if query.UserId != 0 { + if query.UserID != 0 { sql += ` and user_id = ? ` - queryParam = append(queryParam, query.UserId) + queryParam = append(queryParam, query.UserID) } if query.Username != "" { @@ -48,9 +48,9 @@ func GetUser(query models.User) (*models.User, error) { queryParam = append(queryParam, query.Username) } - if query.ResetUuid != "" { + if query.ResetUUID != "" { sql += ` and reset_uuid = ? ` - queryParam = append(queryParam, query.ResetUuid) + queryParam = append(queryParam, query.ResetUUID) } var u []models.User @@ -108,13 +108,13 @@ func ListUsers(query models.User) ([]models.User, error) { func ToggleUserAdminRole(u models.User) error { - projectRole := models.ProjectRole{PrId: 1} //admin project role + projectRole := models.ProjectRole{PrID: 1} //admin project role o := orm.NewOrm() var pr []models.ProjectRole - n, err := o.Raw(`select user_id from user_project_role where user_id = ? and pr_id = ? `, u.UserId, projectRole.PrId).QueryRows(&pr) + n, err := o.Raw(`select user_id from user_project_role where user_id = ? and pr_id = ? `, u.UserID, projectRole.PrID).QueryRows(&pr) if err != nil { return err } @@ -131,7 +131,7 @@ func ToggleUserAdminRole(u models.User) error { return err } defer p.Close() - _, err = p.Exec(u.UserId, projectRole.PrId) + _, err = p.Exec(u.UserID, projectRole.PrID) return err } @@ -142,9 +142,9 @@ func ChangeUserPassword(u models.User, oldPassword ...string) error { var r sql.Result if len(oldPassword) == 0 { //In some cases, it may no need to check old password, just as Linux change password policies. - _, err = o.Raw(`update user set password=?, salt=? where user_id=?`, utils.Encrypt(u.Password, u.Salt), u.Salt, u.UserId).Exec() + _, err = o.Raw(`update user set password=?, salt=? where user_id=?`, utils.Encrypt(u.Password, u.Salt), u.Salt, u.UserID).Exec() } else if len(oldPassword) == 1 { - r, err = o.Raw(`update user set password=?, salt=? where user_id=? and password = ?`, utils.Encrypt(u.Password, u.Salt), u.Salt, u.UserId, utils.Encrypt(oldPassword[0], u.Salt)).Exec() + r, err = o.Raw(`update user set password=?, salt=? where user_id=? and password = ?`, utils.Encrypt(u.Password, u.Salt), u.Salt, u.UserID, utils.Encrypt(oldPassword[0], u.Salt)).Exec() if err != nil { return err } @@ -163,7 +163,7 @@ func ChangeUserPassword(u models.User, oldPassword ...string) error { func ResetUserPassword(u models.User) error { o := orm.NewOrm() - r, err := o.Raw(`update user set password=?, reset_uuid=? where reset_uuid=?`, utils.Encrypt(u.Password, u.Salt), "", u.ResetUuid).Exec() + r, err := o.Raw(`update user set password=?, reset_uuid=? where reset_uuid=?`, utils.Encrypt(u.Password, u.Salt), "", u.ResetUUID).Exec() if err != nil { return err } @@ -179,7 +179,7 @@ func ResetUserPassword(u models.User) error { func UpdateUserResetUuid(u models.User) error { o := orm.NewOrm() - _, err := o.Raw(`update user set reset_uuid=? where email=?`, u.ResetUuid, u.Email).Exec() + _, err := o.Raw(`update user set reset_uuid=? where email=?`, u.ResetUUID, u.Email).Exec() return err } @@ -199,10 +199,10 @@ func CheckUserPassword(query models.User) (*models.User, error) { queryParam := make([]interface{}, 1) - if query.UserId != 0 { + if query.UserID != 0 { sql += ` and password = ? and user_id = ?` queryParam = append(queryParam, utils.Encrypt(query.Password, currentUser.Salt)) - queryParam = append(queryParam, query.UserId) + queryParam = append(queryParam, query.UserID) } else { sql += ` and username = ? and password = ?` queryParam = append(queryParam, currentUser.Username) diff --git a/main.go b/main.go index e8ced9ce2..1b1322b16 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ const ( ) func updateInitPassword(userID int, password string) error { - queryUser := models.User{UserId: userID} + queryUser := models.User{UserID: userID} user, err := dao.GetUser(queryUser) if err != nil { log.Println("Failed to get user, userID:", userID) diff --git a/models/access_log.go b/models/access_log.go index a167d70de..9f23a6261 100644 --- a/models/access_log.go +++ b/models/access_log.go @@ -19,13 +19,13 @@ import ( ) type AccessLog struct { - LogId int - UserId int - ProjectId int64 - RepoName string - Guid string - Operation string - OpTime time.Time + LogID int `orm:"column(log_id)"` + UserID int `orm:"column(user_id)"` + ProjectID int64 `orm:"column(project_id)"` + RepoName string `orm:"column(repo_name)"` + GUID string `orm:"column(GUID)"` + Operation string `orm:"column(operation)"` + OpTime time.Time `orm:"column(op_time)"` Username string Keywords string diff --git a/models/notification.go b/models/notification.go index 853d80bd0..4be24a68d 100644 --- a/models/notification.go +++ b/models/notification.go @@ -1,16 +1,16 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package models @@ -23,7 +23,7 @@ type Notification struct { } type Event struct { - Id string + ID string TimeStamp time.Time Action string Target *Target @@ -35,7 +35,7 @@ type Target struct { MediaType string Digest string Repository string - Url string + URL string } type Actor struct { @@ -43,7 +43,7 @@ type Actor struct { } type Request struct { - Id string + ID string Method string UserAgent string } diff --git a/models/project.go b/models/project.go index 126ee34f4..2196a3983 100644 --- a/models/project.go +++ b/models/project.go @@ -1,16 +1,16 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package models @@ -19,15 +19,15 @@ import ( ) type Project struct { - ProjectId int64 - OwnerId int - Name string - CreationTime time.Time + ProjectID int64 `orm:"column(project_id)"` + OwnerID int `orm:"column(owner_id)"` + Name string `orm:"column(name)"` + CreationTime time.Time `orm:"column(creation_time)"` CreationTimeStr string - Deleted int - UserId int + Deleted int `orm:"column(deleted)"` + UserID int OwnerName string - Public int + Public int `orm:"column(public)"` //This field does not have correspondent column in DB, this is just for UI to disable button Togglable bool } diff --git a/models/project_role.go b/models/project_role.go index dd70feacf..cd85bb829 100644 --- a/models/project_role.go +++ b/models/project_role.go @@ -1,21 +1,21 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package models type ProjectRole struct { - PrId int - ProjectId int64 - RoleId int + PrID int `orm:"column(pr_id)"` + ProjectID int64 `orm:"column(project_id)"` + RoleID int `orm:"column(role_id)"` } diff --git a/models/repo_item.go b/models/repo_item.go index 6315893b8..380a71455 100644 --- a/models/repo_item.go +++ b/models/repo_item.go @@ -1,16 +1,16 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package models @@ -19,14 +19,14 @@ import ( ) type RepoItem struct { - Id string `json:"Id"` - Parent string `json:"Parent"` - Created time.Time `json:"Created"` - CreatedStr string `json:"CreatedStr"` - DurationDays string `json:"Duration Days"` - Author string `json:"Author"` - Architecture string `json:"Architecture"` - Docker_version string `json:"Docker Version"` - Os string `json:"OS"` + ID string `json:"Id"` + Parent string `json:"Parent"` + Created time.Time `json:"Created"` + CreatedStr string `json:"CreatedStr"` + DurationDays string `json:"Duration Days"` + Author string `json:"Author"` + Architecture string `json:"Architecture"` + DockerVersion string `json:"Docker Version"` + Os string `json:"OS"` //Size int `json:"Size"` } diff --git a/models/role.go b/models/role.go index 847fb3347..217e02bba 100644 --- a/models/role.go +++ b/models/role.go @@ -1,16 +1,16 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package models @@ -22,7 +22,7 @@ const ( ) type Role struct { - RoleId int `json:"role_id"` - RoleCode string `json:"role_code"` - Name string `json:"role_name"` + RoleID int `json:"role_id", orm:"column(role_id)"` + RoleCode string `json:"role_code, orm:"column(role_code)""` + Name string `json:"role_name", orm:"column(name)"` } diff --git a/models/tag.go b/models/tag.go index f9bc25fb8..d4823e251 100644 --- a/models/tag.go +++ b/models/tag.go @@ -1,20 +1,20 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package models type Tag struct { Version string `json:version` - ImageId string `json:image_id` + ImageID string `json:image_id` } diff --git a/models/user.go b/models/user.go index 666723dee..6ee909a38 100644 --- a/models/user.go +++ b/models/user.go @@ -1,31 +1,31 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package models type User struct { - UserId int - Username string - Email string - Password string - Realname string - Comment string - Deleted int + UserID int `orm:"column(user_id)"` + Username string `orm:"column(username)"` + Email string `orm:"column(email)"` + Password string `orm:"column(password)"` + Realname string `orm:"column(realname)"` + Comment string `orm:"column(comment)"` + Deleted int `orm:"column(deleted)"` Rolename string - RoleId int + RoleID int RoleList []Role HasAdminRole int - ResetUuid string - Salt string + ResetUUID string `orm:"column(reset_uuid)"` + Salt string `orm:"column(salt)"` } diff --git a/models/user_project_role.go b/models/user_project_role.go index fcd5b1344..fbdff1f80 100644 --- a/models/user_project_role.go +++ b/models/user_project_role.go @@ -1,21 +1,21 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package models type UserProjectRole struct { - UprId int - UserId int - PrId int64 + UprID int `orm:"column(upr_id)"` + UserID int `orm:"column(user_id)"` + PrID int64 `orm:"column(pr_id)"` }