130 lines
4.0 KiB
C#
130 lines
4.0 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
|
||
using DOAN.Admin.WebApi.Filters;
|
||
using Infrastructure.Controllers;
|
||
using DOAN.ServiceCore.Middleware;
|
||
using Mapster;
|
||
using Infrastructure.Enums;
|
||
using Infrastructure;
|
||
using Infrastructure.Attribute;
|
||
using DOAN.Common;
|
||
using Infrastructure.Model;
|
||
using MDM.Services.IPlantService;
|
||
using MDM.Model.Plant;
|
||
using MDM.Model.Plant.Dto;
|
||
//创建时间:2025-11-15
|
||
namespace MDM.Controllers.Plant
|
||
{
|
||
/// <summary>
|
||
/// 车间
|
||
/// </summary>
|
||
[Verify]
|
||
[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(string site_code)
|
||
{
|
||
var response = _PlantWorkshopService.GetFactorySite(site_code);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
} |