add json tag lower camel case

This commit is contained in:
cuiyaming
2021-03-03 15:24:13 +08:00
parent 09482dfc19
commit 845d08585f
3 changed files with 10 additions and 4 deletions

View File

@@ -131,7 +131,7 @@ func (m *_Model) genTableElement(cols []ColumnsInfo) (el []genstruct.GenElement)
if isPK && config.GetIsWebTagPkHidden() {
tmp.AddTag(_tagJSON, "-")
} else {
tmp.AddTag(_tagJSON, mybigcamel.UnMarshal(v.Name))
tmp.AddTag(_tagJSON, mybigcamel.UnSmallMarshal(mybigcamel.Marshal(v.Name)))
}
}
@@ -174,7 +174,7 @@ func (m *_Model) genForeignKey(col ColumnsInfo) (fklist []genstruct.GenElement)
// json tag
if config.GetIsWEBTag() {
tmp.AddTag(_tagJSON, mybigcamel.UnMarshal(v.TableName)+"_list")
tmp.AddTag(_tagJSON, mybigcamel.UnSmallMarshal(mybigcamel.Marshal(v.TableName))+"List")
}
fklist = append(fklist, tmp)

View File

@@ -3,9 +3,8 @@ package model
import (
"encoding/json"
"fmt"
"testing"
"github.com/xxjwxc/gormt/data/config"
"testing"
)
func TestTypeName(t *testing.T) {
@@ -19,6 +18,8 @@ func TestTools(t *testing.T) {
// out, _ := json.Marshal(pkg)
// tools.WriteFile("test.txt", []string{string(out)}, true)
config.SetIsWEBTag(true)
config.SetIsOutFunc(false)
list, _ := Generate(pkg)
fmt.Println(list)