Esempio n. 1
0
        public ContentResult list(VoteQueryRequest request)
        {
            var data = _voteService.List(request);
            var res  = new ResultDto <VoteResponse>
            {
                page    = request.PageIndex,
                total   = request.Total,
                records = request.Records,
                rows    = data
            };

            return(Content(res.Serialize()));
        }
Esempio n. 2
0
        //分页查询辩题
        public List <VoteResponse> List(VoteQueryRequest request)
        {
            List <VoteResponse> list = new List <VoteResponse>();

            try
            {
                StringBuilder join = new StringBuilder();
                if (request.Title.IsNotEmpty())
                {
                    request.Title = $"%{request.Title}%";
                    join.Append(" and title like @Title");
                }
                if (request.Remark.IsNotEmpty())
                {
                    request.Remark = $"%{request.Remark}%";
                    join.Append(" and remark like @Remark");
                }
                if (request.VoteStartTime1.HasValue)
                {
                    join.Append(" and voteStartTime >= @VoteStartTime1");
                }
                if (request.VoteStartTime2.HasValue)
                {
                    request.VoteStartTime2 = request.VoteStartTime2.Value.AddDays(1).AddSeconds(-1);
                    join.Append("  and voteStartTime<=@VoteStartTime2");
                }
                if (request.VoteEndTime1.HasValue)
                {
                    join.Append(" and voteEndTime >= @VoteEndTime1");
                }
                if (request.VoteStartTime2.HasValue)
                {
                    request.VoteEndTime1 = request.VoteEndTime1.Value.AddDays(1).AddSeconds(-1);
                    join.Append("  and voteEndTime<=@VoteEndTime2");
                }
                var sql        = $@"select * from t_sys_vote where isdelete=0 {join.ToString()} order by createtime";
                int totalCount = 0;
                list            = _dbContext.Page <VoteResponse>(sql, out totalCount, request.PageIndex, request.PageSize, request);
                request.Records = totalCount;
            }
            catch (Exception ex)
            {
                LogUtils.LogError("VoteService.List", ex);
            }

            return(list);
        }