|
@@ -0,0 +1,150 @@
|
|
|
+using Infrastructure;
|
|
|
+using Infrastructure.Attribute;
|
|
|
+using Infrastructure.Enums;
|
|
|
+using Infrastructure.Model;
|
|
|
+using Mapster;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using ZR.Model.Dto;
|
|
|
+using ZR.Model.Models;
|
|
|
+using ZR.Service.Business.IBusinessService;
|
|
|
+using ZR.Admin.WebApi.Extensions;
|
|
|
+using ZR.Admin.WebApi.Filters;
|
|
|
+using ZR.Common;
|
|
|
+using ZR.Model.System;
|
|
|
+using ZR.Service.System.IService;
|
|
|
+using System.Data;
|
|
|
+using ZR.Model.Dto.Inspect;
|
|
|
+using ZR.Model.Models.Inspect;
|
|
|
+
|
|
|
+namespace ZR.Admin.WebApi.Controllers
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// Controller
|
|
|
+ ///
|
|
|
+ /// @tableName pda_auto_update
|
|
|
+ /// @author admin
|
|
|
+ /// @date 2024-03-18
|
|
|
+ /// </summary>
|
|
|
+ [Verify]
|
|
|
+ [Route("business/PdaAutoUpdate")]
|
|
|
+ public class PdaAutoUpdateController : BaseController
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 接口
|
|
|
+ /// </summary>
|
|
|
+ private readonly IPdaAutoUpdateService _PdaAutoUpdateService;
|
|
|
+ private readonly ISysFileService FileService;
|
|
|
+ private IWebHostEnvironment hostEnvironment;
|
|
|
+
|
|
|
+ public PdaAutoUpdateController(IPdaAutoUpdateService PdaAutoUpdateService,
|
|
|
+ ISysFileService sysFileService,
|
|
|
+ IWebHostEnvironment hostEnvironment)
|
|
|
+ {
|
|
|
+ _PdaAutoUpdateService = PdaAutoUpdateService;
|
|
|
+ FileService = sysFileService;
|
|
|
+ this.hostEnvironment = hostEnvironment;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="parm"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("list")]
|
|
|
+ [ActionPermissionFilter(Permission = "business:pdaautoupdate:list")]
|
|
|
+ public IActionResult QueryPdaAutoUpdate([FromQuery] PdaAutoUpdateQueryDto parm)
|
|
|
+ {
|
|
|
+ var response = _PdaAutoUpdateService.GetList(parm);
|
|
|
+ return SUCCESS(response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 查询详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="Id"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("{Id}")]
|
|
|
+ [ActionPermissionFilter(Permission = "business:pdaautoupdate:query")]
|
|
|
+ public IActionResult GetPdaAutoUpdate(int Id)
|
|
|
+ {
|
|
|
+ var response = _PdaAutoUpdateService.GetFirst(x => x.Id == Id);
|
|
|
+
|
|
|
+ return SUCCESS(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 添加
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ActionPermissionFilter(Permission = "business:pdaautoupdate:add")]
|
|
|
+ [Log(Title = "", BusinessType = BusinessType.INSERT)]
|
|
|
+ public IActionResult AddPdaAutoUpdate([FromBody] PdaAutoUpdateDto parm)
|
|
|
+ {
|
|
|
+ if (parm == null)
|
|
|
+ {
|
|
|
+ throw new CustomException("请求参数错误");
|
|
|
+ }
|
|
|
+ var modal = parm.Adapt<PdaAutoUpdate>().ToCreate(HttpContext);
|
|
|
+
|
|
|
+ var response = _PdaAutoUpdateService.AddPdaAutoUpdate(modal);
|
|
|
+
|
|
|
+ return ToResponse(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 更新
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPut]
|
|
|
+ [ActionPermissionFilter(Permission = "business:pdaautoupdate:edit")]
|
|
|
+ [Log(Title = "", BusinessType = BusinessType.UPDATE)]
|
|
|
+ public IActionResult UpdatePdaAutoUpdate([FromBody] PdaAutoUpdateDto parm)
|
|
|
+ {
|
|
|
+ if (parm == null)
|
|
|
+ {
|
|
|
+ throw new CustomException("请求实体不能为空");
|
|
|
+ }
|
|
|
+ var modal = parm.Adapt<PdaAutoUpdate>().ToUpdate(HttpContext);
|
|
|
+
|
|
|
+ var response = _PdaAutoUpdateService.UpdatePdaAutoUpdate(modal);
|
|
|
+
|
|
|
+ return ToResponse(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 删除
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpDelete("{ids}")]
|
|
|
+ [ActionPermissionFilter(Permission = "business:pdaautoupdate:delete")]
|
|
|
+ [Log(Title = "", BusinessType = BusinessType.DELETE)]
|
|
|
+ public IActionResult DeletePdaAutoUpdate(string ids)
|
|
|
+ {
|
|
|
+ int[] idsArr = Tools.SpitIntArrary(ids);
|
|
|
+ if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
|
|
|
+
|
|
|
+ var response = _PdaAutoUpdateService.Delete(idsArr);
|
|
|
+
|
|
|
+ return ToResponse(response);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 导入
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("upload")]
|
|
|
+ [Log(Title = "PDA软件安装包导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
|
|
+ [ActionPermissionFilter(Permission = "business:pdaautoupdate:import")]
|
|
|
+ public async Task<IActionResult> ImportDataAsync([FromForm(Name = "file")] IFormFile formFile)
|
|
|
+ {
|
|
|
+ SysFile file = await FileService.SaveFileToLocalNoDateDir(hostEnvironment.WebRootPath, formFile.FileName,"" , HttpContext.GetName(), formFile);
|
|
|
+ //TODO 业务逻辑,自行插入数据到db
|
|
|
+ return SUCCESS($"上传{file.FileName}成功。");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|