persistence

package
v0.0.0-...-29f350e Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAlarmRepository

func NewAlarmRepository(db *gorm.DB) repository.AlarmRepository

NewAlarmRepository ...

func NewMemberDeviceRepository

func NewMemberDeviceRepository(db *gorm.DB) repository.MemberDeviceRepository

NewMemberDeviceRepository ...

func NewMemberRepository

func NewMemberRepository(db *gorm.DB) repository.MemberRepository

NewMemberRepository ...

func NewRoomMemberRepository

func NewRoomMemberRepository(db *gorm.DB) repository.RoomMemberRepository

NewRoomMemberRepository ...

func NewRoomRepository

func NewRoomRepository(db *gorm.DB) repository.RoomRepository

NewRoomRepository ... Domain layer의 RoomRepository interface를 만족시키는 repository impl. gorm connection을 들고 가지고 있다.

func ToEntity

func ToEntity(dto *RoomGorm) *entity.Room

ToEntity : RoomGorm -> entity.Room

func ToMemberEntity

func ToMemberEntity(memberDto *MemberGorm) *entity.Member

ToMemberEntity ...

Types

type AlarmGorm

type AlarmGorm struct {
	ID       uint       `gorm:"primaryKey"`
	MemberID uint       `gorm:"column:member_id"`
	Member   MemberGorm `gorm:"uniqueIndex:unq_room_member_code;column:member_id;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Code     string     `gorm:"uniqueIndex:unq_room_member_code;column:code;type:varchar(512)"`
	Title    string     `gorm:"column:title"`
	RoomID   uint       `gorm:"column:room_id"`
	Room     RoomGorm   `gorm:"uniqueIndex:unq_room_member_code;column:room_id;constraint:OnDelete:CASCADE;"`
	RoomName string     `gorm:"column:room_name"`
	Author   string     `gorm:"column:author"`
	AlarmAt  time.Time  `gorm:"column:alarm_at"`
}

AlarmGorm is a db representation of entity.Member

func (AlarmGorm) TableName

func (AlarmGorm) TableName() string

TableName define gorm table name

type AlarmRepository

type AlarmRepository struct {
	// contains filtered or unexported fields
}

AlarmRepository ...

func (*AlarmRepository) Create

func (ar *AlarmRepository) Create(alarm *entity.Alarm) (*entity.Alarm, error)

Create ...

func (*AlarmRepository) GetAll

func (ar *AlarmRepository) GetAll(accountID uint) (*entity.Alarms, error)

GetAll ...

type AlarmsGorm

type AlarmsGorm []AlarmGorm

AlarmsGorm is a type that represents list of AlarmGorm

type BaseGormModel

type BaseGormModel struct {
	CreatedAt time.Time
	UpdatedAt time.Time
}

BaseGormModel contains common gorm model fields

func (*BaseGormModel) BeforeCreate

func (base *BaseGormModel) BeforeCreate(tx *gorm.DB) error

BeforeCreate do field initialization before insert a row.

type MemberDeviceGorm

type MemberDeviceGorm struct {
	ID       uint       `gorm:"primaryKey"`
	MemberID uint       `gorm:"column:member_id"`
	Member   MemberGorm `gorm:"index;column:member_id;constraint:OnDelete:CASCADE;"`
	// varchar(512)사용 이유: https://stackoverflow.com/questions/11668761/gcm-max-length-for-registration-id
	DeviceToken string `gorm:"column:device_token;type:varchar(512);uniqueIndex:idx_device_token;not null"`
	BaseGormModel
}

MemberDeviceGorm ...

func (MemberDeviceGorm) TableName

func (MemberDeviceGorm) TableName() string

TableName define gorm table name

func (*MemberDeviceGorm) ToEntity

func (dto *MemberDeviceGorm) ToEntity() *entity.MemberDevice

ToEntity ...

type MemberDeviceGorms

type MemberDeviceGorms []MemberDeviceGorm

MemberDeviceGorms define list of MemberDeviceGorm

type MemberDeviceRepository

type MemberDeviceRepository struct {
	// contains filtered or unexported fields
}

MemberDeviceRepository ...

func (*MemberDeviceRepository) CreateIfNotExist

func (mdr *MemberDeviceRepository) CreateIfNotExist(memberID uint, token string) (memberDevice *entity.MemberDevice, err error)

CreateIfNotExist ...

func (*MemberDeviceRepository) Delete

func (mdr *MemberDeviceRepository) Delete(memberDevice *entity.MemberDevice) error

Delete ...

func (*MemberDeviceRepository) DeleteBatch

func (mdr *MemberDeviceRepository) DeleteBatch(tokens []string) error

DeleteBatch ...

func (*MemberDeviceRepository) Get

func (mdr *MemberDeviceRepository) Get(token string) (memberDevice *entity.MemberDevice, err error)

Get ...

func (*MemberDeviceRepository) GetAllMemberTokens

func (mdr *MemberDeviceRepository) GetAllMemberTokens(memberIDs []uint) (tokens []string, err error)

GetAllMemberTokens ...

func (*MemberDeviceRepository) GetAllTokens

func (mdr *MemberDeviceRepository) GetAllTokens(memberID uint) (tokens []string, err error)

GetAllTokens ...

type MemberGorm

type MemberGorm struct {
	ID         uint   `gorm:"primaryKey"`
	Email      string `gorm:"column:email;not null"`
	Name       string `gorm:"column:name;not null;type:varchar(256);uniqueIndex"`
	ProfileURL string `gorm:"column:profile_url"`
	AuthType   string `gorm:"column:auth_type"`
	AlarmFlag  bool   `gorm:"column:alarm_flag"`
	BaseGormModel
}

MemberGorm is a db representation of entity.Member

func ToMemberDTO

func ToMemberDTO(member *entity.Member) *MemberGorm

ToMemberDTO ...

func (MemberGorm) TableName

func (MemberGorm) TableName() string

TableName define gorm table name

type MemberRepository

type MemberRepository struct {
	// contains filtered or unexported fields
}

MemberRepository ...

func (*MemberRepository) Create

func (r *MemberRepository) Create(member *entity.Member) (*entity.Member, error)

Create ...

func (MemberRepository) Delete

func (r MemberRepository) Delete(member *entity.Member) error

Delete ...

func (*MemberRepository) Get

func (r *MemberRepository) Get(id uint) (*entity.Member, error)

Get ...

func (*MemberRepository) GetAllByIDs

func (r *MemberRepository) GetAllByIDs(ids []uint) (*entity.Members, error)

GetAllByIDs ...

func (*MemberRepository) GetByEmail

func (r *MemberRepository) GetByEmail(email string) (*entity.Member, error)

GetByEmail ...

func (*MemberRepository) GetByNickName

func (r *MemberRepository) GetByNickName(name string) (*entity.Member, error)

GetByNickName ...

func (*MemberRepository) Update

func (r *MemberRepository) Update(member *entity.Member) (*entity.Member, error)

Update ...

type MembersGorm

type MembersGorm []MemberGorm

MembersGorm is a type that represents list of MemberGorm

type RoomGorm

type RoomGorm struct {
	ID     uint   `gorm:"primaryKey"`
	Name   string `gorm:"column:name;not null"`
	Code   string `gorm:"column:code;not null"`
	Hint   string `gorm:"column:hint;not null"`
	Theme  string `gorm:"column:theme;not null"`
	Period uint8  `gorm:"column:period;not null"`

	MasterID      uint       `gorm:"column:master_id"`
	Master        MemberGorm `gorm:"column:master_id;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	TurnAccountID uint       `gorm:"column:turn_account_id"`
	DueAt         time.Time  `gorm:"column:due_at"`
	TurnAccount   MemberGorm `gorm:"column:turn_account_id;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`

	Orders datatypes.JSON `gorm:"column:orders"`

	BaseGormModel
}

RoomGorm is a db representation of entity.Room

func ToDTO

func ToDTO(dto *RoomGorm, room *entity.Room) *RoomGorm

ToDTO : entity.Room -> RoomGorm

func (RoomGorm) TableName

func (RoomGorm) TableName() string

TableName define gorm table name

type RoomGorms

type RoomGorms []RoomGorm

RoomGorms define list of RoomGorm

type RoomMemberGorm

type RoomMemberGorm struct {
	ID        uint       `gorm:"primaryKey"`
	RoomID    uint       `gorm:"column:room_id"`
	Room      RoomGorm   `gorm:"uniqueIndex:idx_room_account;column:room_id;constraint:OnDelete:CASCADE;"`
	AccountID uint       `gorm:"column:account_id"`
	Account   MemberGorm `gorm:"uniqueIndex:idx_room_account;column:account_id;constraint:OnDelete:CASCADE;"`
	BaseGormModel
}

RoomMemberGorm is a db representation of entity.RoomMember "idx_room_account" is a unique key combined with (RoomID, AccountID)

func (RoomMemberGorm) TableName

func (RoomMemberGorm) TableName() string

TableName define gorm table name

type RoomMemberGorms

type RoomMemberGorms []RoomMemberGorm

RoomMemberGorms define list of RoomMemberGorm

type RoomMemberRepository

type RoomMemberRepository struct {
	// contains filtered or unexported fields
}

RoomMemberRepository is a impl of domain/repository/roomMemberRepository.go RoomMemberRepository interface

func (*RoomMemberRepository) Create

func (rmr *RoomMemberRepository) Create(roomMember *entity.RoomMember) (*entity.RoomMember, error)

Create ...

func (*RoomMemberRepository) Delete

func (rmr *RoomMemberRepository) Delete(roomMember *entity.RoomMember) error

Delete ...

func (*RoomMemberRepository) GetAllRoomIDs

func (rmr *RoomMemberRepository) GetAllRoomIDs(memberID uint) (roomIDs []uint, err error)

GetAllRoomIDs ...

func (*RoomMemberRepository) GetByUnq

func (rmr *RoomMemberRepository) GetByUnq(roomID, accountID uint) (*entity.RoomMember, error)

GetByUnq func gets RoomMember row by unique_key(RoomID, AccountID)

func (*RoomMemberRepository) SortedMemberIDs

func (rmr *RoomMemberRepository) SortedMemberIDs(memberIDs []uint) (sortedMemberIDs []uint, err error)

SortedMemberIDs ...

type RoomRepository

type RoomRepository struct {
	// contains filtered or unexported fields
}

RoomRepository is a impl of domain/repository/roomRepository.go RoomRepository interface

func (*RoomRepository) Create

func (rr *RoomRepository) Create(room *entity.Room) (*entity.Room, error)

Create func inserts a row to db

func (*RoomRepository) Delete

func (rr *RoomRepository) Delete(room *entity.Room) error

Delete func delete a room

func (*RoomRepository) GetAll

func (rr *RoomRepository) GetAll(accountID uint, roomIDs []uint) (*entity.Rooms, error)

GetAll rooms from masterID or roomIDs

func (*RoomRepository) GetByID

func (rr *RoomRepository) GetByID(id uint) (*entity.Room, error)

GetByID func find a row by entity's ID from db

func (*RoomRepository) Update

func (rr *RoomRepository) Update(room *entity.Room) (*entity.Room, error)

Update func update a room fields

Jump to

Keyboard shortcuts

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