public async Task <Result> GetOrderList(In inData)
        {
            DBHelper   db            = new DBHelper();
            List <int> position_list = await PositionDao.GetChildId(db, inData.user.position_id);

            position_list.Add(inData.user.position_id);
            position_list = position_list.Distinct().ToList();
            List <t_procurement> order_list = await ProcurementDao.GetList(db, position_list.ToArray());

            List <OrderItemResult> order_result_list = new List <OrderItemResult>();

            foreach (var item in order_list)
            {
                order_result_list.Add(new OrderItemResult
                {
                    add_time        = item.add_time.ToString("yyyy-MM-dd HH:mm:ss"),
                    department_name = await DepartmentDao.GetDepartmentName(db, item.department_id),
                    position_name   = await Dao.User.PositionDao.GetPositionName(db, item.position_id),
                    name            = await UserDao.GetUserRealName(db, item.id),
                    order_sn        = item.order_sn,
                    remark          = item.remark,
                    status          = item.status
                });
            }

            Result <List <OrderItemResult> > result = new Result <List <OrderItemResult> > {
                result = true, msg = "OK", data = order_result_list
            };

            return(result);
        }
Exemplo n.º 2
0
        public async Task <Result> Login(In <LoginIn> inData)
        {
            Result result = await VerifyLogin(inData.data);

            if (!result.result)
            {
                return(result);
            }
            DBHelper db   = new DBHelper();
            t_user   user = await UserDao.GetUser(db, inData.data.user_name);

            bool password_flag = VerifyCommon.VerifyPassword(user.id, user.salt, user.password, inData.data.password);

            if (!password_flag)
            {
                db.Close();
                result.msg = "用户名或密码错误";
                return(result);
            }

            LoginResult loginResult = new LoginResult
            {
                user_id         = user.id,
                department_name = await DepartmentDao.GetDepartmentName(db, user.department_id),
                position_name   = await PositionDao.GetPositionName(db, user.position_id),
                department_id   = user.department_id,
                position_id     = user.position_id,
                name            = user.real_name,
                token           = ConcealCommon.EncryptDES(user.id + DateTime.Now.ToString("yyy-MM-dd HH:mm:ss:ms")),
                user_name       = user.user_name,
            };

            db.Close();

            await RedisHelper.Instance.SetStringKeyAsync($"user-multi-token:{loginResult.token}", loginResult, TimeSpan.FromHours(4));

            Result <LoginResult> result1 = new Result <LoginResult>
            {
                data   = loginResult,
                result = true,
                msg    = "登录成功"
            };

            return(result1);
        }