using System; using System.Collections.Generic; using System.Data; using SuperMap.RealEstate.ServiceModel; using Business = SuperMap.RealEstate.FrameWork.Platform.Business; using HCC = HZQR.Common.Common; using HZQR.Common; namespace EShang.Common.GeneralMethod { /// /// 平台接口表相关方法 /// 2023/6/7 15:05:14自动生成 /// public class INTERFACEHelper { #region 获取平台接口表列表 /// /// 获取平台接口表列表 /// /// 事务管理器 /// 查询结果总数 /// 查询条件对象 public static List GetINTERFACEList(Transaction transaction, ref int TotalCount, Model.SearchModel searchModel) { List INTERFACEList = new List(); string WhereSQL = "", RowFilterSQL = ""; if (searchModel.SearchParameter != null) { WhereSQL = OperationDataHelper.GetWhereSQL(searchModel.SearchParameter, searchModel.QueryType); if (WhereSQL != "") { WhereSQL = " WHERE " + WhereSQL; } } DataTable dtINTERFACE = new Business.PERMISSIONAPPLY(transaction).ExecuteDataTable( "SELECT * FROM PLATFORM_FRAMEWORK.T_INTERFACE" + WhereSQL); //增加组合查询条件 if (searchModel.keyWord != null && !string.IsNullOrWhiteSpace(searchModel.keyWord.Key)) { foreach (string KeyName in searchModel.keyWord.Key.Split(',')) { RowFilterSQL += (RowFilterSQL == "" ? "" : " or ") + KeyName + " like '%" + searchModel.keyWord.Value + "%'"; } } if (RowFilterSQL != "") { dtINTERFACE.DefaultView.RowFilter = RowFilterSQL; } //排序: dtINTERFACE.DefaultView.Sort = searchModel.SortStr; dtINTERFACE = dtINTERFACE.DefaultView.ToTable(); //获取查询结果总记录条数 TotalCount = dtINTERFACE.Rows.Count; //根据传入的页码和每页显示条数返回结果 dtINTERFACE = CommonHelper.GetDataTableWithPageSize(dtINTERFACE, searchModel.PageSize, searchModel.PageIndex); foreach (DataRow drINTERFACE in dtINTERFACE.Rows) { Model.INTERFACEModel interfaceModel = new Model.INTERFACEModel(); //绑定平台接口表数据对象 BindDataRowToModel(drINTERFACE, interfaceModel); INTERFACEList.Add(interfaceModel); } return INTERFACEList; } #region 绑定model /// /// 绑定model /// /// datarow数据源 /// model对象 public static void BindDataRowToModel(DataRow drINTERFACE, Model.INTERFACEModel interfaceModel) { if (drINTERFACE["INTERFACE_ID"].ToString() != "") { interfaceModel.INTERFACE_ID = drINTERFACE["INTERFACE_ID"].TryParseToInt(); //接口内码 } interfaceModel.INTERFACE_NAME = drINTERFACE["INTERFACE_NAME"].ToString(); //接口名称 interfaceModel.INTERFACE_ROUTE = drINTERFACE["INTERFACE_ROUTE"].ToString(); //接口路径 interfaceModel.INTERFACE_DOMAINNAME = drINTERFACE["INTERFACE_DOMAINNAME"].ToString(); //接口域名 interfaceModel.INTERFACE_CONTROLLER = drINTERFACE["INTERFACE_CONTROLLER"].ToString(); //接口分类 if (drINTERFACE["INTERFACE_ACCEPTVERBS"].ToString() != "") { interfaceModel.INTERFACE_ACCEPTVERBS = drINTERFACE["INTERFACE_ACCEPTVERBS"].TryParseToShort(); //响应方式(0:GET/POST,1:GET,2:POST) } if (drINTERFACE["PARAMS_FORMAT"].ToString() != "") { interfaceModel.PARAMS_FORMAT = drINTERFACE["PARAMS_FORMAT"].TryParseToShort(); //入参格式(0:field;1:object;2:list;3:nestingmodel;4:nestingmodellist;5:searchmodel) } if (drINTERFACE["RESPONSE_FORMAT"].ToString() != "") { interfaceModel.RESPONSE_FORMAT = drINTERFACE["RESPONSE_FORMAT"].TryParseToShort(); //返参格式(0:string;1:object;2:list;3:nestingmodel;4:nestingmodellist) } if (drINTERFACE["STANDARD_TYPE"].ToString() != "") { interfaceModel.STANDARD_TYPE = drINTERFACE["STANDARD_TYPE"].TryParseToShort(); //是否标准接口(0:否;1:是) } if (drINTERFACE["OPERATE_DATE"].ToString() != "") { interfaceModel.OPERATE_DATE = drINTERFACE["OPERATE_DATE"].TryParseToDateTime(); //操作时间 } interfaceModel.INTERFACE_DESC = drINTERFACE["INTERFACE_DESC"].ToString(); //接口说明 if (drINTERFACE["INTERFACE_PID"].ToString() != "") { interfaceModel.INTERFACE_PID = drINTERFACE["INTERFACE_PID"].TryParseToInt(); //父级接口内码 } if (drINTERFACE["INTERFACE_TYPE"].ToString() != "") { interfaceModel.INTERFACE_TYPE = drINTERFACE["INTERFACE_TYPE"].TryParseToShort(); //接口类型(0:目录,1:接口) } if (drINTERFACE["INTERFACE_AUTHORITY"].ToString() != "") { interfaceModel.INTERFACE_AUTHORITY = drINTERFACE["INTERFACE_AUTHORITY"].TryParseToShort(); //权限验证(0:否;1:是) } interfaceModel.INTERFACE_UNIQUE = drINTERFACE["INTERFACE_UNIQUE"].ToString(); //接口唯一键值 } #endregion #endregion #region 获取平台接口表明细 /// /// 获取平台接口表明细 /// /// 事务管理器 /// 平台接口表内码 public static Model.INTERFACEModel GetINTERFACEDetail(Transaction transaction, int INTERFACEId) { Model.INTERFACEModel interfaceModel = new Model.INTERFACEModel(); string WhereSQL = "WHERE INTERFACE_ID = " + INTERFACEId; //查询明细数据 DataTable dtINTERFACE = new Business.PERMISSIONAPPLY(transaction).ExecuteDataTable( "SELECT * FROM PLATFORM_FRAMEWORK.T_INTERFACE " + WhereSQL); if (dtINTERFACE.Rows.Count > 0) { //绑定平台接口表数据对象 BindDataRowToModel(dtINTERFACE.Rows[0], interfaceModel); } return interfaceModel; } #endregion #region 同步平台接口表 /// /// 赋值平台接口表数据对象 /// /// 事务管理器 /// 平台接口表数据对象 public static bool SynchroINTERFACE(Transaction transaction, Model.INTERFACEModel interfaceModel) { bool SynchroFlag = true; string SQLString; List excludeField = new List(); Dictionary dateFieldList = new Dictionary(); string tableName = "PLATFORM_FRAMEWORK.T_INTERFACE", keyField = "INTERFACE_ID", seqName = "SEQ_INTERFACE"; Business.PERMISSIONAPPLY _PERMISSIONAPPLY = new Business.PERMISSIONAPPLY(transaction); #region 添加SQL语句中需要排除在外的字段 #endregion #region 添加SQL语句中日期相关字段的执行语句 #endregion if (interfaceModel.INTERFACE_ID != null) { string WhereSQL = " WHERE INTERFACE_ID = " + interfaceModel.INTERFACE_ID; DataTable dtINTERFACE = _PERMISSIONAPPLY.ExecuteDataTable( "SELECT * FROM PLATFORM_FRAMEWORK.T_INTERFACE" + WhereSQL); if (dtINTERFACE.Rows.Count > 0) { SQLString = OperationDataHelper.GetTableExcuteSQL( interfaceModel, 1, tableName, keyField, seqName, dateFieldList, excludeField, WhereSQL); } else { return false; } } else { DataTable dtINTERFACE = _PERMISSIONAPPLY.ExecuteDataTable( "SELECT " + seqName + ".NEXTVAL FROM DUAL"); interfaceModel.INTERFACE_ID = dtINTERFACE.Rows[0][0].TryParseToInt(); SQLString = OperationDataHelper.GetTableExcuteSQL( interfaceModel, 0, tableName, keyField, seqName, dateFieldList, excludeField); } _PERMISSIONAPPLY.ExecuteNonQuery(SQLString, null); return SynchroFlag; } #endregion #region 删除平台接口表 /// /// 删除平台接口表 /// /// 事务管理器 /// 平台接口表内码 public static bool DeleteINTERFACE(Transaction transaction, int? INTERFACEId) { bool DeleteFlag = false; if (INTERFACEId != null) { } return DeleteFlag; } #endregion } }