diff --git a/src/dao/user_tag_dao.go b/src/dao/user_tag_dao.go index 9646785..a1f3b02 100644 --- a/src/dao/user_tag_dao.go +++ b/src/dao/user_tag_dao.go @@ -12,4 +12,5 @@ type UserTagDao interface { UserTagUpdate(id interface{}, userTag *model.UserTag, forceColumns ...string) (int64, error) UserTagDeleteBySession(session *xorm.Session, tagID interface{}) (int64, error) UserTagInsert(userTag *model.UserTag) (int, error) + UserTagGetOneByParams(params map[string]interface{}) (*model.UserTag, error) } diff --git a/src/dao/user_tag_records_dao.go b/src/dao/user_tag_records_dao.go index 5ed1966..4b3e0f0 100644 --- a/src/dao/user_tag_records_dao.go +++ b/src/dao/user_tag_records_dao.go @@ -14,4 +14,5 @@ type UserTagRecordsDao interface { UserTagRecordsFindByParams(params map[string]interface{}) (*[]model.UserTagRecords, error) UserTagRecordsExist(uid int64, tagId int) (bool, error) UserTagRecordsDelete(uid int64, tagId int) (int64, error) + UserTagRecordsIsUsedBySession(session *xorm.Session, tagId int) (bool, error) } diff --git a/src/implement/user_tag_implement.go b/src/implement/user_tag_implement.go index d2c7a47..ac96e84 100644 --- a/src/implement/user_tag_implement.go +++ b/src/implement/user_tag_implement.go @@ -4,6 +4,7 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "fmt" "reflect" "xorm.io/xorm" ) @@ -65,3 +66,12 @@ func (u UserTagDb) UserTagInsert(userTag *model.UserTag) (int, error) { } 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 +} diff --git a/src/implement/user_tag_records_implement.go b/src/implement/user_tag_records_implement.go index 881da62..8e956d5 100644 --- a/src/implement/user_tag_records_implement.go +++ b/src/implement/user_tag_records_implement.go @@ -93,3 +93,12 @@ func (u UserTagRecordsDb) UserTagRecordsDelete(uid int64, tagId int) (int64, err } 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 +}