|
12345678910111213141516171819202122232425262728293031323334353637383940 |
- package db
-
- import (
- "applet/app/db/model"
- "applet/app/utils"
- "xorm.io/xorm"
- )
-
- func GetNotice(eg *xorm.Engine, param map[string]string) (*[]model.Notice, int64) {
- var order []model.Notice
- sess := eg.Where("1=1")
- size := utils.StrToInt(param["limit"])
- start := (utils.StrToInt(param["page"]) - 1) * size
- count, err := sess.Limit(size, start).OrderBy("id desc").FindAndCount(&order)
- if err != nil {
- return nil, count
- }
- return &order, count
- }
-
- func GetNoticeById(eg *xorm.Engine, id string) *model.Notice {
- var data model.Notice
- get, err := eg.Where("id=?", id).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
- func GetNoticeByDateCount(eg *xorm.Engine, date string) int64 {
- count, _ := eg.Where("date=?", date).Count(&model.Notice{})
- return count
- }
- func GetNoticeByDate(eg *xorm.Engine, date string) *model.Notice {
- var data model.Notice
- get, err := eg.Where("date=?", date).Get(&data)
- if get == false || err != nil {
- return nil
- }
- return &data
- }
|