diff --git a/src/dao/egg_access_records_dao.go b/src/dao/egg_access_records_dao.go new file mode 100644 index 0000000..b8b5ad7 --- /dev/null +++ b/src/dao/egg_access_records_dao.go @@ -0,0 +1,9 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type EggAccessRecordsDao interface { + //TODO:: You can add specific method definitions here + EggAccessRecordsExist(uid int64, date string, index string) (bool, error) + EggAccessRecordsInsert(m *model.EggAccessRecords) (int64, error) +} diff --git a/src/implement/egg_access_records_implement.go b/src/implement/egg_access_records_implement.go new file mode 100644 index 0000000..42dcc40 --- /dev/null +++ b/src/implement/egg_access_records_implement.go @@ -0,0 +1,33 @@ +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" + "xorm.io/xorm" +) + +func NewEggAccessRecordsDb(engine *xorm.Engine) dao.EggAccessRecordsDao { + return &EggAccessRecordsDb{Db: engine} +} + +type EggAccessRecordsDb struct { + Db *xorm.Engine +} + +func (e EggAccessRecordsDb) EggAccessRecordsExist(uid int64, date string, index string) (bool, error) { + var m model.EggAccessRecords + exist, err := e.Db.Where("uid = ?", uid).And("date = ?", date).And("page_index = ?", index).Exist(&m) + if err != nil { + return false, zhios_order_relate_logx.Error(err.Error()) + } + return exist, nil +} + +func (e EggAccessRecordsDb) EggAccessRecordsInsert(m *model.EggAccessRecords) (int64, error) { + _, err := e.Db.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} diff --git a/src/model/egg_access_records.go b/src/model/egg_access_records.go new file mode 100644 index 0000000..6a82d8f --- /dev/null +++ b/src/model/egg_access_records.go @@ -0,0 +1,8 @@ +package model + +type EggAccessRecords struct { + Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` + Uid int64 `json:"uid" xorm:"not null comment('用户ID') BIGINT(20)"` + PageIndex string `json:"page_index" xorm:"not null comment('页面标识') VARCHAR(50)"` + Date string `json:"date" xorm:"not null default '0000-00-00' comment('访问日期') CHAR(50)"` +}