package test import ( "ecos/application/domain/shop_decoration" "git.sxidc.com/go-framework/baize/framework/core/api/request" "git.sxidc.com/go-framework/baize/framework/core/api/response" "git.sxidc.com/go-tools/utils/strutils" "net/http" "testing" ) func TestShopDecoration(t *testing.T) { Init() defer Destroy() var shopDecorationID string var totalCount int64 shopDecorationInfo := new(shop_decoration.Info) shopDecorationInfos := make([]shop_decoration.Info, 0) tenantID := strutils.SimpleUUID() createUserID := strutils.SimpleUUID() updateUserID := strutils.SimpleUUID() deleteUserID := strutils.SimpleUUID() operatorUserName := strutils.SimpleUUID() name := strutils.SimpleUUID() pageClientType := strutils.SimpleUUID() pageData := strutils.SimpleUUID() pageType := strutils.SimpleUUID() pageShow := strutils.SimpleUUID() newName := strutils.SimpleUUID() newPageClientType := strutils.SimpleUUID() newPageData := strutils.SimpleUUID() newPageType := strutils.SimpleUUID() newPageShow := strutils.SimpleUUID() NewToolKit(t).CreateShopDecoration(tenantID, name, pageClientType, pageData, pageType, pageShow, createUserID, operatorUserName, &shopDecorationID). GetShopDecoration(tenantID, shopDecorationID, shopDecorationInfo). AssertEqual(tenantID, shopDecorationInfo.TenantID, "店铺装修列表租户ID不一致"). AssertEqual(shopDecorationID, shopDecorationInfo.ID, "店铺装修列表ID不一致"). AssertEqual(name, shopDecorationInfo.Name, "店铺装修列表页面名称不一致"). AssertEqual(pageClientType, shopDecorationInfo.PageClientType, "店铺装修列表客户端类型不一致"). AssertEqual(pageData, shopDecorationInfo.PageData, "店铺装修列表页面数据不一致"). AssertEqual(pageType, shopDecorationInfo.PageType, "店铺装修列表页面类型不一致"). AssertEqual(pageShow, shopDecorationInfo.PageShow, "店铺装修列表页面开关状态不一致"). AssertEqual(createUserID, shopDecorationInfo.CreateUserID, "创建用户ID不一致"). AssertEqual(createUserID, shopDecorationInfo.LastUpdateUserID, "最近更新用户ID不一致"). AssertNotEmpty(shopDecorationInfo.CreatedTime, "创建时间为空"). AssertNotEmpty(shopDecorationInfo.LastUpdatedTime, "最近更新时间为空"). GetShopDecorations(tenantID, name, pageClientType, pageData, pageType, pageShow, "1", "1", &shopDecorationInfos, &totalCount). AssertEqual(int(totalCount), len(shopDecorationInfos), "总数不一致"). AssertEqual(tenantID, shopDecorationInfos[0].TenantID, "店铺装修列表租户ID不一致"). AssertEqual(shopDecorationID, shopDecorationInfos[0].ID, "店铺装修列表ID不一致"). AssertEqual(name, shopDecorationInfos[0].Name, "店铺装修列表页面名称不一致"). AssertEqual(pageClientType, shopDecorationInfos[0].PageClientType, "店铺装修列表客户端类型不一致"). AssertEqual(pageData, shopDecorationInfos[0].PageData, "店铺装修列表页面数据不一致"). AssertEqual(pageType, shopDecorationInfos[0].PageType, "店铺装修列表页面类型不一致"). AssertEqual(pageShow, shopDecorationInfos[0].PageShow, "店铺装修列表页面开关状态不一致"). AssertEqual(createUserID, shopDecorationInfos[0].CreateUserID, "创建用户ID不一致"). AssertEqual(createUserID, shopDecorationInfos[0].LastUpdateUserID, "最近更新用户ID不一致"). AssertNotEmpty(shopDecorationInfos[0].CreatedTime, "创建时间为空"). AssertNotEmpty(shopDecorationInfos[0].LastUpdatedTime, "最近更新时间为空"). GetShopDecorations(tenantID, name, pageClientType, pageData, pageType, pageShow, "0", "0", &shopDecorationInfos, &totalCount). AssertEqual(int(totalCount), len(shopDecorationInfos), "总数不一致"). AssertEqual(1, len(shopDecorationInfos), "店铺装修列表数应当为1"). AssertEqual(tenantID, shopDecorationInfos[0].TenantID, "店铺装修列表租户ID不一致"). AssertEqual(shopDecorationID, shopDecorationInfos[0].ID, "店铺装修列表ID不一致"). AssertEqual(name, shopDecorationInfos[0].Name, "店铺装修列表页面名称不一致"). AssertEqual(pageClientType, shopDecorationInfos[0].PageClientType, "店铺装修列表客户端类型不一致"). AssertEqual(pageData, shopDecorationInfos[0].PageData, "店铺装修列表页面数据不一致"). AssertEqual(pageType, shopDecorationInfos[0].PageType, "店铺装修列表页面类型不一致"). AssertEqual(pageShow, shopDecorationInfos[0].PageShow, "店铺装修列表页面开关状态不一致"). AssertEqual(createUserID, shopDecorationInfos[0].CreateUserID, "创建用户ID不一致"). AssertEqual(createUserID, shopDecorationInfos[0].LastUpdateUserID, "最近更新用户ID不一致"). AssertNotEmpty(shopDecorationInfos[0].CreatedTime, "创建时间为空"). AssertNotEmpty(shopDecorationInfos[0].LastUpdatedTime, "最近更新时间为空"). UpdateShopDecoration(shopDecorationID, newName, newPageClientType, newPageData, newPageType, newPageShow, updateUserID, operatorUserName). GetShopDecorations(tenantID, newName, newPageClientType, newPageData, newPageType, newPageShow, "1", "1", &shopDecorationInfos, &totalCount). AssertEqual(int(totalCount), len(shopDecorationInfos), "总数不一致"). AssertEqual(tenantID, shopDecorationInfos[0].TenantID, "店铺装修列表租户ID不一致"). AssertEqual(shopDecorationID, shopDecorationInfos[0].ID, "店铺装修列表ID不一致"). AssertEqual(newName, shopDecorationInfos[0].Name, "店铺装修列表页面名称不一致"). AssertEqual(newPageClientType, shopDecorationInfos[0].PageClientType, "店铺装修列表客户端类型不一致"). AssertEqual(newPageData, shopDecorationInfos[0].PageData, "店铺装修列表页面数据不一致"). AssertEqual(newPageType, shopDecorationInfos[0].PageType, "店铺装修列表页面类型不一致"). AssertEqual(newPageShow, shopDecorationInfos[0].PageShow, "店铺装修列表页面开关状态不一致"). AssertEqual(createUserID, shopDecorationInfos[0].CreateUserID, "创建用户ID不一致"). AssertEqual(updateUserID, shopDecorationInfos[0].LastUpdateUserID, "最近更新用户ID不一致"). AssertNotEmpty(shopDecorationInfos[0].CreatedTime, "创建时间为空"). AssertNotEmpty(shopDecorationInfos[0].LastUpdatedTime, "最近更新时间为空"). DeleteShopDecoration(shopDecorationID, deleteUserID, operatorUserName). GetShopDecorations(tenantID, newName, newPageClientType, newPageData, newPageType, newPageShow, "1", "1", &shopDecorationInfos, &totalCount). AssertEqual(int(totalCount), len(shopDecorationInfos), "总数不一致"). AssertEqual(0, len(shopDecorationInfos), "删除店铺装修列表失败") } /* HAC: TEST RELATION FUNCTIONS */ /* HAC: END TEST RELATION FUNCTIONS */ func (toolKit *ToolKit) CreateShopDecoration(tenantID string, name string, pageClientType string, pageData string, pageType string, pageShow string, createUserID string, operatorUserName string, shopDecorationID *string) *ToolKit { idResponse := new(response.IDResponse) toolKit.SetHeader("Content-Type", "application/json"). SetJsonBody(&shop_decoration.CreateShopDecorationJsonBody{ Name: name, PageClientType: pageClientType, PageData: pageData, PageType: pageType, PageShow: pageShow, TenantIDJsonBody: request.TenantIDJsonBody{TenantID: tenantID}, CreateUserIDJsonBody: request.CreateUserIDJsonBody{CreateUserID: createUserID}, OperatorUserNameJsonBody: request.OperatorUserNameJsonBody{OperatorUserName: operatorUserName}, }). SetJsonResponse(idResponse). Request("/ecos/api/v1/shopDecoration/create", http.MethodPost). AssertStatusCode(http.StatusOK). AssertEqual(true, idResponse.Success, idResponse.Msg). AssertNotEmpty(idResponse.ID, "店铺装修列表ID为空") if shopDecorationID != nil { *shopDecorationID = idResponse.ID } return toolKit } func (toolKit *ToolKit) DeleteShopDecoration(id string, deleteUserID string, operatorUserName string) *ToolKit { msgResponse := new(response.MsgResponse) toolKit.SetHeader("Content-Type", "application/json"). SetJsonResponse(msgResponse). SetQueryParams("id", id). SetQueryParams("deleteUserId", deleteUserID). SetQueryParams("operatorUserName", operatorUserName). Request("/ecos/api/v1/shopDecoration/delete", http.MethodDelete). AssertStatusCode(http.StatusOK). AssertEqual(true, msgResponse.Success, msgResponse.Msg) return toolKit } func (toolKit *ToolKit) UpdateShopDecoration(id string, name string, pageClientType string, pageData string, pageType string, pageShow string, updateUserID string, operatorUserName string) *ToolKit { msgResponse := new(response.MsgResponse) toolKit.SetHeader("Content-Type", "application/json"). SetJsonBody(&shop_decoration.UpdateShopDecorationJsonBody{ IDJsonBody: request.IDJsonBody{ID: id}, Name: name, PageClientType: pageClientType, PageData: pageData, PageType: pageType, PageShow: pageShow, UpdateUserIDJsonBody: request.UpdateUserIDJsonBody{UpdateUserID: updateUserID}, OperatorUserNameJsonBody: request.OperatorUserNameJsonBody{OperatorUserName: operatorUserName}, }). SetJsonResponse(msgResponse). Request("/ecos/api/v1/shopDecoration/update", http.MethodPut). AssertStatusCode(http.StatusOK). AssertEqual(true, msgResponse.Success, msgResponse.Msg) return toolKit } func (toolKit *ToolKit) GetShopDecorations(tenantID string, name string, pageClientType string, pageData string, pageType string, pageShow string, pageNo string, pageSize string, retInfos *[]shop_decoration.Info, retTotalCount *int64) *ToolKit { infosResponse := new(response.InfosResponse[shop_decoration.Info]) toolKit.SetHeader("Content-Type", "application/json"). SetJsonResponse(infosResponse). SetQueryParams("tenantId", tenantID). SetQueryParams("name", name). SetQueryParams("pageClientType", pageClientType). SetQueryParams("pageData", pageData). SetQueryParams("pageType", pageType). SetQueryParams("pageShow", pageShow). SetQueryParams("pageNo", pageNo). SetQueryParams("pageSize", pageSize). Request("/ecos/api/v1/shopDecoration/query", http.MethodGet). AssertStatusCode(http.StatusOK). AssertEqual(true, infosResponse.Success, infosResponse.Msg) if retInfos != nil { *retInfos = make([]shop_decoration.Info, 0) *retInfos = append(*retInfos, infosResponse.Infos...) } if retTotalCount != nil { *retTotalCount = infosResponse.TotalCount } return toolKit } func (toolKit *ToolKit) GetShopDecoration(tenantID string, id string, retInfo *shop_decoration.Info) *ToolKit { infoResponse := new(response.InfoResponse[*shop_decoration.Info]) toolKit.SetHeader("Content-Type", "application/json"). SetJsonResponse(infoResponse). SetQueryParams("tenantId", tenantID). SetQueryParams("id", id). Request("/ecos/api/v1/shopDecoration/get", http.MethodGet). AssertStatusCode(http.StatusOK). AssertEqual(true, infoResponse.Success, infoResponse.Msg) if retInfo != nil { *retInfo = shop_decoration.Info{} *retInfo = *infoResponse.Info } return toolKit } /* HAC: TEST RELATION METHODS */ /* HAC: END TEST RELATION METHODS */