박권수

feat. data process : data type

...@@ -44,14 +44,12 @@ const balanceFactoring = (balance) => { ...@@ -44,14 +44,12 @@ const balanceFactoring = (balance) => {
44 const slicingBalance = max / 5; 44 const slicingBalance = max / 5;
45 45
46 if(parseInt(balance) < slicingBalance || parseInt(balance) > max * 2) 46 if(parseInt(balance) < slicingBalance || parseInt(balance) > max * 2)
47 - return '100';
48 - else if(parseInt(balance) < slicingBalance * 2)
49 return '80'; 47 return '80';
50 - else if(parseInt(balance) < slicingBalance * 3) 48 + else if(parseInt(balance) < slicingBalance * 2)
51 return '60'; 49 return '60';
52 - else if(parseInt(balance) < slicingBalance * 4) 50 + else if(parseInt(balance) < slicingBalance * 3)
53 return '40'; 51 return '40';
54 - else if(parseInt(balance) < slicingBalance * 5) 52 + else if(parseInt(balance) < slicingBalance * 4)
55 return '20'; 53 return '20';
56 else return '0'; 54 else return '0';
57 55
...@@ -59,15 +57,21 @@ const balanceFactoring = (balance) => { ...@@ -59,15 +57,21 @@ const balanceFactoring = (balance) => {
59 57
60 //bottleId가 포함된 data를 받아서 해당 약병의 data를 업데이트한다. 58 //bottleId가 포함된 data를 받아서 해당 약병의 data를 업데이트한다.
61 const bottleInfoUpdate = async(data) => { 59 const bottleInfoUpdate = async(data) => {
62 - const { bottleId, isOpen, openDate, temperature, humidity, balance } = data; 60 + let { bottleId, isOpen, openDate, temperature, humidity, balance } = data;
61 +
62 + bottleId = parseInt(bottleId);
63 + isOpen = parseInt(isOpen);
64 + temperature = parseFloat(temperature);
65 + humidity = parseFloat(humidity);
66 + balance = parseInt(balance);
63 67
64 - if(isOpen === '1') { 68 + if(isOpen) {
65 await Bottle.findOneAndUpdate({ 69 await Bottle.findOneAndUpdate({
66 bottleId 70 bottleId
67 }, { recentOpen : openDate }); 71 }, { recentOpen : openDate });
68 } 72 }
69 73
70 - if(balance !== '-1') { 74 + if(balance !== -1) {
71 await Bottle.findOneAndUpdate({ 75 await Bottle.findOneAndUpdate({
72 bottleId 76 bottleId
73 }, { balance }) 77 }, { balance })
......