Documentation
¶
Index ¶
- Constants
- Variables
- func AddBlog(blog *Blog) error
- func AddCarousel(caro *Carousel) (affected int64, err error)
- func AddContactMsg(msg *ContactMessage) (string, error)
- func AddDBLog(log *DBLog)
- func AddFlagshipProducts(prods ...*FlagshipProduct) (affected int64, err error)
- func AddMailSettings(sett *MailSettings) (id string, err error)
- func AddProduct(prod *Product) error
- func AddProductImage(img *ProductImage) error
- func CalcStartRecordNo(curPageNo, pageSize, totalRecords int) (startRecordNo int, err error)
- func CalcTotalPages(pageSize, totalRecords int) (totalPages int, err error)
- func ChangePwd(name, rawNewPwd, salt string) (affected int64, err error)
- func CountBlogs(cond *Blog) (int64, error)
- func CountCarouses(cond *Carousel) (int64, error)
- func CountContactMsgs(cond *ContactMessage) (int64, error)
- func CountFlagshipProducts(cond *FlagshipProduct) (affected int64, err error)
- func CountProducts(cond *Product) (int64, error)
- func CountProductsButFlagships(cond *Product) (int64, error)
- func ModBlog(blog *Blog) (affected int64, err error)
- func ModCarousel(carousel *Carousel) (affected int64, err error)
- func ModContactMsg(cond *ContactMessage) (affected int64, err error)
- func ModMailSettings(cond *MailSettings) (affected int64, err error)
- func ModProduct(prod *Product) (affected int64, err error)
- func PushPinBlog(id string) (affected int64, err error)
- func PushPinCarousel(id string) (affected int64, err error)
- func PushPinFlagshipProduct(id string) (affected int64, err error)
- func PushPinProduct(id string) (affected int64, err error)
- func RmBlog(cond *Blog) (affected int64, err error)
- func RmCarousel(id string) (affected int64, err error)
- func RmFlagshipProductById(id string) (affected int64, err error)
- func RmProducts(prodIds ...string) (affected int64, err error)
- type Blog
- type BlogImage
- type Carousel
- type ContactMessage
- type DBLog
- type FlagshipProduct
- type Gender
- type Limiter
- type LogicalOp
- type Login
- type Mail
- type MailSettings
- type Page
- func EmptyPage(curPageNo, pageSize int) *Page
- func GetBlogPage(cond *Blog, curPageNo, pageSize int, lazy bool) (page *Page, err error)
- func GetCarouselPage(cond *Carousel, curPageNo, pageSize int) (page *Page, err error)
- func GetContactMsgPage(cond *ContactMessage, curPageNo, pageSize int) (page *Page, err error)
- func GetFlagshipProductPage(cond *FlagshipProduct, curPageNo, pageSize int, lazy bool) (page *Page, err error)
- func GetProductPage(cond *Product, curPageNo, pageSize int, lazy bool) (page *Page, err error)
- func GetProductsButFlagshipsPage(cond *Product, curPageNo, pageSize int, lazy bool) (page *Page, err error)
- func SearchContactMsgPage(cond *ContactMessage, beginDate time.Time, endDate time.Time, op LogicalOp, ...) (page *Page, err error)
- type Pager
- type Product
- type ProductImage
- type User
Constants ¶
View Source
const ( // 操作名称 ACTION_LOGIN string = "login" ACTION_LOGOUT string = "logout" ACTION_SEND_EMAIL string = "send_email" ACTION_SEND_CONTACT_MSG string = "send_contact_msg" // 操作结果 RESULT_SUCC string = "success" RESULT_FAIL string = "fail" // 操作发起者 SPONSOR_VISITOR = "visitor" )
View Source
const ( // 性别常量定义 GENDER_MALE Gender = "male" GENDER_FEMALE Gender = "female" GENDER_OTHER Gender = "other" // 可访问性 ACCESSABLE_PUBLIC uint8 = 1 ACCESSABLE_PRIVATE uint8 = 2 // 图片放置位置。1-封面;2-详情; IMG_PLACE_AT_COVER uint8 = 1 IMG_PLACE_AT_DETAIL uint8 = 2 // 使用markdown。1-使用;2-未使用; USE_MD_YES uint8 = 1 USE_MD_NO uint8 = 2 // 逻辑运算符 LOGICAL_OP_AND string = "AND" LOGICAL_OP_OR string = "OR" //消息状态 MSG_STAT_UNPROCESSED uint8 = 1 MSG_STAT_PROCESSED uint8 = 2 // ISO通用日期格式 LAYOUT_DATE_TIME = "2006-01-02 15:04:05" LAYOUT_NOSEC = "2006-01-02 15:04" LAYOUT_DATE = "2006-01-02" )
View Source
const (
MSG_STATE_RAW int = iota + 1
)
Variables ¶
View Source
var (
ErrLoginInvalid = errors.New("login info invalid")
)
Functions ¶
func AddCarousel ¶
func AddContactMsg ¶
func AddContactMsg(msg *ContactMessage) (string, error)
func AddFlagshipProducts ¶
func AddFlagshipProducts(prods ...*FlagshipProduct) (affected int64, err error)
func AddMailSettings ¶
func AddMailSettings(sett *MailSettings) (id string, err error)
AddMailSettings 新增邮件服务配置
func AddProductImage ¶
func AddProductImage(img *ProductImage) error
AddProductImage 添加产品图片记录。此时并未将产品图片与产品进行关联。
func CalcStartRecordNo ¶
CalcStartRecordNo 计算分页起始记录号
func CalcTotalPages ¶
CalcTotalPages 计算总页数
func CountBlogs ¶
func CountCarouses ¶
func CountContactMsgs ¶
func CountContactMsgs(cond *ContactMessage) (int64, error)
func CountFlagshipProducts ¶
func CountFlagshipProducts(cond *FlagshipProduct) (affected int64, err error)
func CountProducts ¶
func ModCarousel ¶
func ModContactMsg ¶
func ModContactMsg(cond *ContactMessage) (affected int64, err error)
func ModMailSettings ¶
func ModMailSettings(cond *MailSettings) (affected int64, err error)
ModMailSettings 修改邮件服务配置
func ModProduct ¶
func PushPinBlog ¶
func PushPinCarousel ¶
func PushPinFlagshipProduct ¶
func PushPinProduct ¶
func RmCarousel ¶
func RmFlagshipProductById ¶
func RmProducts ¶
Types ¶
type Blog ¶
type Blog struct {
Id string `xorm:"blog_id pk"`
Title string `xorm:"blog_title notnull"`
Intro string `xorm:"-"`
Body string `xorm:"blog_body notnull"`
BodyUseMd uint8 `xorm:"blog_body_use_markdown"` //是否使用了markdown来书写。1-是;2-否;
Tags string `xorm:"blog_tags"`
IsPublic uint8 `xorm:"blog_is_public"` // 是否公开。1-公开;2-不公开。
SortNo uint `xorm:"blog_sort_no"`
Created time.Time `xorm:"blog_created created"`
Modified time.Time `xorm:"blog_modified updated"`
Cover *BlogImage `xorm:"-"`
}
type BlogImage ¶
type BlogImage struct {
Id string `xorm:"blog_img_id pk"`
BlogId string `xorm:"blog_img_blog_id notnull"`
Path string `xorm:"blog_img_path notnull"`
Created time.Time `xorm:"blog_img_created created"`
}
func GetBlogImagesByBlogId ¶
type Carousel ¶
type ContactMessage ¶
type ContactMessage struct {
Id string `xorm:"msg_id pk"`
Name string `xorm:"msg_name notnull"`
Email string `xorm:"msg_email notnull"`
Phone string `xorm:"msg_phone notnull"`
Company string `xorm:"msg_company"`
Text string `xorm:"msg_text"`
State int `xorm:"msg_state notnull"`
Created time.Time `xorm:"msg_created notnull created"`
Modified time.Time `xorm:"msg_modified notnull updated"`
}
联系人消息
func GetContactMsgs ¶
func GetContactMsgs(cond *ContactMessage, lim *Limiter) (list []*ContactMessage, err error)
func (*ContactMessage) TableName ¶
func (this *ContactMessage) TableName() string
type DBLog ¶
type DBLog struct {
Id string `xorm:"log_id pk"`
Sponsor string `xorm:"log_sponsor notnull"`
Terminal string `xorm:"log_terminal notnull"`
Action string `xorm:"log_action notnull"`
Result string `xorm:"log_result notnull"`
Msg string `xorm:"log_msg"`
Created time.Time `xorm:"log_created notnull created"`
}
type FlagshipProduct ¶
type FlagshipProduct struct {
Id string `xorm:"fp_id pk"`
ProductId string `xorm:"fp_prod_id"`
SortNo uint `xorm:"fp_sort_no notnull"`
Created time.Time `xorm:"fp_created created"`
Modified time.Time `xorm:"fp_modified updated"`
Product *Product `xorm:"-"`
}
func GetAllFlagshipProducts ¶
func GetAllFlagshipProducts(lazy bool) (fProds []*FlagshipProduct, err error)
func GetFlagshipProducts ¶
func GetFlagshipProducts(cond *FlagshipProduct, limit, offset int, lazy bool) (fProds []*FlagshipProduct, err error)
func (*FlagshipProduct) TableName ¶
func (this *FlagshipProduct) TableName() string
type Login ¶
type Login struct {
UserId string `xorm:"login_user_id index"`
Name string `xorm:"login_name pk"` // 登录账号(邮箱)
Pwd string `xorm:"login_pwd notnull"`
Salt string `xorm:"login_salt notnull"`
}
func ValidateLogin ¶
校验登录信息
type MailSettings ¶
type MailSettings struct {
Id string `xorm:"mailset_id pk"`
Account string `xorm:"mailset_account notnull"`
Pwd string `xorm:"mailset_pwd notnull"`
Outgoing string `xorm:"mailset_outgoing notnull"`
OutgoingPort uint `xorm:"mailset_outgoing_port notnull"`
Created time.Time `xorm:"mailset_created created"`
Modified time.Time `xorm:"mailset_modified updated"`
// Owner User `xorm:"mailset_owner"`
UserId string `xorm:"mailset_owner notnull"`
}
邮箱服务设置
func GetMailSettingsByUserId ¶
func GetMailSettingsByUserId(userId string) (sett *MailSettings, has bool, err error)
根据用户ID获取用户邮件服务配置信息
func (*MailSettings) TableName ¶
func (this *MailSettings) TableName() string
type Page ¶
type Page struct {
CurPageNo int // 当前页页号
PageSize int // 每页记录数
TotalRecords int // 总记录数
TotalPages int // 总页数
Rows []interface{} // 当前页记录
}
Page 业务逻辑层分页对象
func GetBlogPage ¶
func GetCarouselPage ¶
func GetContactMsgPage ¶
func GetContactMsgPage(cond *ContactMessage, curPageNo, pageSize int) (page *Page, err error)
func GetFlagshipProductPage ¶
func GetFlagshipProductPage(cond *FlagshipProduct, curPageNo, pageSize int, lazy bool) (page *Page, err error)
func GetProductPage ¶
func SearchContactMsgPage ¶
func SearchContactMsgPage(cond *ContactMessage, beginDate time.Time, endDate time.Time, op LogicalOp, curPageNo, pageSize int) (page *Page, err error)
SearchContactMsgPage 查询联系人消息分页记录。此函数与GetContactMsgPage函数的区别是,此函数中条件查询使用的是LIKE查询,并且支持条件之间的and和or逻辑运算。 cond 联系人消息查询条件 beginDate 联系人消息查询条件-消息创建时间下限 endDate 联系人消息查询条件-消息创建时间上限 op 查询条件之间的逻辑运算符(and、or) curPageNo 分页当前页号 pageSize 分页每页显示记录数
type Pager ¶
type Pager interface {
// BuildLimiter 构建数据层分页对象
BuildLimiter() *Limiter
// AddRow 向当前分页中增加行记录
AddRow(interface{}) bool
// BuildPage 构建业务逻辑层分页对象
BuildPage() *Page
}
Pager 业务逻辑层分页接口
type Product ¶
type Product struct {
Id string `xorm:"prod_id pk"`
Title string `xorm:"prod_title notnull"`
Intro string `xorm:"prod_intro notnull"` // 简介
Desc string `xorm:"prod_desc notnull"` // 描述
DescUseMarkdown uint8 `xorm:"prod_desc_use_markdown notnull"` //描述内容是否使用了markdown来书写。1-是;2-否;
IsPublic uint8 `xorm:"prod_is_public notnull"` // 是否公开。
SortNo uint `xorm:"prod_sort_no notnull"` // 排序序号,序号越大越靠前。
Created time.Time `xorm:"prod_created created"`
Modified time.Time `xorm:"prod_modified updated"`
CoverImg *ProductImage `xorm:"-"`
DetailImgs []*ProductImage `xorm:"-"`
}
Product 产品
func GetProductById ¶
func GetProducts ¶
func GetProductsButFlagships ¶
func (*Product) HtmlEscape ¶
type ProductImage ¶
type ProductImage struct {
Id string `xorm:"prod_img_id pk"`
ProductId string `xorm:"prod_img_prod_id notnull"` // 产品ID
Path string `xorm:"prod_img_path notnull"` // 图片存放相对路径
PlaceAt uint8 `xorm:"prod_img_place_at notnull"` // 图片放置的网页位置。1-封面;2-详情;
Created time.Time `xorm:"prod_img_created created"`
}
ProductImage 产品图片
func GetProductImages ¶
func GetProductImages(cond *ProductImage) (images []*ProductImage, err error)
func (*ProductImage) HtmlEscape ¶
func (this *ProductImage) HtmlEscape() *ProductImage
func (*ProductImage) TableName ¶
func (this *ProductImage) TableName() string
type User ¶
type User struct {
UserId string `xorm:"user_id pk"`
FullName string `xorm:"user_full_name"`
Birthday time.Time `xorm:"user_birthday"`
Gender string `xorm:"user_gender"`
Nickname string `xorm:"user_nickname"`
Created time.Time `xorm:"user_created created"`
Modified time.Time `xorm:"user_modified updated"`
LoginName string `xorm:"-"`
}
Click to show internal directories.
Click to hide internal directories.