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 _logger { get; } private readonly ITispContentGroupItemService _service; /// /// 构造函数 /// /// /// public TispContentGroupItemController(ITispContentGroupItemService service, ILogger logger) { _service = service; _logger = logger; } /// /// 根据分组Id取内容列表 /// /// /// [HttpGet("GetContentGroupItemByGroupIdAsync/{id}")] public async Task GetContentGroupItemByGroupIdAsync(Guid id) { try { var list = await _service.GetContentGroupItemByGroupIdAsync(id); return new ApiResult>(list); } catch (Exception ex) { return new ApiResult(ReturnCode.GeneralError, ex.Message); } } /// /// 给内容分组 /// /// /// [Route("CreateContentGroupItemsAsync")] [HttpPost] public async Task CreateContentGroupItemsAsync(IEnumerable 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); } } }