Exemplo n.º 1
0
func (this *SqlBuilder) GetCustomerSql(sql string) string {
	sql = sql + " "
	if len(this.conditions) > 0 {
		if strings.Contains(strings.ToUpper(sql), "WHERE") {
			sql = sql + "AND "
		} else {
			sql = sql + "WHERE "
		}
		sql = sql + this.GetConditonSql()
	}
	if !u.IsNullStr(this.groupBy) {
		sql = sql + " GROUP BY " + this.groupBy + " "
	}
	if len(this.orders) > 0 {
		sql = sql + "ORDER BY "
		for idx, v := range this.orders {
			if idx > 0 {
				sql = sql + ", "
			}
			sql = sql + v + " "
		}
	}
	if this.limit > 0 {
		sql = sql + fmt.Sprintf("LIMIT %d ", this.limit)
	}
	if this.offset > 0 {
		sql = sql + fmt.Sprintf("OFFSET %d ", this.offset)
	}
	return sql
}
Exemplo n.º 2
0
func (this *SqlBuilder) GetCountSql() string {
	sql := fmt.Sprintf("SELECT COUNT(id) FROM %s ", this.table)
	if len(this.conditions) > 0 {
		sql = sql + "WHERE " + this.GetConditonSql()
	}
	if !u.IsNullStr(this.groupBy) {
		sql = sql + " GROUP BY " + this.groupBy
	}
	return sql
}
Exemplo n.º 3
0
func transPurchaseMap(oldMap orm.Params) t.ItemMap {
	var retMap = make(t.ItemMap, 0)
	for key, value := range oldMap {
		retMap[strings.ToLower(key)] = value
	}
	if userName, ok := oldMap["user_name"]; ok {
		retMap["buyer"] = userName
	}
	category, _ := retMap[s.Category].(string)
	retMap[s.Category] = lang.GetLabel(category)
	if supplierSn, ok := retMap[s.Supplier]; ok && !u.IsNullStr(supplierSn) {
		if supplierMap, sok := supplierMgr.Get(supplierSn.(string)); sok {
			retMap[s.Supplier+s.EName] = u.GetStringValue(supplierMap, s.Name)
			retMap[s.Supplier+s.EKey] = u.GetStringValue(supplierMap, s.Keyword)
		}
	}
	return retMap
}