allow for addition of Vorgaenge on Vorgang overview
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { fail } from '@sveltejs/kit';
|
||||
import { BUCKET, client, CONFIGFILENAME, TOKENFILENAME } from '$lib/minio';
|
||||
import { checkIfExactDirectoryExists, getContentOfTextObject } from './s3ClientService';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { db } from './dbService';
|
||||
|
||||
@@ -45,6 +46,31 @@ export const getVorgangByToken = (
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create Vorgang, using a vorgangName and vorgangPIN
|
||||
* @param vorgangName
|
||||
* @param vorgangPIN
|
||||
* @returns {string || false} vorgangToken if successful
|
||||
*/
|
||||
export const createVorgang = (vorgangName: string, vorgangPIN: string): string | boolean => {
|
||||
const vorgangExists = vorgangNameExists(vorgangName);
|
||||
if (vorgangExists) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const vorgangToken = uuidv4();
|
||||
|
||||
const insertSQLStatement = `INSERT INTO cases (token, name, pin) VALUES (?, ?, ?)`;
|
||||
const statement = db.prepare(insertSQLStatement);
|
||||
const info = statement.run(vorgangToken, vorgangName, vorgangPIN);
|
||||
|
||||
if (info.changes) {
|
||||
return vorgangToken;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Vorgang
|
||||
* @param vorgangName
|
||||
|
||||
Reference in New Issue
Block a user