fix: 复合主键表改为单字段 id 以支持 ent 完整生成

This commit is contained in:
zetaloop
2026-04-24 07:32:52 +08:00
parent c62d743320
commit 5ad579f03c
19 changed files with 324 additions and 82 deletions
+10 -1
View File
@@ -15,6 +15,8 @@ import (
// ShopPlayers is the model entity for the ShopPlayers schema.
type ShopPlayers struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// ShopID holds the value of the "shop_id" field.
ShopID int64 `json:"shop_id,omitempty"`
// PlayerID holds the value of the "player_id" field.
@@ -35,7 +37,7 @@ func (*ShopPlayers) scanValues(columns []string) ([]any, error) {
switch columns[i] {
case shopplayers.FieldIsPrimary:
values[i] = new(sql.NullBool)
case shopplayers.FieldShopID, shopplayers.FieldPlayerID:
case shopplayers.FieldID, shopplayers.FieldShopID, shopplayers.FieldPlayerID:
values[i] = new(sql.NullInt64)
case shopplayers.FieldJoinedAt, shopplayers.FieldLeftAt:
values[i] = new(sql.NullTime)
@@ -54,6 +56,12 @@ func (_m *ShopPlayers) assignValues(columns []string, values []any) error {
}
for i := range columns {
switch columns[i] {
case shopplayers.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case shopplayers.FieldShopID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field shop_id", values[i])
@@ -120,6 +128,7 @@ func (_m *ShopPlayers) Unwrap() *ShopPlayers {
func (_m *ShopPlayers) String() string {
var builder strings.Builder
builder.WriteString("ShopPlayers(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("shop_id=")
builder.WriteString(fmt.Sprintf("%v", _m.ShopID))
builder.WriteString(", ")