WebApi

2021-06-29 22:08

阅读:633

标签:splay   etc   nbsp   state   isp   获取   linq   log   eric   

技术分享图片技术分享图片
  1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Net;
  5 using System.Net.Http;
  6 using System.Web.Http;
  7 
  8 namespace VacationOA.API.Controllers
  9 {
 10     using BLL;
 11     using MODEL;
 12     public class VacationAPIController : ApiController
 13     {
 14         StaffBLL staffbll = new StaffBLL();
 15         LeaveBLL leaveBll = new LeaveBLL();
 16         CheckBLL checkbll = new CheckBLL();
 17         [Route("LoginStaff")]
 18         [HttpGet]
 19         public Staff LoginStaff(string name, string department)
 20         {
 21             return staffbll.LoginStaff(name, department);
 22         }
 23         /// 
 24         /// 添加请假单
 25         /// 
 26         /// 
 27         /// 
 28         [Route("AddLeave")]
 29         [HttpPost]
 30         public int AddLeave(Leave l)
 31         {
 32             //异常处理
 33             try
 34             {
 35                 return leaveBll.AddLeave(l);
 36             }
 37             catch (Exception ex)
 38             {
 39                 return 0;
 40             }
 41            
 42         }
 43         /// 
 44         /// 修改请假单
 45         /// 
 46         /// 
 47         /// 
 48 
 49         [Route("updateleave")]
 50         [HttpPost]
 51         public int updateleave(Leave l)
 52         {
 53             return leaveBll.updateleave(l);
 54         }
 55         /// 
 56         /// 获取请假单
 57         /// 
 58         /// 
 59         [Route("GetLeaves")]
 60        [HttpPost]
 61         public Paging GetLeaves(LikeShow ls)
 62         {
 63             Paging paging = new Paging();
 64             List list1 = leaveBll.GetLeaves();
 65             list1 = list1.Where(n => n.staffID.Equals(ls.staffID)).ToList();
 66             if (ls.state != "" && ls.state != null)
 67             {
 68                 list1 = list1.Where(n=>n.state.Equals(ls.state)).ToList();
 69             }
 70             if (ls.starttime != null)
 71             {
 72                 list1 = list1.Where(n => n.startTime>=ls.starttime).ToList();
 73             }
 74             if (ls.endtiome != null)
 75             {
 76                 list1 = list1.Where(n => n.endTimels.endtiome).ToList();
 77             }
 78             if (ls.Department!=null&&ls.Department!="")
 79             {
 80                 list1 = list1.Where(n => n.Department.Equals(ls.Department)).ToList();
 81             }
 82             paging.Currentpage = ls.Currentpage;
 83             paging.Totlepage = list1.Count / 3 + (list1.Count % 3==0?0:1);
 84             paging.RowCounts = list1.Count;
 85             paging.DataBox = list1.Skip((ls.Currentpage-1)*3).Take(3).ToList();
 86             return paging;
 87         }
 88         /// 
 89         /// 获取请假单 我的审核列表
 90         /// 
 91         /// 
 92         [Route("GetLeavesCheck")]
 93         [HttpPost]
 94         public Paging GetLeavesCheck(LikeShow ls)
 95         {
 96             Paging paging = new Paging();
 97             List list1 = leaveBll.GetLeavesCheck();
 98             if (ls.starttime != null)
 99             {
100                 list1 = list1.Where(n => n.startTime >= ls.starttime).ToList();
101             }
102             if (ls.endtiome != null)
103             {
104                 list1 = list1.Where(n => n.endTime  ls.endtiome).ToList();
105             }
106             if (ls.Department != null && ls.Department != "")
107             {
108                 list1 = list1.Where(n => n.Department.Equals(ls.Department)).ToList();
109             }
110             paging.Currentpage = ls.Currentpage;
111             paging.Totlepage = list1.Count / 3 + (list1.Count % 3 == 0 ? 0 : 1);
112             paging.RowCounts = list1.Count;
113             paging.DataBox = list1.Skip((ls.Currentpage - 1) * 3).Take(3).ToList();
114             return paging;
115         }
116         /// 
117         /// 反填请假单
118         /// 
119         [Route("GetleaveByID")]
120         [HttpGet]
121         public Leave GetleaveByID(int id)
122         {
123             List list1 = leaveBll.GetLeaves();
124             return list1.Where(n=>n.leaveID.Equals(id)).FirstOrDefault();
125         }
126         /// 
127         /// 根据假条id查询是否有关于这个假条审核通过的审核单
128         /// 
129         /// 
130         /// 
131         [Route("GetCheckbyid")]
132         [HttpGet]
133         public int GetCheckbyid(int id)
134         {
135             return checkbll.GetCheckbyid(id);
136         }
137         /// 
138         /// 添加审核清单
139         /// 
140         /// 
141         /// 
142         [Route("AddTcheck")]
143         [HttpPost]
144         public int AddTcheck(TCheck tcheck)
145         {
146             return checkbll.AddTcheck(tcheck);
147         }
148         /// 
149         /// 修改请假单的状态,审核时间,说明,
150         /// 
151         /// 
152         /// 
153         [Route("updateleaveState")]
154         [HttpGet]
155         public int updateleaveState(int id, DateTime checktime, string explain, string state)
156         {
157             return leaveBll.updateleaveState(id, checktime, explain, state);
158         }
159         /// 
160         /// 根据id获取对应请假单的审核历史
161         /// 
162         /// 
163         [Route("GetChecks")]
164         [HttpGet]
165         public List GetChecks(int id)
166         {
167             return checkbll.GetChecks(id);
168         }
169     }
170 }
VacationAPIController

 

WebApi

标签:splay   etc   nbsp   state   isp   获取   linq   log   eric   

原文地址:https://www.cnblogs.com/xcleowong/p/10002491.html


评论


亲,登录后才可以留言!