Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0a24e42
Merge pull request #304 from hb1707/master
Aug 10, 2020
f19eb92
refactor(data): fixed mssql sql data error
Aug 10, 2020
a2dc169
Merge branch 'master' of github.com:GoAdminGroup/go-admin
Aug 10, 2020
9c2eedc
fix(logger): fixed logger caller error
Aug 10, 2020
7f74aa6
feat(template): improve ajax action
Aug 11, 2020
2cff7f8
feat(template): improve buttons, add Callbacks() API
Aug 11, 2020
8654cc8
feat(template): improve components
Aug 11, 2020
56b0b67
feat(config): Add config item AllowDelOperationLog
Aug 11, 2020
5936f7a
feat(admin): improve online generator tool
Aug 11, 2020
3d2ee61
feat(config): Add config item OperationLogOff
Aug 11, 2020
e45cbcf
feat(template): improve action
Aug 11, 2020
f209e3e
feat(admin): improve online generator & improve logger
Aug 12, 2020
539bec2
feat(template): improve action
Aug 12, 2020
dbb47be
feat(admin): improve online generator tool
Aug 12, 2020
9dfbd76
feat(admin): improve online generator tool
Aug 12, 2020
1383179
feat(admin): improve generator tool
Aug 12, 2020
39ab187
feat(admin): improve generator tool
Aug 12, 2020
9467f8e
feat(admin): improve online generator tool
Aug 12, 2020
dfe77ff
feat(admin): improve online generator / adm & add API FieldDisplayBut…
Aug 13, 2020
450787c
feat(admin): fixed info table group error
Aug 13, 2020
ff64c44
feat(admin): improve online generator tool
Aug 13, 2020
68c3d1c
feat(admin): improve online generator tool
Aug 13, 2020
0227846
feat(admin): improve online generator tool
Aug 13, 2020
d695667
feat(admin): improve online generator tool
Aug 14, 2020
4d28158
feat(admin): improve online generator
Aug 14, 2020
e082a40
fix(admin): Add field pre process logic before custom update/insert
Aug 14, 2020
ec7ecdc
fix(admin): fixed export function
Aug 14, 2020
5eefe3f
feat(admin): improve online generator
Aug 14, 2020
34ee91a
feat(admin): improve online generator tool
Aug 14, 2020
83e9c06
feat(admin): improve online generator tool
Aug 14, 2020
721aa48
feat(admin): improve online generator tool
Aug 14, 2020
94d8d52
refactor(code): improve code quality
Aug 14, 2020
39df4a0
Add .deepsource.toml
deepsourcebot Aug 14, 2020
9e14dc5
refactor(code): improve code quality
Aug 14, 2020
f2e2f4c
Merge branch 'master' of github.com:GoAdminGroup/go-admin
Aug 14, 2020
dd32ba2
perf(code): improve code performance
Aug 14, 2020
24a3054
perf(code): improve code performance
Aug 15, 2020
b297e00
perf(code): improve code performance
Aug 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version = 1

[[analyzers]]
name = "go"
enabled = true

[analyzers.meta]
import_paths = ["github.com/GoAdminGroup/go-admin"]
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ cilint:
golint:
GO111MODULE=off golint ./...

## form tmpl build

build-form-tmpl:
build-tmpl:
## form tmpl build
adm compile tpl --src ./template/types/tmpls/ --dist ./template/types/tmpl.go --package types --var tmpls
## generator tmpl build
adm compile tpl --src ./plugins/admin/modules/table/tmpl --dist ./plugins/admin/modules/table/tmpl.go --package table --var tmpls

## cli version update

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,6 @@ inspired by [laravel-admin](https://github.com/z-song/laravel-admin)

留下您的github/gitee用户名,我们将会展示在[捐赠名单](DONATION.md)中。

> 目前GoAdmin项目捐赠达666元,联系[作者](http://quick.go-admin.cn/resource/wechat_qrcode.jpg)可进vip用户群,vip群中您的问题将得到优先解答,同时也会根据您的需求进行分析和优先安排,vip群也会提供其他关于golang的福利。
> 恰饭所需,作者精力时间有限,目前GoAdmin项目捐赠达666元,联系[作者](http://quick.go-admin.cn/resource/wechat_qrcode.jpg)可进vip用户群,vip群中您的问题将得到优先解答,同时也会根据您的需求进行分析和优先安排,vip群也会提供其他关于golang的福利。🙏

<img src="http://quick.go-admin.cn/official/assets/imgs/shoukuan.jpg" width="650" />
2 changes: 1 addition & 1 deletion adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (base *BaseAdapter) GetContent(ctx interface{}, getPanelFn types.GetPanelFn
tmpl, tmplName := template.Default().GetTemplate(newBase.IsPjax())

buf := new(bytes.Buffer)
hasError = tmpl.ExecuteTemplate(buf, tmplName, types.NewPage(types.NewPageParam{
hasError = tmpl.ExecuteTemplate(buf, tmplName, types.NewPage(&types.NewPageParam{
User: user,
Menu: menu.GetGlobalMenu(user, wf.GetConnection()).SetActiveClass(config.URLRemovePrefix(newBase.Path())),
Panel: panel.GetContent(config.IsProductionEnvironment()),
Expand Down
4 changes: 2 additions & 2 deletions adapter/beego/beego.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func (bee *Beego) AddHandler(method, path string, handlers gctx.Handlers) {
bee.app.Handlers.AddMethod(method, path, func(c *context.Context) {
for key, value := range c.Input.Params() {
if c.Request.URL.RawQuery == "" {
c.Request.URL.RawQuery += strings.Replace(key, ":", "", -1) + "=" + value
c.Request.URL.RawQuery += strings.ReplaceAll(key, ":", "") + "=" + value
} else {
c.Request.URL.RawQuery += "&" + strings.Replace(key, ":", "", -1) + "=" + value
c.Request.URL.RawQuery += "&" + strings.ReplaceAll(key, ":", "") + "=" + value
}
}
ctx := gctx.NewContext(c.Request)
Expand Down
4 changes: 2 additions & 2 deletions adapter/buffalo/buffalo.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func (bu *Buffalo) AddHandler(method, path string, handlers context.Handlers) {

for key, param := range params {
if c.Request().URL.RawQuery == "" {
c.Request().URL.RawQuery += strings.Replace(key, ":", "", -1) + "=" + param[0]
c.Request().URL.RawQuery += strings.ReplaceAll(key, ":", "") + "=" + param[0]
} else {
c.Request().URL.RawQuery += "&" + strings.Replace(key, ":", "", -1) + "=" + param[0]
c.Request().URL.RawQuery += "&" + strings.ReplaceAll(key, ":", "") + "=" + param[0]
}
}

Expand Down
4 changes: 2 additions & 2 deletions adapter/chi/chi.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ func (ch *Chi) AddHandler(method, path string, handlers context.Handlers) {

for i := 0; i < len(params.Values); i++ {
if r.URL.RawQuery == "" {
r.URL.RawQuery += strings.Replace(params.Keys[i], ":", "", -1) + "=" + params.Values[i]
r.URL.RawQuery += strings.ReplaceAll(params.Keys[i], ":", "") + "=" + params.Values[i]
} else {
r.URL.RawQuery += "&" + strings.Replace(params.Keys[i], ":", "", -1) + "=" + params.Values[i]
r.URL.RawQuery += "&" + strings.ReplaceAll(params.Keys[i], ":", "") + "=" + params.Values[i]
}
}

Expand Down
4 changes: 2 additions & 2 deletions adapter/echo/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func (e *Echo) AddHandler(method, path string, handlers context.Handlers) {

for _, key := range c.ParamNames() {
if c.Request().URL.RawQuery == "" {
c.Request().URL.RawQuery += strings.Replace(key, ":", "", -1) + "=" + c.Param(key)
c.Request().URL.RawQuery += strings.ReplaceAll(key, ":", "") + "=" + c.Param(key)
} else {
c.Request().URL.RawQuery += "&" + strings.Replace(key, ":", "", -1) + "=" + c.Param(key)
c.Request().URL.RawQuery += "&" + strings.ReplaceAll(key, ":", "") + "=" + c.Param(key)
}
}

Expand Down
4 changes: 2 additions & 2 deletions adapter/fasthttp/fasthttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func (fast *Fasthttp) AddHandler(method, path string, handlers context.Handlers)

for key, value := range params {
if httpreq.URL.RawQuery == "" {
httpreq.URL.RawQuery += strings.Replace(key, ":", "", -1) + "=" + value
httpreq.URL.RawQuery += strings.ReplaceAll(key, ":", "") + "=" + value
} else {
httpreq.URL.RawQuery += "&" + strings.Replace(key, ":", "", -1) + "=" + value
httpreq.URL.RawQuery += "&" + strings.ReplaceAll(key, ":", "") + "=" + value
}
}

Expand Down
4 changes: 2 additions & 2 deletions adapter/gf/gf.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/engine"
"github.com/GoAdminGroup/go-admin/modules/config"
"github.com/GoAdminGroup/go-admin/modules/utils"
"github.com/GoAdminGroup/go-admin/plugins"
"github.com/GoAdminGroup/go-admin/plugins/admin/models"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/constant"
Expand Down Expand Up @@ -91,8 +92,7 @@ func (gf *Gf) AddHandler(method, path string, handlers context.Handlers) {
params = append(params, reg2.FindAllString(newPath, -1)...)

for _, param := range params {
p := strings.Replace(param, ":", "", -1)
p = strings.Replace(p, "/", "", -1)
p := utils.ReplaceAll(param, ":", "", "/", "")

if c.Request.URL.RawQuery == "" {
c.Request.URL.RawQuery += p + "=" + c.GetRequestString(p)
Expand Down
5 changes: 2 additions & 3 deletions adapter/gin/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func (gins *Gin) AddHandler(method, path string, handlers context.Handlers) {

for _, param := range c.Params {
if c.Request.URL.RawQuery == "" {
c.Request.URL.RawQuery += strings.Replace(param.Key, ":", "", -1) + "=" + param.Value
c.Request.URL.RawQuery += strings.ReplaceAll(param.Key, ":", "") + "=" + param.Value
} else {
c.Request.URL.RawQuery += "&" + strings.Replace(param.Key, ":", "", -1) + "=" + param.Value
c.Request.URL.RawQuery += "&" + strings.ReplaceAll(param.Key, ":", "") + "=" + param.Value
}
}

Expand Down Expand Up @@ -129,7 +129,6 @@ func (gins *Gin) Redirect() {

// SetContentType implements the method Adapter.SetContentType.
func (gins *Gin) SetContentType() {
return
}

// Write implements the method Adapter.Write.
Expand Down
4 changes: 2 additions & 2 deletions adapter/gorilla/gorilla.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func (g *Gorilla) AddHandler(method, path string, handlers context.Handlers) {

for key, param := range params {
if r.URL.RawQuery == "" {
r.URL.RawQuery += strings.Replace(key, ":", "", -1) + "=" + param
r.URL.RawQuery += strings.ReplaceAll(key, ":", "") + "=" + param
} else {
r.URL.RawQuery += "&" + strings.Replace(key, ":", "", -1) + "=" + param
r.URL.RawQuery += "&" + strings.ReplaceAll(key, ":", "") + "=" + param
}
}

Expand Down
4 changes: 2 additions & 2 deletions adapter/iris/iris.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func (is *Iris) AddHandler(method, path string, handlers context.Handlers) {

for key, value := range params {
if c.Request().URL.RawQuery == "" {
c.Request().URL.RawQuery += strings.Replace(key, ":", "", -1) + "=" + value
c.Request().URL.RawQuery += strings.ReplaceAll(key, ":", "") + "=" + value
} else {
c.Request().URL.RawQuery += "&" + strings.Replace(key, ":", "", -1) + "=" + value
c.Request().URL.RawQuery += "&" + strings.ReplaceAll(key, ":", "") + "=" + value
}
}

Expand Down
2 changes: 0 additions & 2 deletions adm/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,4 @@ func insertPermissionInfoDB(conn db.Connection, name, slug, httpMethod, httpPath
if db.CheckError(err, db.INSERT) {
panic(err)
}

return
}
7 changes: 5 additions & 2 deletions adm/compile_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ var AssetPaths = map[string]string{
}

for _, name := range fileNames {
listContent += ` "` + rootPathArr[1] + strings.Replace(name, rootPath, "", -1)[1:] + `",
listContent += ` "` + rootPathArr[1] + strings.ReplaceAll(name, rootPath, "")[1:] + `",
`
ext := filepath.Ext(name)
if ext == ".css" || ext == ".js" {
fileName := filepath.Base(name)
reg, _ := regexp.Compile(".min.(.*?)" + ext)
pathsContent += ` "` + reg.ReplaceAllString(fileName, ".min"+ext) + `":"` +
rootPathArr[1] + strings.Replace(name, rootPath, "", -1)[1:] + `",
rootPathArr[1] + strings.ReplaceAll(name, rootPath, "")[1:] + `",
`
}
}
Expand All @@ -55,6 +55,9 @@ var AssetPaths = map[string]string{
}`

err = ioutil.WriteFile(outputPath+"/assets_list.go", []byte(listContent), 0644)
if err != nil {
return
}
err = ioutil.WriteFile(outputPath+"/assets_path.go", []byte(pathsContent), 0644)
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion adm/compile_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func getContentFromDir(content, dirPath, rootPath string) string {

if suffix == ".tmpl" {
fmt.Println(dirPath + f.Name())
content += `"` + strings.Replace(dirPath, rootPath, "", -1) + onlyName + `":` + "`" + str + "`,"
content += `"` + strings.ReplaceAll(dirPath, rootPath, "") + onlyName + `":` + "`" + str + "`,"
}
}

Expand Down
16 changes: 8 additions & 8 deletions adm/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ type dbInfo struct {
}

func initSurvey() {
survey.SelectQuestionTemplate = strings.Replace(survey.SelectQuestionTemplate,
"type to filter", "type to filter, enter to select", -1)
survey.MultiSelectQuestionTemplate = strings.Replace(survey.MultiSelectQuestionTemplate,
"enter to select", "space to select", -1)
survey.SelectQuestionTemplate = strings.ReplaceAll(survey.SelectQuestionTemplate,
"type to filter", "type to filter, enter to select")
survey.MultiSelectQuestionTemplate = strings.ReplaceAll(survey.MultiSelectQuestionTemplate,
"enter to select", "space to select")

survey.SelectQuestionTemplate = strings.Replace(survey.SelectQuestionTemplate,
survey.SelectQuestionTemplate = strings.ReplaceAll(survey.SelectQuestionTemplate,
"Use arrows to move, type to filter, enter to select",
getWord("Use arrows to move, type to filter, enter to select"), -1)
getWord("Use arrows to move, type to filter, enter to select"))

survey.MultiSelectQuestionTemplate = strings.Replace(survey.MultiSelectQuestionTemplate,
survey.MultiSelectQuestionTemplate = strings.ReplaceAll(survey.MultiSelectQuestionTemplate,
"Use arrows to move, space to select, type to filter",
getWord("Use arrows to move, space to select, type to filter"), -1)
getWord("Use arrows to move, space to select, type to filter"))
}

func getDBInfoFromINIConfig(cfg *ini.File, connection string) *dbInfo {
Expand Down
3 changes: 2 additions & 1 deletion adm/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ func generating(cfgFile, connName string) {
}
tables = append([]string{"[" + getWord("select all") + "]"}, tables...)

survey.SelectQuestionTemplate = strings.Replace(survey.SelectQuestionTemplate, "<enter> to select", "<space> to select", -1)
survey.SelectQuestionTemplate = strings.ReplaceAll(survey.SelectQuestionTemplate, "<enter> to select",
"<space> to select")

chooseTables = selects(tables)
if len(chooseTables) == 0 {
Expand Down
28 changes: 13 additions & 15 deletions adm/minify.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,48 @@ func cssMinifier(inputDir, outputFile string, hash bool) {
err := removeOutputFile(outputFile)
if err != nil {
log.Panicln("removeOutputFileError", err)
return
}

files, err := getInputFiles(inputDir)
if err != nil {
log.Panicln("getInputFilesError", err)
return
}

notMinifiedString, err := combineFiles(files, inputDir)
if err != nil {
log.Panicln("combineFilesError", err)
return
}

minifiedString, err := makeMini(notMinifiedString, "text/css")
if err != nil {
log.Panicln("doTheMinifyingError", err)
return
}

if hash && filepath.Ext(outputFile) == ".css" {
m5 := md5.New()
m5.Write([]byte(minifiedString))
_, err := m5.Write([]byte(minifiedString))
if err != nil {
log.Panicln("combineFilesError", err)
}
m5res := hex.EncodeToString(m5.Sum(nil))
outputFile = strings.Replace(outputFile, ".css", "."+m5res[len(m5res)-10:]+".css", -1)
outputFile = strings.ReplaceAll(outputFile, ".css", "."+m5res[len(m5res)-10:]+".css")
}

err = writeOutputFile(minifiedString, outputFile)
if err != nil {
log.Panicln("writeOutputFileError", err)
return
}
}

func jsMinifier(inputDir, outputFile string, hash bool) {
err := removeOutputFile(outputFile)
if err != nil {
log.Panicln("removeOutputFileError", err)
return
}

files, err := getInputFiles(inputDir)
if err != nil {
log.Panicln("getInputFilesError", err)
return
}

var b bytes.Buffer
Expand All @@ -81,7 +77,7 @@ func jsMinifier(inputDir, outputFile string, hash bool) {
filePath := inputDir + name
fileTxt, err := ioutil.ReadFile(filePath)
if err != nil {
return
checkError(err)
}

fmt.Println("file path", filePath)
Expand All @@ -91,26 +87,28 @@ func jsMinifier(inputDir, outputFile string, hash bool) {

minifiedString, err := m.Bytes("text/javascript", fileTxt)
if err != nil {
return
checkError(err)
}

_, err = b.Write(minifiedString)
if err != nil {
return
checkError(err)
}
}

if hash && filepath.Ext(outputFile) == ".js" {
m5 := md5.New()
m5.Write(b.Bytes())
_, err := m5.Write(b.Bytes())
if err != nil {
checkError(err)
}
m5res := hex.EncodeToString(m5.Sum(nil))
outputFile = strings.Replace(outputFile, ".js", "."+m5res[len(m5res)-10:]+".js", -1)
outputFile = strings.ReplaceAll(outputFile, ".js", "."+m5res[len(m5res)-10:]+".js")
}

err = writeOutputFile(b.String(), outputFile)
if err != nil {
checkError(err)
return
}
}

Expand Down
Loading