蛋蛋星球 后台端
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.

svc_level_management.go 1.2 KiB

2 weeks ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package svc
  2. import (
  3. "applet/app/db"
  4. md "applet/app/md/member_center"
  5. "applet/app/utils"
  6. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  8. "time"
  9. "xorm.io/xorm"
  10. )
  11. func BatchAddLevelTask(session *xorm.Session, tasks []md.LevelTaskNode, levelId int) (err error) {
  12. nowStr := time.Now().Format("2006-01-02 15:04:05")
  13. m := make([]model.UserLevelTask, len(tasks))
  14. for i, task := range tasks {
  15. m[i].LevelId = levelId
  16. m[i].CreateAt = nowStr
  17. m[i].UpdateAt = nowStr
  18. if task.IsMustTask != "" {
  19. m[i].IsMustTask = utils.StrToInt(task.IsMustTask)
  20. }
  21. if task.TaskType != "" {
  22. m[i].TaskType = utils.StrToInt(task.TaskType)
  23. }
  24. if task.WithinDays != "" {
  25. m[i].WithinDays = utils.StrToInt(task.WithinDays)
  26. }
  27. if task.FinishCount != "" {
  28. m[i].FinishCount = utils.StrToInt(task.FinishCount)
  29. }
  30. if task.TaskTypeLevelId != "" {
  31. m[i].TaskTypeLevelId = utils.StrToInt(task.TaskTypeLevelId)
  32. }
  33. if task.ActiveDays != "" {
  34. m[i].ActiveDays = utils.StrToInt(task.ActiveDays)
  35. }
  36. }
  37. taskDb := implement.NewUserLevelTaskDb(db.Db)
  38. _, err = taskDb.UserLevelTaskBatchInsertBySession(session, m)
  39. if err != nil {
  40. return err
  41. }
  42. return nil
  43. }