Exemple #1
0
        public async Task <List <ApplyProcess> > GetApplyLogByOrderSnAsync(string order_sn)
        {
            string             sql            = g_sqlMaker.Select <t_apply_log>().Where("order_sn", "=", "@order_sn").ToSQL();
            List <t_apply_log> apply_log_list = await g_dbHelper.QueryListAsync <t_apply_log>(sql, new { order_sn });

            IPositionServer     positionServer = new PositionServerImpl(g_dbHelper, g_logServer);
            IUserServer         userServer     = new UserServerImpl(g_dbHelper, g_logServer);
            List <ApplyProcess> apply_list     = new List <ApplyProcess>();

            foreach (var item in apply_log_list)
            {
                t_position position_model = await positionServer.GetPosition(s => new { s.position_name }, item.position_id);

                t_user user_model = await userServer.GetUserById(s => new { s.real_name }, item.user_id);

                apply_list.Add(new ApplyProcess
                {
                    audit_status  = item.apply_status,
                    audit_time    = item.add_time.Value.ToString("yyyy-MM-dd hh:mm"),
                    remark        = item.remark,
                    position_name = position_model.position_name,
                    auditer       = user_model.real_name
                });
            }

            return(apply_list);
        }
        public async Task <bool> ExistPositionAsync(int position_id)
        {
            string sql_position_exist = g_sqlMaker.Select <t_position>(s => new
            {
                s.id
            })
                                        .Where("id", "=", "@id")
                                        .And("state", "=", (int)EnumState.Normal)
                                        .ToSQL();

            t_position model = await g_dbHelper.QueryAsync <t_position>(sql_position_exist, new { id = position_id, state = (int)EnumState.Normal });

            return(model != null);
        }
Exemple #3
0
        public async Task <List <ApplyProcess> > GetApplyLogByOrderSnAsync(EnumOrderType _ot, string order_sn, int _depart, int _start_position)
        {
            string             sql            = g_sqlMaker.Select <t_apply_log>().Where("order_sn", "=", "@order_sn").ToSQL();
            List <t_apply_log> apply_log_list = await g_dbHelper.QueryListAsync <t_apply_log>(sql, new { order_sn });

            IPositionServer     positionServer  = new PositionServerImpl(g_dbHelper, g_logServer);
            IUserServer         userServer      = new UserServerImpl(g_dbHelper, g_logServer);
            List <ApplyProcess> apply_list      = new List <ApplyProcess>();
            IEnumerable <int>   apply_proc_list = GetApplyList(_ot, _depart, _start_position);

            foreach (var item in apply_proc_list)
            {
                t_apply_log apply_log_model = apply_log_list.FirstOrDefault(f => f.position_id == item);
                t_position  position_model  = await positionServer.GetPosition(s => new { s.position_name }, item);

                if (apply_log_model != null)
                {
                    t_user user_model = await userServer.GetUserById(s => new { s.real_name }, apply_log_model.user_id);

                    apply_list.Add(new ApplyProcess
                    {
                        audit_status      = apply_log_model.apply_status,
                        audit_status_desc = ((EnumAuditStatus)apply_log_model.apply_status).GetDesc(),
                        audit_time        = apply_log_model.add_time.Value.ToString("yyyy-MM-dd hh:mm") ?? "",
                        remark            = apply_log_model.remark,
                        position_name     = position_model.position_name,
                        auditer           = user_model.real_name,
                    });
                }
                else
                {
                    apply_list.Add(new ApplyProcess
                    {
                        position_name = position_model.position_name
                    });
                }
            }

            return(apply_list);
        }
Exemple #4
0
        /// <summary>
        /// @xis 登录 2020-3-25 07:52:00
        /// </summary>
        /// <param name="reqmodel"></param>
        /// <returns></returns>
        public async Task <Result> LoginAsync(reqmodel <LoginModel> reqmodel)
        {
            const string         modelname = "UserServerImpl.LoginAsync";
            Result <LoginResult> result    = new Result <LoginResult> {
                status = ErrorCodeConst.ERROR_403, code = ErrorCodeConst.ERROR_100
            };

            string sql_user_select = g_sqlMaker.Select <t_user>(s => new
            {
                s.id,
                s.user_name,
                s.real_name,
                s.salt,
                s.log_pwd,
                s.position_id
            })
                                     .Where($"user_name", "=", "@user_name")
                                     .And("state", "=", "@state")
                                     .ToSQL();

            t_user user = await g_dbHelper.QueryAsync <t_user>(sql_user_select, new { reqmodel.Data.user_name, state = (int)EnumState.Normal });

            if (user == null)
            {
                g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name}" }, EnumLogType.Debug);
                result.code = ErrorCodeConst.ERROR_1004;
                return(result);
            }

            string pwd = EncPassword(user.id, reqmodel.Data.password, user.salt);

            if (user.log_pwd != pwd)
            {
                g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name}" }, EnumLogType.Debug);
                result.code = ErrorCodeConst.ERROR_1004;
                return(result);
            }

            //获取职位信息
            IPositionServer positionServer = new PositionServerImpl(g_dbHelper, g_logServer);
            t_position      position_model = await positionServer.GetPosition(s => new { s.id, s.position_name, s.department_id }, user.position_id);

            if (position_model == null)
            {
                g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name},获取职位信息失败" }, EnumLogType.Debug);
                result.code = ErrorCodeConst.ERROR_1022;
                return(result);
            }

            //获取部门信息
            IDepartmentServer departmentServer = new DepartmentServerImpl(g_dbHelper, g_logServer);
            t_department      depart_model     = await departmentServer.GetDepartment(s => new { s.id, s.department_name }, position_model.department_id);

            if (depart_model == null)
            {
                g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name},获取部门信息失败" }, EnumLogType.Debug);
                result.code = ErrorCodeConst.ERROR_1022;
                return(result);
            }

            //token
            string token = Common.AESEncrypt(Common.MakeMd5(Common.MakeGuid()), Common.MakeGuid());

            LoginResult login_info = new LoginResult
            {
                user_id         = user.id,
                user_name       = user.user_name,
                avatar          = user.avatar,
                real_name       = user.real_name,
                department_id   = depart_model.id,
                department_name = depart_model.department_name,
                position_id     = position_model.id,
                position_name   = position_model.position_name,
                token           = token
            };

            bool login_flag = await TokenRenewalAsync(token, login_info);

            if (!login_flag)
            {
                g_logServer.Log(modelname, "登录失败", new { msg = $"用户名:{reqmodel.Data.user_name},存Redis失败" }, EnumLogType.Debug);
                result.code = ErrorCodeConst.ERROR_1022;
                return(result);
            }

            result.data   = login_info;
            result.status = ErrorCodeConst.ERROR_200;
            result.code   = ErrorCodeConst.ERROR_1008;
            return(result);
        }
 public int Insert(t_position model)
 {
     throw new NotImplementedException();
 }