Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
codebuilder
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张建华@五瓣科技
codebuilder
Commits
8dc8664b
Commit
8dc8664b
authored
May 07, 2020
by
jianhua.zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.生成结构体按照驼峰命名法
2.添加sql映射结构体类型
parent
81e205e1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
2 deletions
+18
-2
codebuilder.iml
.idea/codebuilder.iml
+0
-0
modules.xml
.idea/modules.xml
+1
-1
DBUtil.go
util/DBUtil.go
+16
-1
TypeMap.go
util/TypeMap.go
+1
-0
No files found.
.idea/
postgre-struct-maker-mast
er.iml
→
.idea/
codebuild
er.iml
View file @
8dc8664b
File moved
.idea/modules.xml
View file @
8dc8664b
...
...
@@ -2,7 +2,7 @@
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/
postgre-struct-maker-master.iml"
filepath=
"$PROJECT_DIR$/.idea/postgre-struct-maker-mast
er.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/
codebuilder.iml"
filepath=
"$PROJECT_DIR$/.idea/codebuild
er.iml"
/>
</modules>
</component>
</project>
\ No newline at end of file
util/DBUtil.go
View file @
8dc8664b
package
util
import
(
"../model"
"database/sql"
"fmt"
"github.com/BlackCarDriver/config"
"github.com/BlackCarDriver/log"
"github.com/codebuilder/model"
_
"github.com/go-sql-driver/mysql"
"strings"
)
...
...
@@ -90,6 +90,7 @@ func Report() {
}
jsonName
:=
strings
.
ToLower
(
colName
)
vname
:=
strings
.
ToUpper
(
jsonName
[
0
:
1
])
+
jsonName
[
1
:
]
vname
=
CamelCase
(
vname
)
goRes
.
Write
(
"
\t
%-10s %-10s `json:
\"
%s
\"
`
\n
"
,
vname
,
retype
,
jsonName
)
record
+=
"
\n
"
record
+=
vname
...
...
@@ -109,3 +110,17 @@ func Report() {
fmt
.
Println
(
"表"
,
tableName
,
"映射结构体已完成."
)
}
}
func
CamelCase
(
field
string
)
string
{
var
ret
string
if
strings
.
Contains
(
field
,
"_"
)
{
arr
:=
strings
.
Split
(
field
,
"_"
)
for
str
:=
range
arr
{
ret
+=
strings
.
ToUpper
(
arr
[
str
][
0
:
1
])
+
arr
[
str
][
1
:
]
}
}
else
{
return
field
}
return
ret
}
util/TypeMap.go
View file @
8dc8664b
...
...
@@ -11,6 +11,7 @@ var MGMap = map[string]string{
"boolean"
:
"bool"
,
"timestamp"
:
"time.Time"
,
"date"
:
"time.Time"
,
"text"
:
"string"
,
}
//MySQL type -> typeScript type
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment