mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
change api for statistics and project repo, roleid
This commit is contained in:
parent
9195441881
commit
f43d6dab18
@ -79,7 +79,6 @@ func (s *StatisticAPI) Get() {
|
||||
proMap["total_repos"] = s.GetReposByProject(projectList[i].Name, true)
|
||||
}
|
||||
}
|
||||
log.Debug(projectList)
|
||||
s.Data["json"] = proMap
|
||||
s.ServeJSON()
|
||||
}
|
||||
|
@ -84,19 +84,19 @@ func QueryProject(query models.Project) ([]models.Project, error) {
|
||||
o := orm.NewOrm()
|
||||
|
||||
sql := `select distinct
|
||||
p.project_id, p.owner_id, p.name,p.creation_time, p.update_time, p.public, pm.role role
|
||||
from project p
|
||||
left join project_member pm on p.project_id = pm.project_id
|
||||
where p.deleted = 0 `
|
||||
|
||||
p.project_id, p.owner_id, p.name,p.creation_time, p.update_time, p.public`
|
||||
queryParam := make([]interface{}, 1)
|
||||
|
||||
isAdmin, _ := IsAdminRole(query.UserID)
|
||||
if query.Public == 1 {
|
||||
sql += ` and p.public = ?`
|
||||
sql += ` from project p where p.deleted = 0 and p.public = ?`
|
||||
queryParam = append(queryParam, query.Public)
|
||||
} else if isAdmin, _ := IsAdminRole(query.UserID); isAdmin == false {
|
||||
sql += ` and (pm.user_id = ?) `
|
||||
} else if !isAdmin {
|
||||
sql += `, pm.role role from project p
|
||||
left join project_member pm on p.project_id = pm.project_id
|
||||
where p.deleted = 0 and (pm.user_id = ?) `
|
||||
queryParam = append(queryParam, query.UserID)
|
||||
} else if isAdmin {
|
||||
sql += ` from project p where p.deleted = 0 `
|
||||
}
|
||||
|
||||
if query.Name != "" {
|
||||
@ -112,6 +112,11 @@ func QueryProject(query models.Project) ([]models.Project, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if isAdmin {
|
||||
for i := 0; i < len(r); i++ {
|
||||
r[i].Role = 1
|
||||
}
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user