小贷平台API设计

Posted xiaoma-

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小贷平台API设计相关的知识,希望对你有一定的参考价值。

 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设计的主要内容,如果未能解决你的问题,请参考以下文章

维信小贷发布“蜂鸟”大数据风控云平台

除征信快查外,用户画像和风控模型如何助力网络小贷风控

仁润云丨网络小贷风控数据接口分析(多头借贷,芝麻信用)

小贷项目管理总结

前端工程师都有用哪些比较靠谱的小工具

Express实战 - 应用案例- realworld-API - 路由设计 - mongoose - 数据验证 - 密码加密 - 登录接口 - 身份认证 - token - 增删改查API(代码片段