Skip to content

Commit

Permalink
Merge pull request #30 from IndustryFusion/feature/task-004-03-add_co…
Browse files Browse the repository at this point in the history
…pyright

added date for unique uuid
  • Loading branch information
LahariMIBS authored Oct 11, 2024
2 parents 0b6afc4 + 876fac3 commit 342a2a3
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions backend/src/endpoints/contract/contract.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ export class ContractService {

async createBinding(data: CreateBindingDto) {
try {
let uuid = uuidv5(data.data_provider_company_ifric_id, this.ifricId);
let uuid = uuidv5(data.data_provider_company_ifric_id + data.data_consumer_company_ifric_id + new Date().toISOString(), this.ifricId);
let bindingCodeArr = this.bindingCode.split('-');
let region_code = data.data_provider_company_ifric_id.split("-")[1];
let region_code = data.data_provider_company_ifric_id.split("-")[1].toUpperCase();
const regionData = await this.regionModel.find();
regionData.forEach(value => {
if(value.region_code.startsWith(region_code)) {
region_code = value.region_code;
}
})
let ifricId = `urn:ifric:${bindingCodeArr[0].toLowerCase()}-${region_code}-${bindingCodeArr[1].toLowerCase()}-${bindingCodeArr[2].toLowerCase()}-${uuid}`;
let ifricId = `urn:ifric:${bindingCodeArr[0].toLowerCase()}-${region_code.toLowerCase()}-${bindingCodeArr[1].toLowerCase()}-${bindingCodeArr[2].toLowerCase()}-${uuid}`;
const urnData = new this.urnModel({
urn: ifricId,
created_at: moment().format(),
Expand All @@ -61,10 +61,16 @@ export class ContractService {

async createContract(data: CreateContractDto) {
try {
let uuid = uuidv5(data.data_consumer_company_ifric_id, this.ifricId);
let uuid = uuidv5(data.data_consumer_company_ifric_id + new Date().toISOString(), this.ifricId);
let contractCodeArr = this.contractCode.split('-');
let region_code = data.data_consumer_company_ifric_id.split("-")[1];
let ifricId = `urn:ifric:${contractCodeArr[0].toLowerCase()}-${region_code}-${contractCodeArr[1].toLowerCase()}-${contractCodeArr[2].toLowerCase()}-${uuid}`;
let region_code = data.data_consumer_company_ifric_id.split("-")[1].toUpperCase();
const regionData = await this.regionModel.find();
regionData.forEach(value => {
if(value.region_code.startsWith(region_code)) {
region_code = value.region_code;
}
})
let ifricId = `urn:ifric:${contractCodeArr[0].toLowerCase()}-${region_code.toLowerCase()}-${contractCodeArr[1].toLowerCase()}-${contractCodeArr[2].toLowerCase()}-${uuid}`;
const urnData = new this.urnModel({
urn: ifricId,
created_at: moment().format(),
Expand Down

0 comments on commit 342a2a3

Please sign in to comment.