@@ -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) | |||||
} |
@@ -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 | |||||
} |
@@ -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"` | |||||
} |