network_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package service
  2. import (
  3. "log"
  4. "testing"
  5. "app.yhyue.com/moapp/jybase/es"
  6. "app.yhyue.com/moapp/jybase/mysql"
  7. . "bp.jydev.jianyu360.cn/CRM/application/api/common"
  8. "bp.jydev.jianyu360.cn/CRM/application/api/internal/config"
  9. "bp.jydev.jianyu360.cn/CRM/application/api/internal/types"
  10. )
  11. func initDb() {
  12. CrmMysql = &mysql.Mysql{
  13. Address: "192.168.3.14:4000",
  14. UserName: "root",
  15. PassWord: "=PDT49#80Z!RVv52_z",
  16. DBName: "crm",
  17. MaxOpenConns: 5,
  18. MaxIdleConns: 5,
  19. }
  20. CrmMysql.Init()
  21. ConnectClickhouse(&config.CHouseConfig{
  22. Addr: "192.168.3.207:19000",
  23. UserName: "jytop",
  24. Password: "pwdTopJy123",
  25. DbName: "jianyu",
  26. MaxIdleConns: 2,
  27. MaxOpenConns: 2,
  28. })
  29. es.NewEs("v7", "http://192.168.3.149:9200", 5, "", "")
  30. }
  31. func TestAddOrUpdate(t *testing.T) {
  32. initDb()
  33. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  34. for _, v := range []string{"firstparty", "supplier", "adiffb", "middleman", "agency"} {
  35. text := ""
  36. switch v {
  37. case "firstparty":
  38. text = "甲方"
  39. case "supplier":
  40. text = "供应商"
  41. case "adiffb":
  42. text = "同甲异业"
  43. case "middleman":
  44. text = "中间人"
  45. case "agency":
  46. text = "招标代理机构"
  47. }
  48. text += "_2"
  49. res := Network.AddOrUpdate(&types.AddOrUpdateReq{
  50. PositionId: 943,
  51. Company_id: "112233445566",
  52. Company_name: "王传进的" + text,
  53. Contact_person: "王传进",
  54. Contact_phone: "15037870765",
  55. Introduce_owner_id: "11,22,33",
  56. Introduce_owner_name: "aa,bb,cc",
  57. Introduce_project_id: "44,55,66",
  58. Introduce_project_name: "dd,ee,ff",
  59. Type: "middleman",
  60. })
  61. log.Println(res)
  62. }
  63. }
  64. func TestAssociate(t *testing.T) {
  65. initDb()
  66. //log.Println(NetworkCom.GetEntTagSeat(2))
  67. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 middleman_owner:中间人-业主 middleman_project:中间人-项目 agency:招标代理机构
  68. res := Network.Associate(&types.AssociateReq{
  69. Name: "郑州",
  70. Type: "firstparty",
  71. })
  72. log.Println(res.Data)
  73. }
  74. func TestNetWorkList(t *testing.T) {
  75. initDb()
  76. //类型;firstparty:甲方 supplier:供应商 adiffb:同甲异业 middleman:中间人 agency:招标代理机构
  77. res := Network.List(&types.NetWorkListReq{
  78. PositionId: 943,
  79. Name: "王传进",
  80. })
  81. log.Println(res.Data.(map[string]interface{})["total_page"])
  82. for _, v := range res.Data.(map[string]interface{})["list"].([]map[string]interface{}) {
  83. log.Println(v)
  84. }
  85. }