community

package
v0.0.0-...-3773cab Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMongoDBRepo

func NewMongoDBRepo(s *mgo.Session) *mongoDBRepo

func NewService

func NewService(r repoProvider) *service

Types

type CommunityDB

type CommunityDB struct {
	// Identify community info
	ID          string `bson:"_id"`
	CommunityID string `bson:"community_id"`
	IsGroup     *bool  `bson:"is_group"`  // community or group, a group just for the user has register
	IsPublic    *bool  `bson:"is_public"` // (group only) the public or private, a group can show to every user

	// General community info
	Name        string `bson:"name"`
	Title       string `bson:"title"`
	Description string `bson:"description"`
	CreatedBy   string `bson:"created_by"` // created by user id
	Owner       string `bson:"owner"`      // admin user id

	// Internal info managed by system
	IsDelete  *bool      `bson:"is_deleted"`
	CreatedAt *time.Time `bson:"created_at"` // pointer used to value type -> omitempty can work
	UpdatedAt *time.Time `bson:"updated_at"`
}

CommunityDB represents a community record stored in database

type CommunityInfo

type CommunityInfo struct {
	CommunityID string `json:"community_id" bson:"community_id"`
	Owner       string `json:"owner" bson:"owner"`
	CreatedBy   string `json:"created_by" bson:"created_by"`

	Name        string `json:"name" bson:"name"`
	Title       string `json:"title,omitempty" bson:"title"`
	Description string `json:"description,omitempty" bson:"description"`
	IsGroup     *bool  `json:"is_group,omitempty" bson:"private,omitempty"`
	IsPublic    *bool  `json:"is_public,omitempty" bson:"is_public,omitempty"`

	CreatedAt *time.Time `json:"created_at,omitempty"`
	UpdatedAt *time.Time `json:"updated_at,omitempty"`
}

type CreateRequest

type CreateRequest struct {
	Owner string `json:"owner" validate:"required"`

	Name        string `json:"name" validate:"required"`
	Title       string `json:"title,omitempty" validate:"omitempty"`
	Description string `json:"description,omitempty" validate:"omitempty"`
	IsGroup     *bool  `json:"is_group,omitempty" validate:"omitempty"`
	IsPublic    *bool  `json:"is_public,omitempty" validate:"omitempty"`
}

type Handler

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

func InitHandlerMongoDBInjected

func InitHandlerMongoDBInjected(s *mgo.Session) *Handler

func NewHandler

func NewHandler(s serviceProvider) *Handler

func (*Handler) DeleteCommunity

func (h *Handler) DeleteCommunity(w http.ResponseWriter, r *http.Request)

func (*Handler) GetCommunities

func (h *Handler) GetCommunities(w http.ResponseWriter, r *http.Request)

func (*Handler) GetCommunityById

func (h *Handler) GetCommunityById(w http.ResponseWriter, r *http.Request)

func (*Handler) GetPrivateCommunities

func (h *Handler) GetPrivateCommunities(w http.ResponseWriter, r *http.Request)

func (*Handler) GetPublicCommunities

func (h *Handler) GetPublicCommunities(w http.ResponseWriter, r *http.Request)

func (*Handler) LoadRoutes

func (h *Handler) LoadRoutes() []router.Route

func (*Handler) PostCommunity

func (h *Handler) PostCommunity(w http.ResponseWriter, r *http.Request)

read more about stack and heap, gc | garbage collector

func (*Handler) PutCommunity

func (h *Handler) PutCommunity(w http.ResponseWriter, r *http.Request)

type UpdateRequest

type UpdateRequest struct {
	Owner string `json:"owner,omitempty" validate:"required,omitempty"`

	Name        string `json:"name,omitempty" validate:"omitempty"`
	Title       string `json:"title,omitempty" validate:"omitempty"`
	Description string `json:"description,omitempty" validate:"omitempty"`
	Type        *bool  `json:"type,omitempty" validate:"omitempty"`
	IsPublic    *bool  `json:"is_public,omitempty" validate:"omitempty"`
}

Jump to

Keyboard shortcuts

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