@@ -12,4 +12,5 @@ type UserTagDao interface { | |||||
UserTagUpdate(id interface{}, userTag *model.UserTag, forceColumns ...string) (int64, error) | UserTagUpdate(id interface{}, userTag *model.UserTag, forceColumns ...string) (int64, error) | ||||
UserTagDeleteBySession(session *xorm.Session, tagID interface{}) (int64, error) | UserTagDeleteBySession(session *xorm.Session, tagID interface{}) (int64, error) | ||||
UserTagInsert(userTag *model.UserTag) (int, error) | UserTagInsert(userTag *model.UserTag) (int, error) | ||||
UserTagGetOneByParams(params map[string]interface{}) (*model.UserTag, error) | |||||
} | } |
@@ -14,4 +14,5 @@ type UserTagRecordsDao interface { | |||||
UserTagRecordsFindByParams(params map[string]interface{}) (*[]model.UserTagRecords, error) | UserTagRecordsFindByParams(params map[string]interface{}) (*[]model.UserTagRecords, error) | ||||
UserTagRecordsExist(uid int64, tagId int) (bool, error) | UserTagRecordsExist(uid int64, tagId int) (bool, error) | ||||
UserTagRecordsDelete(uid int64, tagId int) (int64, error) | UserTagRecordsDelete(uid int64, tagId int) (int64, error) | ||||
UserTagRecordsIsUsedBySession(session *xorm.Session, tagId int) (bool, error) | |||||
} | } |
@@ -4,6 +4,7 @@ import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" | zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" | ||||
"fmt" | |||||
"reflect" | "reflect" | ||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -65,3 +66,12 @@ func (u UserTagDb) UserTagInsert(userTag *model.UserTag) (int, error) { | |||||
} | } | ||||
return userTag.Id, nil | return userTag.Id, nil | ||||
} | } | ||||
func (u UserTagDb) UserTagGetOneByParams(params map[string]interface{}) (*model.UserTag, error) { | |||||
var m model.UserTag | |||||
var query = fmt.Sprintf("%s = ?", params["key"]) | |||||
if has, err := u.Db.Where(query, params["value"]).Get(&m); err != nil || has == false { | |||||
return nil, zhios_order_relate_logx.Error(err) | |||||
} | |||||
return &m, nil | |||||
} |
@@ -93,3 +93,12 @@ func (u UserTagRecordsDb) UserTagRecordsDelete(uid int64, tagId int) (int64, err | |||||
} | } | ||||
return affected, nil | return affected, nil | ||||
} | } | ||||
func (u UserTagRecordsDb) UserTagRecordsIsUsedBySession(session *xorm.Session, tagId int) (bool, error) { | |||||
var m model.UserTagRecords | |||||
exist, err := session.Where("tag_id = ?", tagId).Exist(&m) | |||||
if err != nil { | |||||
return false, zhios_order_relate_logx.Error(err) | |||||
} | |||||
return exist, nil | |||||
} |