附近小店
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.
 
 
 

61 lines
1.7 KiB

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/md"
  5. "applet/app/utils"
  6. "xorm.io/xorm"
  7. )
  8. // 查询所有的模板
  9. func GetAllPrinterModuleList(Db *xorm.Engine) ([]model.CommunityTeamStorePrinterModule, error) {
  10. var list []model.CommunityTeamStorePrinterModule
  11. err := Db.Desc("create_time").Find(&list)
  12. if err != nil {
  13. return nil, err
  14. }
  15. return list, nil
  16. }
  17. func GetAllPrinterModuleListByModuleId(Db *xorm.Engine, moduleIds []int) ([]model.CommunityTeamStorePrinterModule, error) {
  18. var list []model.CommunityTeamStorePrinterModule
  19. err := Db.In("id", moduleIds).Find(&list)
  20. if err != nil {
  21. return nil, err
  22. }
  23. return list, nil
  24. }
  25. func GetAllPrinterModuleListByModuleIdOne(Db *xorm.Engine, moduleId int) (*model.CommunityTeamStorePrinterModule, error) {
  26. var list model.CommunityTeamStorePrinterModule
  27. has, err := Db.Where("id=?", moduleId).Get(&list)
  28. if has == false || err != nil {
  29. return nil, err
  30. }
  31. return &list, nil
  32. }
  33. // 分页查询方案
  34. func GetPrinterModuleList(Db *xorm.Engine, parameter *md.IndexRequest) ([]md.ModuleResList, error) {
  35. var list []model.CommunityTeamStorePrinterModule
  36. var webList []md.ModuleResList
  37. session := Db.Where("is_use= 1 ")
  38. //分页
  39. if utils.StrToInt(parameter.P) > 0 && utils.StrToInt(parameter.PageSize) > 0 {
  40. session = session.Limit(utils.StrToInt(parameter.PageSize), (utils.StrToInt(parameter.P)-1)*utils.StrToInt(parameter.PageSize))
  41. }
  42. //排序
  43. err := session.Desc("create_time").Find(&list)
  44. if err != nil {
  45. return nil, err
  46. }
  47. for _, v := range list {
  48. var tmp = md.ModuleResList{
  49. Id: utils.IntToStr(v.Id),
  50. Name: v.Name,
  51. Content: v.Content,
  52. }
  53. webList = append(webList, tmp)
  54. }
  55. return webList, nil
  56. }