company-api.js 13.4 KB

module.exports.getCompanies = async (req, res) => {
    console.log('===== GET getCompanies =====')
    console.log('url', req.originalUrl);
    console.log('headers', req.headers);
    console.log('query', req.query);
    console.log('params', req.params);
    console.log('body', req.body);

    let response = { 
        "link": {
             "prev": "ip:port/partner/api/v1/Companies?taxId=$taxId&keyword=$keyword&page=$page&limit=$limit&sortby=$sortby", 
             "next": "ip:port/partner/api/v1/Companies?taxId=$taxId&keyword=$keyword&page=$page&limit=$limit&sortby=$sortby"
        }, 
        "meta": { 
             "currentPage": 1, 
             "totalPages": 1, 
             "limit": 1 
        }, 
        "total": 2, 
        "results": [ 
             { 
                  "_id": "ifd0zgjzzbw", 
                  "taxId": "0101620010053", 
                  "titleId": "201", 
                  "title": "โครงการ", 
                  "companyNameEn": "provisioning pack", 
                  "companyNameTh": "โปรวิชชั่นนิง แพ็ค", 
                  "companyLogo": "Shiba.jpg", 
                  "files": [ 
                       { 
                            "fileId": "9GSI21SAEGy", 
                            "fileLabel": "สำเนาบัตรประชาชนผู้ทำรายการ", 
                            "fileValue": "ContactIdCard", 
                            "fileName": "9GSI21SAEGy.png" 
                       }, 
                       { 
                            "fileId": "jwgu2rnctcu", 
                            "fileLabel": "หนังสือรับรองบริษัท (อายุไม่เกิน 1 ปี) พร้อมประทับตราบริษัท", 
                            "fileValue": "Certificate", 
                            "fileName": "jwgu2rnctcu.jpg" 
                       } 
                  ], 
                  "businessType": [ 
                       { 
                            "_id": "9GSI21SAEGy", 
                            "businessTypeName": "B2C", 
                            "sortOrder": "1"
                       }, 
                       { 
                            "_id": "jwgu2rnctcu", 
                            "businessTypeName": "B2B", 
                            "sortOrder": "2"
                        } 
                  ], 
                  "businessTypeOther": "B2B2C", 
                  "businessIndustries": [ 
                       { 
                            "_id": "9GSI21SAEGy", 
                            "industryName": "Smart Office", 
                            "sortOrder": "1" 
                       }, 
                       { 
                            "_id": "jwgu2rnctcu", 
                            "industryName": "Smart Health", 
                            "sortOrder": "2"
                       } 
                  ], 
                  "businessIndustryOther": "Education", 
                  "numberOfEmployee": "20", 
                  "socialChannels": [ 
                       { 
                            "socialChannelId": "Xuk6d43LvS5", 
                            "channel": "facebook", 
                            "link": "www.facebook.com" 
                       }, 
                       { 
                            "socialChannelId": "Zuk6d43LvS6", 
                            "channel": "instagram", 
                            "link": "www.instagram.com/dlwlrma" 
                       } 
                  ], 
                  "companyAddress": { 
                       "addressNo": "222/77", 
                       "moo": "1", 
                       "mooban": "Siri Place Rachaphuk-Rattanatibek", 
                       "soi": "5",
                       "building": "D", 
                       "room": "1",
                       "floor": "1", 
                       "street": "Rattanatibek",
                       "provinceCode": "10", 
                       "provinceName": "นนทบุรี/Nonthaburi",
                       "districtCode": "1014", 
                       "districtName": "บางบัวทอง/Bangbuathong",
                       "subDistrictCode": "101401", 
                       "subDisstrictName": "บางรักพัฒนา/Bangrakpattana",
                       "postalCode": "11110" 
                  },
                  "companyBillingAddress": { 
                       "addressNo": "222/77", 
                       "moo": "1", 
                       "mooban": "Siri Place Rachaphuk-Rattanatibek", 
                       "soi": "5",
                       "building": "D", 
                       "room": "1",
                       "floor": "1", 
                       "street": "Rattanatibek",
                       "provinceCode": "10", 
                       "provinceName": "นนทบุรี/Nonthaburi",
                       "districtCode": "1014", 
                       "districtName": "บางบัวทอง/Bangbuathong",
                       "subDistrictCode": "101401", 
                       "subDisstrictName": "บางรักพัฒนา/Bangrakpattana",
                       "postalCode": "11110" 
                  },
                  "yearOfEstablishment": "1990", 
                  "authorizedCapital": "13000000", 
                  "createdBy": "Natnichh@gmail.com", 
                  "createdDate": "2020-08-31T09:13:30.326Z", 
                  "updatedBy": "Natnichh@gmail.com", 
                  "updatedDate": "2020-08-31T09:13:30.326Z" 
             }, { 
                "_id": "ifd0zgjzzbz", 
                "taxId": "0101620010053", 
                "titleId": "201", 
                "title": "โครงการ", 
                "companyNameEn": "provisioning pack", 
                "companyNameTh": "โปรวิชชั่นนิง แพ็ค", 
                "companyLogo": "Shiba.jpg", 
                "files": [ 
                     { 
                          "fileId": "9GSI21SAEGy", 
                          "fileLabel": "สำเนาบัตรประชาชนผู้ทำรายการ", 
                          "fileValue": "ContactIdCard", 
                          "fileName": "9GSI21SAEGy.png" 
                     }, 
                     { 
                          "fileId": "jwgu2rnctcu", 
                          "fileLabel": "หนังสือรับรองบริษัท (อายุไม่เกิน 1 ปี) พร้อมประทับตราบริษัท", 
                          "fileValue": "Certificate", 
                          "fileName": "jwgu2rnctcu.jpg" 
                     } 
                ], 
                "businessType": [ 
                     { 
                          "_id": "9GSI21SAEGy", 
                          "businessTypeName": "B2C", 
                          "sortOrder": "1"
                     }, 
                     { 
                          "_id": "jwgu2rnctcu", 
                          "businessTypeName": "B2B", 
                          "sortOrder": "2"
                      } 
                ], 
                "businessTypeOther": "B2B2C", 
                "businessIndustries": [ 
                     { 
                          "_id": "9GSI21SAEGy", 
                          "industryName": "Smart Office", 
                          "sortOrder": "1" 
                     }, 
                     { 
                          "_id": "jwgu2rnctcu", 
                          "industryName": "Smart Health", 
                          "sortOrder": "2"
                     } 
                ], 
                "businessIndustryOther": "Education", 
                "numberOfEmployee": "20", 
                "socialChannels": [ 
                     { 
                          "socialChannelId": "Xuk6d43LvS5", 
                          "channel": "facebook", 
                          "link": "www.facebook.com" 
                     }, 
                     { 
                          "socialChannelId": "Zuk6d43LvS6", 
                          "channel": "instagram", 
                          "link": "www.instagram.com/dlwlrma" 
                     } 
                ], 
                "companyAddress": { 
                     "addressNo": "222/77", 
                     "moo": "1", 
                     "mooban": "Siri Place Rachaphuk-Rattanatibek", 
                     "soi": "5",
                     "building": "D", 
                     "room": "1",
                     "floor": "1", 
                     "street": "Rattanatibek",
                     "provinceCode": "10", 
                     "provinceName": "นนทบุรี/Nonthaburi",
                     "districtCode": "1014", 
                     "districtName": "บางบัวทอง/Bangbuathong",
                     "subDistrictCode": "101401", 
                     "subDisstrictName": "บางรักพัฒนา/Bangrakpattana",
                     "postalCode": "11110" 
                },
                "companyBillingAddress": { 
                     "addressNo": "222/77", 
                     "moo": "1", 
                     "mooban": "Siri Place Rachaphuk-Rattanatibek", 
                     "soi": "5",
                     "building": "D", 
                     "room": "1",
                     "floor": "1", 
                     "street": "Rattanatibek",
                     "provinceCode": "10", 
                     "provinceName": "นนทบุรี/Nonthaburi",
                     "districtCode": "1014", 
                     "districtName": "บางบัวทอง/Bangbuathong",
                     "subDistrictCode": "101401", 
                     "subDisstrictName": "บางรักพัฒนา/Bangrakpattana",
                     "postalCode": "11110" 
                },
                "yearOfEstablishment": "1990", 
                "authorizedCapital": "13000000", 
                "createdBy": "Natnichh@gmail.com", 
                "createdDate": "2020-08-31T09:13:30.326Z", 
                "updatedBy": "Natnichh@gmail.com", 
                "updatedDate": "2020-08-31T09:13:30.326Z" 
           }  
        ] 
   }
   
    res.send(response)
}

module.exports.contactPersons = async (req, res) => {
    console.log('===== GET contactPersons =====')
    console.log('url', req.originalUrl);
    console.log('headers', req.headers);
    console.log('query', req.query);
    console.log('params', req.params);
    console.log('body', req.body);

    let response = { 
        "link": { 
             "prev": "ip:port/partner/api/v1/contactperson-management/contactpersons?companyId=$companyId&contactFirstname=$contactFirstname&contactLastname=$contactLastname&idCardNo=$idCardNo&page=$page&limit=$limit&sortby=$sortby", 
             "next": "ip:port/partner/api/v1/contactperson-management/contactpersons?companyId=$companyId&contactFirstname=$contactFirstname&contactLastname=$contactLastname&idCardNo=$idCardNo&page=$page&limit=$limit&sortby=$sortby" 
        }, 
        "meta": { 
             "currentPage": 1, 
             "totalPages": 1, 
             "limit": 1 
        }, 
        "total": 2, 
        "results": [ 
             { 
                  "_id": "ifd0zgjzzbw", 
                  "companyId": "15BYQiQOXff", 
                  "email": "aron.olson@gmail.com", 
                  "titleId": "002", 
                  "title": "Mr.", 
                  "contactFirstname": "Aron", 
                  "contactLastname": "Olson", 
                  "contactMobileNo": "0938871199", 
                  "contactBirthday": "20180302000000+0700", 
                  "idCardNo": "1250112345678", 
                  "listBy": "Non Grantee", 
                  "createdBy": "Natnichh@gmail.com", 
                  "createdDate": "2020-08-31T09:13:30.326Z", 
                  "updatedBy": "Natnichh@gmail.com", 
                  "updatedDate": "2020-08-31T09:13:30.326Z",
                  "files": [ 
                       { 
                            "fileId": "9GSI21SAEGy", 
                            "fileLabel": "สำเนาบัตรประชาชนผู้ทำรายการ", 
                            "fileValue": "ContactIdCard", 
                            "fileName": "9GSI21SAEGy.png" 
                       }
                  ]
             },
             { 
                "_id": "ifd0zgjzzbw", 
                "companyId": "15BYQiQOXff", 
                "email": "aron.olson@gmail.com", 
                "titleId": "002", 
                "title": "Mr.", 
                "contactFirstname": "Aron", 
                "contactLastname": "Olson", 
                "contactMobileNo": "0938871199", 
                "contactBirthday": "20180302000000+0700", 
                "idCardNo": "1250112345678", 
                "listBy": "Non Grantee", 
                "createdBy": "Natnichh@gmail.com", 
                "createdDate": "2020-08-31T09:13:30.326Z", 
                "updatedBy": "Natnichh@gmail.com", 
                "updatedDate": "2020-08-31T09:13:30.326Z",
                "files": [ 
                     { 
                          "fileId": "9GSI21SAEGy", 
                          "fileLabel": "สำเนาบัตรประชาชนผู้ทำรายการ", 
                          "fileValue": "ContactIdCard", 
                          "fileName": "9GSI21SAEGy.png" 
                     }
                ]
           } 
        ] 
   }

    res.status(200).send(response)
}