|
123456789101112131415161718192021222324252627282930313233343536373839 |
- package db
-
- import (
- "applet/app/db/model"
- "errors"
- "xorm.io/xorm"
- )
-
- //UserLevelTaskInIDS is 根据ids 获取等级任务
- func UserLevelTaskInIDS(Db *xorm.Engine, ids []int) ([]*model.UserLevelTask, error) {
- var m []*model.UserLevelTask
- if err := Db.In("level_id", ids).Asc("level_id").Find(&m); err != nil {
- return nil, err
- }
- return m, nil
- }
-
- //UserLevelTaskByID is 根据id 获取等级任务列表
- func UserLevelTaskByID(Db *xorm.Engine, id interface{}) ([]*model.UserLevelTask, error) {
- var m []*model.UserLevelTask
- if err := Db.Where("level_id = ?", id).Find(&m); err != nil {
- return nil, err
- }
- return m, nil
- }
-
- //UserLevelTaskOneByID is 根据id 获取等级任务
- func UserLevelTaskOneByID(Db *xorm.Engine, id interface{}) (*model.UserLevelTask, error) {
- m := new(model.UserLevelTask)
- has, err := Db.Where("id = ?", id).Get(m)
- //fmt.Println(m)
- if !has {
- return nil, errors.New("Not found")
- }
- if err != nil {
- return nil, err
- }
- return m, nil
- }
|