Files
coreshoppro/CoreCms.Net.Web.WebApi/Controllers/ArticleController.cs
JianWeie c341aeb8c8 ### 0.3.3 专业版:
【新增】后台新增支付单查询功能,实现支付单微信反馈支付数据,防止出现极端情况下,导致的支付数据回调失败而影响订单业务。#I4ZRMR
【新增】后台新增发票上传功能,前端小程序新增发票下载功能。#I4ZYT3
【新增】商家中心订单查询,增加发票下载查看功能。
【新增】代码生成器Controller模板的导出excel请求增加decimal类型的处理。
【优化】调整前端帮助文档默认传值问题,未指定具体分类情况下,默认取第一个栏目数据。
【修复】修复页面设计上传图片后不进行预览的问题。
2022-03-29 17:07:26 +08:00

144 lines
4.5 KiB
C#

/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Auth.HttpContextUser;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.Entities.Expression;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.UI;
using Essensoft.Paylink.Alipay.Domain;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
namespace CoreCms.Net.Web.WebApi.Controllers
{
/// <summary>
/// 文章api控制器
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class ArticleController : ControllerBase
{
private IHttpContextUser _user;
private readonly ICoreCmsArticleServices _articleServices;
private readonly ICoreCmsArticleTypeServices _articleTypeServices;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="user"></param>
/// <param name="articleServices"></param>
/// <param name="articleTypeServices"></param>
public ArticleController(IHttpContextUser user, ICoreCmsArticleServices articleServices, ICoreCmsArticleTypeServices articleTypeServices)
{
_user = user;
_articleServices = articleServices;
_articleTypeServices = articleTypeServices;
}
#region
/// <summary>
/// 获取通知列表
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<WebApiCallBack> NoticeList([FromBody] FMPageByIntId entity)
{
var jm = new WebApiCallBack();
var list = await _articleServices.QueryPageAsync(p => p.isDel == false, p => p.createTime, OrderByType.Desc,
entity.page, entity.limit);
jm.status = true;
jm.data = list;
return jm;
}
#endregion
#region
/// <summary>
/// 获取文章列表
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<WebApiCallBack> GetArticleList([FromBody] FMPageByIntId entity)
{
var jm = new WebApiCallBack();
var articleType = await _articleTypeServices.QueryAsync();
if (articleType.Any())
{
var where = PredicateBuilder.True<Model.Entities.CoreCmsArticle>();
if (entity.id > 0)
{
where = where.And(p => p.isDel == false && p.typeId == entity.id);
}
else
{
var typeId = articleType.FirstOrDefault()!.id;
where = where.And(p => p.isDel == false && p.typeId == typeId);
}
var list = await _articleServices.QueryPageAsync(where, p => p.createTime, OrderByType.Desc, entity.page, entity.limit);
jm.data = new
{
list,
articleType,
count = list.TotalCount
};
}
else
{
jm.data = new
{
list = new List<CoreCmsArticle>(),
articleType,
count = 0
};
}
jm.status = true;
return jm;
}
#endregion
/// <summary>
/// 获取单个文章内容
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
public async Task<WebApiCallBack> GetArticleDetail([FromBody] FMIntId entity)
{
var jm = new WebApiCallBack();
var model = await _articleServices.ArticleDetail(entity.id);
if (model == null)
{
jm.msg = "数据获取失败";
return jm;
}
jm.status = true;
jm.data = model;
return jm;
}
}
}