models

package
v0.0.0-...-f242362 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func CloseDB

func CloseDB()

func CountReminderSchedule

func CountReminderSchedule(db *gorm.DB) (int, error)

CountReminderSchedule 全数カウント

func CountReminderSetting

func CountReminderSetting(db *gorm.DB) (int, error)

リマインダー数カウント

func CountUser

func CountUser(db *gorm.DB) (int, error)

ユーザー数カウント

func GetDB

func GetDB() *gorm.DB

GetDB DB接続取得

func GetJSTLocation

func GetJSTLocation() *time.Location

func GetReminderSettingsNextNumberForCreate

func GetReminderSettingsNextNumberForCreate(db *gorm.DB) (uint, error)

インサート用に次点のnumber値を取得

func InitDB

func InitDB()

func Transact

func Transact(db *gorm.DB, txFunc func(*gorm.DB) error) (err error)

トランザクション実行

func TransactAndReceiveData

func TransactAndReceiveData(db *gorm.DB, txFunc func(*gorm.DB) (interface{}, error)) (data interface{}, err error)

トランザクション実行し情報を受取る

Types

type ReminderLog

type ReminderLog struct {
	gorm.Model
	UserID            uint   `gorm:"not null;"`
	ReminderSettingID uint   `gorm:"not null;"`
	NotifyTitle       string `gorm:"size:255;not null;"`
	NotifyText        string `gorm:"Type:text;not null;"`
}

type ReminderSchedule

type ReminderSchedule struct {
	gorm.Model
	ReminderSettingID uint      `gorm:"not null;" validate:"required,min=1"`
	NotifyDate        time.Time `gorm:"Type:date;not null;" validate:"required,date"`
}

ReminderSchedule リマインド予定

func CreateReminderSchedule

func CreateReminderSchedule(db *gorm.DB, reminderSettingID uint, notifyDate time.Time) (*ReminderSchedule, error)

CreateReminderSchedule 新規リマインダー予定作成

func GetReminderSchedulesReachedNotifyDate

func GetReminderSchedulesReachedNotifyDate(db *gorm.DB, targetDate time.Time) ([]ReminderSchedule, error)

GetReminderSchedulesBefore 通知日付に達した全リマインド予定取得

func (*ReminderSchedule) DeleteByReminderSetting

func (rSch *ReminderSchedule) DeleteByReminderSetting(db *gorm.DB, rSet ReminderSetting) error

DeleteByReminderSetting リマインド設定(ユニークキー)で削除

func (*ReminderSchedule) GetByID

func (rSch *ReminderSchedule) GetByID(db *gorm.DB, id uint) error

GetByID PKで取得

func (*ReminderSchedule) GetByReminderSetting

func (rSch *ReminderSchedule) GetByReminderSetting(db *gorm.DB, rSet ReminderSetting) error

GetByReminderSetting リマインド設定(ユニークキー)で検索

func (*ReminderSchedule) UpdateNotifyDateDaysAfterBasis

func (rSch *ReminderSchedule) UpdateNotifyDateDaysAfterBasis(db *gorm.DB, basisDate time.Time, daysAfter uint) error

UpdateNotifyDateDaysAfterBasis 通知日付を指定日時から指定日数後に変更する basisDate 起点日付 *基本的にはtime.Now()を指定する事になる

func (*ReminderSchedule) Updates

func (rSch *ReminderSchedule) Updates(db *gorm.DB, notifyDate time.Time) error

Updates 更新

type ReminderSetting

type ReminderSetting struct {
	gorm.Model
	UserID      uint   `gorm:"not null;" validate:"required,numeric,min=1"`
	Number      uint   `gorm:"Type:smallint(5) unsigned;not null; "validate:"required,numeric,min=1"`
	Name        string `gorm:"size:255;not null;" validate:"required,max=100"`
	NotifyTitle string `gorm:"size:255;not null;" validate:"max=100"`
	NotifyText  string `gorm:"Type:text;not null;" validate:"required,max=1000"`
	CycleDays   uint   `gorm:"Type:smallint(5) unsigned;not null;" validate:"required,numeric,min=1,max=365"`
	//ReminderSchedule ReminderSchedule
	ReminderLogs []ReminderLog
}

func CreateReminderSetting

func CreateReminderSetting(db *gorm.DB, userID uint, name, notifyTitle, notifyText string, cycleDays, number uint) (*ReminderSetting, error)

新規リマインダー作成

func GetReminderSettingsByUser

func GetReminderSettingsByUser(db *gorm.DB, user User) ([]ReminderSetting, error)

ユーザーの全リマインド設定取得

func (*ReminderSetting) CalculateNotifyDate

func (rSet *ReminderSetting) CalculateNotifyDate(basisDate time.Time) time.Time

起点日付+通知間隔日数で日付を算出する

func (*ReminderSetting) Delete

func (rSet *ReminderSetting) Delete(db *gorm.DB) error

Delete 削除

func (*ReminderSetting) GetByIDAndUserID

func (rSet *ReminderSetting) GetByIDAndUserID(db *gorm.DB, id, userID uint) error

GetByIDAndUserID PKとUserIDで取得

func (*ReminderSetting) GetById

func (rSet *ReminderSetting) GetById(db *gorm.DB, id uint) error

IDで検索

func (*ReminderSetting) GetByUserIDAndNumber

func (rSet *ReminderSetting) GetByUserIDAndNumber(db *gorm.DB, userID uint, number uint) error

GetByUserIDAndNumber UserIDとNumberで検索

func (*ReminderSetting) Updates

func (rSet *ReminderSetting) Updates(db *gorm.DB, name, notifyTitle, notifyText string, cycleDays uint) error

更新

type User

type User struct {
	gorm.Model
	Email            string `gorm:"size:255;not null;unique_index" validate:"required,email"`
	ReminderSettings []ReminderSetting
	ReminderLogs     []ReminderLog
}

func CreateUser

func CreateUser(db *gorm.DB, email string) (*User, error)

新規ユーザー作成

func (*User) DeleteById

func (user *User) DeleteById(db *gorm.DB, id uint) error

ユーザー削除

func (*User) GetByEmail

func (user *User) GetByEmail(db *gorm.DB, email string) error

Eメールで検索

func (*User) GetByIDForUpdate

func (user *User) GetByIDForUpdate(db *gorm.DB, id uint) error

GetByIDForUpdate IDで検索(排他トランザクション)

func (*User) GetById

func (user *User) GetById(db *gorm.DB, id uint) error

IDで検索

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL