devBoxMigrateController.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.Extensions.Logging;
  4. using Ropin.Inspection.Api.Common;
  5. using Ropin.Inspection.Model;
  6. using Ropin.Inspection.Service.DEV.Interface;
  7. using System.Collections.Generic;
  8. using System.Threading.Tasks;
  9. using System;
  10. using Ropin.Inspection.Model.ViewModel.DEV;
  11. using System.Linq;
  12. namespace Ropin.Inspection.Api.Controllers.DEV
  13. {
  14. public class devBoxMigrateController : BaseController
  15. {
  16. private readonly Idev_DevBoxMigrateService _repository;
  17. /// <summary>
  18. /// 构造函数
  19. /// </summary>
  20. /// <param name="logger"></param>
  21. /// <param name="repository"></param>
  22. public devBoxMigrateController(Idev_DevBoxMigrateService repository)
  23. {
  24. _repository = repository;
  25. }
  26. /// <summary>
  27. /// 创建业主盒子迁移记录
  28. /// </summary>
  29. /// <param name="content"></param>
  30. /// <returns></returns>
  31. [HttpPost("CreateDevBoxMigrateAsync")]
  32. public async Task<ApiResult> CreateDevBoxMigrateAsync(dev_DevBoxMigrateModel content)
  33. {
  34. if (content == null)
  35. {
  36. return new ApiResult(ReturnCode.ArgsError);
  37. }
  38. try
  39. {
  40. await _repository.CreateOneAsync(content);
  41. }
  42. catch (Exception ex)
  43. {
  44. return new ApiResult(ReturnCode.GeneralError, ex.Message);
  45. }
  46. return new ApiResult(ReturnCode.Success);
  47. }
  48. /// <summary>
  49. /// 通过盒子编号获取盒子迁移信息
  50. /// </summary>
  51. /// <param name="id"></param>
  52. /// <returns></returns>
  53. [HttpGet("GetDevBoxMigrateByCodeAsync/{id}")]
  54. [AllowAnonymous]
  55. public async Task<ApiResult> GetDevBoxMigrateByCodeAsync(string id)
  56. {
  57. if (string.IsNullOrEmpty(id))
  58. {
  59. return new ApiResult(ReturnCode.GeneralError);
  60. }
  61. try
  62. {
  63. var content = await _repository.GetConditionAsync(new dev_DevBoxMigrateSearchModel { C_DevBoxCode = id });
  64. var dev = content.ToList();
  65. return new ApiResult<IEnumerable<dev_DevBoxMigrateModel>>(new List<dev_DevBoxMigrateModel>(dev));
  66. }
  67. catch (Exception ex)
  68. {
  69. return new ApiResult(ReturnCode.GeneralError, ex.Message);
  70. }
  71. }
  72. }
  73. }