|
|
@@ -2,7 +2,6 @@ package db |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_o2o_business.git/db/model" |
|
|
|
zhios_o2o_business_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_o2o_business.git/utils/logx" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
@@ -10,7 +9,7 @@ import ( |
|
|
|
func UserProfileFindByArkID(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("arkid_uid = ?", id).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -19,7 +18,7 @@ func UserProfileFindByArkID(Db *xorm.Engine, id interface{}) (*model.UserProfile |
|
|
|
func UserProfileFindByInviteCode(Db *xorm.Engine, code string) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("invite_code = ?", code).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -28,7 +27,7 @@ func UserProfileFindByInviteCode(Db *xorm.Engine, code string) (*model.UserProfi |
|
|
|
func UserProfileFindByCustomInviteCode(Db *xorm.Engine, code string) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("custom_invite_code = ?", code).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -37,7 +36,7 @@ func UserProfileFindByCustomInviteCode(Db *xorm.Engine, code string) (*model.Use |
|
|
|
func UserProfileFindByInviteCodes(Db *xorm.Engine, codes ...string) (*[]model.UserProfile, error) { |
|
|
|
var m []model.UserProfile |
|
|
|
if err := Db.In("invite_code", codes).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -46,7 +45,7 @@ func UserProfileFindByInviteCodes(Db *xorm.Engine, codes ...string) (*[]model.Us |
|
|
|
func UserProfileFindByCustomInviteCodes(Db *xorm.Engine, codes ...string) (*[]model.UserProfile, error) { |
|
|
|
var m []model.UserProfile |
|
|
|
if err := Db.In("custom_invite_code", codes).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -55,7 +54,7 @@ func UserProfileFindByCustomInviteCodes(Db *xorm.Engine, codes ...string) (*[]mo |
|
|
|
func UserProfileFindByID(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("uid = ?", id).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -64,7 +63,7 @@ func UserProfileFindByID(Db *xorm.Engine, id interface{}) (*model.UserProfile, e |
|
|
|
func UserProfileOrderByNew(Db *xorm.Engine) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("invite_code != ''").OrderBy("uid desc").Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -73,7 +72,7 @@ func UserProfileOrderByNew(Db *xorm.Engine) (*model.UserProfile, error) { |
|
|
|
func UserProfileFindByTaobaoOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("third_party_taobao_oid = ?", openid).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -82,7 +81,7 @@ func UserProfileFindByTaobaoOpenID(Db *xorm.Engine, openid interface{}) (*model. |
|
|
|
func UserProfileFindByQQOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("third_party_qq_openid = ?", openid).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -91,7 +90,7 @@ func UserProfileFindByQQOpenID(Db *xorm.Engine, openid interface{}) (*model.User |
|
|
|
func UserProfileFindByAppleToken(Db *xorm.Engine, token interface{}) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("third_party_apple_token = ?", token).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -100,7 +99,7 @@ func UserProfileFindByAppleToken(Db *xorm.Engine, token interface{}) (*model.Use |
|
|
|
func UserProfileFindByWeChatOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("third_party_wechat_openid = ?", openid).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -109,7 +108,7 @@ func UserProfileFindByWeChatOpenID(Db *xorm.Engine, openid interface{}) (*model. |
|
|
|
func UserProfileFindByWeChatMiniOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("third_party_wechat_mini_openid = ?", openid).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -118,7 +117,7 @@ func UserProfileFindByWeChatMiniOpenID(Db *xorm.Engine, openid interface{}) (*mo |
|
|
|
func UserProfileFindByWeChatUnionID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := Db.Where("third_party_wechat_unionid = ?", openid).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -231,7 +230,7 @@ func UserProfileisExistByRelationID(Db *xorm.Engine, RelationID string) (bool, e |
|
|
|
func UserProfileFindByIDs(Db *xorm.Engine, uids ...int) (*[]model.UserProfile, error) { |
|
|
|
var m []model.UserProfile |
|
|
|
if err := Db.In("uid", uids).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -240,7 +239,7 @@ func UserProfileFindByIDs(Db *xorm.Engine, uids ...int) (*[]model.UserProfile, e |
|
|
|
func UserProfileByPuid(Db *xorm.Engine, puid interface{}) (*[]model.UserProfile, error) { |
|
|
|
var m []model.UserProfile |
|
|
|
if err := Db.Where("parent_uid = ?", puid).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -250,12 +249,12 @@ func UsersProfileInByIds(Db *xorm.Engine, ids []int, limit, start int) (*[]model |
|
|
|
var m []model.UserProfile |
|
|
|
if limit == 0 && start == 0 { |
|
|
|
if err := Db.In("uid", ids).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
if err := Db.In("uid", ids).Limit(limit, start).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -265,7 +264,7 @@ func UsersProfileInByUIDByisVerify(Db *xorm.Engine, ids []int, isVerify interfac |
|
|
|
var m []model.UserProfile |
|
|
|
if err := Db.In("uid", ids).Where("is_verify = ?", isVerify). |
|
|
|
Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -275,12 +274,12 @@ func UsersProfileInByIdsByDesc(Db *xorm.Engine, ids []int, limit, start int, c s |
|
|
|
var m []model.UserProfile |
|
|
|
if limit == 0 && start == 0 { |
|
|
|
if err := Db.In("uid", ids).Desc(c).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
if err := Db.In("uid", ids).Desc(c).Limit(limit, start).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -290,12 +289,12 @@ func UsersProfileInByIdsByAsc(Db *xorm.Engine, ids []int, limit, start int, c st |
|
|
|
var m []model.UserProfile |
|
|
|
if limit == 0 && start == 0 { |
|
|
|
if err := Db.In("uid", ids).Asc(c).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
if err := Db.In("uid", ids).Asc(c).Limit(limit, start).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -304,7 +303,7 @@ func UsersProfileInByIdsByAsc(Db *xorm.Engine, ids []int, limit, start int, c st |
|
|
|
func UsersProfileByTaobaoShateIdNotNull(Db *xorm.Engine, limit, start int) (*[]model.UserProfile, error) { |
|
|
|
var m []model.UserProfile |
|
|
|
if err := Db.Where("acc_taobao_share_id > 0").Limit(limit, start).Find(&m); err != nil { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -357,7 +356,7 @@ func UserProfileUpdate(Db *xorm.Engine, uid interface{}, userProfile *model.User |
|
|
|
affected, err = Db.Where("uid=?", uid).Update(userProfile) |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return 0, zhios_o2o_business_logx.Warn(err) |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |
|
|
@@ -374,7 +373,7 @@ func UserProfileUpdateByArkID(Db *xorm.Engine, arkid interface{}, userProfile *m |
|
|
|
affected, err = Db.Where("arkid_uid=?", arkid).Update(userProfile) |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return 0, zhios_o2o_business_logx.Warn(err) |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |
|
|
@@ -387,7 +386,7 @@ func UserProfileDelete(Db *xorm.Engine, uid interface{}) (int64, error) { |
|
|
|
func UserProfileFindByIdWithSession(session *xorm.Session, uid int) (*model.UserProfile, error) { |
|
|
|
var m model.UserProfile |
|
|
|
if has, err := session.Where("uid = ?", uid).Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_o2o_business_logx.Warn(err) |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
@@ -404,7 +403,7 @@ func UserProfileUpdateWithSession(session *xorm.Session, uid interface{}, userPr |
|
|
|
affected, err = session.Where("uid=?", uid).Update(userProfile) |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return 0, zhios_o2o_business_logx.Warn(err) |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |