How to use main method of performance Package

Best Ginkgo code snippet using performance.main

project.go

Source:project.go Github

copy

Full Screen

...141 }142 if screen, err = d.CreateOrUpdateScreen(c, tx, screen); err != nil {143 return144 }145 // 获取的screen自增id复制到maininfo内146 decodedMainInfo.Screens[k].ScreenID = strconv.FormatInt(screen.ID, 10)147 scIDList[int32(k)] = screen.ID148 scStartTimes[int32(k)] = screen.StartTime149 scEndTimes[int32(k)] = screen.EndTime150 }151 // 创建票价152 TkSingleIDList := make(map[int32]int64)153 TkSingleTypeList := make(map[int32]int32)154 var tkPrice model.TicketPrice155 for k, v := range decodedMainInfo.TicketsSingle {156 saleType, _ := strconv.ParseInt(v.Type, 10, 64)157 buyLimit, _ := strconv.ParseInt(v.BuyLimit, 10, 64)158 payMethod, _ := strconv.ParseInt(v.PayMethod, 10, 64)159 ticketID, baseErr := model.GetTicketIDFromBase()160 if ticketID == 0 || baseErr != nil {161 tx.Rollback()162 log.Error("baseCenter获取ticketID失败 ticketid:%s,baseErr:%s", ticketID, baseErr)163 return 0, baseErr164 }165 tkPrice = model.TicketPrice{166 ID: ticketID,167 ProjectID: pid,168 Desc: v.Name,169 Type: 1, // 单场票170 SaleType: int32(saleType),171 Color: v.Color,172 BuyLimit: int32(buyLimit),173 PaymentMethod: int32(payMethod),174 PaymentValue: v.PayValue,175 DescDetail: v.Desc,176 IsSale: 1, // 可售177 IsRefund: -10, // 不可退178 OriginPrice: -1, // 未設置179 MarketPrice: -1,180 SaleStart: TimeNull, // 0000-00-00 00:00:00181 SaleEnd: TimeNull,182 }183 if tkPrice, err = d.CreateOrUpdateTkPrice(c, tx, tkPrice, 0); err != nil {184 return185 }186 //票价限购187 limitData := d.FormatByPrefix(v.BuyLimitNum, "buy_limit_")188 if err = d.CreateOrUpdateTkPriceExtra(c, tx, limitData, ticketID, pid); err != nil {189 return190 }191 // 获取的ticketPrice自增id复制到mainInfo内192 decodedMainInfo.TicketsSingle[k].TicketID = strconv.FormatInt(tkPrice.ID, 10)193 TkSingleIDList[int32(k)] = ticketID194 TkSingleTypeList[int32(k)] = int32(saleType)195 }196 var passScID, allPassScID int64197 // 创建通票场次198 passScID, err = d.GetOrUpdatePassSc(c, tx, pid, decodedMainInfo.TicketsPass, scStartTimes, scEndTimes, scTypePass, 0)199 if err != nil {200 return201 }202 decodedMainInfo.TicketsPass, err = d.InsertOrUpdateTkPass(c, tx, pid, passScID, decodedMainInfo.TicketsPass, TkTypePass, scIDList, TkSingleIDList, TkSingleTypeList)203 if err != nil {204 return205 }206 // 创建联票场次207 allPassScID, err = d.GetOrUpdatePassSc(c, tx, pid, decodedMainInfo.TicketsAllPass, scStartTimes, scEndTimes, scTypeAllPass, 0)208 if err != nil {209 return210 }211 decodedMainInfo.TicketsAllPass, err = d.InsertOrUpdateTkPass(c, tx, pid, allPassScID, decodedMainInfo.TicketsAllPass, TkTypeAllPass, scIDList, TkSingleIDList, TkSingleTypeList)212 if err != nil {213 return214 }215 // 创建标签216 for _, tagID := range decodedMainInfo.TagIDs {217 err = d.CreateTag(c, tx, pid, tagID)218 if err != nil {219 return220 }221 }222 // 创建嘉宾223 guestImgMap := make(map[int64]string)224 // 组合嘉宾对应头像map225 if decodedMainInfo.GuestIDs != nil {226 if decodedMainInfo.GuestImgs == nil {227 var guestInfoList []model.Guest228 if err = d.db.Select("id, guest_img").Where("id IN (?)", decodedMainInfo.GuestIDs).Find(&guestInfoList).Error; err != nil {229 log.Error("获取嘉宾信息失败:%s", err)230 tx.Rollback()231 return232 }233 for _, v := range guestInfoList {234 guestImgMap[v.ID] = v.GuestImg235 }236 } else {237 for _, v := range decodedMainInfo.GuestImgs {238 guestImgMap[v.ID] = v.ImgURL239 }240 }241 }242 var position int64243 for _, guestID := range decodedMainInfo.GuestIDs {244 if err = tx.Create(&model.ProjectGuest{245 ProjectID: pid,246 GuestID: guestID,247 Position: position,248 GuestImg: guestImgMap[guestID],249 }).Error; err != nil {250 log.Error("项目嘉宾添加失败:%s", err)251 tx.Rollback()252 return253 }254 position++255 }256 // 将有场次票价id的mainInfo更新到version_ext257 encodedMainInfo, jsonErr := json.Marshal(decodedMainInfo)258 if jsonErr != nil {259 log.Error("JSONEncode MainInfo失败")260 tx.Rollback()261 return pid, jsonErr262 }263 finalMainInfo := string(encodedMainInfo)264 if len(finalMainInfo) > 4000 {265 log.Error("信息量过大")266 tx.Rollback()267 return pid, ecode.TicketMainInfoTooLarge268 }269 // 编辑version_ext270 err = tx.Model(&model.VersionExt{}).Where("ver_id = ? and type = ?", verID, 1).Update("main_info", finalMainInfo).Error271 if err != nil {272 tx.Rollback()273 log.Error("更新versionext失败: %s", err)274 }275 // 提交事务276 tx.Commit()277 return pid, nil278}279// CreateProject 灌入项目表280func (d *Dao) CreateProject(c context.Context, tx *gorm.DB, verID uint64, decodedMainInfo ProjectMainInfo) (project model.Item, err error) {281 // 创建新project282 venueID, _ := strconv.ParseInt(decodedMainInfo.VenueID, 10, 64)283 placeID, _ := strconv.ParseInt(decodedMainInfo.PlaceID, 10, 64)284 compID, _ := strconv.ParseInt(decodedMainInfo.CompID, 10, 64)285 projectType, _ := strconv.ParseInt(decodedMainInfo.Type, 10, 64)286 projectSponsorType, _ := strconv.ParseInt(decodedMainInfo.SponsorType, 10, 64)287 performanceImg, _ := json.Marshal(decodedMainInfo.PerformanceImg)288 projectInfo := model.Item{289 Name: decodedMainInfo.Name,290 StartTime: decodedMainInfo.StartTime,291 EndTime: decodedMainInfo.EndTime,292 VenueID: venueID,293 PlaceID: placeID,294 CompID: compID,295 PerformanceImage: string(performanceImg),296 TicketDesc: decodedMainInfo.SellingProp,297 Type: int32(projectType),298 VerID: verID,299 SponsorType: int32(projectSponsorType),300 Label: decodedMainInfo.Label,301 BuyNumLimit: BuyNumLimit,302 IsSale: 1, // 默认值可售303 ExpressFee: -2, //默认值304 }305 if err = tx.Create(&projectInfo).Error; err != nil {306 log.Error("新建项目失败:%s", err)307 tx.Rollback()308 return model.Item{}, err309 }310 return projectInfo, nil311}312// CreateProjectExtInfo 灌入项目详情表313func (d *Dao) CreateProjectExtInfo(c context.Context, tx *gorm.DB, projectID int64, performanceDesc string) (err error) {314 projectExtInfo := model.ItemDetail{315 ProjectID: projectID,316 PerformanceDesc: performanceDesc,317 }318 if err = tx.Create(&projectExtInfo).Error; err != nil {319 log.Error("新建项目详情失败:%s", err)320 tx.Rollback()321 return err322 }323 return nil324}325// GetDefaultMainInfo 获取初始化数组的mainInfo326func (d *Dao) GetDefaultMainInfo() ProjectMainInfo {327 return ProjectMainInfo{328 Docs: []ImgInfo{},329 Screens: []Screen{},330 TicketsSingle: []TicketSingle{},331 TicketsPass: []TicketPass{},332 TicketsAllPass: []TicketPass{},333 TagIDs: []string{},334 GuestIDs: []int64{},335 GuestImgs: []GuestImg{},336 }337}...

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("Hello, World!")4}5import "fmt"6func main() {7 fmt.Println("Hello, World!")8}9import "fmt"10func main() {11 fmt.Println("Hello, World!")12}13import "fmt"14func main() {15 fmt.Println("Hello, World!")16}17import "fmt"18func main() {19 fmt.Println("Hello, World!")20}21import "fmt"22func main() {23 fmt.Println("Hello, World!")24}25import "fmt"26func main() {27 fmt.Println("Hello, World!")28}29import "fmt"30func main() {31 fmt.Println("Hello, World!")32}33import "fmt"34func main() {35 fmt.Println("Hello, World!")36}37import "fmt"38func main() {39 fmt.Println("Hello, World!")40}41import "fmt"42func main() {43 fmt.Println("Hello, World!")44}45import "fmt"46func main() {47 fmt.Println("Hello, World!")48}49import "fmt"50func main() {51 fmt.Println("Hello, World!")52}53import "fmt"54func main() {55 fmt.Println("Hello, World!")56}57import "fmt"58func main() {59 fmt.Println("Hello, World!")60}

Full Screen

Full Screen

main

Using AI Code Generation

copy

Full Screen

1import performance2func main() {3 performance.main()4}5import performance6func main() {7 performance.main()8}9import performance10func main() {11 performance.main()12}13import performance14func main() {15 performance.main()16}17import performance18func main() {19 performance.main()20}21import performance22func main() {23 performance.main()24}25import performance26func main() {27 performance.main()28}29import performance30func main() {31 performance.main()32}33import performance34func main() {35 performance.main()36}37import performance38func main() {39 performance.main()40}41import performance42func main() {43 performance.main()44}45import performance46func main() {47 performance.main()48}49import performance50func main() {51 performance.main()52}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Ginkgo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful