2026-01-10 10:05:56 +08:00

130 lines
4.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Infrastructure;
using Infrastructure.Attribute;
using Infrastructure.Controllers;
using Infrastructure.Enums;
using Infrastructure.Model;
using Mapster;
using MDM.Model.Plant;
using MDM.Model.Plant.Dto;
using MDM.Services.IPlantService;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RIZO.Admin.WebApi.Filters;
using RIZO.Common;
using RIZO.ServiceCore.Middleware;
//创建时间2025-11-15
namespace MDM.Controllers.Plant
{
/// <summary>
/// 车间
/// </summary>
[AllowAnonymous]
[Route("MasterDataManagement/Plant/PlantWorkshop")]
public class PlantWorkshopController : BaseController
{
/// <summary>
/// 车间接口
/// </summary>
private readonly IPlantWorkshopService _PlantWorkshopService;
public PlantWorkshopController(IPlantWorkshopService PlantWorkshopService)
{
_PlantWorkshopService = PlantWorkshopService;
}
/// <summary>
/// 查询车间列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
[HttpGet("list")]
[ActionPermissionFilter(Permission = "business:plantworkshop:list")]
public IActionResult QueryPlantWorkshop([FromQuery] PlantWorkshopQueryDto parm)
{
var response = _PlantWorkshopService.GetList(parm);
return SUCCESS(response);
}
/// <summary>
/// 查询车间详情
/// </summary>
/// <param name="WorkshopId"></param>
/// <returns></returns>
[HttpGet("{WorkshopId}")]
[ActionPermissionFilter(Permission = "business:plantworkshop:query")]
public IActionResult GetPlantWorkshop(int WorkshopId)
{
var response = _PlantWorkshopService.GetInfo(WorkshopId);
var info = response.Adapt<PlantWorkshop>();
return SUCCESS(info);
}
/// <summary>
/// 添加车间
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionPermissionFilter(Permission = "business:plantworkshop:add")]
[Log(Title = "车间", BusinessType = BusinessType.INSERT)]
public IActionResult AddPlantWorkshop([FromBody] PlantWorkshopDto parm)
{
var modal = parm.Adapt<PlantWorkshop>().ToCreate(HttpContext);
var response = _PlantWorkshopService.AddPlantWorkshop(modal);
return SUCCESS(response);
}
/// <summary>
/// 更新车间
/// </summary>
/// <returns></returns>
[HttpPut]
[ActionPermissionFilter(Permission = "business:plantworkshop:edit")]
[Log(Title = "车间", BusinessType = BusinessType.UPDATE)]
public IActionResult UpdatePlantWorkshop([FromBody] PlantWorkshopDto parm)
{
var modal = parm.Adapt<PlantWorkshop>().ToUpdate(HttpContext);
var response = _PlantWorkshopService.UpdatePlantWorkshop(modal);
return ToResponse(response);
}
/// <summary>
/// 删除车间
/// </summary>
/// <returns></returns>
[HttpDelete("{ids}")]
[ActionPermissionFilter(Permission = "business:plantworkshop:delete")]
[Log(Title = "车间", BusinessType = BusinessType.DELETE)]
public IActionResult DeletePlantWorkshop(string ids)
{
int[] idsArr = Tools.SpitIntArrary(ids);
if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
var response = _PlantWorkshopService.Delete(idsArr);
return ToResponse(response);
}
//TODO 获取工厂
/// <summary>
/// 获取工厂
/// </summary>
/// <param name="site_code">工厂code</param>
/// <returns></returns>
[HttpGet("get_factory_site")]
public IActionResult GetFactorySite()
{
var response = _PlantWorkshopService.GetFactorySite();
return SUCCESS(response);
}
}
}