更新model
This commit is contained in:
@@ -101,8 +101,8 @@ func (obj *_ExampleMgr) GetFromUserID(UserID int) (result Example, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromUserID 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetsBatchFromUserID(UserIDs []int) (results []*Example, err error) {
|
||||
// GetBatchFromUserID 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetBatchFromUserID(UserIDs []int) (results []*Example, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("user_id IN (?)", UserIDs).Find(&results).Error
|
||||
|
||||
return
|
||||
@@ -115,8 +115,8 @@ func (obj *_ExampleMgr) GetFromName(Name string) (results []*Example, err error)
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromName 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetsBatchFromName(Names []string) (results []*Example, err error) {
|
||||
// GetBatchFromName 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetBatchFromName(Names []string) (results []*Example, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("name IN (?)", Names).Find(&results).Error
|
||||
|
||||
return
|
||||
@@ -129,8 +129,8 @@ func (obj *_ExampleMgr) GetFromSex(Sex int) (results []*Example, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromSex 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetsBatchFromSex(Sexs []int) (results []*Example, err error) {
|
||||
// GetBatchFromSex 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetBatchFromSex(Sexs []int) (results []*Example, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("sex IN (?)", Sexs).Find(&results).Error
|
||||
|
||||
return
|
||||
@@ -143,8 +143,8 @@ func (obj *_ExampleMgr) GetFromJob(Job int) (results []*Example, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromJob 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetsBatchFromJob(Jobs []int) (results []*Example, err error) {
|
||||
// GetBatchFromJob 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetBatchFromJob(Jobs []int) (results []*Example, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("job IN (?)", Jobs).Find(&results).Error
|
||||
|
||||
return
|
||||
@@ -157,9 +157,25 @@ func (obj *_ExampleMgr) GetFromID(ID int) (results []*Example, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromID 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetsBatchFromID(IDs []int) (results []*Example, err error) {
|
||||
// GetBatchFromID 批量唯一主键查找
|
||||
func (obj *_ExampleMgr) GetBatchFromID(IDs []int) (results []*Example, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id IN (?)", IDs).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_ExampleMgr) FetchByPrimaryKey(UserID int) (result Example, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("user_id = ?", UserID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FetchByIndex primay or index 获取唯一内容
|
||||
func (obj *_ExampleMgr) FetchByIndex(Sex int) (result Example, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("sex = ?", Sex).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -149,8 +149,8 @@ func (obj *_OrganMgr) GetFromID(ID int) (result Organ, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromID 批量唯一主键查找
|
||||
func (obj *_OrganMgr) GetsBatchFromID(IDs []int) (results []*Organ, err error) {
|
||||
// GetBatchFromID 批量唯一主键查找
|
||||
func (obj *_OrganMgr) GetBatchFromID(IDs []int) (results []*Organ, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id IN (?)", IDs).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
@@ -185,8 +185,8 @@ func (obj *_OrganMgr) GetFromUserID(UserID int) (results []*Organ, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromUserID 批量唯一主键查找
|
||||
func (obj *_OrganMgr) GetsBatchFromUserID(UserIDs []int) (results []*Organ, err error) {
|
||||
// GetBatchFromUserID 批量唯一主键查找
|
||||
func (obj *_OrganMgr) GetBatchFromUserID(UserIDs []int) (results []*Organ, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("user_id IN (?)", UserIDs).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
@@ -221,8 +221,8 @@ func (obj *_OrganMgr) GetFromType(Type int) (results []*Organ, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromType 批量唯一主键查找
|
||||
func (obj *_OrganMgr) GetsBatchFromType(Types []int) (results []*Organ, err error) {
|
||||
// GetBatchFromType 批量唯一主键查找
|
||||
func (obj *_OrganMgr) GetBatchFromType(Types []int) (results []*Organ, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("type IN (?)", Types).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
@@ -257,8 +257,8 @@ func (obj *_OrganMgr) GetFromScore(Score int) (results []*Organ, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromScore 批量唯一主键查找
|
||||
func (obj *_OrganMgr) GetsBatchFromScore(Scores []int) (results []*Organ, err error) {
|
||||
// GetBatchFromScore 批量唯一主键查找
|
||||
func (obj *_OrganMgr) GetBatchFromScore(Scores []int) (results []*Organ, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("score IN (?)", Scores).Find(&results).Error
|
||||
if err == nil && obj.isRelated {
|
||||
for i := 0; i < len(results); i++ {
|
||||
@@ -274,3 +274,39 @@ func (obj *_OrganMgr) GetsBatchFromScore(Scores []int) (results []*Organ, err er
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_OrganMgr) FetchByPrimaryKey(ID int) (result Organ, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("id = ?", ID).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info []User //
|
||||
err = obj.DB.Table("user").Where("sex = ?", result.UserID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserList = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FetchByIndex primay or index 获取唯一内容
|
||||
func (obj *_OrganMgr) FetchByIndex(UserID int) (result Organ, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("user_id = ?", UserID).Find(&result).Error
|
||||
if err == nil && obj.isRelated {
|
||||
{
|
||||
var info []User //
|
||||
err = obj.DB.Table("user").Where("sex = ?", result.UserID).Find(&info).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
result.UserList = info
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ func (obj *_UserMgr) GetFromUserID(UserID int) (result User, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromUserID 批量唯一主键查找
|
||||
func (obj *_UserMgr) GetsBatchFromUserID(UserIDs []int) (results []*User, err error) {
|
||||
// GetBatchFromUserID 批量唯一主键查找
|
||||
func (obj *_UserMgr) GetBatchFromUserID(UserIDs []int) (results []*User, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("userId IN (?)", UserIDs).Find(&results).Error
|
||||
|
||||
return
|
||||
@@ -110,8 +110,8 @@ func (obj *_UserMgr) GetFromName(Name string) (results []*User, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromName 批量唯一主键查找
|
||||
func (obj *_UserMgr) GetsBatchFromName(Names []string) (results []*User, err error) {
|
||||
// GetBatchFromName 批量唯一主键查找
|
||||
func (obj *_UserMgr) GetBatchFromName(Names []string) (results []*User, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("name IN (?)", Names).Find(&results).Error
|
||||
|
||||
return
|
||||
@@ -124,8 +124,8 @@ func (obj *_UserMgr) GetFromSex(Sex int) (results []*User, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromSex 批量唯一主键查找
|
||||
func (obj *_UserMgr) GetsBatchFromSex(Sexs []int) (results []*User, err error) {
|
||||
// GetBatchFromSex 批量唯一主键查找
|
||||
func (obj *_UserMgr) GetBatchFromSex(Sexs []int) (results []*User, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("sex IN (?)", Sexs).Find(&results).Error
|
||||
|
||||
return
|
||||
@@ -138,9 +138,25 @@ func (obj *_UserMgr) GetFromJob(Job int) (results []*User, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetsBatchFromJob 批量唯一主键查找
|
||||
func (obj *_UserMgr) GetsBatchFromJob(Jobs []int) (results []*User, err error) {
|
||||
// GetBatchFromJob 批量唯一主键查找
|
||||
func (obj *_UserMgr) GetBatchFromJob(Jobs []int) (results []*User, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("job IN (?)", Jobs).Find(&results).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//////////////////////////primary index case ////////////////////////////////////////////
|
||||
|
||||
// FetchByPrimaryKey primay or index 获取唯一内容
|
||||
func (obj *_UserMgr) FetchByPrimaryKey(UserID int) (result User, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("userId = ?", UserID).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FetchByIndex primay or index 获取唯一内容
|
||||
func (obj *_UserMgr) FetchByIndex(Sex int) (result User, err error) {
|
||||
err = obj.DB.Table(obj.GetTableName()).Where("sex = ?", Sex).Find(&result).Error
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user