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 return -1, log
} }
var count float64 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 return int(count), log
} }
@ -70,7 +71,7 @@ func getGoodAvailability(w http.ResponseWriter, r *http.Request) {
if count < 0 { if count < 0 {
return 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") { switch r.Header.Get("Content-Type") {
case "application/json": case "application/json":
lib.Write(w, count) lib.Write(w, count)

View File

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

View File

@ -14,9 +14,9 @@ angular.module('microStock')
$scope.submit = function(){ $scope.submit = function(){
$http.post(config.store.goods.productById.replace("%d",$stateParams.productid)+'?count='+$scope.count,$scope.obj).then(function(){ $http.post(config.store.goods.productById.replace("%d",$stateParams.productid)+'?count='+$scope.count,$scope.obj).then(function(){
$scope.obj = {}; $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(){ }, 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+'.'};
}); });
}; };
}]); }]);