func(c *membershipTierImpl) InsertSql(ctx context.Context, entity *MembershipTierEntity) (sql string) {
t := reflect.ValueOf(columnsMembershipTier)
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
if t.Kind() != reflect.Struct {
log.WithCtx(ctx).Errorf("not struct")
return
}
fieldNum := t.NumField()
sql = "insert into " + tableMembershipTier + "(`" + strings.ToLower(t.Field(0).String())+"`"
for i := 1; i < fieldNum; i++ {
sql += ", `" + strings.ToLower(t.Field(i).String())+"`"
}
sql += ") values (?"
for i := 1; i < fieldNum; i++ {
sql += ",?"
}
sql += ")"
return
}
func(c *membershipTierImpl) UpdateSql(ctx context.Context, entity *MembershipTierEntity) (sql string) {
t := reflect.ValueOf(columnsMembershipTier)
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
if t.Kind() != reflect.Struct {
log.WithCtx(ctx).Errorf("not struct")
return
}
fieldNum := t.NumField()
sql = "update" + tableMembershipTier + " set " + strings.ToLower(t.Field(0).String())+" = ?"
for i := 1; i < fieldNum; i++ {
sql += ", " + strings.ToLower(t.Field(i).String())+" = ?"
}
sql += " where user_id = ? and shop_id = ? limit 1"
return
}