forked from OS-ABC/Kcoin-Golang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package models | ||
|
||
import( | ||
"fmt" | ||
) | ||
|
||
// 导入项目时的信息 | ||
type ProjectDetail struct { | ||
ProjectName string `gorm:"column:project_name" json:"projectName"` | ||
ProjectCoverUrl string `gorm:"column:project_cover_url" json:"projectCoverUrl"` | ||
Introduction string `gorm:"column:project_description" json:"introdection"` | ||
GithubUrl string `gorm:"column:project_url" json:"githubUrl"` | ||
DecideType int `json:"decideType"` | ||
} | ||
|
||
func AddProject(project *ProjectDetail) int { | ||
tem := -1 | ||
DB.Table("k_project").Select("project_id").Where("project_url = ?", project.GithubUrl).First(&tem) | ||
if tem >= 0 { // 说明有ID,即项目已在平台内 | ||
return 0 | ||
} else if err := DB.Table("k_project").Create(&project).Error; err != nil { | ||
fmt.Println(err.Error()) | ||
return -1 | ||
} else { | ||
return 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters