Documentation ¶
Index ¶
Constants ¶
View Source
const MaxLIstLimit = 1000
View Source
const (
TableName = "vote"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IRepository ¶
type IRepository interface { // Get returns the album with the specified album ID. Get(ctx context.Context, id uint) (*Vote, error) // Count returns the number of albums. //Count(ctx context.Context) (uint, error) // Query returns the list of albums with the given offset and limit. Query(ctx context.Context, offset, limit uint) ([]Vote, error) SetDefaultConditions(conditions map[string]interface{}) // Create saves a new album in the storage. Create(ctx context.Context, entity *Vote) error // Update updates the album with given ID in the storage. Update(ctx context.Context, entity *Vote) error // Delete removes the album with given ID from the storage. Delete(ctx context.Context, entity *Vote) error First(ctx context.Context, user *Vote) (*Vote, error) }
IRepository encapsulates the logic to access albums from the data source.
type IService ¶
type IService interface { NewEntity(postId uint, val int) *Vote Get(ctx context.Context, id uint) (*Vote, error) Query(ctx context.Context, offset, limit uint) ([]Vote, error) List(ctx context.Context) ([]Vote, error) //Count(ctx context.Context) (uint, error) Vote(ctx context.Context, entity *Vote) error Unvote(ctx context.Context, entity *Vote) error Create(ctx context.Context, entity *Vote) error Update(ctx context.Context, entity *Vote) error Delete(ctx context.Context, entity *Vote) error First(ctx context.Context, user *Vote) (*Vote, error) }
IService encapsulates usecase logic for user.
func NewService ¶
func NewService(repo IRepository, logger log.ILogger) IService
NewService creates a new service.
type Vote ¶
type Vote struct { ID uint `gorm:"PRIMARY_KEY" json:"id"` PostID uint `sql:"type:int REFERENCES post(id)" json:"postId"` UserID uint `sql:"type:int REFERENCES \"user\"(id)" json:"user"` User user.User `gorm:"FOREIGNKEY:UserID;association_autoupdate:false" json:"author"` Value int `json:"vote"` CreatedAt time.Time `json:"created"` UpdatedAt time.Time `json:"updated"` DeletedAt *time.Time `gorm:"INDEX" json:"deleted"` }
Vote is the user entity
Click to show internal directories.
Click to hide internal directories.