码迷,mamicode.com
首页 > Windows程序 > 详细

小贷平台API设计

时间:2020-07-10 09:17:35      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:val   lis   esc   add   ike   dex   color   for   update   

 1 public List<Dai> Show(string name="")
 2         {
 3             using (SqlConnection conn=new SqlConnection("Data Source=.;Initial Catalog=Dai6_21;Integrated Security=True"))
 4             {
 5                 if (string.IsNullOrEmpty(name))
 6                 {
 7                     return conn.Query<Dai>($"select * from Dai").ToList();
 8                 }
 9                 else
10                 {
11                     return conn.Query<Dai>($"select * from Dai where Name like ‘%{name}%‘").ToList();
12                 }
13                 
14             }
15         }
16         public int Add(Dai m)
17         {
18             using (SqlConnection conn=new SqlConnection("Data Source=.;Initial Catalog=Dai6_21;Integrated Security=True"))
19             {
20                 var sql = string.Format($"insert into Dai values(‘{m.Name}‘,‘{m.Zhon}‘,‘{m.identit}‘,‘{m.DDate}‘,‘{m.DMoney}‘)");
21                 return conn.Execute(sql);
22             }
23         }
24         public int Del(int id)
25         {
26             using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Dai6_21;Integrated Security=True"))
27             {
28                 var sql = $"delete from Dai where Id={id}";
29                 return conn.Execute(sql);
30             }
31         }
32         public int Upd(Dai d)
33         {
34             using (SqlConnection conn=new SqlConnection("Data Source=.;Initial Catalog=Dai6_21;Integrated Security=True"))
35             {
36                 string sql = $"update Dai set Name=‘{d.Name}‘,Zhon=‘{d.Zhon}‘,identit=‘{d.identit}‘,DDate=‘{d.DDate}‘,DMoney=‘{d.DMoney}‘ where Id=‘{d.Id}‘";
37                 return conn.Execute(sql);
38             }
39 
40         }
41         public Dai Getfan(int DId)
42         {
43             var list =Show();
44             var mod = list.Where(m => m.Id == DId).FirstOrDefault();
45             return mod;
46         }
47         public int Login(string Name,string Pwd)
48         {
49             using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=Dai6_21;Integrated Security=True"))
50             {
51                 string sql = $"select * from deposit where UName=‘{Name}‘ and Pwd=‘{Pwd}‘";
52                 return Convert.ToInt32(conn.ExecuteScalar(sql));
53             }
54         }
55         
56         
 1 DDAL dal = new DDAL();
 2         
 3         
 4         [HttpGet]
 5         public async Task<PageModel> Show(int pageIndex=1,int pageSize=2,string name="")
 6         {
 7 
 8             List<Dai> list = await Task.Run(() => { return dal.Show(name); });
 9             
10             PageModel page = new PageModel();
11             page.TotalCount = list.Count / 2 + (list.Count % 2 > 0 ? 1 : 0);
12             page.List = list.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
13 
14             return page;
15         }
16         
17 
18         [HttpPost]
19         public  int Add(Dai m)
20         {
21             return dal.Add(m);
22         }
23         [HttpDelete]
24         public int Del(int id)
25         {
26             return dal.Del(id);
27         }
28         [HttpPost]
29         public int Upd(Dai d)
30         {
31             return dal.Upd(d);
32 
33         }
34         [HttpGet]
35         public Dai Getfan(int DId)
36         {
37             return dal.Getfan(DId);
38         }
39         [HttpGet]
40         public int Login(string Name, string Pwd)
41         {
42             return dal.Login(Name, Pwd);
43         }

 

小贷平台API设计

标签:val   lis   esc   add   ike   dex   color   for   update   

原文地址:https://www.cnblogs.com/XiaoMa-/p/13277411.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!