delete useless files

This commit is contained in:
Wenkai Yin 2016-03-29 13:40:15 +08:00
parent 5b5b0593d7
commit d8785196c0
2 changed files with 0 additions and 150 deletions

View File

@ -1,52 +0,0 @@
/*
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 dao
/*
import (
"github.com/vmware/harbor/models"
"github.com/astaxie/beego/orm"
)
// GetUserByProject gets all members of the project.
func GetUserByProject(projectID int64, queryUser models.User) ([]models.User, error) {
o := orm.NewOrm()
u := []models.User{}
sql := `select
u.user_id, u.username, r.name rolename, r.role_id
from user u left join user_project_role upr
on u.user_id = upr.user_id
left join project_role pr
on pr.pr_id = upr.pr_id
left join role r
on r.role_id = pr.role_id
where u.deleted = 0
and pr.project_id = ? `
queryParam := make([]interface{}, 1)
queryParam = append(queryParam, projectID)
if queryUser.Username != "" {
sql += " and u.username like ? "
queryParam = append(queryParam, queryUser.Username)
}
sql += ` order by u.user_id `
_, err := o.Raw(sql, queryParam).QueryRows(&u)
return u, err
}
*/

View File

@ -1,98 +0,0 @@
/*
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 dao
/*
import (
"github.com/vmware/harbor/models"
"github.com/astaxie/beego/orm"
)
// AddProjectRole ...
func AddProjectRole(projectRole models.ProjectRole) (int64, error) {
o := orm.NewOrm()
p, err := o.Raw("insert into project_role (project_id, role_id) values (?, ?)").Prepare()
if err != nil {
return 0, err
}
defer p.Close()
r, err := p.Exec(projectRole.ProjectID, projectRole.RoleID)
if err != nil {
return 0, err
}
id, err := r.LastInsertId()
return id, err
}
// AddUserProjectRole inserts role information to table project_role and user_project_role.
func AddUserProjectRole(userID int, projectID int64, roleID int) error {
o := orm.NewOrm()
var pr []models.ProjectRole
var prID int
sql := `select pr.pr_id, pr.project_id, pr.role_id from project_role pr where pr.project_id = ? and pr.role_id = ?`
n, err := o.Raw(sql, projectID, roleID).QueryRows(&pr)
if err != nil {
return err
}
if n == 0 { //project role not found, insert a pr record
p, err := o.Raw("insert into project_role (project_id, role_id) values (?, ?)").Prepare()
if err != nil {
return err
}
defer p.Close()
r, err := p.Exec(projectID, roleID)
if err != nil {
return err
}
id, err := r.LastInsertId()
if err != nil {
return err
}
prID = int(id)
} else if n > 0 {
prID = pr[0].PrID
}
p, err := o.Raw("insert into user_project_role (user_id, pr_id) values (?, ?)").Prepare()
if err != nil {
return err
}
defer p.Close()
_, err = p.Exec(userID, prID)
return err
}
// DeleteUserProjectRoles ...
func DeleteUserProjectRoles(userID int, projectID int64) error {
o := orm.NewOrm()
sql := `delete from user_project_role where user_id = ? and pr_id in
(select pr_id from project_role where project_id = ?)`
p, err := o.Raw(sql).Prepare()
if err != nil {
return err
}
_, err = p.Exec(userID, projectID)
return err
}
*/