コード例 #1
0
ファイル: LeavingMsgTest.cs プロジェクト: huxuanchenxy/nsda
 public void List()
 {
     LeavingMsgQueryRequest request = new LeavingMsgQueryRequest {
         PageIndex = 1,
         PageSize  = 10
     };
     var list = service.List(request);
 }
コード例 #2
0
        public ContentResult listleavingmsg(LeavingMsgQueryRequest request)
        {
            var data = _leavingMsgService.List(request);
            var res  = new ResultDto <LeavingMsgResponse>
            {
                page    = request.PageIndex,
                total   = request.Total,
                records = request.Records,
                rows    = data
            };

            return(Content(res.Serialize()));
        }
コード例 #3
0
        //1.3 留言列表
        public List <LeavingMsgResponse> List(LeavingMsgQueryRequest request)
        {
            List <LeavingMsgResponse> list = new List <LeavingMsgResponse>();

            try
            {
                StringBuilder join = new StringBuilder();
                if (request.Name.IsNotEmpty())
                {
                    request.Name = $"%{request.Name}%";
                    join.Append(" and name like @Name");
                }
                if (request.Mobile.IsNotEmpty())
                {
                    request.Mobile = $"%{request.Mobile}%";
                    join.Append(" and mobile like @Mobile");
                }
                if (request.Email.IsNotEmpty())
                {
                    request.Email = $"%{request.Email}%";
                    join.Append(" and email like @Email");
                }
                if (request.CreateStart.HasValue)
                {
                    join.Append(" and createtime >= @CreateStart");
                }
                if (request.CreateEnd.HasValue)
                {
                    request.CreateEnd = request.CreateEnd.Value.AddDays(1).AddSeconds(-1);
                    join.Append("  and createtime<=@CreateEnd");
                }
                var sql        = $"select * from t_sys_leavingmsg where isdelete=0 {join.ToString()} order by createtime desc";
                int totalCount = 0;
                list            = _dbContext.Page <LeavingMsgResponse>(sql, out totalCount, request.PageIndex, request.PageSize, request);
                request.Records = totalCount;
            }
            catch (Exception ex)
            {
                LogUtils.LogError("LeavingMsgService.List", ex);
            }
            return(list);
        }