models

package
v0.0.0-...-8295693 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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 AddBlog

func AddBlog(blog *Blog) error

func AddCarousel

func AddCarousel(caro *Carousel) (affected int64, err error)

func AddContactMsg

func AddContactMsg(msg *ContactMessage) (string, error)

func AddDBLog

func AddDBLog(log *DBLog)

func AddFlagshipProducts

func AddFlagshipProducts(prods ...*FlagshipProduct) (affected int64, err error)

func AddMailSettings

func AddMailSettings(sett *MailSettings) (id string, err error)

AddMailSettings 新增邮件服务配置

func AddProduct

func AddProduct(prod *Product) error

添加产品及其图片信息

func AddProductImage

func AddProductImage(img *ProductImage) error

AddProductImage 添加产品图片记录。此时并未将产品图片与产品进行关联。

func CalcStartRecordNo

func CalcStartRecordNo(curPageNo, pageSize, totalRecords int) (startRecordNo int, err error)

CalcStartRecordNo 计算分页起始记录号

func CalcTotalPages

func CalcTotalPages(pageSize, totalRecords int) (totalPages int, err error)

CalcTotalPages 计算总页数

func ChangePwd

func ChangePwd(name, rawNewPwd, salt string) (affected int64, err error)

修改用户登录密码

func CountBlogs

func CountBlogs(cond *Blog) (int64, error)

func CountCarouses

func CountCarouses(cond *Carousel) (int64, error)

func CountContactMsgs

func CountContactMsgs(cond *ContactMessage) (int64, error)

func CountFlagshipProducts

func CountFlagshipProducts(cond *FlagshipProduct) (affected int64, err error)

func CountProducts

func CountProducts(cond *Product) (int64, error)

func CountProductsButFlagships

func CountProductsButFlagships(cond *Product) (int64, error)

func ModBlog

func ModBlog(blog *Blog) (affected int64, err error)

func ModCarousel

func ModCarousel(carousel *Carousel) (affected int64, err error)

func ModContactMsg

func ModContactMsg(cond *ContactMessage) (affected int64, err error)

func ModMailSettings

func ModMailSettings(cond *MailSettings) (affected int64, err error)

ModMailSettings 修改邮件服务配置

func ModProduct

func ModProduct(prod *Product) (affected int64, err error)

func PushPinBlog

func PushPinBlog(id string) (affected int64, err error)

func PushPinCarousel

func PushPinCarousel(id string) (affected int64, err error)

func PushPinFlagshipProduct

func PushPinFlagshipProduct(id string) (affected int64, err error)

func PushPinProduct

func PushPinProduct(id string) (affected int64, err error)

func RmBlog

func RmBlog(cond *Blog) (affected int64, err error)

func RmCarousel

func RmCarousel(id string) (affected int64, err error)

func RmFlagshipProductById

func RmFlagshipProductById(id string) (affected int64, err error)

func RmProducts

func RmProducts(prodIds ...string) (affected int64, err error)

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:"-"`
}

func GetBlogById

func GetBlogById(id string, lazy bool) (blog *Blog, has bool, err error)

func GetBlogs

func GetBlogs(cond *Blog, lim *Limiter, lazy bool) (list []*Blog, err error)

func (*Blog) TableName

func (this *Blog) TableName() string

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

func GetBlogImagesByBlogId(blogId string) (imgs []*BlogImage, err error)

func (*BlogImage) TableName

func (this *BlogImage) TableName() string
type Carousel struct {
	Id       string    `xorm:"caro_id pk"`
	ImgPath  string    `xorm:"caro_img_path notnull"`
	Caption  string    `xorm:"caro_caption notnull"`
	SortNo   uint      `xorm:"caro_sort_no"`
	Created  time.Time `xorm:"caro_created created"`
	Modified time.Time `xorm:"caro_modified updated"`
}

func GetCarouselById

func GetCarouselById(id string) (carousel *Carousel, has bool, err error)

func GetCarousels

func GetCarousels(cond *Carousel, lim *Limiter) (list []*Carousel, err error)

func (*Carousel) TableName

func (this *Carousel) TableName() string

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"`
}

func (*DBLog) TableName

func (this *DBLog) TableName() string

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 Gender

type Gender string

性别

type Limiter

type Limiter struct {
	// Limit 分页中每页记录数
	Limit int
	// Offset 分页记录开始序号(偏移量)
	Offset int
}

Limiter 数据层分页对象

type LogicalOp

type LogicalOp 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

func ValidateLogin(name, rawPwd string) (login *Login, has bool, err error)

校验登录信息

func (*Login) TableName

func (this *Login) TableName() string

type Mail

type Mail struct {
	Id      string
	To      string
	Subject string
	Body    string
}

邮件

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 EmptyPage

func EmptyPage(curPageNo, pageSize int) *Page

func GetBlogPage

func GetBlogPage(cond *Blog, curPageNo, pageSize int, lazy bool) (page *Page, err error)

func GetCarouselPage

func GetCarouselPage(cond *Carousel, curPageNo, pageSize int) (page *Page, err error)

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 GetProductPage(cond *Product, curPageNo, pageSize int, lazy bool) (page *Page, err error)

func GetProductsButFlagshipsPage

func GetProductsButFlagshipsPage(cond *Product, curPageNo, pageSize int, lazy bool) (page *Page, err error)

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 业务逻辑层分页接口

func NewPager

func NewPager(elemType reflect.Type, curPageNo, pageSize, totalRecords int) Pager

NewPager 新建业务逻辑层分页对象。 elemType 分页中每条记录所代表的对象的反射类型 curPageNo 当前页页号 pageSize 每页记录数 totalRecords 总记录数

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 GetProductById(id string, lazy bool) (prod *Product, has bool, err error)

func GetProducts

func GetProducts(cond *Product, limit, offset int, lazy bool) ([]*Product, error)

func GetProductsButFlagships

func GetProductsButFlagships(cond *Product, limit, offset int, lazy bool) ([]*Product, error)

func (*Product) HtmlEscape

func (this *Product) HtmlEscape() *Product

func (*Product) TableName

func (this *Product) TableName() string

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:"-"`
}

func CheckLogin

func CheckLogin(loginName, rawPwd string) (user *User, has bool, err error)

func GetUserById

func GetUserById(userId string) (user *User, has bool, err error)

根据用户信息ID查询用户信息

func (*User) TableName

func (this *User) TableName() string

Jump to

Keyboard shortcuts

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