genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

[TASK] log on avaidble

This commit is contained in:
Martin Geno 2017-05-19 11:47:38 +02:00
parent 0d8fd0feca
commit 7fbc6c23f2
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
3 changed files with 6 additions and 6 deletions

View File

@ -60,7 +60,8 @@ func getGoodAvailablityCount(w http.ResponseWriter, r *http.Request) (int, *logr
return -1, log
}
var count float64
(&models.Good{}).FilterAvailable(database.Read.Where("product_id = ?", id)).Count(&count)
var g models.Good
g.FilterAvailable(database.Read).Where("product_id = ?", id).Count(&count)
return int(count), log
}
@ -70,7 +71,7 @@ func getGoodAvailability(w http.ResponseWriter, r *http.Request) {
if count < 0 {
return
}
log = log.WithField("type", r.Header.Get("Content-Type"))
log = log.WithField("c", count).WithField("type", r.Header.Get("Content-Type"))
switch r.Header.Get("Content-Type") {
case "application/json":
lib.Write(w, count)

View File

@ -2,6 +2,7 @@
package http
import (
"fmt"
"net/http"
"testing"
"time"
@ -86,7 +87,6 @@ func TestAddGood(t *testing.T) {
test.Close()
}
/*
// Function to test delGood()
func TestDelGood(t *testing.T) {
assertion, router := test.Init(t)
@ -127,4 +127,3 @@ func TestDelGood(t *testing.T) {
test.Close()
}
*/

View File

@ -14,9 +14,9 @@ angular.module('microStock')
$scope.submit = function(){
$http.post(config.store.goods.productById.replace("%d",$stateParams.productid)+'?count='+$scope.count,$scope.obj).then(function(){
$scope.obj = {};
$scope.msg = {type:'success',text:'Saved '+count+' good(s) from product '+$scope.product.title+'.'};
$scope.msg = {type:'success',text:'Saved '+$scope.count+' good(s) from product '+$scope.product.title+'.'};
}, function(){
$scope.msg = {type:'error',text:'Error: Saved '+count+' good(s) from product '+$scope.product.title+'.'};
$scope.msg = {type:'error',text:'Error: Saved '+$scope.count+' good(s) from product '+$scope.product.title+'.'};
});
};
}]);