import { BaseRoute, Inject, Route, Router, Session,RouteResultType } from "noomi"; import { __AmCondService } from "../../service/__data/__condservice"; import { __AmDataService } from "../../service/__data/__dataservice"; @Router({ namespace: "/amcond", path: "*" }) class __AmCondRoute extends BaseRoute { @Inject(__AmCondService) service: __AmCondService; /** * 获取条件列表 * @returns */ async query(){ try{ let cond = {}; if(this.model.conditions){ cond = JSON.parse(this.model.conditions); } return await this.service.query(cond,this.model.pageNo,this.model.pageSize); }catch(e){ return{success:false,message:e} } } /** * 按条件id删除 * @returns void */ async del(){ try{ await this.service.delete(this.model.condId); return {success:true} }catch(e){ return{success:false,message:e} } } /** * 获取自己的条件(批次)列表 * @returns */ async getselfcond(){ try{ let cond:Record = {}; const session:Session = await this.request.getSession(); let authInfo:any = session.get("authInfo"); if(!authInfo || !authInfo.userId){ throw '用户未登录'; } if(this.model.conditions){ cond = JSON.parse(this.model.conditions); } cond['amDataImport.amUser.userId'] = authInfo.userId; return await this.service.query(cond,this.model.pageNo,this.model.pageSize); }catch(e){ return{success:false,message:e} } } /** * 导出条件数据 */ // @Route({ // path:"/exportdata", // results:[{ // type:RouteResultType.STREAM // }] // }) async exportdata(){ try{ const path = await this.service.exportCondData(this.response,this.model.condId); return{ type:'file', data:path }; }catch(e){ return{success:false,message:e} } } }