Documentation ¶
Index ¶
- Constants
- Variables
- func GetPermissions(opts *Options) ([]*Permission, ApiErr)
- func GetPermissionsByIds(ids []string) ([]*Permission, ApiErr)
- func GetPost(opts *Options) (*Post, ApiErr)
- func GetPostById(id uint32, opts *Options) (*Post, ApiErr)
- func GetPosts(opts *Options) ([]*Post, uint32, ApiErr)
- func GetRole(opts *Options) (*Role, ApiErr)
- func GetRoleById(id uint32, opts *Options) (*Role, ApiErr)
- func GetRoles(opts *Options) ([]*Role, ApiErr)
- func GetSetting(opts *Options) (*JsonSetting, ApiErr)
- func GetUser(opts *Options) (*User, ApiErr)
- func GetUserById(id uint32, opts *Options) (*User, ApiErr)
- func GetUserByName(name string, opts *Options) (*User, ApiErr)
- func GetUsers(opts *Options) ([]*User, uint32, ApiErr)
- func IsRoleExist(name string) (bool, *Role, ApiErr)
- func NewEngine() (err error)
- func UserSignin(u *User, opts *Options) (*User, ApiErr)
- type ApiErr
- func ChangePassword(oldPassword, newPassword, verifyPassword string, userId uint32, opts *Options) (bool, ApiErr)
- func CreatePermission(perm *Permission, opts *Options) ApiErr
- func CreatePost(post *Post, opts *Options) ApiErr
- func CreateRole(role *Role, opts *Options) ApiErr
- func CreateSettings(settings []*Setting) ApiErr
- func CreateUser(u *User, opts *Options) ApiErr
- func DeletePost(id uint32, opts *Options) ApiErr
- func DeleteRole(id uint32, opts *Options) ApiErr
- func EditPost(post *Post, opts *Options) ApiErr
- func EditRole(role *Role, opts *Options) ApiErr
- func EditSetting(setting *JsonSetting, opts *Options) ApiErr
- func EditUser(u *User, opts *Options) ApiErr
- func InitialDatabase() ApiErr
- func UnknowError(msg string) ApiErr
- type GormAdapter
- type JsonSetting
- type Menu
- type Navigation
- type Options
- type Pagination
- type Permission
- type Post
- type RestApi
- type Role
- type Setting
- type User
Constants ¶
View Source
const ( PostStatusPublished string = "published" PostStatusDraft string = "draft" )
View Source
const APP_VERSION = "0.1.0"
View Source
const CacheKeyAppSettings string = "cache_app_settings"
View Source
const (
SiteOwner string = "owner"
)
Variables ¶
View Source
var ApiMsg = apiMsg{ Success: ApiErr{Code: 0, Message: ""}, Created: ApiErr{Code: 0, Message: "msg.created"}, Saved: ApiErr{Code: 0, Message: "msg.saved"}, Deleted: ApiErr{Code: 0, Message: "msg.deleted"}, DatabaseFailed: ApiErr{Code: 1, Message: "msg.db_initialization_failed"}, NeedToSignIn: ApiErr{Code: 2, Message: "msg.need_to_sign_in"}, NoPermission: ApiErr{Code: 9, Message: "msg.no_permission"}, SaveFail: ApiErr{Code: 10, Message: "msg.save_fail"}, LoadFail: ApiErr{Code: 10, Message: "msg.load_fail"}, ErrRoleNameCanNotBeEmpty: ApiErr{Code: 101, Message: "msg.role_name_not_be_empty"}, ErrRoleNameTooLong: ApiErr{Code: 102, Message: "msg.role_name_too_long"}, ErrNotSupportNumericRole: ApiErr{Code: 103, Message: "msg.not_support_numeric_role"}, ErrRoleDescriptionTooLong: ApiErr{Code: 104, Message: "msg.role_description_too_long"}, ErrRoleCanNotBeEmpty: ApiErr{Code: 105, Message: "msg.role_not_be_empty"}, ErrRoleAlreadyExist: ApiErr{Code: 106, Message: "msg.role_exist"}, ErrRoleNotFound: ApiErr{Code: 107, Message: "msg.role_not_found"}, ErrRoleHaveUsersCanNotBeDeleted: ApiErr{Code: 108, Message: "msg.role_have_users_not_be_deleted"}, ErrPermissionCanNotBeEmpty: ApiErr{Code: 109, Message: "msg.perm_not_be_empty"}, ErrPermissionAlreadyExist: ApiErr{Code: 110, Message: "msg.perm_exist"}, ErrUserNameCanNotBeEmpty: ApiErr{Code: 201, Message: "msg.user_name_not_be_empty"}, ErrUserNameTooLong: ApiErr{Code: 202, Message: "msg.user_name_too_long"}, ErrNotSupportNumericUser: ApiErr{Code: 203, Message: "msg.not_support_numeric_user"}, ErrUserPasswordCanNotBeEmpty: ApiErr{Code: 204, Message: "msg.user_password_not_be_empty"}, ErrUserPasswordTooLong: ApiErr{Code: 205, Message: "msg.user_password_too_long"}, ErrUserAlreadyExist: ApiErr{Code: 206, Message: "msg.user_exist"}, ErrUserNotFound: ApiErr{Code: 207, Message: "msg.user_not_found"}, ErrPasswordIncorrect: ApiErr{Code: 208, Message: "msg.password_incorrect"}, ErrPasswordNotMatch: ApiErr{Code: 209, Message: "msg.passwords_not_match"}, ErrPasswordRequired: ApiErr{Code: 210, Message: "msg.password_required"}, ErrPasswordTooShort: ApiErr{Code: 211, Message: "msg.password_at_least_8_char"}, ErrPostTitleTooLong: ApiErr{Code: 301, Message: "msg.post_title_too_long"}, ErrPostSlugTooLong: ApiErr{Code: 302, Message: "msg.post_slug_too_long"}, ErrPostMetaTitleTooLong: ApiErr{Code: 303, Message: "msg.post_meta_title_too_long"}, ErrPostMetaDescriptionTooLong: ApiErr{Code: 304, Message: "msg.post_meta_description_too_long"}, ErrPostSlugAlreadyExist: ApiErr{Code: 305, Message: "msg.post_slug_exist"}, ErrPostNotFound: ApiErr{Code: 306, Message: "msg.post_not_found"}, ErrFileNotSupported: ApiErr{Code: 901, Message: "msg.file_not_supported"}, ErrFileTooLarge: ApiErr{Code: 902, Message: "msg.file_too_large"}, }
View Source
var (
HasEngine bool
)
Functions ¶
func GetPermissions ¶
func GetPermissions(opts *Options) ([]*Permission, ApiErr)
GetPermissions returns all permissions
func GetPermissionsByIds ¶
func GetPermissionsByIds(ids []string) ([]*Permission, ApiErr)
GetPermissionsByIds returns all permissions by given ids
func GetSetting ¶
func GetSetting(opts *Options) (*JsonSetting, ApiErr)
Types ¶
type ApiErr ¶
func ChangePassword ¶
func CreatePermission ¶
func CreatePermission(perm *Permission, opts *Options) ApiErr
CreatePermission creates a permission
func CreatePost ¶
func CreateRole ¶
func CreateSettings ¶
func CreateUser ¶
func DeletePost ¶
func DeleteRole ¶
func EditSetting ¶
func EditSetting(setting *JsonSetting, opts *Options) ApiErr
func InitialDatabase ¶
func InitialDatabase() ApiErr
func UnknowError ¶
type GormAdapter ¶
type GormAdapter struct { Columns []string Query interface{} Args []interface{} Map map[string]interface{} OrderBy string Joins string }
GormAdapter
- models.Options{
- GormAdp: &models.GormAdapter{Query: "column=value1"}},
- }
- models.Options{
- GormAdp: &models.GormAdapter{Query: "column=?", Args: []interface{}{"column-value"}},
- }
- models.Options{
- GormAdp: &models.GormAdapter{Map: map[string]interface{}{"column1": "value1", "column2": "value2"}},
- }
type JsonSetting ¶
type JsonSetting struct { AppUrl string `json:"app_url` Title string `json:"title"` Description string `json:"description"` Logo string `json:"logo"` Cover string `json:"cover"` Language string `json:"language"` PostsPerPage uint32 `json:"posts_per_page"` ForceI18n bool `json:"force_i18n"` ActiveApps []string `json:"active_apps"` InstallApps []string `json:"install_apps"` AntHead string `json:"ant_head"` AntFoot string `json:"ant_foot"` Permalink string `json:"permalink"` ActiveTheme string `json:"active_theme"` IsPrivate bool `json:"is_private"` Password string `json:"password"` Version string `json:"version"` }
func (*JsonSetting) NavigationSerialize ¶
func (c *JsonSetting) NavigationSerialize() string
type Navigation ¶
type Navigation struct {}
type Options ¶
type Options struct { User *User Role *Role Permission *Permission Permissions []*Permission Limit uint32 Page uint32 Offset uint32 Include string GormAdp *GormAdapter }
Model Assistant
type Pagination ¶
type Permission ¶
type Permission struct { Id uint32 `json:"id" gorm:"primary_key"` Name string `json:"name" sql:"not null;type:varchar(20)"` Slug string `json:"slug" sql:"not null;type:varchar(20)"` ObjectType string `json:"-" sql:"not null;type:varchar(20)"` IsCore bool `json:"is_core" sql:"not null;type:tinyint(1)"` }
type Post ¶
type Post struct { Id uint32 `json:"id" gorm:"primary_key"` Title string `json:"title" sql:"not null;type:varchar(150);"` Slug string `json:"slug" sql:"not null;type:varchar(200);"` Markdown string `json:"markdown" sql:"not null;type:text;"` Html string `json:"html" sql:"not null;type:text;"` Cover string `json:"cover" sql:"type:varchar(150)"` Language string `json:"language" sql:"type:varchar(6)"` Page bool `json:"page" sql:"not null;type:tinyint(1)"` Featured bool `json:"featured" sql:"not null;type:tinyint(1)"` Status string `json:"status" sql:"not null;type:varchar(20)"` MetaTitle string `json:"meta_title" sql:"type:varchar(150)"` MetaDescription string `json:"meta_description" sql:"type:varchar(200)"` AuthorId uint32 `json:"-" sql:"not null;type:bigint unsigned;"` PublishedAt time.Time `json:"published_at" sql:"not null;type:datetime;"` PublishedBy uint32 `json:"-" sql:"not null;type:bigint unsigned;"` CreatedAt time.Time `json:"-" sql:"not null;type:datetime;"` CreatedBy uint32 `json:"-" sql:"not null;type:bigint unsigned;"` UpdatedAt time.Time `json:"-" sql:"type:datetime;"` UpdatedBy uint32 `json:"-" sql:"type:bigint unsigned;"` Author *User `json:"author,omitempty"` }
func (*Post) GetPageMeta ¶
type RestApi ¶
type RestApi struct { Data interface{} `json:"data"` Error ApiErr `json:"error"` Pagination *Pagination `json:"pagination"` }
type Role ¶
type Role struct { Id uint32 `json:"id" gorm:"primary_key"` Name string `json:"name" sql:"not null;type:varchar(50);"` Description string `json:"description" sql:"type:varchar(150)"` Slug string `json:"slug" sql:"type:varchar(100);"` CreatedAt time.Time `json:"created_at" sql:"type:datetime;"` CreatedBy uint32 `json:"-" sql:"type:bigint unsigned;"` UpdatedAt time.Time `json:"updated_at" sql:"type:datetime;"` UpdatedBy uint32 `json:"-" sql:"type:bigint unsigned;"` Permissions []Permission `json:"permissions" gorm:"many2many:permissions_roles;"` }
func (*Role) GetPermissions ¶
func (c *Role) GetPermissions()
type Setting ¶
type Setting struct { Id uint32 `gorm:"primary_key"` Key string `sql:"not null;type:varchar(50);"` Value string `sql:"type:text"` Type string `sql:"type:varchar(20);"` CreatedAt time.Time `sql:"not null;type:datetime;"` CreatedBy uint32 `sql:"not null;type:bigint unsigned;"` UpdatedAt time.Time `sql:"type:datetime;"` UpdatedBy uint32 `sql:"type:bigint unsigned;"` }
type User ¶
type User struct { Id uint32 `json:"id" gorm:"primary_key"` Name string `json:"name" sql:"type:varchar(50);"` Password string `json:"-" sql:"type:char(40);"` Slug string `json:"slug" sql:"type:varchar(100);unique_index;"` Email string `json:"email" sql:"type:varchar(50);"` Bio string `json:"bio" sql:"type:varchar(200);"` Avatar string `json:"avatar" sql:"type:varchar(200);"` Cover string `json:"cover" sql:"type:varchar(200);"` Website string `json:"website" sql:"type:varchar(200);"` Location string `json:"location" sql:"type:varchar(200);"` Language string `json:"language" sql:"type:varchar(6);"` Salt string `json:"-" sql:"type:char(10);"` LastLogin time.Time `json:"last_login" sql:"type:datetime;"` Status string `json:"status" sql:"type:varchar(20);"` CreatedAt time.Time `json:"-" sql:"type:datetime;"` CreatedBy uint32 `json:"-" sql:"type:bigint unsigned;"` UpdatedAt time.Time `json:"-" sql:"type:datetime;"` UpdatedBy uint32 `json:"-" sql:"type:bigint unsigned;"` Roles []Role `json:"roles" gorm:"many2many:roles_users;"` }
func (*User) EncodePassword ¶
func (c *User) EncodePassword()
EncodePassword encodes password to safe format.
Click to show internal directories.
Click to hide internal directories.