面包店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

db_notice.go 996 B

7 months ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetNotice(eg *xorm.Engine, param map[string]string) (*[]model.Notice, int64) {
  8. var order []model.Notice
  9. sess := eg.Where("1=1")
  10. size := utils.StrToInt(param["limit"])
  11. start := (utils.StrToInt(param["page"]) - 1) * size
  12. count, err := sess.Limit(size, start).OrderBy("id desc").FindAndCount(&order)
  13. if err != nil {
  14. return nil, count
  15. }
  16. return &order, count
  17. }
  18. func GetNoticeById(eg *xorm.Engine, id string) *model.Notice {
  19. var data model.Notice
  20. get, err := eg.Where("id=?", id).Get(&data)
  21. if get == false || err != nil {
  22. return nil
  23. }
  24. return &data
  25. }
  26. func GetNoticeByDateCount(eg *xorm.Engine, date string) int64 {
  27. count, _ := eg.Where("date=?", date).Count(&model.Notice{})
  28. return count
  29. }
  30. func GetNoticeByDate(eg *xorm.Engine, date string) *model.Notice {
  31. var data model.Notice
  32. get, err := eg.Where("date=?", date).Get(&data)
  33. if get == false || err != nil {
  34. return nil
  35. }
  36. return &data
  37. }