LR-20210131IOQH\Administrator
2021-08-10 d4a6d65f5e449c3e5464aa18ae97bf8953987217
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
using DTO;
using IServices;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using zhengcaioa.Models;
 
namespace Services
{
    public class DtChannelArticleNewsService: IDtChannelArticleNewsService
    {
        private readonly zcwebContext _context;
        private readonly IMapper _mapper;
        public DtChannelArticleNewsService(zcwebContext context, IMapper mapper)
        {
            _context = context;
            _mapper = mapper;
        }
 
 
        public List<DtChannelArticleNewsDTO> GetList(DtChannelArticleNewsDTOSearch searchEntity)
        {
 
            var entity = (from a in _context.DtChannelArticleNews.Where(x => x.Status == 0)
                          join b in _context.DtArticleCategories on a.CategoryId equals b.Id
 
 
                          where a.Status == 0
                              && (string.IsNullOrWhiteSpace(searchEntity.UserName) || a.UserName == searchEntity.UserName.Trim())
                                 && ( !searchEntity.AddTime.HasValue || a.AddTime >= searchEntity.AddTime.Value.Date )
                                  && (!searchEntity.EndTime.HasValue || a.AddTime < searchEntity.EndTime.Value.Date )
                                 
                                  && (searchEntity.CategoryId <= 0 || b.ParentId == searchEntity.CategoryId )
                          select a
                          ).ToList();
 
 
            var result = _mapper.Map<List<DtChannelArticleNewsDTO>>(entity);
 
 
            return result;
        }
    }
}