[TASK] log on avaidble
This commit is contained in:
parent
0d8fd0feca
commit
7fbc6c23f2
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -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+'.'};
|
||||
});
|
||||
};
|
||||
}]);
|
||||
|
|
Reference in New Issue