Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8c60bc8

Browse files
committed
加上判断
1 parent 5c70475 commit 8c60bc8

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/logic/project.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ func (self ProjectLogic) Publish(ctx context.Context, user *model.Me, form url.V
3434
id := form.Get("id")
3535
isModify := id != ""
3636

37-
if !isModify && self.UriExists(ctx, form.Get("uri")) {
38-
err = errors.New("uri存在")
39-
return
40-
}
41-
4237
project := &model.OpenProject{}
4338

4439
if isModify {
@@ -66,9 +61,16 @@ func (self ProjectLogic) Publish(ctx context.Context, user *model.Me, form url.V
6661

6762
project.Username = user.Username
6863
}
69-
64+
if project.Uri == "" {
65+
project.Uri = strings.Replace(project.Name, " ", "-", -1)
66+
}
7067
project.Uri = strings.ToLower(project.Uri)
7168

69+
if !isModify && self.UriExists(ctx, form.Get("uri")) {
70+
err = errors.New("项目已存在")
71+
return
72+
}
73+
7274
github := "github.com"
7375
pos := strings.Index(project.Src, github)
7476
if pos != -1 {
@@ -223,6 +225,8 @@ func (self ProjectLogic) ParseProjectList(pUrl string) error {
223225
pUrl = "http://" + pUrl
224226
}
225227

228+
logger.Infoln("parse project url:", pUrl)
229+
226230
var (
227231
doc *goquery.Document
228232
err error

0 commit comments

Comments
 (0)