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; /// /// 构造函数 /// /// /// public devBoxMigrateController(Idev_DevBoxMigrateService repository) { _repository = repository; } /// /// 创建业主盒子迁移记录 /// /// /// [HttpPost("CreateDevBoxMigrateAsync")] public async Task 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); } /// /// 通过盒子编号获取盒子迁移信息 /// /// /// [HttpGet("GetDevBoxMigrateByCodeAsync/{id}")] [AllowAnonymous] public async Task 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>(new List(dev)); } catch (Exception ex) { return new ApiResult(ReturnCode.GeneralError, ex.Message); } } } }