package db

import (
	"applet/app/db/model"
	"applet/app/utils/logx"
	"xorm.io/xorm"
)

func OtherCityLoginByUid(Db *xorm.Engine, uid int) (*model.OtherCityLoginList, error) {
	var o model.OtherCityLoginList
	has, err := Db.Where("uid = ?", uid).Desc("time").Get(&o)
	if err != nil || !has {
		return nil, err
	}
	return &o, nil
}

// 插入
func OtherCityLoginByInsert(Db *xorm.Engine, list *model.OtherCityLoginList) {
	row, err := Db.InsertOne(list)
	if err != nil || row == 0 {
		_ = logx.Warn(err)
	}
}

// 更新
func OtherCityLoginByUpdate(Db *xorm.Engine, list *model.OtherCityLoginList) {
	row, err := Db.ID(list.Id).Cols("is_notice").Update(list)
	if err != nil || row == 0 {
		_ = logx.Warn(err)
	}
}
