package schema type ymtSchema struct{} func (ymtSchema) TableName(t string) string { if t == "order" { return "order_info" } return t } func (s ymtSchema) MapField(t, f string) (string, bool) { if t == "order" { switch f { case "order_number": return "order_no", true case "key": return "key_code", true case "creator": return "user_id", true case "out_trade_no": return "out_order_no", true case "plan_id": return "activity_id", true case "reseller_id": return "merchant_id", true case "product_id": return "goods_id", true case "pay_amount": return "pay_price", true case "key_batch_id": return "key_batch_name", true default: return f, true } } return f, true } func (s ymtSchema) BuildJoins(need map[string]bool, main string) []string { out := []string{} if need["order_cash"] { out = append(out, " LEFT JOIN `order_cash` ON `order_cash`.order_no = `order_info`.order_no") } if need["order_voucher"] { out = append(out, " LEFT JOIN `order_voucher` ON `order_voucher`.order_no = `order_info`.order_no") } if need["order_digit"] { out = append(out, " LEFT JOIN `order_digit` ON `order_digit`.order_no = `order_info`.order_no") } if need["goods_voucher_batch"] { out = append(out, " LEFT JOIN `goods_voucher_batch` ON `goods_voucher_batch`.channel_batch_no = `order_voucher`.channel_batch_no") } if need["goods_voucher_subject_config"] { out = append(out, " LEFT JOIN `goods_voucher_subject_config` ON `goods_voucher_subject_config`.id = `goods_voucher_batch`.voucher_subject_id") } if need["merchant"] { out = append(out, " LEFT JOIN `merchant` ON `merchant`.id = `order_info`.merchant_id") } if need["activity"] { out = append(out, " LEFT JOIN `activity` ON `activity`.id = `order_info`.activity_id") } return out } func (s ymtSchema) FilterColumn(key string) (string, string, bool) { switch key { case "creator_in": return "order", "user_id", true case "create_time_between": return "order", "create_time", true case "type_eq": return "order", "type", true case "out_trade_no_eq": return "order", "out_order_no", true case "account_eq": return "order", "account", true case "plan_id_eq": return "order", "activity_id", true case "key_batch_id_eq": return "order", "key_batch_name", true case "product_id_eq": return "order", "goods_id", true case "reseller_id_eq": return "order", "merchant_id", true case "code_batch_id_eq": return "order", "supplier_product_id", true case "order_cash_cash_activity_id_eq": return "order_cash", "activity_id", true case "order_voucher_channel_activity_id_eq": return "order_voucher", "channel_batch_no", true default: return "", "", false } }