123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- 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 Ropin.Inspection.Service.Interface;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Api
- {
- public class TdevBoxController : BaseController
- {
- public ILogger<TdevBoxController> _logger { get; }
- private readonly ITdevBoxService _TdevBoxService;
- private readonly ITdevBoxDevSpotService _TdevBoxDevSpotService;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="TdevBoxService"></param>
- /// <param name="logger"></param>
- public TdevBoxController(ITdevBoxService TdevBoxService, ILogger<TdevBoxController> logger, ITdevBoxDevSpotService TdevBoxDevSpotService)
- {
- _TdevBoxService = TdevBoxService;
- _logger = logger;
- _TdevBoxDevSpotService = TdevBoxDevSpotService;
- }
-
- /// <summary>
- /// 创建业主盒子信息
- /// </summary>
- /// <param name="content"></param>
- /// <returns></returns>
- [HttpPost("CreateBoxAsync")]
- public async Task<ApiResult> CreateBoxAsync(TdevBoxViewModel content)
- {
- if (content == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- await _TdevBoxService.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("DeleteBoxAsync/{id}")]
- public async Task<ApiResult> DeleteBoxAsync(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TdevBoxService.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("UpdateBoxAsync/{id}")]
- [AllowAnonymous]
- public async Task<ApiResult> UpdateBoxAsync(string id, TdevBoxUpdateModel updateModel)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TdevBoxService.UpdateAsync(id, updateModel);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
- /// <summary>
- /// 取业主盒子信息
- /// </summary>
- /// <returns></returns>
- [HttpPost("GetDevStoreDocAsync")]
- [AllowAnonymous]
- public async Task<ApiResult> GetDevStoreDocAsync(TdevBoxSearchModel searchModel)
- {
- if (searchModel == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- var contentList = await _TdevBoxService.GetConditionAsync(searchModel);
- return new ApiResult<PagesModel<TdevBoxViewModel>>(new PagesModel<TdevBoxViewModel>(contentList, searchModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 通过id获取业主盒子信息
- /// </summary>
- /// <returns></returns>
- [HttpPost("GetDevStoreDocByIDAsync")]
- [AllowAnonymous]
- public async Task<ApiResult> GetDevStoreDocByIDAsync(TdevBoxSearchModel searchModel)
- {
- if (searchModel == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- var content = await _TdevBoxService.GetConditionByIdAsync(searchModel.C_ID);
- TdevBoxDevSpotSearchModel tdev = new TdevBoxDevSpotSearchModel();
- tdev.C_BoxCode = searchModel.C_ID;
- var contentList = await _TdevBoxDevSpotService.GetConditionAsync(tdev);
- TdevBoxViewSpotModel data = new TdevBoxViewSpotModel();
- data.entity = content;
- data.tdevBoxes = contentList.ToList();
- return new ApiResult<TdevBoxViewSpotModel>(data);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 拷贝业主盒子信息
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- [HttpGet("CopyBoxStoreInfo")]
- [AllowAnonymous]
- public async Task<ApiResult> CopyBoxStoreInfo(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TdevBoxService.CopyCreateAsync(id);
- return new ApiResult(ReturnCode.Success);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
- /// <summary>
- /// 通过
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- //[HttpGet("GetDevStoreDocByCodeAsync/{id}")]
- //[AllowAnonymous]
- //public async Task<ApiResult> GetDevStoreDocByCodeAsync(string id)
- //{
- // if (string.IsNullOrEmpty(id))
- // {
- // return new ApiResult(ReturnCode.GeneralError);
- // }
- // try
- // {
- // var content = await _TdevBoxService.GetConditionAsync(new TdevBoxSearchModel { C_StoreCode = id });
- // var dev = content.ToList();
- // return new ApiResult<IEnumerable<TdevBoxViewModel>>(new List<TdevBoxViewModel>(dev));
- // }
- // catch (Exception ex)
- // {
- // return new ApiResult(ReturnCode.GeneralError, ex.Message);
- // }
- //}
- }
- }
|