Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vssue]Vssue Dev #2

Open
sunshinev opened this issue May 13, 2020 · 14 comments
Open

[Vssue]Vssue Dev #2

sunshinev opened this issue May 13, 2020 · 14 comments
Labels

Comments

@sunshinev
Copy link
Owner

https://sunshinev.github.io/go-sword-home/forum

@sunshinev
Copy link
Owner Author

First

@sunshinev
Copy link
Owner Author

欢迎大家在这里讨论问题

@sunshinev
Copy link
Owner Author

如果使用过程中,有任何问题,也可以在这里反馈

@andrewlcgu
Copy link

支持一下

@sunshinev
Copy link
Owner Author

@andrewlcgu

支持一下

感谢支持

@lizeyun
Copy link

lizeyun commented May 20, 2020

cannot use data["id"] (type int) as type int64 in field value
image
我的jianbi建表语句,请问是有什么冲突吗

@sunshinev
Copy link
Owner Author

@lizeyun

cannot use data["id"] (type int) as type int64 in field value
image
我的jianbi建表语句,请问是有什么冲突吗

这个可能是解析表结构的时候,没有解析bigint导致的。建表的时候,可以使用int类型试下

@sunshinev
Copy link
Owner Author

@lizeyun

cannot use data["id"] (type int) as type int64 in field value
image
我的jianbi建表语句,请问是有什么冲突吗

底层的db to struct解析bigint的时候,转换成了int64
20d8d7c25a5a77a67feaa9364bb723661590116017.jpg

@sunshinev
Copy link
Owner Author

sunshinev commented May 25, 2020

为什么用go做这个代码生成有一些问题呢。因为数据库转换结构体的时候,有个类型的映射。生成前端代码的时候,JavaScript也要做类型映射。所以涉及到数据库、golang、js的类型对应。

在建表的时候尽可能的使用

数据库type golang
"tinyint", "int", "smallint", "mediumint" golangInt
"bigint" golangInt64
"char", "enum", "varchar", "longtext", "mediumtext", "text", "tinytext", "json" "string"
"date", "datetime", "time", "timestamp" golangTime
"decimal", "double" golangFloat64
"float" golangFloat32
"binary", "blob", "longblob", "mediumblob", "varbinary" golangByteArray

@sunshinev
Copy link
Owner Author

v0.0.7 修改了生成项目的数据连接无法连接远程数据库的问题,增加了host:port

db, err := gorm.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", d.User, d.Password, d.Host, d.Port, d.Database))

@noahlias
Copy link

noahlias commented Jul 8, 2020

@sunshinev some problem about the new project by go-sword generate :
1: id/created_at/updated_at this column is required in table and it will influences the frontend style
image

2: the model generate is wrong which i need to modify the package model
image

@noahlias
Copy link

noahlias commented Jul 8, 2020

@sunshinev some problem about the new project by go-sword generate :
1: id/created_at/updated_at this column is required in table and it will influences the frontend style
image

2: the model generate is wrong which i need to modify the package model
image

More interesting when i add some the three column :
then deploy the project ;it didn't Reproduce the second problem

@sunshinev
Copy link
Owner Author

@Alias4bb

@sunshinev some problem about the new project by go-sword generate :
1: id/created_at/updated_at this column is required in table and it will influences the frontend style
image

2: the model generate is wrong which i need to modify the package model
image

More interesting when i add some the three column :
then deploy the project ;it didn't Reproduce the second problem

当初设计的时候,为了满足生成的页面结构统一,所以 id/created_at/updated_at 这三个字段是必须的

@sunshinev
Copy link
Owner Author

v1.0.0更新

  1. 底层db转换struct进行了重写
  2. 使用切片代替map,解决字段排序问题
  3. 服务启动进行了重写,添加config包来解决全局配置GlobalConfig
  4. 调整后的结构体主要有int32/string/float64/time.Time四种类型

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants