Example #1
0
func FindItemByItemSalePriceLTE(price, limit string) ([]entity.Item, error) {
	if limit == "" {
		limit = "100"
	}

	q := "SELECT * FROM item WHERE itemSalePrice <= " + price + " ORDER BY itemNo LIMIT " + limit
	items, err := datastore.ItemQueryWithCache(q)
	if err != nil {
		return nil, err
	}

	return items, nil
}
Example #2
0
func FindItemBySupplier(supplier, limit string) ([]entity.Item, error) {
	if limit == "" {
		limit = "100"
	}

	q := "SELECT * FROM item WHERE itemSupplier = '" + supplier + "' ORDER BY itemNo LIMIT " + limit
	items, err := datastore.ItemQueryWithCache(q)
	if err != nil {
		return nil, err
	}

	return items, nil
}
Example #3
0
func FindItemByItemSoldQuantityGTE(quantity, limit string) ([]entity.Item, error) {
	if limit == "" {
		limit = "100"
	}

	q := "SELECT * FROM item WHERE itemSoldQuantity >= " + quantity + " ORDER BY itemNo LIMIT " + limit
	items, err := datastore.ItemQueryWithCache(q)
	if err != nil {
		return nil, err
	}

	return items, nil
}
Example #4
0
func FindItemByItemID(itemID string) (item entity.Item, err error) {
	if itemID == "" {
		return
	}

	q := "SELECT * FROM item WHERE id = '" + itemID + "'"

	items, err := datastore.ItemQueryWithCache(q)
	if err != nil {
		return
	}

	if len(items) == 0 {
		return
	}

	return items[0], nil
}
Example #5
0
func FindItemByPostItemStateNotEQ(state, limit string) ([]entity.Item, error) {
	if limit == "" {
		limit = "100"
	}

	q := "SELECT postItemId FROM post4 WHERE postItemState <> '" + state + "'"
	posts, err := datastore.PostQueryForItemID(q)
	if err != nil {
		return nil, err
	}

	itemIDMap := make(map[string]bool, len(posts))
	for i := range posts {
		if itemIDMap[posts[i]] {
			continue
		}
		itemIDMap[posts[i]] = true
	}

	itemIDs := make([]byte, 11*len(posts))
	for id := range itemIDMap {
		itemIDs = append(itemIDs, "'"...)
		itemIDs = append(itemIDs, id...)
		itemIDs = append(itemIDs, "',"...)
	}

	q = "SELECT * FROM item WHERE id IN(" + string(itemIDs) + ") ORDER BY userNo LIMIT " + limit
	items, err := datastore.ItemQueryWithCache(q)
	if err != nil {
		return nil, err
	}

	if len(items) == 0 {
		return nil, nil
	}

	return items, nil

}