chenhaozhe
5 天以前 d516af1f95472c0a5f86ab3b789c7b1e3c1c8656
WebAPI/Controllers/BaseSet/Gy_PropertyController.cs
@@ -19,6 +19,73 @@
        DataSet ds;
        #region 辅助属性列表-分页
        [Route("Gy_Property/listPage")]
        [HttpGet]
        public object listPage(string sWhere, string user, int page, int size)
        {
            try
            {
                List<object> columnNameList = new List<object>();  //定义声明变量 ,把通过 new List<object>()创建的 实例,赋值给变量
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Gy_Property", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限查询!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_IF_PropertyList " + page + "," + size + "," + "''", "h_p_Gy_CarList");
                }
                else
                {
                    sWhere = sWhere.Replace("'", "''");
                    ds = oCN.RunProcReturn("exec h_p_IF_PropertyList " + page + "," + size + ",'" + sWhere + "'", "h_p_Gy_CarList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.list = columnNameList;
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "没有返回任何记录!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        /// 返回辅助属性列表
        ///参数:string sql。