130 lines
4.2 KiB
C#
130 lines
4.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
|
||
using System.Linq.Expressions;
|
||
using System.Threading.Tasks;
|
||
|
||
using ZR.Model.Business;
|
||
using ZR.Model.Business.Dto;
|
||
using ZR.Service.Business;
|
||
using ZR.Service.Business.IBusinessService;
|
||
|
||
//创建时间:2025-09-23
|
||
namespace ZR.Admin.WebApi.Controllers.Business
|
||
{
|
||
/// <summary>
|
||
/// App 更新表
|
||
/// </summary>
|
||
[Route("business/OdfAppUpdates")]
|
||
public class OdfAppUpdatesController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// App 更新表接口
|
||
/// </summary>
|
||
private readonly IOdfAppUpdatesService _OdfAppUpdatesService;
|
||
|
||
public OdfAppUpdatesController(IOdfAppUpdatesService OdfAppUpdatesService)
|
||
{
|
||
_OdfAppUpdatesService = OdfAppUpdatesService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询App 更新表列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "odfappupdates:list")]
|
||
public IActionResult QueryOdfAppUpdates([FromQuery] OdfAppUpdatesQueryDto parm)
|
||
{
|
||
var response = _OdfAppUpdatesService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询App 更新表详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "odfappupdates:query")]
|
||
public IActionResult GetOdfAppUpdates(int Id)
|
||
{
|
||
var response = _OdfAppUpdatesService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<OdfAppUpdatesDto>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改状态
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("status")]
|
||
[ActionPermissionFilter(Permission = "odfappupdates:add")]
|
||
[Log(Title = "App 更新表", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult OdfAppStatus([FromBody] OdfAppUpdatesStatusDto parm)
|
||
{
|
||
var modal = _OdfAppUpdatesService.GetById(parm.Id);
|
||
if (modal != null)
|
||
{
|
||
if (parm.IsActive)
|
||
{
|
||
// 先将所有激活状态设置为未激活
|
||
_OdfAppUpdatesService.UpdateAllActiveToInactive();
|
||
}
|
||
modal.IsActive = parm.IsActive;
|
||
var response = _OdfAppUpdatesService.UpdateOdfAppUpdates(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
return SUCCESS(null);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加App 更新表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("add")]
|
||
[ActionPermissionFilter(Permission = "odfappupdates:add")]
|
||
[Log(Title = "App 更新表", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddOdfAppUpdates([FromBody] OdfAppUpdatesDto parm)
|
||
{
|
||
var modal = parm.Adapt<OdfAppUpdates>().ToCreate(HttpContext);
|
||
parm.CreateTime = DateTime.Now;
|
||
var response = _OdfAppUpdatesService.AddOdfAppUpdates(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新App 更新表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "odfappupdates:edit")]
|
||
[Log(Title = "App 更新表", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateOdfAppUpdates([FromBody] OdfAppUpdatesDto parm)
|
||
{
|
||
var modal = parm.Adapt<OdfAppUpdates>().ToUpdate(HttpContext);
|
||
var response = _OdfAppUpdatesService.UpdateOdfAppUpdates(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除App 更新表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "odfappupdates:delete")]
|
||
[Log(Title = "App 更新表", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteOdfAppUpdates([FromRoute] string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<int>(ids);
|
||
|
||
return ToResponse(_OdfAppUpdatesService.Delete(idArr));
|
||
}
|
||
|
||
}
|
||
} |