面包店
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.
 
 
 
 
 

40 line
980 B

  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "errors"
  5. "xorm.io/xorm"
  6. )
  7. //UserLevelTaskInIDS is 根据ids 获取等级任务
  8. func UserLevelTaskInIDS(Db *xorm.Engine, ids []int) ([]*model.UserLevelTask, error) {
  9. var m []*model.UserLevelTask
  10. if err := Db.In("level_id", ids).Asc("level_id").Find(&m); err != nil {
  11. return nil, err
  12. }
  13. return m, nil
  14. }
  15. //UserLevelTaskByID is 根据id 获取等级任务列表
  16. func UserLevelTaskByID(Db *xorm.Engine, id interface{}) ([]*model.UserLevelTask, error) {
  17. var m []*model.UserLevelTask
  18. if err := Db.Where("level_id = ?", id).Find(&m); err != nil {
  19. return nil, err
  20. }
  21. return m, nil
  22. }
  23. //UserLevelTaskOneByID is 根据id 获取等级任务
  24. func UserLevelTaskOneByID(Db *xorm.Engine, id interface{}) (*model.UserLevelTask, error) {
  25. m := new(model.UserLevelTask)
  26. has, err := Db.Where("id = ?", id).Get(m)
  27. //fmt.Println(m)
  28. if !has {
  29. return nil, errors.New("Not found")
  30. }
  31. if err != nil {
  32. return nil, err
  33. }
  34. return m, nil
  35. }