123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using YiSha.Business.OrganizationManage;
- using YiSha.Entity.OrganizationManage;
- using YiSha.IBusiness.OrganizationManage;
- using YiSha.Model.Param;
- using YiSha.Model.Param.OrganizationManage;
- using YiSha.Util.Model;
- namespace YiSha.Admin.WebApi.Controllers
- {
- [Route("[controller]/[action]")]
- [ApiController]
- [AuthorizeFilter]
- public class NewsController : ControllerBase
- {
- private INewsBLL _newsBLL;
- public NewsController(INewsBLL newsBLL)
- {
- _newsBLL = newsBLL;
- }
- #region 获取数据
- /// <summary>
- /// 获取文章列表
- /// </summary>
- /// <param name="param"></param>
- /// <param name="pagination"></param>
- /// <returns></returns>
- [HttpGet]
- public async Task<TData<List<NewsEntity>>> GetPageList([FromQuery] NewsListParam param, [FromQuery] Pagination pagination)
- {
- TData<List<NewsEntity>> obj = await _newsBLL.GetPageListPartial(param, pagination);
- return obj;
- }
- /// <summary>
- /// 获取文章列表
- /// </summary>
- /// <param name="param"></param>
- /// <param name="pagination"></param>
- /// <returns></returns>
- [HttpGet]
- public async Task<TData<List<NewsEntity>>> GetPageContentList([FromQuery] NewsListParam param, [FromQuery] Pagination pagination)
- {
- TData<List<NewsEntity>> obj = await _newsBLL.GetPageContentListPartial(param, pagination);
- return obj;
- }
- /// <summary>
- /// 获取文章内容
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet]
- public async Task<TData<NewsEntity>> GetForm([FromQuery] int id)
- {
- TData<NewsEntity> obj = await _newsBLL.GetEntityPartial(id);
- return obj;
- }
- #endregion
- #region 提交数据
- /// <summary>
- /// 保存文章
- /// </summary>
- /// <param name="entity"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<TData<int>> SaveForm([FromBody] NewsEntity entity)
- {
- TData<int> obj = await _newsBLL.SaveFormPartial(entity);
- return obj;
- }
- [HttpPost]
- public async Task<TData<int>> SaveViewTimes([FromBody] IdParam param)
- {
- TData<int> obj = null;
- TData<NewsEntity> objNews = await _newsBLL.GetEntityPartial(param.Id);
- NewsEntity newsEntity = new NewsEntity();
- if (objNews.Data != null)
- {
- newsEntity.Id = param.Id;
- newsEntity.ViewTimes = objNews.Data.ViewTimes;
- newsEntity.ViewTimes++;
- obj = await _newsBLL.SaveFormPartial(newsEntity);
- }
- else
- {
- obj = new TData<int>();
- obj.Message = "文章不存在";
- }
- return obj;
- }
- #endregion
- }
- }
|