67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
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
|
|
*/
|
|
|