public async Task <ApiResult> ListPageCommon(ConstructionPlanCommonParm parm)
        {
            ApiResult ret = new ApiResult();

            try
            {
                ret.data = await _repo.ListPageCommon(parm);
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
            }
            return(ret);
        }
 public async Task <object> ListPageCommon(ConstructionPlanCommonParm parm)
 {
     return(await WithConnection(async c =>
     {
         object ret = null;
         StringBuilder sql = new StringBuilder();
         sql.Append("SELECT c.*,o.name,u.user_name FROM construction_plan_import_common c ")
         .Append("left join org_tree o on c.company=o.id ")
         .Append("left join user u on c.created_by=u.id ")
         .Append(" where 1=1");
         StringBuilder whereSql = new StringBuilder();
         if (parm.Year != null)
         {
             whereSql.Append(" and c.year=" + parm.Year);
         }
         if (parm.Line != null)
         {
             whereSql.Append(" and c.line=" + parm.Line);
         }
         if (parm.Company != null)
         {
             whereSql.Append(" and c.company=" + parm.Company);
         }
         if (parm.Department != null)
         {
             whereSql.Append(" and c.department=" + parm.Department);
         }
         sql.Append(whereSql).Append(" limit " + (parm.page - 1) * parm.rows + "," + parm.rows);;
         var tmp = await c.QueryAsync <ConstructionPlanImportCommon>(sql.ToString());
         if (tmp.Count() > 0)
         {
             sql.Clear();
             sql.Append("SELECT count(*) FROM construction_plan_import_common c ")
             .Append(" where 1=1 ").Append(whereSql);
             int total = await c.QueryFirstOrDefaultAsync <int>(sql.ToString());
             ret = new { rows = tmp.ToList(), total };
         }
         else
         {
             ret = new { rows = new List <ConstructionPlanImportCommon>(), total = 0 };
         }
         return ret;
     }));
 }
        public ActionResult ListPageCommon([FromQuery] ConstructionPlanCommonParm parm)
        {
            var resp = _service.ListPageCommon(parm);

            return(Ok(resp.Result));
        }