interface -> any
This commit is contained in:
18
base.go
18
base.go
@ -25,7 +25,7 @@ type BaseDao struct {
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:06 下午 2021/8/8
|
||||
func (b *BaseDao) Create(dbInstance *gorm.DB, data interface{}, optionList ...SetOption) error {
|
||||
func (b *BaseDao) Create(dbInstance *gorm.DB, data any, optionList ...SetOption) error {
|
||||
o := &Option{}
|
||||
for _, itemFunc := range optionList {
|
||||
itemFunc(o)
|
||||
@ -42,7 +42,7 @@ func (b *BaseDao) Create(dbInstance *gorm.DB, data interface{}, optionList ...Se
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:12 下午 2021/8/8
|
||||
func (b *BaseDao) Update(dbInstance *gorm.DB, updateData interface{}, optionFuncList ...SetOption) (int64, error) {
|
||||
func (b *BaseDao) Update(dbInstance *gorm.DB, updateData any, optionFuncList ...SetOption) (int64, error) {
|
||||
dbInstance = b.setTxCondition(dbInstance, optionFuncList...)
|
||||
r := dbInstance.Updates(updateData)
|
||||
return r.RowsAffected, r.Error
|
||||
@ -53,7 +53,7 @@ func (b *BaseDao) Update(dbInstance *gorm.DB, updateData interface{}, optionFunc
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 17:05 2024/1/13
|
||||
func (b *BaseDao) UpdateOne(dbInstance *gorm.DB, updateData interface{}, optionFuncList ...SetOption) (int64, error) {
|
||||
func (b *BaseDao) UpdateOne(dbInstance *gorm.DB, updateData any, optionFuncList ...SetOption) (int64, error) {
|
||||
optionFuncList = append(optionFuncList, WithLimit(1, 0))
|
||||
return b.Update(dbInstance, updateData, optionFuncList...)
|
||||
}
|
||||
@ -63,7 +63,7 @@ func (b *BaseDao) UpdateOne(dbInstance *gorm.DB, updateData interface{}, optionF
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:14 下午 2021/8/8
|
||||
func (b *BaseDao) List(dbInstance *gorm.DB, result interface{}, optionFuncList ...SetOption) error {
|
||||
func (b *BaseDao) List(dbInstance *gorm.DB, result any, optionFuncList ...SetOption) error {
|
||||
dbInstance = b.setTxCondition(dbInstance, optionFuncList...)
|
||||
return dbInstance.Find(result).Error
|
||||
}
|
||||
@ -73,7 +73,7 @@ func (b *BaseDao) List(dbInstance *gorm.DB, result interface{}, optionFuncList .
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:46 2023/2/9
|
||||
func (b *BaseDao) Delete(dbInstance *gorm.DB, dataModel interface{}, optionFuncList ...SetOption) (int64, error) {
|
||||
func (b *BaseDao) Delete(dbInstance *gorm.DB, dataModel any, optionFuncList ...SetOption) (int64, error) {
|
||||
dbInstance = dbInstance.Model(dataModel)
|
||||
dbInstance = b.setTxCondition(dbInstance, optionFuncList...).Delete(dataModel)
|
||||
return dbInstance.RowsAffected, dbInstance.Error
|
||||
@ -84,7 +84,7 @@ func (b *BaseDao) Delete(dbInstance *gorm.DB, dataModel interface{}, optionFuncL
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 8:25 下午 2021/8/8
|
||||
func (b *BaseDao) Detail(dbInstance *gorm.DB, result interface{}, optionFuncList ...SetOption) error {
|
||||
func (b *BaseDao) Detail(dbInstance *gorm.DB, result any, optionFuncList ...SetOption) error {
|
||||
dbInstance = b.setTxCondition(dbInstance, optionFuncList...)
|
||||
return dbInstance.First(result).Error
|
||||
}
|
||||
@ -94,12 +94,12 @@ func (b *BaseDao) Detail(dbInstance *gorm.DB, result interface{}, optionFuncList
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:14 2023/10/15
|
||||
func (b *BaseDao) DetailByPrimaryID(dbInstance *gorm.DB, result interface{}, primaryID interface{}, primaryKey ...string) error {
|
||||
func (b *BaseDao) DetailByPrimaryID(dbInstance *gorm.DB, result any, primaryID any, primaryKey ...string) error {
|
||||
primaryKeyField := "id"
|
||||
if len(primaryKey) > 0 {
|
||||
primaryKeyField = primaryKey[0]
|
||||
}
|
||||
return b.Detail(dbInstance, result, WithWhere(map[string]interface{}{
|
||||
return b.Detail(dbInstance, result, WithWhere(map[string]any{
|
||||
primaryKeyField: primaryID,
|
||||
}))
|
||||
}
|
||||
@ -253,7 +253,7 @@ func (b *BaseDao) setTxCondition(tx *gorm.DB, optionFuncList ...SetOption) *gorm
|
||||
// or 语句
|
||||
if nil != o.OR {
|
||||
expression := ""
|
||||
valList := make([]interface{}, 0)
|
||||
valList := make([]any, 0)
|
||||
for _, o := range o.OR {
|
||||
if len(expression) > 0 {
|
||||
expression = expression + " OR "
|
||||
|
Reference in New Issue
Block a user