using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Ropin.Inspection.Api.Common; using Ropin.Inspection.Model; using Ropin.Inspection.Service.DEV.Interface; using System.Collections.Generic; using System.Threading.Tasks; using System; using Ropin.Inspection.Model.ViewModel.DEV; using System.Linq; namespace Ropin.Inspection.Api.Controllers.DEV { public class devBoxMigrateController : BaseController { private readonly Idev_DevBoxMigrateService _repository; /// <summary> /// 构造函数 /// </summary> /// <param name="logger"></param> /// <param name="repository"></param> public devBoxMigrateController(Idev_DevBoxMigrateService repository) { _repository = repository; } /// <summary> /// 创建业主盒子迁移记录 /// </summary> /// <param name="content"></param> /// <returns></returns> [HttpPost("CreateDevBoxMigrateAsync")] public async Task<ApiResult> CreateDevBoxMigrateAsync(dev_DevBoxMigrateModel 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> [HttpGet("GetDevBoxMigrateByCodeAsync/{id}")] [AllowAnonymous] public async Task<ApiResult> GetDevBoxMigrateByCodeAsync(string id) { if (string.IsNullOrEmpty(id)) { return new ApiResult(ReturnCode.GeneralError); } try { var content = await _repository.GetConditionAsync(new dev_DevBoxMigrateSearchModel { C_DevBoxCode = id }); var dev = content.ToList(); return new ApiResult<IEnumerable<dev_DevBoxMigrateModel>>(new List<dev_DevBoxMigrateModel>(dev)); } catch (Exception ex) { return new ApiResult(ReturnCode.GeneralError, ex.Message); } } } }