Comments (5)
OK,多谢,我会在 6.0 版本中尝试修复这些问题.
可以随时关注 6.0 的更新:https://github.com/LyricTian/gin-admin/tree/v6.0
from gin-admin.
Model 中的RecordID和ID用起来有些别扭而且意义有些混淆。因为数据库查询时一般外键和主键的关系是,如果User表里主键是ID,那么别的表里使用它时,很自然应该是UserID。但现在因为Entity里实际有两个ID,一个是自增量ID,类型是number,另一个是 UUID,类型是String。而在程序中实际使用的是UUID那个,也就是RecordID。这样就会很别扭。考虑到Scale,UUID是必要的,自增量ID也是需要的。所以最好两者都保留但是把原来的ID列名改为RecordID,而UUID的列改名为ID。这样更符合用户习惯,而且从意义上来说,RecordID本来就是那条记录的ID,ID是实际数据关系中的数据标示。
User.RecordID=xxxx.UserID
or
User.ID=xxxx.UserID
?
供参考。
// Model base model
type Model struct {
RecordID int `gorm:"column:record_id;primary_key;auto_increment;"`
CreatedAt time.Time `gorm:"column:created_at;"`
UpdatedAt time.Time `gorm:"column:updated_at;"`
DeletedAt *time.Time `gorm:"column:deleted_at;index;"`
}
-> 或者保持这种internal int,external uuid的结构,但把RecordID改为其它一个比较容易懂的列名。
比如:
// Model base model
type Model struct {
ID int `gorm:"column:id;primary_key;auto_increment;"`
CreatedAt time.Time `gorm:"column:created_at;"`
UpdatedAt time.Time `gorm:"column:updated_at;"`
DeletedAt *time.Time `gorm:"column:deleted_at;index;"`
}
// Model base model
type User struct {
ExtID string `gorm:"column:ext_id"`
UUID string `gorm:"column:uuid"`
}
因为RecordID给人感觉是数据增量的ID,和当前record的ID是一个意思。
-> ah, 看到新版本了,已经统一一个ID了。可以忽略以上建议。
from gin-admin.
OK!
from gin-admin.
之后版本更新后,Id ,created_by,created_time 被聚合在Model中,个人建议entity应该保持纯净,只留主外键等sql结构,尽量sql表结构一致,无需聚合,到时候拿cli刷的时候也没有太大的问题
from gin-admin.
搞一个自定义config的扩展。框架的config就不用和扩展的config混合了
from gin-admin.
Related Issues (20)
- Start failed - sonyflake not created HOT 2
- ParseJSON 建议优化一下
- 有人在生产中使用吗
- swagger 报错:No operations defined in spec!
- 有人遇到过程序偶尔自己退出的问题吗
- 问个不关代码的,V10什么时候发 HOT 7
- Injector结构体的CasbinEnforcer、Auth字段是否多余 HOT 1
- TablePrefix没有生效 HOT 3
- jwtauth store service is not working ?
- Failed to read configuration file
- rbac_model.conf should use keyMatch3 HOT 1
- gin-admin-cli生成的项目有问题 HOT 3
- 感觉启动速度有点慢
- 有交流群吗 HOT 1
- gin-admin-cli生成代码报错 HOT 1
- /api/v1/loggers?current=1&pageSize=10 ERROR: column b.id does not exist (SQLSTATE 42703) HOT 1
- [功能建议] Module 是不是可以考虑使用接口 ?
- Error while generate a new module
- 移动前端api 怎么实现 HOT 1
- is there a way to generate ReactJS files from Swagger?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gin-admin.