85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Dapper;
|
|
using dccdc.Models;
|
|
|
|
namespace dccdc.DAL
|
|
{
|
|
public class DuanXinYanZhengDal
|
|
{
|
|
/// <summary>
|
|
/// 获取手机号的当时验证次数
|
|
/// </summary>
|
|
/// <param name="mobile"></param>
|
|
/// <returns></returns>
|
|
public int getDRYZCS(string mobile)
|
|
{
|
|
//throw new NotImplementedException();
|
|
string sql = "select count(1) from DuanXinYanZheng where ShouJiHao=@mobile and datediff(d,sendtime,getdate())=0";
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.ExecuteScalar<int>(sql,new { mobile=mobile });
|
|
}
|
|
}
|
|
|
|
public DuanXinYanZheng Create(DuanXinYanZheng yzm)
|
|
{
|
|
//throw new NotImplementedException();
|
|
string sql = @"INSERT INTO [DuanXinYanZheng]
|
|
([state]
|
|
,[IP]
|
|
,[SessionID]
|
|
,[cookie]
|
|
,[smscode]
|
|
,[sendtime]
|
|
,[YanZhengShiJian]
|
|
,[YanZhengYouXiaoQi]
|
|
,[bz]
|
|
,[ShouJiHao])
|
|
VALUES
|
|
(@state
|
|
,@IP
|
|
,@SessionID
|
|
,@cookie
|
|
,@smscode
|
|
,@sendtime
|
|
,@YanZhengShiJian
|
|
,@YanZhengYouXiaoQi
|
|
,@bz
|
|
,@ShouJiHao)
|
|
select SCOPE_IDENTITY()
|
|
";
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
yzm.id = conn.ExecuteScalar<int>(sql, yzm);
|
|
return yzm;
|
|
}
|
|
}
|
|
|
|
public DuanXinYanZheng getYZMById(string yzmid)
|
|
{
|
|
//throw new NotImplementedException();
|
|
int izymid = 0;
|
|
int.TryParse(yzmid, out izymid);
|
|
string sql = "select * from DuanXinYanZheng where id=@id";
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<Models.DuanXinYanZheng>(sql, new { id = izymid }).FirstOrDefault();
|
|
}
|
|
}
|
|
|
|
public void YanZhenged(DuanXinYanZheng yzm)
|
|
{
|
|
//throw new NotImplementedException();
|
|
string sql = "update DuanXinYanZheng set state=1,YanZhengShiJian=getdate() where id=@id";
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
conn.Execute(sql, new { id = yzm.id });
|
|
}
|
|
}
|
|
}
|
|
}
|