ApiChanges:GWM

This commit is contained in:
sriramv 2022-05-28 10:41:21 +05:30
parent f150df4efb
commit 1323db4660
4 changed files with 348 additions and 9 deletions

View File

@ -1,6 +1,6 @@
const { sequelize,Test} = require('../models')
const { logMsg } = require('../services/logger.js');
require('dotenv').config();
exports.Welcome = (req, res) =>
{
try
@ -9,7 +9,7 @@ exports.Welcome = (req, res) =>
console.log(Msg);
logMsg.info("Api Call Success");
res.send({'status':200 , message:"Success." ,'data': Msg});
console.log(process.env.test);
} catch(err) {

View File

@ -5,7 +5,27 @@ exports.createNotes = async (req, res) =>
{
try
{
await Workingnotes.create(req.body);
for (const value of req.body.notes)
{
notes = JSON.stringify(value);
data = {
losid: req.body.losid,
module_name: req.body.module_name,
entity_reference: req.body.entity_reference,
notes: notes,
sheet_no : value.name,
user_id: req.body.user_id,
createdby: req.body.createdby
};
// insert working notes data
await Workingnotes.create(data)
.then(data=>{ logMsg.info("Notes insert Success");})
.catch(err=>{ logMsg.info("Notes insert Failed");});
}
res.send({'status':200 , message:"Success." ,'data': "no data"});
} catch(err) {
@ -15,6 +35,39 @@ exports.createNotes = async (req, res) =>
};
exports.updateNotes = async (req, res) =>
{
try
{
for (const value of req.body.notes)
{
notesData = await Workingnotes.findOne({where :{losid : req.body.losid , module_name : req.body.module_name, sheet_no : value.name , is_active:1}});
id = notesData.dataValues.id;
notes = JSON.stringify(value);
// update working notes data
await Workingnotes.update({notes: notes , updatedby: req.body.updatedby} , { where: { id: id } })
.then(data=>{ logMsg.info("Notes update Success");})
.catch(err=>{ logMsg.info("Notes update Failed");});
}
res.send({'status':200 , message:"Success." ,'data': "no data"});
} catch(err) {
res.status(500).send({'status':404,
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); } //end of try catch
};
exports.notesList = async (req, res) =>
{
try
@ -23,10 +76,11 @@ exports.notesList = async (req, res) =>
if(req.query.entity_reference == undefined)
{
notesData = await Workingnotes.findAll({where :{losid : req.query.losid , module_name : req.query.module_name}});
notesData = await Workingnotes.findAll({where :{losid : req.query.losid , module_name : req.query.module_name , is_active:1}});
console.log(JSON.parse(notesData[2].notes))
res.send({'status':200 , message:"Success." ,'data': notesData});
}else{
notesData = await Workingnotes.findAll({where :{losid : req.query.losid , module_name : req.query.module_name , entity_reference : req.query.entity_reference}});
notesData = await Workingnotes.findAll({where :{losid : req.query.losid , module_name : req.query.module_name , entity_reference : req.query.entity_reference, is_active:1}});
res.send({'status':200 , message:"Success." ,'data': notesData});
}
@ -36,4 +90,239 @@ exports.notesList = async (req, res) =>
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
}); } //end of try catch
};
};
const myData = [ {
"name": "sheet1",
"freeze": "A1",
"styles": [
{
"font": {
"italic": true
}
},
{
"color": "#f7ccac"
},
{
"color": "#f7ccac",
"bgcolor": "#93d051"
},
{
"color": "#7030a0",
"bgcolor": "#93d051"
}
],
"merges": [],
"rows": {
"0": {
"cells": {
"0": {
"text": "ddsd"
},
"1": {
"text": "fdfdf",
"style": 0
},
"2": {
"text": "ddd"
}
}
},
"1": {
"cells": {
"6": {
"text": "dfdfd"
}
}
},
"2": {
"cells": {
"4": {
"text": "dfdf"
}
}
},
"4": {
"cells": {
"6": {
"text": "dfd"
}
}
},
"5": {
"cells": {
"3": {
"text": "dfddf"
},
"5": {
"text": "df"
}
}
},
"6": {
"cells": {
"8": {
"text": "dfdf"
}
}
},
"9": {
"cells": {
"2": {
"text": "dfdf"
},
"6": {
"text": "dfdf",
"style": 3
}
}
},
"10": {
"cells": {
"4": {
"text": "ddsd"
}
}
},
"11": {
"cells": {
"3": {
"text": "fff"
}
}
},
"12": {
"cells": {
"1": {
"text": "dfdf"
}
}
},
"len": 100
},
"cols": {
"len": 26
},
"validations": [],
"autofilter": {}
},{
"name": "sheet2",
"freeze": "A1",
"styles": [
{
"font": {
"italic": true
}
},
{
"color": "#f7ccac"
},
{
"color": "#f7ccac",
"bgcolor": "#93d051"
},
{
"color": "#7030a0",
"bgcolor": "#93d051"
}
],
"merges": [],
"rows": {
"0": {
"cells": {
"0": {
"text": "123"
},
"1": {
"text": "123",
"style": 0
},
"2": {
"text": "123"
}
}
},
"1": {
"cells": {
"6": {
"text": "dfdfd"
}
}
},
"2": {
"cells": {
"4": {
"text": "dfdf"
}
}
},
"4": {
"cells": {
"6": {
"text": "dfd"
}
}
},
"5": {
"cells": {
"3": {
"text": "dfddf"
},
"5": {
"text": "df"
}
}
},
"6": {
"cells": {
"8": {
"text": "dfdf"
}
}
},
"9": {
"cells": {
"2": {
"text": "dfdf"
},
"6": {
"text": "dfdf",
"style": 3
}
}
},
"10": {
"cells": {
"4": {
"text": "ddsd"
}
}
},
"11": {
"cells": {
"3": {
"text": "fff"
}
}
},
"12": {
"cells": {
"1": {
"text": "dfdf"
}
}
},
"len": 100
},
"cols": {
"len": 26
},
"validations": [],
"autofilter": {}
}
]

View File

@ -20,6 +20,7 @@ module.exports = (sequelize, DataTypes) => {
module_name: { type: DataTypes.STRING },
entity_reference: { type: DataTypes.STRING },
notes: { type: DataTypes.STRING },
sheet_no: { type: DataTypes.STRING },
user_id: { type: DataTypes.INTEGER },
is_active: { type: DataTypes.INTEGER },
createdby: { type: DataTypes.INTEGER },

View File

@ -65,12 +65,12 @@ module.exports = app => {
* example: gst
* entity_reference:
* type: string
* description: (gst_no/cin_no)->entity_
* description: (gst_no/cin_no)->entity_reference key
* example: cin756kjbjh76
* notes:
* type: string
* type: array
* description:
* example: notes...
* example: []
* user_id:
* type: integer
* description:
@ -99,6 +99,55 @@ module.exports = app => {
*/
router.post("/createNotes", Notescontroller.createNotes);
/**
* @swagger
* definitions:
* updateNotes:
* type: object
* properties:
* losid:
* type: string
* description: losid
* example: MW112233
* module_name:
* type: string
* description: gst (module_name)
* example: gst
* entity_reference:
* type: string
* description: (gst_no/cin_no)->entity_reference key
* example: cin756kjbjh76
* notes:
* type: array
* description:
* example: []
* user_id:
* type: integer
* description:
* example: 1
* updatedby:
* type: integer
* description:
* example: 1
*/
/**
* @swagger
* /api/updateNotes:
* post:
* summary: Pull SalesPd Data
* description: Pull SalesPd Data
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/updateNotes'
* responses:
* 200:
* description: success
* 500:
* description: failed
*/
router.post("/updateNotes", Notescontroller.updateNotes);