123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Ropin.Core.Extensions.Redis;
- using Ropin.Inspection.Api.Common;
- using Ropin.Inspection.Api.Controllers;
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Service;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Api
- {
- public class TdevBoxDevSpotController : BaseController
- {
- public ILogger<TdevBoxDevSpotController> _logger { get; }
- private readonly IRedisBasketRepository _redisService;
- private readonly ITdevBoxDevSpotService _TdevBoxDevSpotService;
-
-
-
-
-
- public TdevBoxDevSpotController(ITdevBoxDevSpotService TdevBoxDevSpotService, IRedisBasketRepository redisService,ILogger<TdevBoxDevSpotController> logger)
- {
- _TdevBoxDevSpotService = TdevBoxDevSpotService;
- _logger = logger;
- _redisService = redisService;
- }
-
-
-
-
-
- [HttpPost("CreateBoxDevSpotAsync")]
- [AllowAnonymous]
- public async Task<ApiResult> CreateBoxDevSpotAsync(TdevBoxDevSpotViewModel content)
- {
- if (content == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- await _TdevBoxDevSpotService.CreateOneAsync(content);
- await _redisService.Set("mqtt_BoxDevSpot_IsUpdate", "1", TimeSpan.FromDays(7));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
-
-
-
-
-
- [HttpDelete("DeleteBoxDevSpotAsync/{id}")]
- public async Task<ApiResult> DeleteBoxDevSpotAsync(string id)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TdevBoxDevSpotService.DeleteAsync(id);
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
-
-
-
-
-
-
- [HttpPut("UpdateBoxDevSpotAsync/{id}")]
- [AllowAnonymous]
- public async Task<ApiResult> UpdateBoxDevSpotAsync(string id, TdevBoxDevSpotUpdateModel updateModel)
- {
- if (string.IsNullOrEmpty(id))
- {
- return new ApiResult(ReturnCode.GeneralError);
- }
- try
- {
- await _TdevBoxDevSpotService.UpdateAsync(id, updateModel);
- await _redisService.Set("mqtt_BoxDevSpot_IsUpdate", "1", TimeSpan.FromDays(7));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- return new ApiResult(ReturnCode.Success);
- }
-
-
-
-
- [HttpPost("GetBoxDevSpotAsync")]
- [AllowAnonymous]
- public async Task<ApiResult> GetBoxDevSpotAsync(TdevBoxDevSpotSearchModel searchModel)
- {
- if (searchModel == null)
- {
- return new ApiResult(ReturnCode.ArgsError);
- }
- try
- {
- var contentList = await _TdevBoxDevSpotService.GetConditionAsync(searchModel);
- return new ApiResult<PagesModel<TdevBoxDevSpotViewModel>>(new PagesModel<TdevBoxDevSpotViewModel>(contentList, searchModel));
- }
- catch (Exception ex)
- {
- return new ApiResult(ReturnCode.GeneralError, ex.Message);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
|