通用权限管理系统基类中数据库的连接

    public class BaseController : Controller

    {



        /// <summary>

        /// 用户中心Dbhelper 

        /// </summary>

        public IDbHelper DbHelperUserCenter = GetDbConnection(BaseSystemInfo.UserCenterDbType, BaseSystemInfo.UserCenterDbConnection, ConfigHelper.GetConfigBool("BusinessDbEncrypt"));

        /// <summary>

        /// 业务库Dbhelper 

        /// </summary>

        public IDbHelper DbHelperBusiness = GetDbConnection(BaseSystemInfo.BusinessDbType, BaseSystemInfo.BusinessDbConnection, ConfigHelper.GetConfigBool("UserCenterDbEncrypt"));

        /// <summary>

        /// 获得DbHelper

        /// </summary>

        /// <param name="currentDbType">数据库类别</param>

        /// <param name="dbConnection">连接字符串</param>

        /// <param name="dbEncrypt">是否加密</param>

        /// <returns>IDbHelper</returns>

        private static IDbHelper GetDbConnection(CurrentDbType currentDbType, string dbConnection, bool dbEncrypt = false)

        {

            if (dbEncrypt)

            {

                dbConnection= SecretUtil.Decrypt(dbConnection);

            }

            return DbHelperFactory.GetHelper(currentDbType, dbConnection);

        }



..........

}

 

这里是mvc中基类的写法,其中提供了数据库使用加密方式后的解密方法。

 

你可能感兴趣的:(权限管理)