Ejemplo n.º 1
0
        public async Task <IEnumerable <UserLocal> > UserList(ArguUserList arguUserList)
        {
            int    limitBefore = (arguUserList.Page - 1) * arguUserList.Limit;
            string wheresql    = $" where 1 = 1";

            if (!string.IsNullOrWhiteSpace(arguUserList.UserName))
            {
                wheresql += $" and username like '%{arguUserList.UserName}%' ";
            }
            if (!string.IsNullOrWhiteSpace(arguUserList.Mobilephone))
            {
                wheresql += $" and mobnilephone = '{arguUserList.Mobilephone}' ";
            }
            if (!string.IsNullOrWhiteSpace(arguUserList.PickName))
            {
                wheresql += $" and pickname like '{arguUserList.PickName}'";
            }
            if (arguUserList.Status != null)
            {
                wheresql += $" and status = {arguUserList.Status}";
            }
            var commandText = $"select * from {EntityHelper.CallName<UserLocal>()} {wheresql} limit {limitBefore},{arguUserList.Limit}";
            var userList    = await QueryAsync <UserLocal>(commandText, null);

            return(userList);
        }
Ejemplo n.º 2
0
        public async Task <ResultUserInfo> GetUserInfo(string userName)
        {
            var commandText    = $"select * from {EntityHelper.CallName<UserLocal>()} A left join {EntityHelper.CallName<UserToken>()} B ON A.id = B.user_id where A.username = @username";
            var resultUserInfo = await QueryOneAsync <ResultUserInfo>(commandText, new { userName });

            return(resultUserInfo);
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <UserLocal> > GatchUserListByID(int id)
        {
            var commandText     = $"select * from {EntityHelper.CallName<UserLocal>()} where id = @id";
            var resultUserLocal = await QueryAsync <UserLocal>(commandText, new { id });

            return(resultUserLocal);
        }
Ejemplo n.º 4
0
 public void MysqlExecute()
 {
     MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
     UserLocalDAL userLocalDAL = new UserLocalDAL();
     var          commandText  = $"update {EntityHelper.CallName<UserLocal>()} set status = 7 where id > 30";
     var          result       = userLocalDAL.Execute(commandText, null);
 }
Ejemplo n.º 5
0
        public async Task <ResultUserLocal> CheckUserLogin(string userName)
        {
            var commandText     = $"select * from {EntityHelper.CallName<UserLocal>()} where username = @username";
            var resultUserLocal = await QueryOneAsync <ResultUserLocal>(commandText, new { userName });

            return(resultUserLocal);
        }
Ejemplo n.º 6
0
        public void MysqlExecuteScalar()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL userLocalDAL = new UserLocalDAL();
            var          commandText  = $"select * from {EntityHelper.CallName<UserLocal>()} where id = @id";
            int          id           = 21;
            var          result       = userLocalDAL.ExecuteScalar <int>(commandText, new { id });

            Assert.Equal(id, result);
        }
Ejemplo n.º 7
0
        public async Task UpdateTenPayResult(string ordercode, int id)
        {
            string commandText = $"Update {EntityHelper.CallName<TenpayResultLog>()} set ordercode = @ordercode where id = @id";
            var    parameters  = new DynamicParameters();

            parameters.Add("@id", id);
            parameters.Add("@ordercode", ordercode);
            await ExecuteAsync(commandText, parameters);

            //await ExecuteAsync(commandText, new { ordercode, id});
        }
Ejemplo n.º 8
0
        public async Task <bool> CheckMobilephoneExist(string mobilePhone)
        {
            var commandText = $"select count(1) from {EntityHelper.CallName<UserLocal>()} where mobilephone = @mobilephone";
            var count       = await ExecuteScalarAsync <int>(commandText, new { mobilePhone = mobilePhone });

            if (count > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 9
0
        public async Task <bool> CheckUsernameExist(string userName)
        {
            var commandText = $"select count(1) from {EntityHelper.CallName<UserLocal>()} where username = @username";
            var count       = await ExecuteScalarAsync <int>(commandText, new { username = userName });

            if (count > 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 10
0
        public void MysqlExecuteTra()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL userLocalDAL = new UserLocalDAL();
            var          commandText  = $"update {EntityHelper.CallName<UserLocal>()} set status = 7 where id > 30";

            using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = userLocalDAL.Connection)
                {
                    var result = userLocalDAL.Execute(connection, commandText, null);
                }
            }
        }
Ejemplo n.º 11
0
        public void MysqlExecuteScalarTra()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL userLocalDAL = new UserLocalDAL();
            var          commandText  = $"select status from {EntityHelper.CallName<UserLocal>()} where id = @id";
            var          commandText2 = $"update {EntityHelper.CallName<UserLocal>()} set status = 5 where id = @id";

            using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = userLocalDAL.Connection)
                {
                    int id      = 22;
                    var result1 = userLocalDAL.ExecuteScalar <int>(connection, commandText2, new { id });
                    var result2 = userLocalDAL.ExecuteScalar <int>(connection, commandText, new { id });
                    Assert.Equal(5, result2);
                }
            }
        }
Ejemplo n.º 12
0
        public async Task UpdateToken(string token, DateTime expiration_time, int id)
        {
            var commandText = $"Update {EntityHelper.CallName<UserToken>()} set token = @token, expiration_time = @expiration_time where id = @id";

            await ExecuteAsync(commandText, new { token, expiration_time, id });
        }
Ejemplo n.º 13
0
        public async Task <UserToken> FindToken(string token)
        {
            var commandText = $"Select * from {EntityHelper.CallName<UserToken>()} where token = @token";

            return(await QueryOneAsync <UserToken>(commandText, new { token }));
        }
Ejemplo n.º 14
0
        public ActionResult <string> GetTableName()
        {
            string TableName = EntityHelper.CallName <CustomerInfo>();

            return(TableName);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 主键属性对象
        /// </summary>
        //public PropertyInfo PrimaryKey { get; set; }

        public BaseDAL()
        {
            this.TableName = EntityHelper.CallName <T>();
            //this.PrimaryKey = EntityHelper.GetSingleKey<T>();
        }