Commit 81020b6a by jay

vendor backend

1 parent 0b26196c
Showing 37 changed files with 1472 additions and 14 deletions
......@@ -16,6 +16,7 @@
"@strapi/strapi": "4.3.6",
"axios": "^1.1.3",
"better-sqlite3": "7.4.6",
"csv-parse": "^5.5.5",
"mysql": "^2.18.1",
"pg": "^8.8.0",
"strapi-plugin-ckeditor5": "^2.1.1-rc.1"
......@@ -6421,6 +6422,11 @@
"integrity": "sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==",
"license": "MIT"
},
"node_modules/csv-parse": {
"version": "5.5.5",
"resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-5.5.5.tgz",
"integrity": "sha512-erCk7tyU3yLWAhk6wvKxnyPtftuy/6Ak622gOO7BCJ05+TYffnPCJF905wmOQm+BpkX54OdAl8pveJwUdpnCXQ=="
},
"node_modules/dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
......@@ -21873,6 +21879,11 @@
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.0.tgz",
"integrity": "sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA=="
},
"csv-parse": {
"version": "5.5.5",
"resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-5.5.5.tgz",
"integrity": "sha512-erCk7tyU3yLWAhk6wvKxnyPtftuy/6Ak622gOO7BCJ05+TYffnPCJF905wmOQm+BpkX54OdAl8pveJwUdpnCXQ=="
},
"dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
......@@ -17,6 +17,7 @@
"@strapi/strapi": "4.3.6",
"axios": "^1.1.3",
"better-sqlite3": "7.4.6",
"csv-parse": "^5.5.5",
"mysql": "^2.18.1",
"pg": "^8.8.0",
"strapi-plugin-ckeditor5": "^2.1.1-rc.1"
......
......@@ -4,15 +4,21 @@
"info": {
"singularName": "master-city",
"pluralName": "master-cities",
"displayName": "Master-city"
"displayName": "Master-city",
"description": ""
},
"options": {
"draftAndPublish": true
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
},
"masterState": {
"type": "relation",
"relation": "oneToOne",
"target": "api::master-state.master-state"
}
}
}
{
"kind": "collectionType",
"collectionName": "master_countries",
"info": {
"singularName": "master-country",
"pluralName": "master-countries",
"displayName": "Master-country",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
}
}
}
'use strict';
/**
* master-country controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::master-country.master-country');
'use strict';
/**
* master-country router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::master-country.master-country');
'use strict';
/**
* master-country service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::master-country.master-country');
{
"kind": "collectionType",
"collectionName": "master_pincodes",
"info": {
"singularName": "master-pincode",
"pluralName": "master-pincodes",
"displayName": "Master-pincode",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
}
}
}
'use strict';
/**
* master-pincode controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::master-pincode.master-pincode');
'use strict';
/**
* master-pincode router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::master-pincode.master-pincode');
'use strict';
/**
* master-pincode service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::master-pincode.master-pincode');
{
"kind": "collectionType",
"collectionName": "master_states",
"info": {
"singularName": "master-state",
"pluralName": "master-states",
"displayName": "Master-state",
"description": ""
},
"options": {
"draftAndPublish": false
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
},
"masterCountry": {
"type": "relation",
"relation": "oneToOne",
"target": "api::master-country.master-country"
}
}
}
'use strict';
/**
* master-state controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::master-state.master-state');
'use strict';
/**
* master-state router
*/
const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::master-state.master-state');
'use strict';
/**
* master-state service
*/
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::master-state.master-state');
......@@ -26,6 +26,41 @@
},
"phone": {
"type": "string"
},
"pan": {
"type": "string"
},
"panImage": {
"type": "string"
},
"gst": {
"type": "string"
},
"gstImage": {
"type": "string"
},
"businessName": {
"type": "string"
},
"logo": {
"type": "string"
},
"state": {
"type": "string"
},
"city": {
"type": "string"
},
"pincode": {
"type": "string"
},
"country": {
"type": "string"
},
"user": {
"type": "relation",
"relation": "oneToOne",
"target": "plugin::users-permissions.user"
}
}
}
......@@ -9,6 +9,23 @@ const { getService } = require("@strapi/plugin-users-permissions/server/utils");
const { createCoreController } = require("@strapi/strapi").factories;
module.exports = createCoreController("api::vendor.vendor", () => ({
async importSeedData(ctx) {
await strapi.service("api::vendor.vendor").importCountrySeedData();
await strapi.service("api::vendor.vendor").importStateSeedData();
await strapi.service("api::vendor.vendor").importCitySeedData();
await strapi.service("api::vendor.vendor").importPincodeSeedData();
// await strapi.service("api::jeweler.jeweler").importColorSeedData();
// await strapi.service("api::jeweler.jeweler").importKaratSeedData();
// await strapi.service("api::jeweler.jeweler").importOccasionSeedData();
// await strapi.service("api::jeweler.jeweler").importOrnametTypeSeedData();
// await strapi.service("api::jeweler.jeweler").importOrnametTypeMetalSeedData();
// await strapi.service("api::jeweler.jeweler").importJewelerDetailsSeedData();
// await strapi.service("api::jeweler.jeweler").importShopDetailsSeedData();
// await strapi.service("api::jeweler.jeweler").importProductsSeedData();
// await strapi.service("api::jeweler.jeweler").importProductSizeSeedData();
ctx.send({ ok: true });
},
async create(ctx) {
// console.log("ctx", ctx.request.body);
// Get user from user entity
......@@ -21,20 +38,26 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
},
});
// Check if its already existing in vendor entity
// console.log("currentUser", currentUser);
console.log("currentUser", currentUser);
console.log(
"phoneNumber",
ctx.request.body.data.mobileNo,
ctx.request.body.data.email
);
let existingUser;
existingUser = await strapi.entityService.findMany("api::vendor.vendor", {
fields: ["id"],
filter: { phoneNumber: ctx.request.body.data.phoneNumber },
// fields: ["id"],
filters: { phone: {$eq: ctx.request.body.data.mobileNo} },
});
console.log("existingUser> 1", existingUser);
if (!existingUser) {
existingUser = await strapi.entityService.findMany("api::vendor.vendor", {
fields: ["id"],
filters: { email: ctx.request.body.data.email },
// fields: ["id"],
filters: { email: {$eq: ctx.request.body.data.email} },
});
}
console.log("existingUser > 2", existingUser);
// Generate one time password (otp)
const oneTimePassword = Math.floor(1000 + Math.random() * 9000);
......@@ -52,11 +75,17 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
// TODO: Code to send OTP on email
// TODO: Code to send OTP on SMS
console.log("ctx.request.body.data", ctx.request.body.data);
console.log("existingUser", existingUser);
if (existingUser && existingUser.length !== 0) {
} else {
ctx.request.body.data.user = currentUser.id;
const response = await strapi.entityService.create("api::vendor.vendor", {
data: { ...ctx.request.body.data, publishedAt: date },
data: {
...ctx.request.body.data,
phone: ctx.request.body.data.mobileNo,
publishedAt: date,
},
});
console.log("response", response);
return { otpSent: true, data: response };
......
......@@ -8,6 +8,14 @@ const routes = {
//some Configuration
},
},
{
method: "POST",
path: "/jeweler/import-seed-data",
handler: "api::vendor.vendor.importSeedData",
config: {
// some configuration...
}
},
],
};
......
[
{
"name": "Mumbai",
"state": "Maharashtra"
},
{
"name": "Pune",
"state": "Maharashtra"
},
{
"name": "Nagpur",
"state": "Maharashtra"
},
{
"name": "Thane",
"state": "Maharashtra"
},
{
"name": "Nashik",
"state": "Maharashtra"
},
{
"name": "Kalyan-Dombivali",
"state": "Maharashtra"
},
{
"name": "Vasai-Virar",
"state": "Maharashtra"
},
{
"name": "Solapur",
"state": "Maharashtra"
},
{
"name": "Mira-Bhayandar",
"state": "Maharashtra"
},
{
"name": "Bhiwandi",
"state": "Maharashtra"
},
{
"name": "Amravati",
"state": "Maharashtra"
},
{
"name": "Nanded-Waghala",
"state": "Maharashtra"
},
{
"name": "Sangli",
"state": "Maharashtra"
},
{
"name": "Malegaon",
"state": "Maharashtra"
},
{
"name": "Akola",
"state": "Maharashtra"
},
{
"name": "Latur",
"state": "Maharashtra"
},
{
"name": "Dhule",
"state": "Maharashtra"
},
{
"name": "Ahmednagar",
"state": "Maharashtra"
},
{
"name": "Ichalkaranji",
"state": "Maharashtra"
},
{
"name": "Parbhani",
"state": "Maharashtra"
},
{
"name": "Panvel",
"state": "Maharashtra"
},
{
"name": "Yavatmal",
"state": "Maharashtra"
},
{
"name": "Achalpur",
"state": "Maharashtra"
},
{
"name": "Osmanabad",
"state": "Maharashtra"
},
{
"name": "Nandurbar",
"state": "Maharashtra"
},
{
"name": "Satara",
"state": "Maharashtra"
},
{
"name": "Wardha",
"state": "Maharashtra"
},
{
"name": "Udgir",
"state": "Maharashtra"
},
{
"name": "Aurangabad",
"state": "Maharashtra"
},
{
"name": "Amalner",
"state": "Maharashtra"
},
{
"name": "Akot",
"state": "Maharashtra"
},
{
"name": "Pandharpur",
"state": "Maharashtra"
},
{
"name": "Shrirampur",
"state": "Maharashtra"
},
{
"name": "Parli",
"state": "Maharashtra"
},
{
"name": "Washim",
"state": "Maharashtra"
},
{
"name": "Ambejogai",
"state": "Maharashtra"
},
{
"name": "Manmad",
"state": "Maharashtra"
},
{
"name": "Ratnagiri",
"state": "Maharashtra"
},
{
"name": "Uran Islampur",
"state": "Maharashtra"
},
{
"name": "Pusad",
"state": "Maharashtra"
},
{
"name": "Sangamner",
"state": "Maharashtra"
},
{
"name": "Shirpur-Warwade",
"state": "Maharashtra"
},
{
"name": "Malkapur",
"state": "Maharashtra"
},
{
"name": "Wani",
"state": "Maharashtra"
},
{
"name": "Lonavla",
"state": "Maharashtra"
},
{
"name": "Talegaon Dabhade",
"state": "Maharashtra"
},
{
"name": "Anjangaon",
"state": "Maharashtra"
},
{
"name": "Umred",
"state": "Maharashtra"
},
{
"name": "Palghar",
"state": "Maharashtra"
},
{
"name": "Shegaon",
"state": "Maharashtra"
},
{
"name": "Ozar",
"state": "Maharashtra"
},
{
"name": "Phaltan",
"state": "Maharashtra"
},
{
"name": "Yevla",
"state": "Maharashtra"
},
{
"name": "Shahade",
"state": "Maharashtra"
},
{
"name": "Vita",
"state": "Maharashtra"
},
{
"name": "Umarkhed",
"state": "Maharashtra"
},
{
"name": "Warora",
"state": "Maharashtra"
},
{
"name": "Pachora",
"state": "Maharashtra"
},
{
"name": "Tumsar",
"state": "Maharashtra"
},
{
"name": "Manjlegaon",
"state": "Maharashtra"
},
{
"name": "Sillod",
"state": "Maharashtra"
},
{
"name": "Arvi",
"state": "Maharashtra"
},
{
"name": "Nandura",
"state": "Maharashtra"
},
{
"name": "Vaijapur",
"state": "Maharashtra"
},
{
"name": "Wadgaon Road",
"state": "Maharashtra"
},
{
"name": "Sailu",
"state": "Maharashtra"
},
{
"name": "Murtijapur",
"state": "Maharashtra"
},
{
"name": "Tasgaon",
"state": "Maharashtra"
},
{
"name": "Mehkar",
"state": "Maharashtra"
},
{
"name": "Yawal",
"state": "Maharashtra"
},
{
"name": "Pulgaon",
"state": "Maharashtra"
},
{
"name": "Nilanga",
"state": "Maharashtra"
},
{
"name": "Wai",
"state": "Maharashtra"
},
{
"name": "Umarga",
"state": "Maharashtra"
},
{
"name": "Paithan",
"state": "Maharashtra"
},
{
"name": "Rahuri",
"state": "Maharashtra"
},
{
"name": "Nawapur",
"state": "Maharashtra"
},
{
"name": "Tuljapur",
"state": "Maharashtra"
},
{
"name": "Morshi",
"state": "Maharashtra"
},
{
"name": "Purna",
"state": "Maharashtra"
},
{
"name": "Satana",
"state": "Maharashtra"
},
{
"name": "Pathri",
"state": "Maharashtra"
},
{
"name": "Sinnar",
"state": "Maharashtra"
},
{
"name": "Uchgaon",
"state": "Maharashtra"
},
{
"name": "Uran",
"state": "Maharashtra"
},
{
"name": "Pen",
"state": "Maharashtra"
},
{
"name": "Karjat",
"state": "Maharashtra"
},
{
"name": "Manwath",
"state": "Maharashtra"
},
{
"name": "Partur",
"state": "Maharashtra"
},
{
"name": "Sangole",
"state": "Maharashtra"
},
{
"name": "Mangrulpir",
"state": "Maharashtra"
},
{
"name": "Risod",
"state": "Maharashtra"
},
{
"name": "Shirur",
"state": "Maharashtra"
},
{
"name": "Savner",
"state": "Maharashtra"
},
{
"name": "Sasvad",
"state": "Maharashtra"
},
{
"name": "Pandharkaoda",
"state": "Maharashtra"
},
{
"name": "Talode",
"state": "Maharashtra"
},
{
"name": "Shrigonda",
"state": "Maharashtra"
},
{
"name": "Shirdi",
"state": "Maharashtra"
},
{
"name": "Raver",
"state": "Maharashtra"
},
{
"name": "Mukhed",
"state": "Maharashtra"
},
{
"name": "Rajura",
"state": "Maharashtra"
},
{
"name": "Vadgaon Kasba",
"state": "Maharashtra"
},
{
"name": "Tirora",
"state": "Maharashtra"
},
{
"name": "Mahad",
"state": "Maharashtra"
},
{
"name": "Lonar",
"state": "Maharashtra"
},
{
"name": "Sawantwadi",
"state": "Maharashtra"
},
{
"name": "Pathardi",
"state": "Maharashtra"
},
{
"name": "Pauni",
"state": "Maharashtra"
},
{
"name": "Ramtek",
"state": "Maharashtra"
},
{
"name": "Mul",
"state": "Maharashtra"
},
{
"name": "Soyagaon",
"state": "Maharashtra"
},
{
"name": "Mangalvedhe",
"state": "Maharashtra"
},
{
"name": "Narkhed",
"state": "Maharashtra"
},
{
"name": "Shendurjana",
"state": "Maharashtra"
},
{
"name": "Patur",
"state": "Maharashtra"
},
{
"name": "Mhaswad",
"state": "Maharashtra"
},
{
"name": "Loha",
"state": "Maharashtra"
},
{
"name": "Nandgaon",
"state": "Maharashtra"
},
{
"name": "Warud",
"state": "Maharashtra"
}
]
\ No newline at end of file
[
{
"name": "Gold"
},
{
"name": "Silver"
},
{
"name": "Rose"
},
{
"name": "Green"
},
{
"name": "Yellow"
}
]
[
{
"businessEmail": "sales@kalyanjewels.com",
"businessPhoneNumber": "9892997823",
"businessName": "Kalyan Jewellers",
"pocFirstName": "Hardik",
"pocLastName": "Zaveri",
"pocEmail": "hzaveri@gmail.com",
"pocPhoneNumber": "876965489",
"pan": "ABCTY1234D",
"kycDone": true,
"user": "Hzaveri",
"address1": "Lokmanya Tilak Rd, Boriwali West",
"address2": "Mini Zaveri Bazaar",
"masterPincode": 400001,
"masterCity": "Mumbai",
"masterState": "Maharashtra",
"masterCountry": "India",
"approximateAnnualTurnover": "112 CR",
"ageOfBusiness": "25",
"brandName": "Kalyan Jewellers",
"isProfileCompleted": true,
"oneTimePassword": "",
"isConcentGiven": true,
"gstNumber": "18AABCU9603R1ZM"
},
{
"businessEmail": "enquiries@tanishq.com",
"businessPhoneNumber": "8977654789",
"businessName": "Tanishq",
"pocFirstName": "Rajesh ",
"pocLastName": "Patel",
"pocEmail": "rajesh.patel@tanishq.com",
"pocPhoneNumber": "9870098700",
"pan": "XYZXX1234A",
"kycDone": true,
"user": "Patel.Rajesh",
"address1": "Turner Rd, Bandra West",
"address2": "Near Tavaa Restaurant",
"masterPincode": 400002,
"masterCity": "Mumbai",
"masterState": "Maharashtra",
"masterCountry": "India",
"approximateAnnualTurnover": "405 CR",
"ageOfBusiness": "18",
"brandName": "Tanishq",
"isProfileCompleted": true,
"oneTimePassword": "",
"isConcentGiven": true,
"gstNumber": "14DDBXX8803B1PK"
}
]
[
{
"name": "22 Karat"
},
{
"name": "95 Karat"
},
{
"name": "18 Karat"
},
{
"name": "24 Karat"
}
]
\ No newline at end of file
[
{
"name": "Traditional"
},
{
"name": "Casual Wear"
},
{
"name": "Wedding"
},
{
"name": "Office Wear"
},
{
"name": "Engagement"
},
{
"name": "Anniversary"
},
{
"name": "Modern Wear"
},
{
"name": "Anniversary"
},
{
"name": "Office Party"
},
{
"name": "Ethnic Wear"
}
]
[
{
"name": "Earrings"
},
{
"name": "Chain"
},
{
"name": "Nose Pin"
},
{
"name": "Necklace"
},
{
"name": "Bracelet"
},
{
"name": "Pendant"
},
{
"name": "Anklet"
},
{
"name": "Necklace & Earrings Set"
},
{
"name": "Earrings & Pendant Set"
},
{
"name": "Ring"
}
]
\ No newline at end of file
[{
"name": "400001",
"city": "Mumbai"
},
{
"name": "400002",
"city": "Mumbai"
},
{
"name": "400003",
"city": "Mumbai"
},
{
"name": "400004",
"city": "Mumbai"
},
{
"name": "400005",
"city": "Mumbai"
},
{
"name": "400006",
"city": "Mumbai"
},
{
"name": "400007",
"city": "Mumbai"
},
{
"name": "400008",
"city": "Mumbai"
},
{
"name": "400009",
"city": "Mumbai"
},
{
"name": "400010",
"city": "Mumbai"
},
{
"name": "400011",
"city": "Mumbai"
},
{
"name": "400012",
"city": "Mumbai"
},
{
"name": "400013",
"city": "Mumbai"
},
{
"name": "400014",
"city": "Mumbai"
},
{
"name": "400015",
"city": "Mumbai"
},
{
"name": "400016",
"city": "Mumbai"
},
{
"name": "400017",
"city": "Mumbai"
},
{
"name": "400018",
"city": "Mumbai"
},
{
"name": "400019",
"city": "Mumbai"
},
{
"name": "400020",
"city": "Mumbai"
}
]
\ No newline at end of file
[
{
"shop": "",
"totalQuantity": "Jamshedji Tata",
"currentlyOnRentQuantity": "8977654789",
"currentlyAvailableQuantity": "Tanishq",
"productSize": "Linking Rd, Santacruz West"
}
]
[
{
"name": "Jamshedji Tata",
"jeweler": "8977654789",
"brandName": "Tanishq",
"address1": "Linking Rd, Santacruz West",
"address2": "Near Benetton",
"masterPincode": "400005",
"masterCity": "Mumbai",
"masterState": "Maharashtra",
"masterCountry": "India",
"shopEmail": "sales@tanishq.com",
"pocFirstName": "Om",
"pocLastName": "Prakash",
"pocPhoneNumber": "9868933584",
"pocEmail": "omprakash@gmail.com",
"geographicalAreaServed": "Area 1",
"workingHoursFrom": "9",
"workingHoursTo": "10",
"termsAndConditions": "Terms of service are the legal agreements between a service provider and a person who wants to use that service. The person must agree to abide by the terms of service in order to use the offered service. Terms of service can also be merely a disclaimer, especially regarding the use of websites",
"shopPhoneNumber": "9863359584",
"bankAccountHolderName": "Om Prakash",
"bankAccountType": "current",
"bankAccountNumber": "858587474859669",
"bankIfscCode": "HDFC0000128"
},
{
"name": "T.S. Kalyanaraman",
"jeweler": "9892997823",
"brandName": "Kalyan Jewellers",
"address1": "Lokmanya Tilak Rd, Boriwali West",
"address2": "Mini Zaveri Bazaar",
"masterPincode": "400006",
"masterCity": "Mumbai",
"masterState": "Maharashtra",
"masterCountry": "India",
"shopEmail": "enquiry@kalyanjewellers.com",
"pocFirstName": "Hardik",
"pocLastName": "Zaveri",
"pocPhoneNumber": "7788956546",
"pocEmail": "hzaveri@gmail.com",
"geographicalAreaServed": "Area 2",
"workingHoursFrom": "7",
"workingHoursTo": "8",
"termsAndConditions": "Please read these Terms of Use carefully before using the Platform. By using the Platform, you signify your assent and agreement to these Terms of Use. If you do not agree to these Terms of Use, then you are not authorised to continue use of the Platform.",
"shopPhoneNumber": "8877995467",
"bankAccountHolderName": "Hardik Zaveri",
"bankAccountType": "current",
"bankAccountNumber": "454537868709898",
"bankIfscCode": "UTIB0000400"
},
{
"name": "Jamshedji Tata",
"jeweler": "8977654789",
"brandName": "Tanishq",
"address1": "Turner Rd, Bandra West",
"address2": "Near Tavaa Restaurant",
"masterPincode": "400007",
"masterCity": "Mumbai",
"masterState": "Maharashtra",
"masterCountry": "India",
"shopEmail": "sales@tanishq.com",
"pocFirstName": "Rajesh ",
"pocLastName": "Patel",
"pocPhoneNumber": "9870098700",
"pocEmail": "rajesh.patel@gmail.com",
"geographicalAreaServed": "Area 1",
"workingHoursFrom": "8",
"workingHoursTo": "9",
"termsAndConditions": "The term Tanishq was coined by Mr. Xerxes Desai by marrying the words ‘Tan’ meaning body and ‘Nishk’ meaning a gold ornament and Tanishq’s very first state-of-art jewellery factory with a proper karigaar park was set up in Hosur in Tamil Nadu. ",
"shopPhoneNumber": "9823456789",
"bankAccountHolderName": "Rajesh Patel",
"bankAccountType": "current",
"bankAccountNumber": "5445567557880909",
"bankIfscCode": "SBIN0005943"
}
]
[{
"name": "Andaman and Nicobar Islands",
"country": "India"
},
{
"name": "Andhra Pradesh",
"country": "India"
},
{
"name": "Arunachal Pradesh",
"country": "India"
},
{
"name": "Assam",
"country": "India"
},
{
"name": "Bihar",
"country": "India"
},
{
"name": "Chandigarh",
"country": "India"
},
{
"name": "Chhattisgarh",
"country": "India"
},
{
"name": "Dadra and Nagar Haveli",
"country": "India"
},
{
"name": "Daman and Diu",
"country": "India"
},
{
"name": "Delhi",
"country": "India"
},
{
"name": "Goa",
"country": "India"
},
{
"name": "Gujarat",
"country": "India"
},
{
"name": "Haryana",
"country": "India"
},
{
"name": "Himachal Pradesh",
"country": "India"
},
{
"name": "Jammu and Kashmir",
"country": "India"
},
{
"name": "Jharkhand",
"country": "India"
},
{
"name": "Karnataka",
"country": "India"
},
{
"name": "Kerala",
"country": "India"
},
{
"name": "Ladakh",
"country": "India"
},
{
"name": "Lakshadweep",
"country": "India"
},
{
"name": "Madhya Pradesh",
"country": "India"
},
{
"name": "Maharashtra",
"country": "India"
},
{
"name": "Manipur",
"country": "India"
},
{
"name": "Meghalaya",
"country": "India"
},
{
"name": "Mizoram",
"country": "India"
},
{
"name": "Nagaland",
"country": "India"
},
{
"name": "Odisha",
"country": "India"
},
{
"name": "Puducherry",
"country": "India"
},
{
"name": "Punjab",
"country": "India"
},
{
"name": "Rajasthan",
"country": "India"
},
{
"name": "Sikkim",
"country": "India"
},
{
"name": "Tamil Nadu",
"country": "India"
},
{
"name": "Telangana",
"country": "India"
},
{
"name": "Tripura",
"country": "India"
},
{
"name": "Uttar Pradesh",
"country": "India"
},
{
"name": "Uttarakhand",
"country": "India"
},
{
"name": "West Bengal",
"country": "India"
}
]
\ No newline at end of file
[
{
"name": "Gold"
},
{
"name": "Silver"
},
{
"name": "Platinum"
}
]
\ No newline at end of file
'use strict';
"use strict";
/**
* vendor service
*/
const { createCoreService } = require('@strapi/strapi').factories;
const { createCoreService } = require("@strapi/strapi").factories;
const { factories } = require("@strapi/strapi");
const fs = require("fs");
const { parse } = require("csv-parse");
module.exports = createCoreService('api::vendor.vendor');
module.exports = createCoreService(
"api::vendor.vendor",
({ strapi: Strapi }) => ({
async importCountrySeedData() {
const countryData = await fs.promises.readFile(
`${__dirname}/../seed-data/country.json`,
"utf8"
);
const countries = JSON.parse(countryData);
// console.log(countries);
// get rid of all existing countries.
const deletedCnt = await strapi.db
.query("api::master-country.master-country")
.deleteMany({ where: {} });
// console.log(`Bulk deleted existing countries, got rid of: ${deletedCnt.count} country records.`);
// re-create them again.
for (let i = 0; i < countries.length; i++) {
const country = countries[i];
// console.log(`Attempting to create country: `, country);
await strapi.entityService.create(
"api::master-country.master-country",
{
data: {
name: country.name,
},
}
);
}
},
async importStateSeedData() {
const stateData = await fs.promises.readFile(
`${__dirname}/../seed-data/state.json`,
"utf8"
);
const states = JSON.parse(stateData);
// console.log(states);
// get rid of all existing states.
const deletedCnt = await strapi.db
.query("api::master-state.master-state")
.deleteMany({ where: {} });
// console.log(`Bulk deleted existing states, got rid of: ${deletedCnt.count} state records.`);
// re-create them again.
for (let i = 0; i < states.length; i++) {
const state = states[i];
const matchingCountries = await strapi.entityService.findMany(
"api::master-country.master-country",
{
fields: ["id"],
filters: { name: state.country },
}
);
let statefinal;
if (!matchingCountries || matchingCountries.length === 0) {
console.log(
`Unable to resolve a country with name ${
state.country
}, skipping creation of state ${JSON.stringify(state)}`
);
} else {
// console.log(`Attempting to create state: `, state);
statefinal = await strapi.entityService.create(
"api::master-state.master-state",
{
data: {
name: state.name,
masterCountry: matchingCountries[0].id,
},
}
);
// console.log("state", statefinal);
}
}
},
async importCitySeedData() {
const cityData = await fs.promises.readFile(
`${__dirname}/../seed-data/city.json`,
"utf8"
);
const cities = JSON.parse(cityData);
// console.log(citys);
// get rid of all existing citys.
const deletedCnt = await strapi.db
.query("api::master-city.master-city")
.deleteMany({ where: {} });
// console.log(`Bulk deleted existing citys, got rid of: ${deletedCnt.count} city records.`);
// re-create them again.
for (let i = 0; i < cities.length; i++) {
const city = cities[i];
const matchingStates = await strapi.entityService.findMany(
"api::master-state.master-state",
{
fields: ["id"],
filters: { name: city.state },
}
);
if (!matchingStates || matchingStates.length === 0) {
console.log(
`Unable to resolve a state with name ${
city.state
}, skipping creation of city ${JSON.stringify(city)}`
);
} else {
// console.log(`Attempting to create city: `, city);
await strapi.entityService.create("api::master-city.master-city", {
data: {
name: city.name,
masterState: matchingStates[0].id,
},
});
}
}
},
async importPincodeSeedData() {
// const pincodeData = await fs.readFile(`${__dirname}/../seed-data/StateCityPinMasterSeeder.csv`);
// const records = parse(fileContent, );
// const pincodes = parse(pincodeData,{columns: true});
// console.log(citys);
let pincodeData = [];
const deletedCnt = await strapi.db
.query("api::master-pincode.master-pincode")
.deleteMany({ where: {} });
const deletedStateCnt = await strapi.db
.query("api::master-state.master-state")
.deleteMany({ where: {} });
const deletedCityCnt = await strapi.db
.query("api::master-city.master-city")
.deleteMany({ where: {} });
// const pincodeData = fs.createReadStream(`${__dirname}/../seed-data/StateCityPinMasterSeeder.csv`).pipe(parse({ delimiter: ",", from_line: 1 }));
fs.createReadStream(
`${__dirname}/../seed-data/StateCityPinMasterSeeder.csv`
)
.pipe(parse({}))
.on("data", (data) => {
// console.log("data", data);
pincodeData.push(data);
})
.on("end", () => {
resolveSeedData(pincodeData);
});
const resolveSeedData = async (seedData) => {
console.log("pincode data", seedData);
for (let i = 0; i < seedData.length; i++) {
const singleData = seedData[i];
const pincode = singleData[0];
const city = singleData[1];
const state = singleData[2];
let stateId;
let cityId;
console.log("pincode", pincode);
console.log("city", city);
console.log("state", state);
const resolveCountry = await strapi
.query("api::master-country.master-country")
.findOne({
where: {
$and: [{ name: "India" }],
},
});
console.log("resolveCountry", resolveCountry);
let resolveState = await strapi
.query("api::master-state.master-state")
.findOne({
where: {
$and: [{ name: state }],
},
});
console.log("resolveState", resolveState);
if (resolveState == null) {
resolveState = await strapi.entityService.create(
"api::master-state.master-state",
{
data: {
name: state,
masterCountry: resolveCountry.id,
},
}
);
console.log("resolveState", resolveState);
stateId = resolveState.id;
} else {
stateId = resolveState.id;
}
let resolveCity = await strapi
.query("api::master-city.master-city")
.findOne({
where: {
$and: [{ name: city, masterState: stateId }],
},
});
console.log("resolveCity", resolveCity);
if (resolveCity == null) {
resolveCity = await strapi.entityService.create(
"api::master-city.master-city",
{
data: {
name: city,
masterState: stateId,
},
}
);
console.log("resolveCity", resolveCity);
cityId = resolveCity.id;
} else {
cityId = resolveCity.id;
}
let resolvePincode = await strapi
.query("api::master-pincode.master-pincode")
.findOne({
where: {
$and: [{ name: state }],
},
});
let currentCity = await strapi
.query("api::master-city.master-city")
.findOne({
where: {
$and: [{ name: city }],
},
});
if (resolvePincode == null) {
resolvePincode = await strapi.entityService.create(
"api::master-pincode.master-pincode",
{
data: {
name: pincode,
masterCity: currentCity.id,
},
}
);
}
}
};
},
})
);
......@@ -67,7 +67,7 @@
"type": "string",
"private": true
},
"dialCode": {
"phone": {
"type": "string"
}
}
......
......@@ -59,13 +59,14 @@ const userPermissionExtension = (plugin) => {
throw new ApplicationError("Please find a valid user role.");
}
const { email, username, provider } = params;
const { email, username, provider, phone } = params;
const identifierFilter = {
$or: [
{ email: email },
{ username: email },
{ username },
{ email: username },
{phone: phone}
],
};
const conflictingUserCount = await strapi
......@@ -102,6 +103,7 @@ const userPermissionExtension = (plugin) => {
email: email,
username,
confirmed: false,
phone: phone
};
const user = await strapi
......
......@@ -3877,6 +3877,11 @@
"resolved" "https://registry.npmjs.org/csstype/-/csstype-3.1.0.tgz"
"version" "3.1.0"
"csv-parse@^5.5.5":
"integrity" "sha512-erCk7tyU3yLWAhk6wvKxnyPtftuy/6Ak622gOO7BCJ05+TYffnPCJF905wmOQm+BpkX54OdAl8pveJwUdpnCXQ=="
"resolved" "https://registry.npmjs.org/csv-parse/-/csv-parse-5.5.5.tgz"
"version" "5.5.5"
"dashdash@^1.12.0":
"integrity" "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g=="
"resolved" "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz"
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!