Skip to content

Commit

Permalink
version v0.6.7
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Oct 1, 2021
1 parent cf03732 commit dfa40ad
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 26 deletions.
38 changes: 19 additions & 19 deletions data/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 25 additions & 1 deletion global/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestProcessDelete(t *testing.T) {
}

func TestProcessSetting(t *testing.T) {
args := []interface{}{"service"}
args := []interface{}{"service", ""}
process := gou.NewProcess("xiang.table.Setting", args...)
response := table.ProcessSetting(process)
assert.NotNil(t, response)
Expand All @@ -125,3 +125,27 @@ func TestProcessSetting(t *testing.T) {
assert.True(t, res.Has("view"))
assert.True(t, res.Has("insert"))
}
func TestProcessSettingList(t *testing.T) {
args := []interface{}{"service", "list"}
process := gou.NewProcess("xiang.table.Setting", args...)
response := table.ProcessSetting(process)
assert.NotNil(t, response)
res := any.Of(response).Map()
assert.True(t, res.Has("actions"))
assert.True(t, res.Has("layout"))
assert.True(t, res.Has("primary"))
}

func TestProcessSettingListEdit(t *testing.T) {
args := []interface{}{"service", "list, edit"}
process := gou.NewProcess("xiang.table.Setting", args...)
response := table.ProcessSetting(process)
assert.NotNil(t, response)
res := any.Of(response).MapStr().Dot()
assert.True(t, res.Has("list.actions"))
assert.True(t, res.Has("list.layout"))
assert.True(t, res.Has("list.primary"))
assert.True(t, res.Has("edit.actions"))
assert.True(t, res.Has("edit.layout"))
assert.True(t, res.Has("edit.primary"))
}
2 changes: 1 addition & 1 deletion global/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// VERSION 版本号
const VERSION = "0.6.6"
const VERSION = "0.6.7"

// DOMAIN 许可域
const DOMAIN = "*.iqka.com"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/spf13/cobra v1.2.1 // indirect
github.com/stretchr/testify v1.7.0
github.com/yaoapp/gou v0.0.0-20211001062655-04dd63da82aa // indirect
github.com/yaoapp/kun v0.6.5
github.com/yaoapp/kun v0.6.7
github.com/yaoapp/xun v0.5.2 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ github.com/yaoapp/kun v0.6.4 h1:5iEoZwaE0GZCLzB5uGmEr8X547CGvy0L61Ochmp47nY=
github.com/yaoapp/kun v0.6.4/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA=
github.com/yaoapp/kun v0.6.5 h1:RNEQp8EIiyGKyX64QfyoP8OreQBg0cCtF15xwUEUCNI=
github.com/yaoapp/kun v0.6.5/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA=
github.com/yaoapp/kun v0.6.6 h1:Rkj3d5J+nEXps1JCRPBSvajsvaSNs7ekQAKqVlcqjBE=
github.com/yaoapp/kun v0.6.6/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA=
github.com/yaoapp/kun v0.6.7 h1:OgdArT+RLC6KI4LV1mpPFZLQijIQ/PdMP7S76NCn+BY=
github.com/yaoapp/kun v0.6.7/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA=
github.com/yaoapp/xun v0.5.2 h1:DedZ26FpcXfkLnPKXzJsrbVmpWDRx9adUo8AvOcNT+g=
github.com/yaoapp/xun v0.5.2/go.mod h1:y107NMHO635nhqJxMt582i1iqLjnNxAoeYr5/500UBw=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
29 changes: 26 additions & 3 deletions table/process.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package table

import (
"strings"

"github.com/yaoapp/gou"
"github.com/yaoapp/kun/maps"
)
Expand Down Expand Up @@ -82,15 +84,19 @@ func ProcessDelete(process *gou.Process) interface{} {
// ProcessSetting xiang.table.Setting
// 删除指定主键值的数据记录, 请求成功返回null
func ProcessSetting(process *gou.Process) interface{} {
process.ValidateArgNums(1)
process.ValidateArgNums(2)
name := process.ArgsString(0)
field := process.ArgsString(1)
table := Select(name)
api := table.APIs["setting"]
if process.NumOfArgsIs(2) && api.IsAllow(process.Args[1]) {
return nil
}

fields := strings.Split(field, ",")
if api.ProcessIs("xiang.table.Setting") {
return maps.Map{

setting := maps.Map{
"name": table.Name,
"title": table.Title,
"decription": table.Decription,
Expand All @@ -101,7 +107,24 @@ func ProcessSetting(process *gou.Process) interface{} {
"view": table.View,
"insert": table.Insert,
}

if len(fields) == 1 && setting.Has(fields[0]) {
field := strings.TrimSpace(fields[0])
return setting.Get(field)
}

if len(fields) > 1 {
res := maps.Map{}
for _, field := range fields {
field = strings.TrimSpace(field)
if setting.Has(field) {
res.Set(field, setting.Get(field))
}
}
return res
}
return setting
}

return gou.NewProcess(api.Process).Run()
return gou.NewProcess(api.Process, fields).Run()
}
2 changes: 1 addition & 1 deletion xiang/apis/table.http.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"path": "/:name/setting",
"method": "GET",
"process": "xiang.table.Setting",
"in": ["$param.name"],
"in": ["$param.name", "$query.select"],
"out": {
"status": 200,
"type": "application/json"
Expand Down

0 comments on commit dfa40ad

Please sign in to comment.