示例#1
0
        public async Task <ActionResult <ApiResult> > GetPageList([FromQuery] UserParm parm)
        {
            ApiResult ret = new ApiResult {
                code = Code.Failure
            };

            try
            {
                ret = await _service.GetPageList(parm);
            }
            catch (System.Exception ex)
            {
                ret.msg = string.Format(
                    "获取分页数据User失败, 异常信息:{0}",
                    ex.Message);
            }
            return(ret);
        }
示例#2
0
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);
            string method = Request["Method"] ?? "";

            if (!string.IsNullOrEmpty(method))
            {
                parm = new UserParm(context);
                foreach (MethodInfo mi in this.GetType().GetMethods())
                {
                    if (mi.Name.ToLower() == method.ToLower())
                    {
                        mi.Invoke(this, null);
                        break;
                    }
                }
            }
        }
示例#3
0
        public async Task <ApiResult> GetPageList(UserParm parm)
        {
            ApiResult ret = new ApiResult();

            try
            {
                //parm.UserID = _userID;
                //parm.UserID = 40;
                var data = await _repo.GetPageList(parm);

                ret.code = Code.Success;
                ret.data = data;
            }
            catch (Exception ex)
            {
                ret.code = Code.Failure;
                ret.msg  = ex.Message;
            }

            return(ret);
        }
示例#4
0
        public async Task <UserPageView> GetPageList(UserParm parm)
        {
            return(await WithConnection(async c =>
            {
                StringBuilder sql = new StringBuilder();
                sql.Append($@"  SELECT 
                a.id,
                a.acc_name,
                a.password,
                a.random_num,
                a.user_name,
                a.job_number,
                a.role_id,
                a.age,
                a.nation,
                a.nativeplace,
                a.edu,
                a.job_title,
                a.position,
                a.id_card,
                a.birth,
                a.sex,
                a.mobile,
                a.mobile_short,
                a.email,
                a.address,
                a.id_photo,
                a.out_man,
                a.created_time,
                a.created_by,
                a.updated_time,
                a.updated_by,
                a.is_del,
                a.is_super,
                b.`user_name` AS created_name,
                c.`user_name` AS updated_name
                 FROM USER a 
                LEFT JOIN USER b  ON a.`created_by` = b.id
                LEFT JOIN USER c ON a.`updated_by`= c.id
                 ");

                sql.Append(" WHERE a.is_del = 0 ");

                if (!string.IsNullOrEmpty(parm.UserName))
                {
                    sql.Append(" and a.user_name like '%" + parm.UserName.Trim() + "%' ");
                }
                if (!string.IsNullOrEmpty(parm.JobNumber))
                {
                    sql.Append(" and a.job_number like '%" + parm.JobNumber.Trim() + "%' ");
                }
                var data = await c.QueryAsync <User>(sql.ToString());
                var total = data.ToList().Count;

                sql.Append(" order by a." + parm.sort + " " + parm.order)
                .Append(" limit " + (parm.page - 1) * parm.rows + "," + parm.rows);
                var ets = await c.QueryAsync <User>(sql.ToString());
                await GetRefList(ets.ToList());

                UserPageView ret = new UserPageView();
                ret.rows = ets.ToList();
                ret.total = total;
                return ret;
            }));
        }