base_test.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package service
  2. import (
  3. dao "dashoo.cn/micro/app/dao/proj"
  4. "fmt"
  5. "github.com/gogf/gf/frame/g"
  6. "github.com/gogf/gf/util/gconv"
  7. "testing"
  8. )
  9. func TestCreateSystemMessage(t *testing.T) {
  10. msg := g.MapStrStr{
  11. "msgTitle": "ces",
  12. "msgContent": "<p>111111111</p>",
  13. "msgType": "20",
  14. "msgStatus": "10",
  15. "recvUserIds": "1,2,4",
  16. "sendType": "10,20,30",
  17. }
  18. if err := CreateSystemMessage(msg); err != nil {
  19. t.Errorf("CreateSystemMessage() error = %v", err)
  20. }
  21. }
  22. func TestCreateSystem(t *testing.T) {
  23. dd := dao.NewProjBusinessDynamicsDao("8b9ec443")
  24. data, err := dd.WhereLike("opn_type", "4%").WhereNotIn("bus_id", []int{114, 118, 176, 177, 190, 198, 301, 339, 346, 372, 443, 446, 457, 485, 486, 492, 506, 507, 524, 559, 612, 629}).
  25. Order("bus_id ASC, opn_date DESC").All()
  26. if err != nil {
  27. fmt.Println(err)
  28. }
  29. var id int
  30. var count int
  31. for _, v := range data {
  32. fmt.Println(*v)
  33. if v.OpnType == "41" && count == 0 {
  34. if id == 0 {
  35. id = v.Id
  36. } else {
  37. id = 0
  38. }
  39. }
  40. count++
  41. if v.OpnType == "40" && id != 0 && count == 2 {
  42. context := gconv.Map(v.OpnContent)
  43. _, err = dd.Data("remark", g.Map{"nboType": context["nboType"], "origNboType": context["origNboType"]}).WherePri(id).Update()
  44. if err != nil {
  45. fmt.Println(err)
  46. }
  47. id = 0
  48. count = 0
  49. }
  50. }
  51. }