--新增新闻接口--
parent
a4738c3c7a
commit
2e729a12ce
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取top多少的新闻
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<MessageModel<List<NewsInfoResponse>>> GetTopNews([FromQuery] NewsRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = new List<NewsInfoResponse>();
|
||||
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<List<NewsInfoResponse>>()
|
||||
{
|
||||
msg = "success",
|
||||
success = true,
|
||||
response = list
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new MessageModel<List<NewsInfoResponse>>()
|
||||
{
|
||||
msg = ex.Message
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id 获取新闻详情
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<MessageModel<NewsDetailInfoResponse>> 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<NewsDetailInfoResponse>()
|
||||
{
|
||||
msg = "success",
|
||||
response = result,
|
||||
success = true
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new MessageModel<NewsDetailInfoResponse>()
|
||||
{
|
||||
msg = ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -435,6 +435,21 @@
|
|||
薪资
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.Models.D_NewsInfo.Author">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.Models.D_NewsInfo.Summary">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.Models.D_NewsInfo.Click">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.Models.D_OccMapTag.OccId">
|
||||
<summary>
|
||||
职业id
|
||||
|
|
@ -2031,6 +2046,11 @@
|
|||
选科文字展示
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.Models.V_CustomerInfo.subjectgroupName">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.Models.V_CustomerInfo.Expectedscore">
|
||||
<summary>
|
||||
考生预计分数
|
||||
|
|
@ -4294,6 +4314,21 @@
|
|||
本科还是专科
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.NewsDetailInfoResponse.Author">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.NewsDetailInfoResponse.Summary">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.NewsDetailInfoResponse.Click">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:New_College.Model.ViewModels.OccupationResult.Id">
|
||||
<summary>
|
||||
主键id
|
||||
|
|
|
|||
|
|
@ -311,6 +311,20 @@
|
|||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:New_College.Api.Controllers.Front.NewsInfoController.GetTopNews(New_College.Model.Request.NewsRequest)">
|
||||
<summary>
|
||||
获取top多少的新闻
|
||||
</summary>
|
||||
<param name="request"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:New_College.Api.Controllers.Front.NewsInfoController.GetDetail(New_College.Model.Request.NewsDetailRequest)">
|
||||
<summary>
|
||||
根据Id 获取新闻详情
|
||||
</summary>
|
||||
<param name="request"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:New_College.Api.Controllers.Front.OrderController.CreateOrder(New_College.Model.ViewModels.UniOrderQuery)">
|
||||
<summary>
|
||||
下订单
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
using New_College.IServices.BASE;
|
||||
using New_College.Model.Models;
|
||||
|
||||
namespace New_College.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// ID_NewsCategoryServices
|
||||
/// </summary>
|
||||
public interface ID_NewsCategoryServices :IBaseServices<D_NewsCategory>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using New_College.IServices.BASE;
|
||||
using New_College.Model.Models;
|
||||
|
||||
namespace New_College.IServices
|
||||
{
|
||||
/// <summary>
|
||||
/// ID_NewsInfoServices
|
||||
/// </summary>
|
||||
public interface ID_NewsInfoServices :IBaseServices<D_NewsInfo>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Author { get; set; }
|
||||
public string Title { get; set; }
|
||||
|
||||
public string CoverImg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Summary { get; set; }
|
||||
|
||||
|
||||
public string Detail { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Click { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -105,6 +105,13 @@ namespace New_College.Model.Models
|
|||
[SugarColumn(IsNullable = true)]
|
||||
public string Subjectgroup { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string subjectgroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 考生预计分数
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,8 @@ namespace New_College.Model.ViewModels
|
|||
/// </summary>
|
||||
public double? Expectedscore { get; set; } = 0;
|
||||
|
||||
public string subjectgroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为VIP
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Author { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string CoverImg { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Summary { get; set; }
|
||||
public string Detail { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Click { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// D_NewsCategoryRepository
|
||||
/// </summary>
|
||||
public class D_NewsCategoryRepository : BaseRepository<D_NewsCategory>, ID_NewsCategoryRepository
|
||||
{
|
||||
public D_NewsCategoryRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// D_NewsInfoRepository
|
||||
/// </summary>
|
||||
public class D_NewsInfoRepository : BaseRepository<D_NewsInfo>, ID_NewsInfoRepository
|
||||
{
|
||||
public D_NewsInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using New_College.IRepository.Base;
|
||||
using New_College.Model.Models;
|
||||
|
||||
namespace New_College.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// ID_NewsCategoryRepository
|
||||
/// </summary>
|
||||
public interface ID_NewsCategoryRepository : IBaseRepository<D_NewsCategory>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using New_College.IRepository.Base;
|
||||
using New_College.Model.Models;
|
||||
|
||||
namespace New_College.IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// ID_NewsInfoRepository
|
||||
/// </summary>
|
||||
public interface ID_NewsInfoRepository : IBaseRepository<D_NewsInfo>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -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<D_NewsCategory>, ID_NewsCategoryServices
|
||||
{
|
||||
private readonly IBaseRepository<D_NewsCategory> _dal;
|
||||
public D_NewsCategoryServices(IBaseRepository<D_NewsCategory> dal)
|
||||
{
|
||||
this._dal = dal;
|
||||
base.BaseDal = dal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<D_NewsInfo>, ID_NewsInfoServices
|
||||
{
|
||||
private readonly IBaseRepository<D_NewsInfo> _dal;
|
||||
public D_NewsInfoServices(IBaseRepository<D_NewsInfo> dal)
|
||||
{
|
||||
this._dal = dal;
|
||||
base.BaseDal = dal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue