123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Api.Controllers;
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Service;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Api
- {
- public class TdevBoxTemplateController : BaseController
- {
- public ILogger<TdevBoxTemplateController> _logger { get; }
- private readonly ITdevBoxTemplateService _TdevBoxTemplateService;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="TdevBoxTemplateService"></param>
- /// <param name="logger"></param>
- public TdevBoxTemplateController(ITdevBoxTemplateService TdevBoxTemplateService, ILogger<TdevBoxTemplateController> logger)
- {
- _TdevBoxTemplateService = TdevBoxTemplateService;
- _logger = logger;
- }
-
- /// <summary>
- /// 创建盒子模板信息
- /// </summary>
- /// <param name="content"></param>
- /// <returns></returns>
- [HttpPost("CreateBoxTemplateAsync")]
- public async Task<ApiResult> CreateBoxTemplateAsync(TdevBoxTemplateViewModel content)
- {
- if (content == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- await _TdevBoxTemplateService.CreateOneAsync(content);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 删除盒子模板信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpDelete("DeleteBoxTemplateAsync/{id}")]
- public async Task<ApiResult> DeleteBoxTemplateAsync(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TdevBoxTemplateService.DeleteAsync(id);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 更新盒子模板信息
- /// </summary>
- /// <param name="id"></param>
- /// <param name="updateModel"></param>
- /// <returns></returns>
- [HttpPut("UpdateBoxTemplateAsync/{id}")]
- [AllowAnonymous]
- public async Task<ApiResult> UpdateBoxTemplateAsync(string id, TdevBoxTemplateUpdateModel updateModel)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TdevBoxTemplateService.UpdateAsync(id, updateModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 通过id获取盒子模板信息
- /// </summary>
- /// <returns></returns>
- [HttpPost("GetBoxTemplateAsync")]
- [AllowAnonymous]
- public async Task<ApiResult> GetBoxTemplateAsync(TdevBoxTemplateSearchModel searchModel)
- {
- if (searchModel == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- var contentList = await _TdevBoxTemplateService.GetConditionAsync(searchModel);
- return new ApiResult<PagesModel<TdevBoxTemplateViewModel>>(new PagesModel<TdevBoxTemplateViewModel>(contentList, searchModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- //[HttpGet("GetBoxTemplateByCodeAsync/{id}")]
- //[AllowAnonymous]
- //public async Task<ApiResult> GetBoxTemplateByCodeAsync(string id)
- //{
- // if (string.IsNullOrEmpty(id))
- // {
- // return new ApiResult(ReturnCode.GeneralError);
- // }
- // try
- // {
- // var content = await _TdevBoxTemplateService.GetConditionAsync(new TdevBoxTemplateSearchModel { C_Name = id });
- // var dev = content.ToList();
- // return new ApiResult<IEnumerable<TdevBoxTemplateViewModel>>(new List<TdevBoxTemplateViewModel>(dev));
- // }
- // catch (Exception ex)
- // {
- // return new ApiResult(ReturnCode.GeneralError, ex.Message);
- // }
- //}
- }
- }
|