123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- using log4net;
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Api.Controllers.LGS;
- using Ropin.Inspection.Model.SearchModel.LGS;
- using Ropin.Inspection.Model.ViewModel.LGS;
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Service.LGS.Interface;
- using Ropin.Inspection.Service.VMC.Interface;
- using System.Threading.Tasks;
- using System;
- using Ropin.Inspection.Model.ViewModel.VMC;
- using Ropin.Inspection.Model.SearchModel.VMC;
- namespace Ropin.Inspection.Api.Controllers.VMC
- {
- public class VmcCameraTemplateController : BaseController
- {
- private readonly IVmcCameraTemplateService _repository;
- private static readonly ILog log = LogManager.GetLogger(typeof(VmcCameraTemplateController));
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="repository"></param>
- public VmcCameraTemplateController(IVmcCameraTemplateService repository)
- {
- _repository = repository;
- }
- /// <summary>
- /// 创建模板
- /// </summary>
- /// <param name="content"></param>
- /// <returns></returns>
- [HttpPost("CreateTemplateAsync")]
- public async Task<ApiResult> CreateTemplateAsync(VmcCameraTemplateViewModel content)
- {
- if (content == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- await _repository.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("DeleteTemplateAsync/{id}")]
- public async Task<ApiResult> DeleteTemplateAsync(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _repository.DeleteAsync(id);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 禁用模板
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpPut("ForbiddenTemplateAsync/{id}")]
- public async Task<ApiResult> ForbiddenTemplateAsync(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _repository.ForbiddenAsync(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("UpdateTemplateAsync/{id}")]
- [AllowAnonymous]
- public async Task<ApiResult> UpdateTemplateAsync(string id, VmcCameraTemplateViewModel updateModel)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _repository.UpdateAsync(updateModel, id);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 获取模板列表
- /// </summary>
- /// <returns></returns>
- [HttpPost("PageAsync")]
- [AllowAnonymous]
- public async Task<ApiResult> PageAsync(VmcCameraTemplateSearch searchModel)
- {
- if (searchModel == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- var contentList = await _repository.GetConditionAsync(searchModel);
- return new ApiResult<PagesModel<VmcCameraTemplateViewModel>>(new PagesModel<VmcCameraTemplateViewModel>(contentList, searchModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 通过id获取大模板详情
- /// </summary>
- /// <returns></returns>
- [HttpGet("DetailsAsync")]
- [AllowAnonymous]
- public async Task<ApiResult> DetailsAsync(string Id)
- {
- if (string.IsNullOrEmpty(Id))
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- VmcCameraTemplateViewModel data = await _repository.GetByIdAsync(Id);
- return new ApiResult<VmcCameraTemplateViewModel>(data);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- }
- }
|