Surya: swagger

This commit is contained in:
surya 2021-08-25 18:20:30 +05:30
parent e2d2114a77
commit 7c07a02d47
3 changed files with 360 additions and 75 deletions

View File

@ -326,7 +326,8 @@ exports.Deleteitem = (req, res) => {
// Retrieve all items from the database which is under by the represent section.
exports.ItemFilter = (req, res) => {
const section = req.params.section
Itemsmaster.findAll({where : { section : section }})
const statement = req.params.statement
Itemsmaster.findAll({where : { section : section}})
// sequelize.query("SELECT itemsmaster.id,itemsmaster.statement as statement_id,statementsmaster.statement,itemsmaster.section as section_id,sectionsmaster.section,itemsmaster.subsection as subsection_id,subsectionsmaster.subsection,subsectionsmaster.itemtext as subsection_itemtext ,itemsmaster.itemtext,itemsmaster.is_active,pvtltd,llp,others,formula,is_calculated,itemsmaster.createdby,itemsmaster.createdon,itemsmaster.updatedby,itemsmaster.updatedon FROM itemsmaster JOIN statementsmaster ON itemsmaster.statement=statementsmaster.id JOIN sectionsmaster ON itemsmaster.section= sectionsmaster.id JOIN subsectionsmaster ON itemsmaster.subsection= subsectionsmaster.id")
.then(data => {
res.send({'status':200,'message':"success",'data':data});

View File

@ -34,6 +34,6 @@ module.exports = (sequelize, DataTypes) => {
updatedAt: 'updatedon',
}
)
logMsg.info("Success-model ")
// logMsg.info("Success-model ")
return Statementsmaster
}

View File

@ -1,10 +1,11 @@
module.exports = app => {
const request = require("request");
const cors=require('cors');
const financials = require("../controllers/financial.controller.js");
const master = require("../controllers/master.controller.js");
const { logMsg } = require('../services/logger.js');
var router = require("express").Router();
/**
* @openapi
@ -31,9 +32,39 @@ module.exports = app => {
router.get("/MasterDatas", financials.MasterDatas);
//master.controller api's
// get statment master data
/**
/**
* @swagger
* definitions:
* statement:
* type: object
* properties:
* statement:
* type: string
* description: name of the statement
* example: 'profit'
* is_active:
* type: integer
* description: the state of statement(0 means inactive,1 means active)
* example: 1
* createdby:
* type: integer
* description: The person who created
* example: 1
* updatedby:
* type: integer
* description: The person who modified
* example: 1
*/
//master.controller api's
// get statment master data
//logMsg.info("Success -route ");
/**
* @openapi
* /api/StatementsList:
* get:
@ -42,29 +73,64 @@ module.exports = app => {
* 200:
* description: Returns a mysterious string.
*/
logMsg.info("Success -route ");
router.get("/StatementsList", master.StatementsList);
/**
* @swagger
* /api/Insertstatement:
* post:
* summary: create statement
* description: create statement
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/statement'
* responses:
* 200:
* description: statement created succesfully
* 500:
* description: failure in creating statement
*/
/**
* @openapi
* /api/Insertstatement:
* get:
* description: This is Insert api statement!
* responses:
* 200:
* description: Returns a mysterious string.
*/
router.post("/Insertstatement", master.Insertstatement);
/**
* @openapi
* /api/Updatestatement/:id:
* get:
* description: This is update api statement!
* responses:
* 200:
* description: Returns a mysterious string.
* @swagger
* /api/Updatestatement/{id}:
* put:
* summary: update statement
* description: update statement
* consumes:
* - application/json
* produces:
* - application/json
* parameters:
* - in: path
* name: id
* schema:
* type: integer
* required: true
* description: id of the statement
* example: 2
* - in: body
* name: body
* required: true
* description: body object
* schema:
* $ref: '#/definitions/statement'
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/statement'
* responses:
* 200:
* description: success
* content:
* application/json:
* schema:
* $ref: '#/definitions/statement'
*/
router.put("/Updatestatement/:id", master.Updatestatement);
/**
@ -79,6 +145,34 @@ module.exports = app => {
router.put("/Deletestatement/:id", master.Deletestatement);
/**
* @swagger
* definitions:
* section:
* type: object
* properties:
* statement:
* type: integer
* description: id of the statement
* example: 1
* section:
* type: string
* description: name of the section
* example: 'section'
* is_active:
* type: integer
* description: the state of section(0 means inactive,1 means active)
* example: 1
* createdby:
* type: integer
* description: The person who created
* example: 1
* updatedby:
* type: integer
* description: The person who modified
* example: 1
*/
/**
* @openapi
@ -91,24 +185,60 @@ module.exports = app => {
*/
router.get("/SectionList", master.SectionList);
/**
* @openapi
* /api/Insertsection:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
*/
/**
* @swagger
* /api/Insertsection:
* post:
* summary: create section
* description: create section
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/section'
* responses:
* 200:
* description: section created succesfully
* 500:
* description: failure in creating section
*/
router.post("/Insertsection", master.Insertsection);
/**
* @openapi
* /api/Updatesection/:id:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
/**
* @swagger
* /api/Updatesection/{id}:
* put:
* summary: update section
* description: update section
* consumes:
* - application/json
* produces:
* - application/json
* parameters:
* - in: path
* name: id
* schema:
* type: integer
* required: true
* description: id of the section
* example: 2
* - in: body
* name: body
* required: true
* description: body object
* schema:
* $ref: '#/definitions/section'
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/section'
* responses:
* 200:
* description: success
* content:
* application/json:
* schema:
* $ref: '#/definitions/section'
*/
router.put("/Updatesection/:id", master.Updatesection);
/**
@ -122,7 +252,34 @@ module.exports = app => {
*/
router.put("/Deletesection/:id", master.Deletesection);
//************************************************************
/**
* @swagger
* definitions:
* subsection:
* type: object
* properties:
* section:
* type: integer
* description: id of the section
* example: 1
* subsection:
* type: string
* description: name of the subsection
* example: 'subsection'
* is_active:
* type: integer
* description: the state of subsection(0 means inactive,1 means active)
* example: 1
* createdby:
* type: integer
* description: The person who created
* example: 1
* updatedby:
* type: integer
* description: The person who modified
* example: 1
*/
/**
* @openapi
* /api/SubsectionList:
@ -133,24 +290,60 @@ module.exports = app => {
* description: Returns a mysterious string.
*/
router.get("/SubsectionList", master.SubsectionList);
/**
* @openapi
* /api/Insertsubsection:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
*/
/**
* @swagger
* /api/Insertsubsection:
* post:
* summary: create subsection
* description: create subsection
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/subsection'
* responses:
* 200:
* description: subsection created succesfully
* 500:
* description: failure in creating subsection
*/
router.post("/Insertsubsection", master.Insertsubsection);
/**
* @openapi
* /api/Updatesubsection/:id:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
/**
* @swagger
* /api/Updatesubsection/{id}:
* put:
* summary: update subsection
* description: update subsection
* consumes:
* - application/json
* produces:
* - application/json
* parameters:
* - in: path
* name: id
* schema:
* type: integer
* required: true
* description: id of the subsection
* example: 2
* - in: body
* name: body
* required: true
* description: body object
* schema:
* $ref: '#/definitions/subsection'
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/subsection'
* responses:
* 200:
* description: success
* content:
* application/json:
* schema:
* $ref: '#/definitions/subsection'
*/
router.put("/Updatesubsection/:id", master.Updatesubsection);
/**
@ -165,6 +358,61 @@ module.exports = app => {
router.put("/Deletesubsection/:id", master.Deletesubsection);
/**
* @swagger
* definitions:
* item:
* type: object
* properties:
* statement:
* type: integer
* description: id of the statement
* example: 1
* section:
* type: integer
* description: id of the section
* example: 1
* subsection:
* type: integer
* description: id of the subsection
* example: 1
* itemtext:
* type: string
* description: name of the item
* example: 'itemtext'
* pvtltd:
* type: integer
* description: pvtltd - Private Limited
* example: 1
* llp:
* type: integer
* description: llp
* example: 1
* others:
* type: integer
* description: others
* example: 1
* formula:
* type: string
* description: formula
* example: 'a+b'
* is_calculated:
* type: integer
* description: is_calculated - it shows the field need to be calculate or not
* example: 1
* is_active:
* type: integer
* description: the state of section(0 means inactive,1 means active)
* example: 1
* createdby:
* type: integer
* description: The person who created
* example: 1
* updatedby:
* type: integer
* description: The person who modified
* example: 1
*/
/**
* @openapi
* /api/ItemList:
@ -175,24 +423,60 @@ module.exports = app => {
* description: Returns a mysterious string.
*/
router.get("/ItemList", master.ItemList);
/**
* @openapi
* /api/Insertitem:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
*/
/**
* @swagger
* /api/Insertitem:
* post:
* summary: create item
* description: create item
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/item'
* responses:
* 200:
* description: item created succesfully
* 500:
* description: failure in creating item
*/
router.post("/Insertitem", master.Insertitem);
/**
* @openapi
* /api/Updateitem/:id:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
/**
* @swagger
* /api/Updateitem/{id}:
* put:
* summary: update item
* description: update item
* consumes:
* - application/json
* produces:
* - application/json
* parameters:
* - in: path
* name: id
* schema:
* type: integer
* required: true
* description: id of the item
* example: 2
* - in: body
* name: body
* required: true
* description: body object
* schema:
* $ref: '#/definitions/item'
* requestBody:
* content:
* application/json:
* schema:
* $ref: '#/definitions/item'
* responses:
* 200:
* description: success
* content:
* application/json:
* schema:
* $ref: '#/definitions/item'
*/
router.put("/Updateitem/:id", master.Updateitem);
/**