コード例 #1
0
ファイル: MaintenanceRepo.cs プロジェクト: huxuanchenxy/fund
 public async Task <PMEntityView> ListEntityPage(PMEntityParm parm)
 {
     return(await WithConnection(async c =>
     {
         PMEntityView ret = new PMEntityView();
         ret.total = 0;
         ret.rows = new List <PMEntity>();
         string sql = "SELECT m.*,d.name,u1.user_name,o.name as tname,e.eqp_name " +
                      " FROM pm_entity m " +
                      " left join dictionary_tree d on d.id=m.status " +
                      " left join equipment e on e.id=m.eqp " +
                      " left join org_tree o on o.id=m.team " +
                      " left join user u1 on u1.id=m.updated_by " +
                      " where 1=1 ";
         string sqlwhere = "";
         if (!string.IsNullOrWhiteSpace(parm.Title))
         {
             sqlwhere += " and m.title like '%" + parm.Title + "%' ";
         }
         if (parm.Status != null)
         {
             sqlwhere += " and m.status = " + parm.Status;
         }
         if (parm.Start != null)
         {
             sqlwhere += " and m.updated_time >= '" + parm.Start + "' ";
         }
         if (parm.End != null)
         {
             sqlwhere += " and m.updated_time <= '" + parm.End + "' ";
         }
         sql = sql + sqlwhere + " order by " + parm.sort + " " + parm.order
               + " limit " + (parm.page - 1) * parm.rows + "," + parm.rows;
         var tmp = await c.QueryAsync <PMEntity>(sql);
         if (tmp.Count() > 0)
         {
             sql = "select count(*) FROM pm_Entity m where 1=1 " + sqlwhere;
             ret.total = await c.QueryFirstOrDefaultAsync <int>(sql);
             ret.rows = tmp.ToList();
         }
         return ret;
     }));
 }
コード例 #2
0
        public async Task <ApiResult> ListEntityPage(PMEntityParm parm)
        {
            ApiResult ret = new ApiResult();

            try
            {
                PMEntityView view = await _repo.ListEntityPage(parm);

                List <QueryItem> locations = await _importRepo.ListAllLocations();

                foreach (var item in view.rows)
                {
                    item.LocationName = locations.Where(a => a.LocationBy == item.Locationby && a.ID == item.Location)
                                        .FirstOrDefault().Name;
                }
                ret.data = view;
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
            }
            return(ret);
        }
コード例 #3
0
        public ActionResult ListEntityPage([FromQuery] PMEntityParm parm)
        {
            var ret = _service.ListEntityPage(parm);

            return(Ok(ret.Result));
        }