1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Model.ViewModel;
- using Ropin.Inspection.Service.Interface;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Api.Controllers
- {
- public class TispContentGroupItemController : BaseController
- {
- public ILogger<TispContentGroupItemController> _logger { get; }
- private readonly ITispContentGroupItemService _service;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="service"></param>
- /// <param name="logger"></param>
- public TispContentGroupItemController(ITispContentGroupItemService service, ILogger<TispContentGroupItemController> logger)
- {
- _service = service;
- _logger = logger;
- }
- /// <summary>
- /// 根据分组Id取内容列表
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("GetContentGroupItemByGroupIdAsync/{id}")]
- public async Task<ApiResult> GetContentGroupItemByGroupIdAsync(Guid id)
- {
- try
- {
- var list = await _service.GetContentGroupItemByGroupIdAsync(id);
- return new ApiResult<IEnumerable<TispContentGroupItemViewModel>>(list);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 给内容分组
- /// </summary>
- /// <param name="items"></param>
- /// <returns></returns>
- [Route("CreateContentGroupItemsAsync")]
- [HttpPost]
- public async Task<ApiResult> CreateContentGroupItemsAsync(IEnumerable<TispContentGroupItemCreateViewModel> items)
- {
- if (items == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- await _service.CreateContentGroupItemsAsync(items);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- }
- }
|