about_us_test.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. package test
  2. import (
  3. "erpims/application/domain/about_us"
  4. "git.sxidc.com/go-framework/baize/framework/core/api/request"
  5. "git.sxidc.com/go-framework/baize/framework/core/api/response"
  6. "git.sxidc.com/go-tools/utils/strutils"
  7. "net/http"
  8. "testing"
  9. )
  10. func TestAboutUs(t *testing.T) {
  11. Init()
  12. defer Destroy()
  13. var aboutUsID string
  14. var totalCount int64
  15. aboutUsInfo := new(about_us.Info)
  16. aboutUsInfos := make([]about_us.Info, 0)
  17. createUserID := strutils.SimpleUUID()
  18. updateUserID := strutils.SimpleUUID()
  19. deleteUserID := strutils.SimpleUUID()
  20. operatorUserName := strutils.SimpleUUID()
  21. companyTel := strutils.SimpleUUID()
  22. onlineShoppingTel := strutils.SimpleUUID()
  23. afterSaleTel := strutils.SimpleUUID()
  24. companyAddress := strutils.SimpleUUID()
  25. postCode := strutils.SimpleUUID()
  26. fax := strutils.SimpleUUID()
  27. email := strutils.SimpleUUID()
  28. wxMpQrCode := strutils.SimpleUUID()
  29. copyright := strutils.SimpleUUID()
  30. recordNumber := strutils.SimpleUUID()
  31. contactQrCode := strutils.SimpleUUID()
  32. newCompanyTel := strutils.SimpleUUID()
  33. newOnlineShoppingTel := strutils.SimpleUUID()
  34. newAfterSaleTel := strutils.SimpleUUID()
  35. newCompanyAddress := strutils.SimpleUUID()
  36. newPostCode := strutils.SimpleUUID()
  37. newFax := strutils.SimpleUUID()
  38. newEmail := strutils.SimpleUUID()
  39. newWxMpQrCode := strutils.SimpleUUID()
  40. newCopyright := strutils.SimpleUUID()
  41. newRecordNumber := strutils.SimpleUUID()
  42. newContactQrCode := strutils.SimpleUUID()
  43. NewToolKit(t).CreateAboutUs(companyTel, onlineShoppingTel, afterSaleTel, companyAddress, postCode, fax, email, wxMpQrCode, copyright, recordNumber, contactQrCode, createUserID, operatorUserName, &aboutUsID).
  44. GetAboutUs(aboutUsID, aboutUsInfo).
  45. AssertEqual(aboutUsID, aboutUsInfo.ID, "关于我们ID不一致").
  46. AssertEqual(companyTel, aboutUsInfo.CompanyTel, "关于我们公司电话不一致").
  47. AssertEqual(onlineShoppingTel, aboutUsInfo.OnlineShoppingTel, "关于我们网购热线不一致").
  48. AssertEqual(afterSaleTel, aboutUsInfo.AfterSaleTel, "关于我们访问路径不一致").
  49. AssertEqual(companyAddress, aboutUsInfo.CompanyAddress, "关于我们公司地址不一致").
  50. AssertEqual(postCode, aboutUsInfo.PostCode, "关于我们邮编不一致").
  51. AssertEqual(fax, aboutUsInfo.Fax, "关于我们传真不一致").
  52. AssertEqual(email, aboutUsInfo.Email, "关于我们邮箱不一致").
  53. AssertEqual(wxMpQrCode, aboutUsInfo.WxMpQrCode, "关于我们微信公众号二维码不一致").
  54. AssertEqual(copyright, aboutUsInfo.Copyright, "关于我们版权所有不一致").
  55. AssertEqual(recordNumber, aboutUsInfo.RecordNumber, "关于我们备案号不一致").
  56. AssertEqual(contactQrCode, aboutUsInfo.ContactQrCode, "关于我们联系方式二维码不一致").
  57. AssertEqual(createUserID, aboutUsInfo.CreateUserID, "创建用户ID不一致").
  58. AssertEqual(createUserID, aboutUsInfo.LastUpdateUserID, "最近更新用户ID不一致").
  59. AssertNotEmpty(aboutUsInfo.CreatedTime, "创建时间为空").
  60. AssertNotEmpty(aboutUsInfo.LastUpdatedTime, "最近更新时间为空").
  61. GetAboutUses(companyTel, onlineShoppingTel, afterSaleTel, companyAddress, postCode, fax, email, wxMpQrCode, copyright, recordNumber, contactQrCode, "1", "1", &aboutUsInfos, &totalCount).
  62. AssertEqual(int(totalCount), len(aboutUsInfos), "总数不一致").
  63. AssertEqual(aboutUsID, aboutUsInfos[0].ID, "关于我们ID不一致").
  64. AssertEqual(companyTel, aboutUsInfos[0].CompanyTel, "关于我们公司电话不一致").
  65. AssertEqual(onlineShoppingTel, aboutUsInfos[0].OnlineShoppingTel, "关于我们网购热线不一致").
  66. AssertEqual(afterSaleTel, aboutUsInfos[0].AfterSaleTel, "关于我们访问路径不一致").
  67. AssertEqual(companyAddress, aboutUsInfos[0].CompanyAddress, "关于我们公司地址不一致").
  68. AssertEqual(postCode, aboutUsInfos[0].PostCode, "关于我们邮编不一致").
  69. AssertEqual(fax, aboutUsInfos[0].Fax, "关于我们传真不一致").
  70. AssertEqual(email, aboutUsInfos[0].Email, "关于我们邮箱不一致").
  71. AssertEqual(wxMpQrCode, aboutUsInfos[0].WxMpQrCode, "关于我们微信公众号二维码不一致").
  72. AssertEqual(copyright, aboutUsInfos[0].Copyright, "关于我们版权所有不一致").
  73. AssertEqual(recordNumber, aboutUsInfos[0].RecordNumber, "关于我们备案号不一致").
  74. AssertEqual(contactQrCode, aboutUsInfos[0].ContactQrCode, "关于我们联系方式二维码不一致").
  75. AssertEqual(createUserID, aboutUsInfos[0].CreateUserID, "创建用户ID不一致").
  76. AssertEqual(createUserID, aboutUsInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
  77. AssertNotEmpty(aboutUsInfos[0].CreatedTime, "创建时间为空").
  78. AssertNotEmpty(aboutUsInfos[0].LastUpdatedTime, "最近更新时间为空").
  79. GetAboutUses(companyTel, onlineShoppingTel, afterSaleTel, companyAddress, postCode, fax, email, wxMpQrCode, copyright, recordNumber, contactQrCode, "0", "0", &aboutUsInfos, &totalCount).
  80. AssertEqual(int(totalCount), len(aboutUsInfos), "总数不一致").
  81. AssertEqual(1, len(aboutUsInfos), "关于我们数应当为1").
  82. AssertEqual(aboutUsID, aboutUsInfos[0].ID, "关于我们ID不一致").
  83. AssertEqual(companyTel, aboutUsInfos[0].CompanyTel, "关于我们公司电话不一致").
  84. AssertEqual(onlineShoppingTel, aboutUsInfos[0].OnlineShoppingTel, "关于我们网购热线不一致").
  85. AssertEqual(afterSaleTel, aboutUsInfos[0].AfterSaleTel, "关于我们访问路径不一致").
  86. AssertEqual(companyAddress, aboutUsInfos[0].CompanyAddress, "关于我们公司地址不一致").
  87. AssertEqual(postCode, aboutUsInfos[0].PostCode, "关于我们邮编不一致").
  88. AssertEqual(fax, aboutUsInfos[0].Fax, "关于我们传真不一致").
  89. AssertEqual(email, aboutUsInfos[0].Email, "关于我们邮箱不一致").
  90. AssertEqual(wxMpQrCode, aboutUsInfos[0].WxMpQrCode, "关于我们微信公众号二维码不一致").
  91. AssertEqual(copyright, aboutUsInfos[0].Copyright, "关于我们版权所有不一致").
  92. AssertEqual(recordNumber, aboutUsInfos[0].RecordNumber, "关于我们备案号不一致").
  93. AssertEqual(contactQrCode, aboutUsInfos[0].ContactQrCode, "关于我们联系方式二维码不一致").
  94. AssertEqual(createUserID, aboutUsInfos[0].CreateUserID, "创建用户ID不一致").
  95. AssertEqual(createUserID, aboutUsInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
  96. AssertNotEmpty(aboutUsInfos[0].CreatedTime, "创建时间为空").
  97. AssertNotEmpty(aboutUsInfos[0].LastUpdatedTime, "最近更新时间为空").
  98. UpdateAboutUs(aboutUsID, newCompanyTel, newOnlineShoppingTel, newAfterSaleTel, newCompanyAddress, newPostCode, newFax, newEmail, newWxMpQrCode, newCopyright, newRecordNumber, newContactQrCode, updateUserID, operatorUserName).
  99. GetAboutUses(newCompanyTel, newOnlineShoppingTel, newAfterSaleTel, newCompanyAddress, newPostCode, newFax, newEmail, newWxMpQrCode, newCopyright, newRecordNumber, newContactQrCode, "1", "1", &aboutUsInfos, &totalCount).
  100. AssertEqual(int(totalCount), len(aboutUsInfos), "总数不一致").
  101. AssertEqual(aboutUsID, aboutUsInfos[0].ID, "关于我们ID不一致").
  102. AssertEqual(newCompanyTel, aboutUsInfos[0].CompanyTel, "关于我们公司电话不一致").
  103. AssertEqual(newOnlineShoppingTel, aboutUsInfos[0].OnlineShoppingTel, "关于我们网购热线不一致").
  104. AssertEqual(newAfterSaleTel, aboutUsInfos[0].AfterSaleTel, "关于我们访问路径不一致").
  105. AssertEqual(newCompanyAddress, aboutUsInfos[0].CompanyAddress, "关于我们公司地址不一致").
  106. AssertEqual(newPostCode, aboutUsInfos[0].PostCode, "关于我们邮编不一致").
  107. AssertEqual(newFax, aboutUsInfos[0].Fax, "关于我们传真不一致").
  108. AssertEqual(newEmail, aboutUsInfos[0].Email, "关于我们邮箱不一致").
  109. AssertEqual(newWxMpQrCode, aboutUsInfos[0].WxMpQrCode, "关于我们微信公众号二维码不一致").
  110. AssertEqual(newCopyright, aboutUsInfos[0].Copyright, "关于我们版权所有不一致").
  111. AssertEqual(newRecordNumber, aboutUsInfos[0].RecordNumber, "关于我们备案号不一致").
  112. AssertEqual(newContactQrCode, aboutUsInfos[0].ContactQrCode, "关于我们联系方式二维码不一致").
  113. AssertEqual(createUserID, aboutUsInfos[0].CreateUserID, "创建用户ID不一致").
  114. AssertEqual(updateUserID, aboutUsInfos[0].LastUpdateUserID, "最近更新用户ID不一致").
  115. AssertNotEmpty(aboutUsInfos[0].CreatedTime, "创建时间为空").
  116. AssertNotEmpty(aboutUsInfos[0].LastUpdatedTime, "最近更新时间为空").
  117. DeleteAboutUs(aboutUsID, deleteUserID, operatorUserName).
  118. GetAboutUses(newCompanyTel, newOnlineShoppingTel, newAfterSaleTel, newCompanyAddress, newPostCode, newFax, newEmail, newWxMpQrCode, newCopyright, newRecordNumber, newContactQrCode, "1", "1", &aboutUsInfos, &totalCount).
  119. AssertEqual(int(totalCount), len(aboutUsInfos), "总数不一致").
  120. AssertEqual(0, len(aboutUsInfos), "删除关于我们失败")
  121. }
  122. /* HAC: TEST RELATION FUNCTIONS */
  123. /* HAC: END TEST RELATION FUNCTIONS */
  124. func (toolKit *ToolKit) CreateAboutUs(companyTel string, onlineShoppingTel string, afterSaleTel string, companyAddress string, postCode string, fax string, email string, wxMpQrCode string, copyright string, recordNumber string, contactQrCode string, createUserID string, operatorUserName string, aboutUsID *string) *ToolKit {
  125. idResponse := new(response.IDResponse)
  126. toolKit.SetHeader("Content-Type", "application/json").
  127. SetJsonBody(&about_us.CreateAboutUsJsonBody{
  128. CompanyTel: companyTel, OnlineShoppingTel: onlineShoppingTel, AfterSaleTel: afterSaleTel, CompanyAddress: companyAddress, PostCode: postCode, Fax: fax, Email: email, WxMpQrCode: wxMpQrCode, Copyright: copyright, RecordNumber: recordNumber, ContactQrCode: contactQrCode,
  129. CreateUserIDJsonBody: request.CreateUserIDJsonBody{CreateUserID: createUserID},
  130. OperatorUserNameJsonBody: request.OperatorUserNameJsonBody{OperatorUserName: operatorUserName},
  131. }).
  132. SetJsonResponse(idResponse).
  133. Request("/erpims/api/v1/aboutUs/create", http.MethodPost).
  134. AssertStatusCode(http.StatusOK).
  135. AssertEqual(true, idResponse.Success, idResponse.Msg).
  136. AssertNotEmpty(idResponse.ID, "关于我们ID为空")
  137. if aboutUsID != nil {
  138. *aboutUsID = idResponse.ID
  139. }
  140. return toolKit
  141. }
  142. func (toolKit *ToolKit) DeleteAboutUs(id string, deleteUserID string, operatorUserName string) *ToolKit {
  143. msgResponse := new(response.MsgResponse)
  144. toolKit.SetHeader("Content-Type", "application/json").
  145. SetJsonResponse(msgResponse).
  146. SetQueryParams("id", id).
  147. SetQueryParams("deleteUserId", deleteUserID).
  148. SetQueryParams("operatorUserName", operatorUserName).
  149. Request("/erpims/api/v1/aboutUs/delete", http.MethodDelete).
  150. AssertStatusCode(http.StatusOK).
  151. AssertEqual(true, msgResponse.Success, msgResponse.Msg)
  152. return toolKit
  153. }
  154. func (toolKit *ToolKit) UpdateAboutUs(id string, companyTel string, onlineShoppingTel string, afterSaleTel string, companyAddress string, postCode string, fax string, email string, wxMpQrCode string, copyright string, recordNumber string, contactQrCode string, updateUserID string, operatorUserName string) *ToolKit {
  155. msgResponse := new(response.MsgResponse)
  156. toolKit.SetHeader("Content-Type", "application/json").
  157. SetJsonBody(&about_us.UpdateAboutUsJsonBody{
  158. IDJsonBody: request.IDJsonBody{ID: id},
  159. CompanyTel: companyTel,
  160. OnlineShoppingTel: onlineShoppingTel,
  161. AfterSaleTel: afterSaleTel,
  162. CompanyAddress: companyAddress,
  163. PostCode: postCode,
  164. Fax: fax,
  165. Email: email,
  166. WxMpQrCode: wxMpQrCode,
  167. Copyright: copyright,
  168. RecordNumber: recordNumber,
  169. ContactQrCode: contactQrCode,
  170. UpdateUserIDJsonBody: request.UpdateUserIDJsonBody{UpdateUserID: updateUserID},
  171. OperatorUserNameJsonBody: request.OperatorUserNameJsonBody{OperatorUserName: operatorUserName},
  172. }).
  173. SetJsonResponse(msgResponse).
  174. Request("/erpims/api/v1/aboutUs/update", http.MethodPut).
  175. AssertStatusCode(http.StatusOK).
  176. AssertEqual(true, msgResponse.Success, msgResponse.Msg)
  177. return toolKit
  178. }
  179. func (toolKit *ToolKit) GetAboutUses(companyTel string, onlineShoppingTel string, afterSaleTel string, companyAddress string, postCode string, fax string, email string, wxMpQrCode string, copyright string, recordNumber string, contactQrCode string, pageNo string, pageSize string, retInfos *[]about_us.Info, retTotalCount *int64) *ToolKit {
  180. infosResponse := new(response.InfosResponse[about_us.Info])
  181. toolKit.SetHeader("Content-Type", "application/json").
  182. SetJsonResponse(infosResponse).
  183. SetQueryParams("companyTel", companyTel).
  184. SetQueryParams("onlineShoppingTel", onlineShoppingTel).
  185. SetQueryParams("afterSaleTel", afterSaleTel).
  186. SetQueryParams("companyAddress", companyAddress).
  187. SetQueryParams("postCode", postCode).
  188. SetQueryParams("fax", fax).
  189. SetQueryParams("email", email).
  190. SetQueryParams("wxMpQrCode", wxMpQrCode).
  191. SetQueryParams("copyright", copyright).
  192. SetQueryParams("recordNumber", recordNumber).
  193. SetQueryParams("contactQrCode", contactQrCode).
  194. SetQueryParams("pageNo", pageNo).
  195. SetQueryParams("pageSize", pageSize).
  196. Request("/erpims/api/v1/aboutUs/query", http.MethodGet).
  197. AssertStatusCode(http.StatusOK).
  198. AssertEqual(true, infosResponse.Success, infosResponse.Msg)
  199. if retInfos != nil {
  200. *retInfos = make([]about_us.Info, 0)
  201. *retInfos = append(*retInfos, infosResponse.Infos...)
  202. }
  203. if retTotalCount != nil {
  204. *retTotalCount = infosResponse.TotalCount
  205. }
  206. return toolKit
  207. }
  208. func (toolKit *ToolKit) GetAboutUs(id string, retInfo *about_us.Info) *ToolKit {
  209. infoResponse := new(response.InfoResponse[*about_us.Info])
  210. toolKit.SetHeader("Content-Type", "application/json").
  211. SetJsonResponse(infoResponse).
  212. SetQueryParams("id", id).
  213. Request("/erpims/api/v1/aboutUs/get", http.MethodGet).
  214. AssertStatusCode(http.StatusOK).
  215. AssertEqual(true, infoResponse.Success, infoResponse.Msg)
  216. if retInfo != nil {
  217. *retInfo = about_us.Info{}
  218. *retInfo = *infoResponse.Info
  219. }
  220. return toolKit
  221. }
  222. /* HAC: TEST RELATION METHODS */
  223. /* HAC: END TEST RELATION METHODS */