|
|
@@ -1,9 +1,10 @@ |
|
|
|
package implement |
|
|
|
package implement |
|
|
|
|
|
|
|
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" |
|
|
|
"reflect" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
@@ -23,3 +24,36 @@ func (u UserTagDb) UserTagAllByAsc() ([]*model.UserTag, error) { |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserTagDb) UserTagAllByAscByPage(page, limit int) (*[]model.UserTag, int64, error) { |
|
|
|
var m []model.UserTag |
|
|
|
total, err := u.Db.Asc("id").Limit(limit, (page-1)*limit).FindAndCount(&m) |
|
|
|
if err != nil { |
|
|
|
return nil, 0, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return &m, total, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserTagDb) UserTagUpdate(id interface{}, userTag *model.UserTag, forceColumns ...string) (int64, error) { |
|
|
|
var ( |
|
|
|
affected int64 |
|
|
|
err error |
|
|
|
) |
|
|
|
if forceColumns != nil { |
|
|
|
affected, err = u.Db.Where("id=?", id).MustCols(forceColumns...).Update(userTag) |
|
|
|
} else { |
|
|
|
affected, err = u.Db.Where("id=?", id).Update(userTag) |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return 0, zhios_order_relate_logx.Error(err.Error()) |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserTagDb) UserTagDeleteBySession(session *xorm.Session, tagID interface{}) (int64, error) { |
|
|
|
if reflect.TypeOf(tagID).Kind() == reflect.Slice { |
|
|
|
return session.In("id", tagID).Delete(model.UserTag{}) |
|
|
|
} else { |
|
|
|
return session.Where("id = ?", tagID).Delete(model.UserTag{}) |
|
|
|
} |
|
|
|
} |