1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package commonm
- import ("github.com/astaxie/beego/orm"
- "wuyebaoxiuapi/models")
- // 物业公告
- type PropertyNotice struct {
- Id int
- Title string
- Content string
- CreateTime int
- FCreateTime string
- }
- func init() {
- orm.RegisterModel(new(PropertyNotice))
- }
- func (a *PropertyNotice) TableName() string {
- return models.TableName("property_notice")
- }
- func NewPropertyNotice()(*PropertyNotice) {
- return new(PropertyNotice)
- }
- func (a *PropertyNotice) Add(propertyNotice *PropertyNotice)(int64, error) {
- return orm.NewOrm().Insert(a)
- }
- func (a *PropertyNotice)FindPropertyNotices(page, pageSize int) ([]*PropertyNotice, int64) {
- offset := (page - 1) * pageSize
- list := make([]*PropertyNotice, 0)
- query := orm.NewOrm().QueryTable(models.TableName("property_notice"))
- total, _ := query.Count()
- query.OrderBy("-id").Limit(pageSize, offset).All(&list)
- return list, total
- }
- func (a *PropertyNotice)FindPropertyNoticeById(id int) (*PropertyNotice, error) {
- err := orm.NewOrm().QueryTable(models.TableName("property_notice")).Filter("id", id).One(a)
- if err != nil {
- return nil, err
- }
- return a, nil
- }
- func (a *PropertyNotice) Update(fields ...string) error {
- if _, err := orm.NewOrm().Update(a, fields...); err != nil {
- return err
- }
- return nil
- }
- func (a *PropertyNotice)Delete(id int) (int64, error) {
- query := orm.NewOrm().QueryTable(models.TableName("property_notice"))
- return query.Filter("id", id).Delete()
- }
|