Skip to content

Commit

Permalink
🔖 v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Apr 8, 2020
1 parent 82ced61 commit c35ea84
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.vscode
upload
*.exe
*.db
*.db
build
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
## LAN-SHARE in Golang
## LAN-SHARE in Golang
Easily share files to other devices in the same local area network.

## Usage
```
Usage of lan-share.exe:
-port int
specify the server listening port. (default 3000)
-token string
specify the private token. (default "token")
```

Example: `./lan-share.exe -port 80 -token private`

##
2 changes: 1 addition & 1 deletion controler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func GetIndex(c *gin.Context) {
files, _ := model.Query(query)

c.HTML(http.StatusOK, "template.gohtml", gin.H{
"message": "Welcome!",
"message": "",
"files": files,
})
}
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
)

func main() {
gin.SetMode(gin.ReleaseMode)
flag.Parse()

db, err := model.InitDB()
Expand Down
4 changes: 3 additions & 1 deletion model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"os"
"strings"
)

type File struct {
Expand Down Expand Up @@ -50,6 +51,7 @@ func (file *File) Delete() error {
func Query(query string) ([]*File, error) {
var files []*File
var err error
err = DB.Where("filename LIKE ?", "%"+query+"%").Find(&files).Error
query = strings.ToLower(query)
err = DB.Where("filename LIKE ? or description LIKE ? or uploader LIKE ? or time LIKE ?", "%"+query+"%", "%"+query+"%", "%"+query+"%", "%"+query+"%").Find(&files).Error
return files, err
}

0 comments on commit c35ea84

Please sign in to comment.