File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,11 +6,12 @@ import (
66)
77
88type Meta struct {
9- ID uint `json:"id" gorm:"primaryKey"`
10- Path string `json:"path" gorm:"unique" binding:"required"`
11- Password string `json:"password"`
12- Hide string `json:"hide"`
13- Upload bool `json:"upload"`
9+ ID uint `json:"id" gorm:"primaryKey"`
10+ Path string `json:"path" gorm:"unique" binding:"required"`
11+ Password string `json:"password"`
12+ Hide string `json:"hide"`
13+ Upload bool `json:"upload"`
14+ OnlyShows string `json:"only_shows"`
1415}
1516
1617func GetMetaByPath (path string ) (* Meta , error ) {
Original file line number Diff line number Diff line change @@ -88,8 +88,10 @@ func SuccessResp(c *gin.Context, data ...interface{}) {
8888}
8989
9090func Hide (meta * model.Meta , files []model.File ) []model.File {
91- //meta, _ := model.GetMetaByPath(path)
92- if meta != nil && meta .Hide != "" {
91+ if meta == nil {
92+ return files
93+ }
94+ if meta .Hide != "" {
9395 tmpFiles := make ([]model.File , 0 )
9496 hideFiles := strings .Split (meta .Hide , "," )
9597 for _ , item := range files {
@@ -99,5 +101,15 @@ func Hide(meta *model.Meta, files []model.File) []model.File {
99101 }
100102 files = tmpFiles
101103 }
104+ if meta .OnlyShows != "" {
105+ tmpFiles := make ([]model.File , 0 )
106+ showFiles := strings .Split (meta .OnlyShows , "," )
107+ for _ , item := range files {
108+ if utils .IsContain (showFiles , item .Name ) {
109+ tmpFiles = append (tmpFiles , item )
110+ }
111+ }
112+ files = tmpFiles
113+ }
102114 return files
103115}
You can’t perform that action at this time.
0 commit comments