shenjiachi vor 6 Tagen
Ursprung
Commit
3dd56831ac
3 geänderte Dateien mit 96 neuen und 0 gelöschten Zeilen
  1. +11
    -0
      src/dao/user_egg_energy_aggregation_dao.go
  2. +70
    -0
      src/implement/user_egg_energy_aggregation_implement.go
  3. +15
    -0
      src/model/user_egg_energy_aggregation.go

+ 11
- 0
src/dao/user_egg_energy_aggregation_dao.go Datei anzeigen

@@ -0,0 +1,11 @@
package dao

import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"

type UserEggEnergyAggregationDao interface {
//TODO:: You can add specific method definitions here
UserEggEnergyAggregationInsert(UserEggEnergyAggregation *model.UserEggEnergyAggregation) (int64, error)
UserEggEnergyAggregationUpdate(id interface{}, UserEggEnergyAggregation *model.UserEggEnergyAggregation, forceColums ...string) (int64, error)
UserEggEnergyAggregationGetOneByTime(day, week, month, year int, uid int64) (*model.UserEggEnergyAggregation, error)
UserEggEnergyAggregationGetLastOneByUid(uid int64) (*model.UserEggEnergyAggregation, error)
}

+ 70
- 0
src/implement/user_egg_energy_aggregation_implement.go Datei anzeigen

@@ -0,0 +1,70 @@
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 NewUserEggEnergyAggregationDb(engine *xorm.Engine) dao.UserEggEnergyAggregationDao {
return &UserEggEnergyAggregationDb{Db: engine}
}

type UserEggEnergyAggregationDb struct {
Db *xorm.Engine
}

func (u UserEggEnergyAggregationDb) UserEggEnergyAggregationInsert(UserEggEnergyAggregation *model.UserEggEnergyAggregation) (int64, error) {
_, err := u.Db.InsertOne(UserEggEnergyAggregation)
if err != nil {
return 0, err
}
return UserEggEnergyAggregation.Id, nil
}

func (u UserEggEnergyAggregationDb) UserEggEnergyAggregationUpdate(id interface{}, UserEggEnergyAggregation *model.UserEggEnergyAggregation, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = u.Db.Where("id=?", id).Cols(forceColums...).Update(UserEggEnergyAggregation)
} else {
affected, err = u.Db.Where("id=?", id).Update(UserEggEnergyAggregation)
}
if err != nil {
return 0, err
}
return affected, nil
}

func (u UserEggEnergyAggregationDb) UserEggEnergyAggregationGetOneByTime(day, week, month, year int, uid int64) (*model.UserEggEnergyAggregation, error) {
var m model.UserEggEnergyAggregation
has, err := u.Db.Where("day = ?", day).
And("week = ?", week).
And("month = ?", month).
And("year = ?", year).
And("uid = ?", uid).
Get(&m)
if err != nil {
return nil, err
}
if !has {
return nil, nil
}
return &m, nil
}

func (u UserEggEnergyAggregationDb) UserEggEnergyAggregationGetLastOneByUid(uid int64) (*model.UserEggEnergyAggregation, error) {
var m model.UserEggEnergyAggregation
has, err := u.Db.Where("uid = ?", uid).
Desc("create_at").
Get(&m)
if err != nil {
return nil, err
}
if !has {
return nil, nil
}
return &m, nil
}

+ 15
- 0
src/model/user_egg_energy_aggregation.go Datei anzeigen

@@ -0,0 +1,15 @@
package model

type UserEggEnergyAggregation struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Uid int64 `json:"uid" xorm:"not null BIGINT(20)"`
TodayData string `json:"today_data" xorm:"not null comment('今日数量') DECIMAL(20,8)"`
ThisWeekData string `json:"this_week_data" xorm:"not null comment('本周数量') DECIMAL(20,8)"`
ThisMonthData string `json:"this_month_data" xorm:"not null comment('本月数量') DECIMAL(20,8)"`
Day int `json:"day" xorm:"not null default 0 comment('日期') INT(11)"`
Week int `json:"week" xorm:"not null default 0 comment('周数') INT(11)"`
Month int `json:"month" xorm:"not null default 0 comment('月数') INT(11)"`
Year int `json:"year" xorm:"not null default 0 comment('年份') INT(11)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

Laden…
Abbrechen
Speichern