diff --git a/src/dao/egg_energy_assistance_detail_dao.go b/src/dao/egg_energy_assistance_detail_dao.go new file mode 100644 index 0000000..3d33d2b --- /dev/null +++ b/src/dao/egg_energy_assistance_detail_dao.go @@ -0,0 +1,9 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type EggEnergyAssistanceDetailDao interface { + //TODO:: You can add specific method definitions here + AssistanceDetailInsert(m *model.EggEnergyAssistanceDetail) (int64, error) + AssistanceDetailExist(uid, assistedUid, signId int64) (bool, error) +} diff --git a/src/implement/egg_energy_assistance_detail_implement.go b/src/implement/egg_energy_assistance_detail_implement.go new file mode 100644 index 0000000..986ded0 --- /dev/null +++ b/src/implement/egg_energy_assistance_detail_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" + "xorm.io/xorm" +) + +func NewEggEnergyAssistanceDetailDb(engine *xorm.Engine) dao.EggEnergyAssistanceDetailDao { + return &EggEnergyAssistanceDetailDb{Db: engine} +} + +type EggEnergyAssistanceDetailDb struct { + Db *xorm.Engine +} + +func (e EggEnergyAssistanceDetailDb) AssistanceDetailInsert(m *model.EggEnergyAssistanceDetail) (int64, error) { + _, err := e.Db.InsertOne(m) + if err != nil { + return 0, err + } + return m.Id, nil +} + +func (e EggEnergyAssistanceDetailDb) AssistanceDetailExist(uid, assistedUid, signId int64) (bool, error) { + exist, err := e.Db.Where("uid = ?", uid). + And("assisted_uid = ?", assistedUid). + And("sign_id = ?", signId).Exist(&model.EggEnergyAssistanceDetail{}) + if err != nil { + return false, err + } + return exist, nil +} diff --git a/src/model/egg_energy_assistance_detail.go b/src/model/egg_energy_assistance_detail.go new file mode 100644 index 0000000..6db3c23 --- /dev/null +++ b/src/model/egg_energy_assistance_detail.go @@ -0,0 +1,10 @@ +package model + +type EggEnergyAssistanceDetail struct { + Id int64 `json:"id" xorm:"pk autoincr comment('自增主键') BIGINT(20)"` + Uid int64 `json:"uid" xorm:"not null comment('用户id') BIGINT(20)"` + AssistedUid int64 `json:"assisted_uid" xorm:"not null comment('助力用户id') BIGINT(20)"` + SignId int64 `json:"sign_id" xorm:"not null comment('签到id') BIGINT(20)"` + CreatedAt string `json:"created_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` + UpdatedAt string `json:"updated_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` +}