Giter VIP home page Giter VIP logo

Comments (5)

LyricTian avatar LyricTian commented on May 17, 2024

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

from gin-admin.

ngudeveloper avatar ngudeveloper commented on May 17, 2024

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.

LyricTian avatar LyricTian commented on May 17, 2024

OK!

from gin-admin.

whiteworker avatar whiteworker commented on May 17, 2024

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

from gin-admin.

chenyu1990 avatar chenyu1990 commented on May 17, 2024

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

from gin-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.