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