import { Like } from "typeorm" ; const dayjs = require ( "dayjs" ) ; export function createStringDate ( format ? ) { return dayjs ( ) . format ( format || "YYYY-MM-DD HH:mm:ss" ) ; } param target param params export function createTableSearchConfig ( target ? , params ? ) { const config = { status : 1 } ; if ( target && target . length ) { target . forEach ( ( key ) => { if ( params && params [ key ] ) { config [ key ] = Like ( `%${ params [ key ] || "" }%` ) ; } } ) ; } return config ; } param params export function createTableSorterConfig ( params ? ) { const config = { } ; if ( params ) { const sorter = JSON . parse ( params ) ; Object . keys ( sorter ) . forEach ( ( key ) => { config [ key ] = sorter [ key ] === "ascend" ? "ASC" : "DESC" ; } ) ; } else { config . createTime = "DESC" ; } return config ; }