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

一些小建议 #73

Open
whiteworker opened this issue Mar 26, 2020 · 5 comments
Open

一些小建议 #73

whiteworker opened this issue Mar 26, 2020 · 5 comments

Comments

@whiteworker
Copy link

首先感谢开源,下面是一些小建议
1、QueryParam可以用gin的bind绑定整个实体,不用一个个属性赋值
2、QueryParam可以继承分页,不用每次调用方法GetPaginationParam
3、swagger不指定host
4、校验不通过,将详细的错误返回
5、实体增加required (cli)

@LyricTian
Copy link
Owner

LyricTian commented Mar 31, 2020

OK,多谢,我会在 6.0 版本中尝试修复这些问题.
可以随时关注 6.0 的更新:https://github.com/LyricTian/gin-admin/tree/v6.0

@ngudeveloper
Copy link

ngudeveloper commented May 2, 2020

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了。可以忽略以上建议。

@LyricTian
Copy link
Owner

OK!

@whiteworker
Copy link
Author

之后版本更新后,Id ,created_by,created_time 被聚合在Model中,个人建议entity应该保持纯净,只留主外键等sql结构,尽量sql表结构一致,无需聚合,到时候拿cli刷的时候也没有太大的问题

@chenyu1990
Copy link
Contributor

搞一个自定义config的扩展。框架的config就不用和扩展的config混合了

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

No branches or pull requests

4 participants