Commit 380228451c9e4cabe5af0605c18db9cdddddb950

Authored by Nung Poti
1 parent cf8b0fb9
Exists in master

update moment

common/models/customer.js
1 var console = process.console; 1 var console = process.console;
2 module.exports = function(Customer) { 2 module.exports = function(Customer) {
3 Customer.getName =function(ctx,cb){ 3 Customer.getName =function(ctx,cb){
  4 + console.tag('input').error(ctx);
4 var respone = { 5 var respone = {
5 "resultCode":"20000", 6 "resultCode":"20000",
6 "resultDescription":"Success", 7 "resultDescription":"Success",
@@ -8,6 +9,7 @@ module.exports = function(Customer) { @@ -8,6 +9,7 @@ module.exports = function(Customer) {
8 "Name": ctx.name 9 "Name": ctx.name
9 } 10 }
10 }; 11 };
  12 + console.tag('response').warning(respone);
11 cb(null,respone); 13 cb(null,respone);
12 }; 14 };
13 Customer.remoteMethod('getName',{ 15 Customer.remoteMethod('getName',{
common/models/item.js
1 var console = process.console; 1 var console = process.console;
2 var unirest = require('unirest'); 2 var unirest = require('unirest');
  3 +var moment = require('moment');
3 module.exports = function(Item) { 4 module.exports = function(Item) {
4 Item.disableRemoteMethod("create", true);// post 5 Item.disableRemoteMethod("create", true);// post
5 Item.disableRemoteMethod("find", false);// get 6 Item.disableRemoteMethod("find", false);// get
@@ -48,8 +49,7 @@ module.exports = function(Item) { @@ -48,8 +49,7 @@ module.exports = function(Item) {
48 var data = { 49 var data = {
49 "name":ctx 50 "name":ctx
50 }; 51 };
51 - unirest.post("http://localhost:3000/api/AddChannels/getName").send(data).end(function(response){  
52 - console.log(response.body); 52 + unirest.post("http://localhost:3000/api/customer/getName").send(data).end(function(response){
53 cb(null,response.body) 53 cb(null,response.body)
54 }); 54 });
55 }; 55 };
@@ -94,8 +94,20 @@ module.exports = function(Item) { @@ -94,8 +94,20 @@ module.exports = function(Item) {
94 "price": 0 94 "price": 0
95 },http: { source: 'body' }}, 95 },http: { source: 'body' }},
96 returns: {arg: 'data', type: 'object', root: true} 96 returns: {arg: 'data', type: 'object', root: true}
  97 + });
97 98
98 - })  
99 99
  100 + Item.Moment = function(cb){
  101 + var this_time = {
  102 + "default": moment().format(),
  103 + "DD-MM-YYY":moment().format("DD-MM-YYYY"),
  104 + "HH:MM:SS":moment().format("HH:mm:ss")
  105 + };
  106 + cb(null,this_time);
  107 + };
  108 + Item.remoteMethod('Moment',{
  109 + http:{path:'/Moment',verb:'get'},
  110 + returns: {arg: 'data', type: 'object', root: true}
  111 + })
100 112
101 }; 113 };
common/models/order.js
@@ -8,7 +8,9 @@ module.exports = function(Order) { @@ -8,7 +8,9 @@ module.exports = function(Order) {
8 Order.disableRemoteMethod("create", true);// post 8 Order.disableRemoteMethod("create", true);// post
9 Order.AddOrder = function(ctx,cb){ 9 Order.AddOrder = function(ctx,cb){
10 console.log(ctx); 10 console.log(ctx);
11 - findCustomer(ctx,cb,findItems) 11 + findCustomer(ctx,cb,findItems);
  12 +
  13 +
12 }; 14 };
13 function findCustomer(ctx,cb,next){ 15 function findCustomer(ctx,cb,next){
14 console.tag('Input').log(ctx); 16 console.tag('Input').log(ctx);
@@ -52,7 +54,6 @@ module.exports = function(Order) { @@ -52,7 +54,6 @@ module.exports = function(Order) {
52 } 54 }
53 }) 55 })
54 } 56 }
55 -  
56 Order.remoteMethod('AddOrder',{ 57 Order.remoteMethod('AddOrder',{
57 http:{path:'/customer/:customer_id/item/:item_id',verb:'get'}, 58 http:{path:'/customer/:customer_id/item/:item_id',verb:'get'},
58 accepts: { arg: 'ctx', type: 'object', http: function(ctx) { 59 accepts: { arg: 'ctx', type: 'object', http: function(ctx) {
@@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
19 "loopback-connector-mongodb": "^1.15.2", 19 "loopback-connector-mongodb": "^1.15.2",
20 "loopback-connector-mysql": "^2.3.0", 20 "loopback-connector-mysql": "^2.3.0",
21 "loopback-datasource-juggler": "^2.39.0", 21 "loopback-datasource-juggler": "^2.39.0",
  22 + "moment": "^2.13.0",
22 "path": "^0.12.7", 23 "path": "^0.12.7",
23 "scribe-js": "^2.0.4", 24 "scribe-js": "^2.0.4",
24 "serve-favicon": "^2.0.1", 25 "serve-favicon": "^2.0.1",
server/datasources.json
@@ -13,16 +13,6 @@ @@ -13,16 +13,6 @@
13 "user": "", 13 "user": "",
14 "connector": "mongodb" 14 "connector": "mongodb"
15 }, 15 },
16 - "account": {  
17 - "host": "server8.sourcecode.co.th",  
18 - "port": 3306,  
19 - "url": "",  
20 - "database": "account",  
21 - "password": "A83kKhoAH4jcEHMY",  
22 - "name": "account",  
23 - "user": "npm_account",  
24 - "connector": "mysql"  
25 - },  
26 "radius": { 16 "radius": {
27 "host": "server8.sourcecode.co.th", 17 "host": "server8.sourcecode.co.th",
28 "port": 3306, 18 "port": 3306,
@@ -32,75 +22,5 @@ @@ -32,75 +22,5 @@
32 "name": "radius", 22 "name": "radius",
33 "user": "npm_radius", 23 "user": "npm_radius",
34 "connector": "mysql" 24 "connector": "mysql"
35 - },  
36 - "refill": {  
37 - "host": "server8.sourcecode.co.th",  
38 - "port": 3306,  
39 - "url": "",  
40 - "database": "refill",  
41 - "password": "Fe8Vf63LtdGQaFtd",  
42 - "name": "refill",  
43 - "user": "npm_refill",  
44 - "connector": "mysql"  
45 - },  
46 - "smartquotation": {  
47 - "host": "server8.sourcecode.co.th",  
48 - "port": 3306,  
49 - "url": "",  
50 - "database": "smartquotation",  
51 - "password": "Bwa7Z6ZRosU4RuAH",  
52 - "name": "smartquotation",  
53 - "user": "npm_smtquot",  
54 - "connector": "mysql"  
55 - },  
56 - "smartzone": {  
57 - "host": "server8.sourcecode.co.th",  
58 - "port": 3306,  
59 - "url": "",  
60 - "database": "smartzone",  
61 - "password": "pADobokFAoPC384B",  
62 - "name": "account",  
63 - "user": "npm_szv3",  
64 - "connector": "mysql"  
65 - },  
66 - "smartzonev4": {  
67 - "host": "server8.sourcecode.co.th",  
68 - "port": 3306,  
69 - "url": "",  
70 - "database": "smartzonev4",  
71 - "password": "Q7TsWo7UNbCsi3sb",  
72 - "name": "smartzonev4",  
73 - "user": "npm_szv4",  
74 - "connector": "mysql"  
75 - },  
76 - "thespecialdress": {  
77 - "host": "server8.sourcecode.co.th",  
78 - "port": 3306,  
79 - "url": "",  
80 - "database": "thespecialdress",  
81 - "password": "bXGhkLoTJ9atAx72",  
82 - "name": "thespecialdress",  
83 - "user": "npm_tsd",  
84 - "connector": "mysql"  
85 - },  
86 - "thespecialdress_wp": {  
87 - "host": "server8.sourcecode.co.th",  
88 - "port": 3306,  
89 - "url": "",  
90 - "database": "thespecialdress_wp",  
91 - "password": "gAUmK7Jcvq4F7CUs",  
92 - "name": "thespecialdress_wp",  
93 - "user": "npm_tsdwp",  
94 - "connector": "mysql"  
95 - },  
96 - "vtigercrm510": {  
97 - "host": "server8.sourcecode.co.th",  
98 - "port": 3306,  
99 - "url": "",  
100 - "database": "vtigercrm510",  
101 - "password": "X6UUfWM8GJEPBzv3",  
102 - "name": "vtigercrm510",  
103 - "user": "npm_vtiger",  
104 - "connector": "mysql"  
105 } 25 }
106 } 26 }