From bf475ac92b09ef66940b3a20a23fcd8408d68208 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 26 四月 2024 14:38:11 +0800 Subject: [PATCH] preload --- models/salary_plan.go | 4 ++++ controllers/salary_plan_controller.go | 2 +- 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/controllers/salary_plan_controller.go b/controllers/salary_plan_controller.go index 150a07c..fb8d9aa 100644 --- a/controllers/salary_plan_controller.go +++ b/controllers/salary_plan_controller.go @@ -71,7 +71,7 @@ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") return } - find, total, err := models.NewSalaryPlanSearch().SetPage(params.Page, params.PageSize).Find() + find, total, err := models.NewSalaryPlanSearch().SetPage(params.Page, params.PageSize).SetPreload(true).Find() if err != nil { util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") return diff --git a/models/salary_plan.go b/models/salary_plan.go index fc47b52..1c326ec 100644 --- a/models/salary_plan.go +++ b/models/salary_plan.go @@ -62,6 +62,10 @@ db = db.Where("id = ?", slf.ID) } + if slf.Preload { + db = db.Model(&SalaryPlan{}).Preload("WorkTypes") + } + return db } -- Gitblit v1.8.0