| | |
| | | !isNullOrEmpty(params[Keys[k]]) && |
| | | Keys[k] != 'page' && |
| | | Keys[k] != 'pageSize' && |
| | | Keys[k] != 'TABLE_NAME' //必需在页面的查询部分加入'TABLE_NAME'字段并赋值表名 |
| | | Keys[k] != 'TABLE_NAME' |
| | | ) { |
| | | sqlcmd += `And ${Keys[k]} like '%${params[Keys[k]]}%'`; |
| | | } |
| | |
| | | return model; |
| | | } |
| | | |
| | | export async function SaveEntity<T>(params: T, isUpdate: boolean, entityName: string) { |
| | | let data; |
| | | if (isUpdate) { |
| | | data = await defHttp.post( |
| | | { url: Api.UpdateEntity, params: genAction(entityName, params) }, |
| | | { |
| | | errorMessageMode: 'none', |
| | | isTransformResponse: false, |
| | | }, |
| | | ); |
| | | } else { |
| | | params.ID = buildUUID(); //生成GUID |
| | | data = await defHttp.post( |
| | | { url: Api.AddEntity, params: genAction(entityName, params) }, |
| | | { |
| | | errorMessageMode: 'none', |
| | | isTransformResponse: false, |
| | | }, |
| | | ); |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | export async function DeleteEntity<T>(params: T, entityName: string) { |
| | | const usParams = genAction(entityName, [params]); |
| | | return await defHttp.post( |
| | | { url: Api.DeleteList, params: usParams }, |
| | | { |
| | | errorMessageMode: 'none', |
| | | isTransformResponse: false, |
| | | }, |
| | | ); |
| | | } |
| | | |
| | | //获取服务器Json文件返回Json数据 |
| | | export async function fetchJson(url: string) { |
| | | try { |
| | | const response = await fetch(url); |
| | |
| | | console.error('Error fetching columns:', error); |
| | | } |
| | | } |
| | | |
| | | // 泛型函数,获取类的名称 |
| | | export function getClassName<T>(ctor: new () => T): string { |
| | | return ctor.name; |
| | | } |