1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using Cksoft.Data;
- using Cksoft.Data.Repository;
- using DllEapDal;
- using DllEapEntity.Dtos;
- using DllEapEntity.PM;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace DllEapBll.Controllers
- {
- /// <summary>
- /// 机台保养
- /// </summary>
- [Authorize]
- [ApiController]
- [Route("eap/api/[controller]/[action]")]
- public class MachineToPmController : ControllerBase
- {
- /// <summary>
- /// 机台保养情况列表
- /// </summary>
- /// <param name="filter"></param>
- /// <param name="sort"></param>
- /// <param name="states"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <param name="sortField"></param>
- /// <param name="sortOrder"></param>
- /// <returns></returns>
- [HttpGet]
- public LayuiModel<MachineToPM> Get(string filter, string sort, string states, int pageIndex = 1, int pageSize = 10, string sortField = "ID", string sortOrder = "ascend")
- {
- if (!string.IsNullOrEmpty(sort))
- {
- var arr = sort.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
- if (arr != null && arr.Length > 0)
- {
- sortField = arr[0];
- sortOrder = arr[1];
- }
- }
- if (sortOrder == "descend")
- {
- sortOrder = "desc";
- }
- else
- {
- sortOrder = "asc";
- }
- int start, end;
- start = (pageIndex - 1) * pageSize + 1;
- end = start + pageSize;
- using (IDatabase db = DbFactory.Base("eapslave"))
- {
- db.BeginTrans();
- var dal = new MachineToPmDal(db);
- // var total = dal.GetCount(filter);
- int total = 0;
- string errorinfo = string.Empty;
- var roles = dal.Get(start, pageSize, sortOrder, sortField, filter, states, errorinfo, out total);
- return new LayuiModel<MachineToPM>
- {
- code = 1,
- count = total,
- data = roles,
- msg = ""
- };
- }
- }
- /// <summary>
- /// 详情
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet]
- public MachineToPM GetSingle(int id)
- {
- using (IDatabase db = DbFactory.Base("eapslave"))
- {
- var dal = new MachineToPmDal(db);
- return dal.Get(id);
- }
- }
- }
- }
|