增加根据主键ID查询详情
This commit is contained in:
parent
2a7f06060d
commit
3164f53b99
15
base.go
15
base.go
@ -78,6 +78,21 @@ func (b *BaseDao) Detail(dbInstance *gorm.DB, result interface{}, optionFuncList
|
||||
return dbInstance.First(result).Error
|
||||
}
|
||||
|
||||
// DetailByPrimaryID ...
|
||||
//
|
||||
// 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 {
|
||||
primaryKeyField := "id"
|
||||
if len(primaryKey) > 0 {
|
||||
primaryKeyField = primaryKey[0]
|
||||
}
|
||||
return b.Detail(dbInstance, result, WithWhere(map[string]interface{}{
|
||||
primaryKeyField: primaryID,
|
||||
}))
|
||||
}
|
||||
|
||||
// IsNotFound 增加结果是否为数据不存在的判断
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
|
Loading…
Reference in New Issue
Block a user