yl
2023-05-30 925394b1b7f61a2c2a15fdaa0ecd0763214ccda1
VueWebApi/DLL/DAL/LoginDAL.cs
@@ -1,6 +1,7 @@
using Dapper;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
@@ -19,13 +20,17 @@
        public static List<SqlParameter> listStr = new List<SqlParameter>(); //定义全局参数集合
        public static SqlParameter[] parameters; //定义全局SqlParameter参数数组
        public static string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
        //获取企业配置Enterprise
        private static readonly string Enterprise = ConfigurationManager.AppSettings["Enterprise"];
        #region [登录查询]
        public static DataTable LoginSearch(string username, string password)
        {
            //执行sql
            strProcName = "select *  from [dbo].[TUser] where usercode=@username and password=@password";
            strProcName = @"select *  from [dbo].[TUser] U
                            left join TGroup G on U.usergroup_code = G.group_code
                            where U.usercode=@username and U.password=@password and U.is_delete='0'";
            //创建参数
            listStr.Add(new SqlParameter("@username", username));
            listStr.Add(new SqlParameter("@password", password));
@@ -131,12 +136,13 @@
                }).ToList();
                for (int i = 0; i < data.Count; i++)
                {
                    sql = @"select distinct mu.right_code as code,mu.right_name as name,mu.right_seq,mu.is_delete as flag,imgurl
                    sql = @"select *  from(
                            select distinct mu.right_code as code,mu.right_name as name,mu.right_seq,mu.is_delete as flag,imgurl
                     from TRight mu
                            inner join TRoleRightRelation rl on mu.right_code=rl.right_code
                            inner join TUserRoleRelation ro on rl.role_code=ro.role_code
                            where mu.type=@usertype and ro.user_code=@usercode and mu.parent_id=@paent_id 
                     order by mu.right_seq, mu.right_code";
                            ) as AA order by  CAST(AA.right_seq AS DECIMAL) ASC,AA.code";
                    dynamicParams.Add("@usercode", usercode);
                    dynamicParams.Add("@usertype", usertype);
                    dynamicParams.Add("@paent_id", data[i].code);
@@ -163,7 +169,7 @@
        }
        #endregion
        #region[修改密码]
        public static ToMessage UpdateUserPassword(string usercode, string username, string password, string newpassword)
@@ -223,7 +229,7 @@
        }
        #endregion
        #region[登出]
        #region[PC登出]
        public static ToMessage LoginOut(int userid, string usercode, string username, string usertype)
        {
            var sql = "";
@@ -239,7 +245,7 @@
                cont = DapperHelper.SQL(sql, dynamicParams);
                if (cont > 0)
                {
                    redis.Remove("LoginUserID" + usertype + userid, 0); //删除redis
                    redis.Remove(Enterprise+"LoginUserID" + usertype + userid, 0); //删除redis
                    mes.code = "200";
                    mes.count = 0;
                    mes.Message = "登出成功!";
@@ -263,5 +269,80 @@
            return mes;
        }
        #endregion
        #region[App登出]
        public static ToMessage LoginAppOut(int userid, string usercode, string username, string usertype)
        {
            var sql = "";
            var cont = 0;
            var dynamicParams = new DynamicParameters();
            RedisHelper redis = new RedisHelper();
            try
            {
                sql = @"update T_Bas_Login set outdate=@outdate,status='N'  where usercode=@usercode and origin=@usertype";
                dynamicParams.Add("@usercode", usercode);
                dynamicParams.Add("@outdate", DateTime.Now.ToString());
                dynamicParams.Add("@usertype", usertype);
                cont = DapperHelper.SQL(sql, dynamicParams);
                if (cont > 0)
                {
                    mes.code = "200";
                    mes.count = 0;
                    mes.Message = "登出成功!";
                    mes.data = null;
                }
                else
                {
                    mes.code = "300";
                    mes.count = 0;
                    mes.Message = "登出失败!";
                    mes.data = null;
                }
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
        #region[App登录查询安灯呼叫信息]
        public static ToMessage LoginAppAnDonMessage(int userid, string usercode, string username, string usertype)
        {
            var sql = "";
            var dynamicParams = new DynamicParameters();
            RedisHelper redis = new RedisHelper();
            try
            {
                sql = @"select B.eqp_code,E.name as eqp_name,B.wkshp_code,T.org_name as wkshp_name,
                        A.type as typecode,D.name as typename,B.start_user,B.start_date
                        from TAnDnMessagePush A
                        inner join TAnDon_Task_Info B on A.m_id=B.id
                        left  join TEqpInfo E on B.eqp_code=E.code
                        left  join TOrganization T on B.wkshp_code=T.org_code
                        left  join TAnDonType D on A.type=d.code
                        where A.resp_user=@username and B.status='START' and T.description='W'";
                dynamicParams.Add("@username", username);
                var data = DapperHelper.selectdata(sql, dynamicParams);
                mes.code = "200";
                mes.count = 0;
                mes.Message = "查询成功!";
                mes.data = data;
            }
            catch (Exception e)
            {
                mes.code = "300";
                mes.count = 0;
                mes.Message = e.Message;
                mes.data = null;
            }
            return mes;
        }
        #endregion
    }
}