diff --git a/hasaki-gen-crud/template.go b/hasaki-gen-crud/template.go index c4929aa..864c2d6 100644 --- a/hasaki-gen-crud/template.go +++ b/hasaki-gen-crud/template.go @@ -56,9 +56,11 @@ func (TempLowHead3A60 *Temp3A60) init() { //todo } -func (TempLowHead3A60 *Temp3A60) joinTable() (types, sqlx, condition, alias string) { +func (TempLowHead3A60 *Temp3A60) joinTable() (typesAndsqlxAndcondition [][]string) { //todo - return "LEFT", "", "Temp3A60.id=Temp3A60_id", "tmp" + return [][]string{ + // {"LEFT", "(SELECT id as mbrand_id,name FROM `ox_brand`) as tmp", "tmp.mbrand_id=brand_id"}, + } } // saveAllCols 保存时是否全量保存 @@ -170,9 +172,9 @@ func (TempLowHead3A60 *Temp3A60) Load() (err error) { session := TempLowHead3A60.getXorm().NewSession() defer session.Close() - types, sqlx, condition, alias := TempLowHead3A60.joinTable() - if sqlx != "" { - session = session.Join(types, sqlx, condition, alias) + typesAndSqlxAndCndition := TempLowHead3A60.joinTable() + for _, v := range typesAndSqlxAndCndition { + session = session.Join(v[0], v[1], v[2]) } if whereQuery != "" { @@ -205,9 +207,9 @@ func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) { session.Close() }() - types, sqlx, condition, alias := TempLowHead3A60.joinTable() - if sqlx != "" { - session = session.Join(types, sqlx, condition, alias) + typesAndSqlxAndCndition := TempLowHead3A60.joinTable() + for _, v := range typesAndSqlxAndCndition { + session = session.Join(v[0], v[1], v[2]) } if q != "" { @@ -244,11 +246,10 @@ func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60, session.Close() }() - types, sqlx, condition, alias := TempLowHead3A60.joinTable() - if sqlx != "" { - session = session.Join(types, sqlx, condition, alias) + typesAndSqlxAndCndition := TempLowHead3A60.joinTable() + for _, v := range typesAndSqlxAndCndition { + session = session.Join(v[0], v[1], v[2]) } - if q != "" { session = session.Where(q, args...) }