diff --git a/go.mod b/go.mod index 86a0f36b..fc162021 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/gaochao1/sw v4.0.0+incompatible github.com/garyburd/redigo v1.6.2 github.com/gin-contrib/pprof v1.3.0 + github.com/gin-contrib/static v0.0.1 github.com/gin-gonic/gin v1.6.3 github.com/go-ping/ping v0.0.0-20201115131931-3300c582a663 github.com/go-sql-driver/mysql v1.5.0 diff --git a/go.sum b/go.sum index 29580d98..5e4e11b9 100644 --- a/go.sum +++ b/go.sum @@ -284,6 +284,8 @@ github.com/gin-contrib/pprof v1.3.0 h1:G9eK6HnbkSqDZBYbzG4wrjCsA4e+cvYAHUZw6W+W9 github.com/gin-contrib/pprof v1.3.0/go.mod h1:waMjT1H9b179t3CxuG1cV3DHpga6ybizwfBaM5OXaB0= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-contrib/static v0.0.1 h1:JVxuvHPuUfkoul12N7dtQw7KRn/pSMq7Ue1Va9Swm1U= +github.com/gin-contrib/static v0.0.1/go.mod h1:CSxeF+wep05e0kCOsqWdAWbSszmc31zTIbD8TvWl7Hs= github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= diff --git a/src/models/role.go b/src/models/role.go index 8abe03e7..3c2e079c 100644 --- a/src/models/role.go +++ b/src/models/role.go @@ -89,7 +89,7 @@ func (r *Role) Save(ops []string) error { session := DB["rdb"].NewSession() defer session.Close() - cnt, err := session.Where("name=?", r.Name).Count(new(Role)) + cnt, err := session.Where("name=? and cate=?", r.Name, r.Cate).Count(new(Role)) if err != nil { return err } diff --git a/src/modules/server/http/http_server.go b/src/modules/server/http/http_server.go index 5204fd85..aebd5a82 100644 --- a/src/modules/server/http/http_server.go +++ b/src/modules/server/http/http_server.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "github.com/gin-contrib/static" "github.com/gin-gonic/gin" "github.com/didi/nightingale/v4/src/common/address" @@ -41,6 +42,8 @@ func Start() { r.Use(loggerMid) } + r.Use(static.Serve("/", static.LocalFile("./pub", false))) + Config(r) initStats()