From 2e729a12ce48cbec4a47a63e49674982f8b6be7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=93=E5=A4=A7=E5=B8=88?= <156663459@qq.com> Date: Sun, 31 Jan 2021 16:05:23 +0800 Subject: [PATCH] =?UTF-8?q?--=E6=96=B0=E5=A2=9E=E6=96=B0=E9=97=BB=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3--?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Front/NewsInfoController.cs | 103 ++++++++++++++++++ New_College.Api/New_College.Model.xml | 35 ++++++ New_College.Api/New_College.xml | 14 +++ .../ID_NewsCategoryServices.cs | 12 ++ New_College.IServices/ID_NewsInfoServices.cs | 12 ++ New_College.Model/Models/D_NewsCategory.cs | 12 ++ New_College.Model/Models/D_NewsInfo.cs | 34 ++++++ New_College.Model/Models/V_CustomerInfo.cs | 7 ++ .../Request/NewsDetailRequest.cs | 11 ++ New_College.Model/Request/NewsRequest.cs | 14 +++ .../ViewModels/Result/CustomerInfoResult.cs | 2 + .../ViewModels/Result/NewsInfoResponse.cs | 44 ++++++++ .../BASE/D_NewsCategoryRepository.cs | 17 +++ .../BASE/D_NewsInfoRepository.cs | 17 +++ .../BASE/ID_NewsCategoryRepository.cs | 12 ++ .../BASE/ID_NewsInfoRepository.cs | 12 ++ .../D_NewsCategoryServices.cs | 18 +++ New_College.Services/D_NewsInfoServices.cs | 18 +++ .../V_CustomerInfoServices.cs | 5 + 19 files changed, 399 insertions(+) create mode 100644 New_College.Api/Controllers/Front/NewsInfoController.cs create mode 100644 New_College.IServices/ID_NewsCategoryServices.cs create mode 100644 New_College.IServices/ID_NewsInfoServices.cs create mode 100644 New_College.Model/Models/D_NewsCategory.cs create mode 100644 New_College.Model/Models/D_NewsInfo.cs create mode 100644 New_College.Model/Request/NewsDetailRequest.cs create mode 100644 New_College.Model/Request/NewsRequest.cs create mode 100644 New_College.Model/ViewModels/Result/NewsInfoResponse.cs create mode 100644 New_College.Repository/BASE/D_NewsCategoryRepository.cs create mode 100644 New_College.Repository/BASE/D_NewsInfoRepository.cs create mode 100644 New_College.Repository/BASE/ID_NewsCategoryRepository.cs create mode 100644 New_College.Repository/BASE/ID_NewsInfoRepository.cs create mode 100644 New_College.Services/D_NewsCategoryServices.cs create mode 100644 New_College.Services/D_NewsInfoServices.cs diff --git a/New_College.Api/Controllers/Front/NewsInfoController.cs b/New_College.Api/Controllers/Front/NewsInfoController.cs new file mode 100644 index 0000000..57dcf69 --- /dev/null +++ b/New_College.Api/Controllers/Front/NewsInfoController.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using New_College.IServices; +using New_College.Model; +using New_College.Model.Request; +using New_College.Model.ViewModels; + +namespace New_College.Api.Controllers.Front +{ + [Route("api/front/[controller]/[action]")] + [ApiController] + public class NewsInfoController : ControllerBase + { + + private readonly ID_NewsCategoryServices iD_NewsCategory; + private readonly ID_NewsInfoServices d_NewsInfo; + public NewsInfoController(ID_NewsCategoryServices d_NewsCategoryServices, ID_NewsInfoServices d_NewsInfoServices) + { + this.iD_NewsCategory = d_NewsCategoryServices; + this.d_NewsInfo = d_NewsInfoServices; + } + + + + /// + /// 获取top多少的新闻 + /// + /// + /// + [HttpGet] + public async Task>> GetTopNews([FromQuery] NewsRequest request) + { + try + { + var list = new List(); + var query = (await d_NewsInfo.Query(e => e.IsDelete == false && e.CategoryId == request.CategoryId)).Take(request.Top).OrderByDescending(s => s.CreateTime); + list = query.Select(s => new NewsInfoResponse + { + CoverImg = s.CoverImg, + CreateTime = s.CreateTime.Value, + Id = s.Id, + Title = s.Title + }).ToList(); + return new MessageModel>() + { + msg = "success", + success = true, + response = list + }; + } + catch (Exception ex) + { + return new MessageModel>() + { + msg = ex.Message + + }; + } + } + + + /// + /// 根据Id 获取新闻详情 + /// + /// + /// + [HttpGet] + public async Task> GetDetail([FromQuery] NewsDetailRequest request) + { + try + { + var result = new NewsDetailInfoResponse(); + var single = await d_NewsInfo.QueryById(request.Id); + result.Author = single.Author; + result.Click = single.Click; + result.CoverImg = single.CoverImg; + result.CreateTime = single.CreateTime.Value; + result.Id = single.Id; + result.Summary = single.Summary; + result.Title = single.Title; + result.Detail = single.Detail; + return new MessageModel() + { + msg = "success", + response = result, + success = true + }; + } + catch (Exception ex) + { + return new MessageModel() + { + msg = ex.Message + }; + } + } + + } +} diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml index db410fb..3879a3c 100644 --- a/New_College.Api/New_College.Model.xml +++ b/New_College.Api/New_College.Model.xml @@ -435,6 +435,21 @@ 薪资 + + + + + + + + + + + + + + + 职业id @@ -2031,6 +2046,11 @@ 选科文字展示 + + + + + 考生预计分数 @@ -4294,6 +4314,21 @@ 本科还是专科 + + + + + + + + + + + + + + + 主键id diff --git a/New_College.Api/New_College.xml b/New_College.Api/New_College.xml index e0fa722..adedd83 100644 --- a/New_College.Api/New_College.xml +++ b/New_College.Api/New_College.xml @@ -311,6 +311,20 @@ + + + 获取top多少的新闻 + + + + + + + 根据Id 获取新闻详情 + + + + 下订单 diff --git a/New_College.IServices/ID_NewsCategoryServices.cs b/New_College.IServices/ID_NewsCategoryServices.cs new file mode 100644 index 0000000..fe2e9e5 --- /dev/null +++ b/New_College.IServices/ID_NewsCategoryServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_NewsCategoryServices + /// + public interface ID_NewsCategoryServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.IServices/ID_NewsInfoServices.cs b/New_College.IServices/ID_NewsInfoServices.cs new file mode 100644 index 0000000..c685580 --- /dev/null +++ b/New_College.IServices/ID_NewsInfoServices.cs @@ -0,0 +1,12 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; + +namespace New_College.IServices +{ + /// + /// ID_NewsInfoServices + /// + public interface ID_NewsInfoServices :IBaseServices + { + } +} \ No newline at end of file diff --git a/New_College.Model/Models/D_NewsCategory.cs b/New_College.Model/Models/D_NewsCategory.cs new file mode 100644 index 0000000..6be4993 --- /dev/null +++ b/New_College.Model/Models/D_NewsCategory.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_NewsCategory : EntityModel + { + public string CategoryName { get; set; } + + } +} diff --git a/New_College.Model/Models/D_NewsInfo.cs b/New_College.Model/Models/D_NewsInfo.cs new file mode 100644 index 0000000..83c6810 --- /dev/null +++ b/New_College.Model/Models/D_NewsInfo.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Models +{ + public class D_NewsInfo : RootEntity + { + + public int CategoryId { get; set; } + /// + /// + /// + public string Author { get; set; } + public string Title { get; set; } + + public string CoverImg { get; set; } + + /// + /// + /// + public string Summary { get; set; } + + + public string Detail { get; set; } + + /// + /// + /// + public int Click { get; set; } + + + } +} diff --git a/New_College.Model/Models/V_CustomerInfo.cs b/New_College.Model/Models/V_CustomerInfo.cs index a2a8f7a..846c137 100644 --- a/New_College.Model/Models/V_CustomerInfo.cs +++ b/New_College.Model/Models/V_CustomerInfo.cs @@ -105,6 +105,13 @@ namespace New_College.Model.Models [SugarColumn(IsNullable = true)] public string Subjectgroup { get; set; } + + /// + /// + /// + [SugarColumn(IsNullable = true)] + public string subjectgroupName { get; set; } + /// /// 考生预计分数 /// diff --git a/New_College.Model/Request/NewsDetailRequest.cs b/New_College.Model/Request/NewsDetailRequest.cs new file mode 100644 index 0000000..ae279bf --- /dev/null +++ b/New_College.Model/Request/NewsDetailRequest.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Request +{ + public class NewsDetailRequest + { + public int Id { get; set; } + } +} diff --git a/New_College.Model/Request/NewsRequest.cs b/New_College.Model/Request/NewsRequest.cs new file mode 100644 index 0000000..5163588 --- /dev/null +++ b/New_College.Model/Request/NewsRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.Request +{ + public class NewsRequest + { + public int Top { get; set; } = 5; + + public int CategoryId { get; set; } + + } +} diff --git a/New_College.Model/ViewModels/Result/CustomerInfoResult.cs b/New_College.Model/ViewModels/Result/CustomerInfoResult.cs index b797c14..c3802b2 100644 --- a/New_College.Model/ViewModels/Result/CustomerInfoResult.cs +++ b/New_College.Model/ViewModels/Result/CustomerInfoResult.cs @@ -65,6 +65,8 @@ namespace New_College.Model.ViewModels /// public double? Expectedscore { get; set; } = 0; + public string subjectgroupName { get; set; } + /// /// 是否为VIP /// diff --git a/New_College.Model/ViewModels/Result/NewsInfoResponse.cs b/New_College.Model/ViewModels/Result/NewsInfoResponse.cs new file mode 100644 index 0000000..573fb80 --- /dev/null +++ b/New_College.Model/ViewModels/Result/NewsInfoResponse.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace New_College.Model.ViewModels +{ + + public class NewsInfoResponse + { + public int Id { get; set; } + + public string Title { get; set; } + + public string CoverImg { get; set; } + + public DateTime CreateTime { get; set; } + + } + + + public class NewsDetailInfoResponse + { + + public int Id { get; set; } + /// + /// + /// + public string Author { get; set; } + public string Title { get; set; } + public string CoverImg { get; set; } + /// + /// + /// + public string Summary { get; set; } + public string Detail { get; set; } + /// + /// + /// + public int Click { get; set; } + public DateTime CreateTime { get; set; } + } + + +} diff --git a/New_College.Repository/BASE/D_NewsCategoryRepository.cs b/New_College.Repository/BASE/D_NewsCategoryRepository.cs new file mode 100644 index 0000000..15ca741 --- /dev/null +++ b/New_College.Repository/BASE/D_NewsCategoryRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_NewsCategoryRepository + /// + public class D_NewsCategoryRepository : BaseRepository, ID_NewsCategoryRepository + { + public D_NewsCategoryRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/D_NewsInfoRepository.cs b/New_College.Repository/BASE/D_NewsInfoRepository.cs new file mode 100644 index 0000000..0b67237 --- /dev/null +++ b/New_College.Repository/BASE/D_NewsInfoRepository.cs @@ -0,0 +1,17 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Repository.Base; + +namespace New_College.Repository +{ + /// + /// D_NewsInfoRepository + /// + public class D_NewsInfoRepository : BaseRepository, ID_NewsInfoRepository + { + public D_NewsInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_NewsCategoryRepository.cs b/New_College.Repository/BASE/ID_NewsCategoryRepository.cs new file mode 100644 index 0000000..9bbbbc4 --- /dev/null +++ b/New_College.Repository/BASE/ID_NewsCategoryRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_NewsCategoryRepository + /// + public interface ID_NewsCategoryRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_NewsInfoRepository.cs b/New_College.Repository/BASE/ID_NewsInfoRepository.cs new file mode 100644 index 0000000..fecd17d --- /dev/null +++ b/New_College.Repository/BASE/ID_NewsInfoRepository.cs @@ -0,0 +1,12 @@ +using New_College.IRepository.Base; +using New_College.Model.Models; + +namespace New_College.IRepository +{ + /// + /// ID_NewsInfoRepository + /// + public interface ID_NewsInfoRepository : IBaseRepository + { + } +} \ No newline at end of file diff --git a/New_College.Services/D_NewsCategoryServices.cs b/New_College.Services/D_NewsCategoryServices.cs new file mode 100644 index 0000000..b671a93 --- /dev/null +++ b/New_College.Services/D_NewsCategoryServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_NewsCategoryServices : BaseServices, ID_NewsCategoryServices + { + private readonly IBaseRepository _dal; + public D_NewsCategoryServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/D_NewsInfoServices.cs b/New_College.Services/D_NewsInfoServices.cs new file mode 100644 index 0000000..12e623b --- /dev/null +++ b/New_College.Services/D_NewsInfoServices.cs @@ -0,0 +1,18 @@ + +using New_College.IServices; +using New_College.Model.Models; +using New_College.Services.BASE; +using New_College.IRepository.Base; + +namespace New_College.Services +{ + public class D_NewsInfoServices : BaseServices, ID_NewsInfoServices + { + private readonly IBaseRepository _dal; + public D_NewsInfoServices(IBaseRepository dal) + { + this._dal = dal; + base.BaseDal = dal; + } + } +} \ No newline at end of file diff --git a/New_College.Services/V_CustomerInfoServices.cs b/New_College.Services/V_CustomerInfoServices.cs index cdd217e..7306099 100644 --- a/New_College.Services/V_CustomerInfoServices.cs +++ b/New_College.Services/V_CustomerInfoServices.cs @@ -63,6 +63,7 @@ namespace New_College.Services IsVIP = info.IsVIP, Subject = info.Subject, Subjectgroup = info.Subjectgroup, + subjectgroupName = info.subjectgroupName, VipCode = info.VipCode, IsUpdateScore = info.IsUpdateScore, Year = info.Year @@ -104,6 +105,7 @@ namespace New_College.Services IsVIP = info.IsVIP, Subject = info.Subject, Subjectgroup = info.Subjectgroup, + subjectgroupName = info.subjectgroupName, VipCode = info.VipCode, IsUpdateScore = info.IsUpdateScore, Year = info.Year @@ -152,6 +154,7 @@ namespace New_College.Services IsVIP = info.IsVIP, Subject = info.Subject, Subjectgroup = info.Subjectgroup, + subjectgroupName = info.subjectgroupName, VipCode = info.VipCode, IsUpdateScore = info.IsUpdateScore, CustomerType = info.CustomerType, @@ -295,6 +298,7 @@ namespace New_College.Services IsVIP = userinfo.IsVIP, Subject = userinfo.Subject, Subjectgroup = userinfo.Subjectgroup, + subjectgroupName = userinfo.subjectgroupName, ClassName = userinfo.ClassName, SchoolName = userinfo.SchoolName, Year = userinfo.Year, @@ -328,6 +332,7 @@ namespace New_College.Services IsVIP = userinfo.IsVIP, Subject = userinfo.Subject, Subjectgroup = userinfo.Subjectgroup, + subjectgroupName = userinfo.subjectgroupName, Year = userinfo.Year }); }