project_interface_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package project
  2. import (
  3. "sfis/db"
  4. "sfis/lock"
  5. "sfis/model"
  6. "sfis/service"
  7. "testing"
  8. )
  9. var (
  10. projectNameArray = []string{"河南大学", "工程建设", "医疗器械"}
  11. winnerArray = []string{""}
  12. zbRqArray = []string{""}
  13. )
  14. func Test_ProjectInterface(t *testing.T) {
  15. appID := "sfPQRYRQMAAwcGBwYBCgcA"
  16. //userName := "赛博英杰"
  17. productID := 1003
  18. lock.MainLock.Lock()
  19. userLock := lock.UserLockMap[appID]
  20. lock.MainLock.Unlock()
  21. userLock.Lock()
  22. userProduct := &model.UserProduct{}
  23. db.GetSFISDB().First(userProduct, &model.UserProduct{AppID: appID, ProductID: productID})
  24. check(&lock.LeftNumCost{
  25. AppID: appID,
  26. ProductID: productID,
  27. LeftNum: userProduct.LeftNum,
  28. ProductType: 0,
  29. DataNumLimitOneTimes: userProduct.DataNumLimitOneTimes,
  30. GetData1: func() (i interface{}, i2 int, err error) {
  31. return service.ProjectListData("", "", "", false)
  32. },
  33. })
  34. }
  35. func check(cost1 lock.Cost) {
  36. if b := cost1.Before(); b {
  37. data, status, _ := cost1.GetData()
  38. if data != nil {
  39. data := data.([]map[string]interface{})
  40. if len(data) > 0 {
  41. cost1.Deduction()
  42. cost1.After()
  43. }
  44. }
  45. }
  46. }