go-sword icon indicating copy to clipboard operation
go-sword copied to clipboard

[Vssue]Vssue Dev

Open sunshinev opened this issue 4 years ago • 14 comments

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

sunshinev avatar May 13 '20 09:05 sunshinev

First

sunshinev avatar May 13 '20 09:05 sunshinev

欢迎大家在这里讨论问题

sunshinev avatar May 13 '20 09:05 sunshinev

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

sunshinev avatar May 13 '20 10:05 sunshinev

支持一下

andrewlcgu avatar May 13 '20 11:05 andrewlcgu

@andrewlcgu

支持一下

感谢支持

sunshinev avatar May 13 '20 11:05 sunshinev

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

lizeyun avatar May 20 '20 06:05 lizeyun

@lizeyun

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

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

sunshinev avatar May 22 '20 02:05 sunshinev

@lizeyun

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

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

sunshinev avatar May 22 '20 02:05 sunshinev

为什么用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 avatar May 25 '20 03:05 sunshinev

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))

sunshinev avatar May 26 '20 06:05 sunshinev

@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 avatar Jul 08 '20 08:07 noahlias

@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

noahlias avatar Jul 08 '20 08:07 noahlias

@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 avatar Sep 06 '20 14:09 sunshinev

v1.0.0更新

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

sunshinev avatar Sep 11 '20 15:09 sunshinev