Support TS, swagger,Template(xls,docx),PDF convert

This commit is contained in:
Sorawit Bholsithi 2023-10-07 17:29:53 +07:00
parent b221deb1cf
commit 8d7654423a
84 changed files with 3604 additions and 1 deletions

67
libs/report-template.ts Normal file
View file

@ -0,0 +1,67 @@
export interface templateData {
template: string;
reportName: string;
data: object
}
export interface IDictionary<TValue> {
[key: string]: TValue;
}
export function mimeToExtension(mime: string): string {
const mimeList: IDictionary<string> = {
"application/pdf": "pdf",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
"application/msword": "doc",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
"application/vnd.ms-excel": "xls",
"application/vnd.ms-powerpoint": "ppt",
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
"application/vnd.oasis.opendocument.text": "odt",
"application/vnd.oasis.opendocument.spreadsheet":"ods",
"application/vnd.oasis.opendocument.presentation":"odp",
"text/html": "html",
"application/json": "json",
"text/csv": "csv",
"text/markdown": "md",
"text/plain": "txt",
"application/rtf": "rtf"
}
if (mimeList[mime]) {
return mimeList[mime]
} else if (mime.match(/^application\/x\./)) {
return mime.substr(mime.indexOf('.') + 1);
} else {
return mime
}
}
/** javascript-obfuscator:disable
* @swagger
* tags:
* name: report-template
* description: API Template docx xlsx Mail Merge Template soffice
*/
/** javascript-obfuscator:disable
* @swagger
* components:
* schemas:
* templateData:
* type: object
* required:
* - template
* - reportName
* - data
* - finished
* properties:
* template:
* type: string
* description: name of template
* reportName:
* type: string
* description: name of report for download
* data:
* type: object
* description: value for template
*/