/***********************************************************************
* Project: CoreCms
* ProjectName: 百分兵法管理系统
* Web: hhtp://chuanyin.com
* Author:
* Email:
* CreateTime: 202403/02
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Auth.HttpContextUser;
using CoreCms.Net.Configuration;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.UI;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
namespace CoreCms.Net.Web.WebApi.Controllers
{
///
/// 公告控制器
///
[Route("api/[controller]/[action]")]
[ApiController]
public class NoticeController : ControllerBase
{
private IHttpContextUser _user;
private ICoreCmsNoticeServices _noticeServices;
///
/// 构造函数
///
///
///
public NoticeController(IHttpContextUser user, ICoreCmsNoticeServices noticeServices)
{
_user = user;
_noticeServices = noticeServices;
}
#region 列表
///
/// 列表
///
///
[HttpPost]
public async Task NoticeList([FromBody] FMPageByIntId entity)
{
var jm = new WebApiCallBack();
var list = await _noticeServices.QueryPageAsync(p => p.isDel == false, p => p.createTime, OrderByType.Desc, entity.page, entity.limit);
jm.status = true;
jm.data = list;
return jm;
}
#endregion
///
/// 获取单个公告内容
///
///
///
[HttpPost]
public async Task NoticeInfo([FromBody] FMIntId entity)
{
var jm = new WebApiCallBack();
var model = await _noticeServices.QueryByIdAsync(entity.id);
if (model == null)
{
jm.msg = "数据获取失败";
return jm;
}
jm.status = true;
jm.data = model;
return jm;
}
}
}