handle project name is nil

This commit is contained in:
Wenkai Yin 2016-05-20 11:32:12 +08:00
parent 4b27ef7a25
commit 7920803735
2 changed files with 4 additions and 1 deletions

View File

@ -100,6 +100,10 @@ func (p *ProjectAPI) Post() {
// Head ...
func (p *ProjectAPI) Head() {
projectName := p.GetString("project_name")
if len(projectName) == 0 {
p.CustomAbort(http.StatusBadRequest, "project_name is needed")
}
project, err := dao.GetProjectByName(projectName)
if err != nil {
log.Errorf("error occurred in GetProjectByName: %v", err)

View File

@ -250,7 +250,6 @@ func getProjects(public int, projectName string) ([]models.Project, error) {
}
sql += " order by name "
var projects []models.Project
log.Debugf("sql xxx", sql)
if _, err := o.Raw(sql, queryParam).QueryRows(&projects); err != nil {
return nil, err
}