表结构 type BaseModel struct { ID int64 gorm:"primaryKey;autoIncrement" CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt gorm:"index" }

type UserPowDeclaring struct { BaseModel TradeUnitID int64 gorm:"uniqueIndex:idx_id_time_type" TradeUnitName string gorm:"needDes" PriceArea string gorm:"comment:河东/河西" Time time.Time gorm:"uniqueIndex:idx_id_time_type" Status int32 gorm:"index;comment:1-未提交 2-已提交 3-已通过 4-已驳回" PowPlanType int32 gorm:"uniqueIndex:idx_id_time_type;comment:1-月度用电计划 2-月内用电计划 3-现货用电计划" DeclareType int32 gorm:"comment:1:导入" UserType int32 //用户类型 1:现货 2:非现货 ContractTransfer string //是否参与合同转让 SalesAccount string //户号 }

使用方式 if err = db.Debug().Clauses( clause.Returning{Columns: []clause.Column{{Name: "id"}}}, clause.OnConflict{ Columns: []clause.Column{{Name: "trade_unit_id"}, {Name: "time"}, {Name: "pow_plan_type"}}, DoUpdates: clause.AssignmentColumns([]string{"trade_unit_name", "price_area", "declare_type", "user_type", "contract_transfer"}), }).Create(&userMonthDeclare).Error; err != nil { resource.BusinessAlarmSend(fmt.Sprintf("date:%v err:%v 生成用户月度申报失败", zeroTm, err.Error())) return nil, err }

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking