168 lines
4.8 KiB
C#
168 lines
4.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
||
using DOAN.Admin.WebApi.Filters;
|
||
using DOAN.Service.huate_group.Recipe.IService;
|
||
using DOAN.Model.huate_group.recipe;
|
||
using DOAN.Model.huate_group.recipe.Dto;
|
||
using System.ComponentModel;
|
||
|
||
//创建时间:2024-08-21
|
||
namespace DOAN.Admin.WebApi.Controllers.huate_group.Recipe
|
||
{
|
||
/// <summary>
|
||
/// 配方表
|
||
/// </summary>
|
||
[Verify]
|
||
[Route("huate_group/Recipe/Recipe")]
|
||
public class RecipeController : BaseController
|
||
{
|
||
/// <summary>
|
||
/// 配方表接口
|
||
/// </summary>
|
||
private readonly IRecipeService _RecipeService;
|
||
|
||
public RecipeController(IRecipeService RecipeService)
|
||
{
|
||
_RecipeService = RecipeService;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询配方表列表
|
||
/// </summary>
|
||
/// <param name="parm"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("list")]
|
||
[ActionPermissionFilter(Permission = "recipe:list")]
|
||
public IActionResult QueryRecipe([FromQuery] RecipeQueryDto parm)
|
||
{
|
||
var response = _RecipeService.GetList(parm);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询配方表详情
|
||
/// </summary>
|
||
/// <param name="Id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet("{Id}")]
|
||
[ActionPermissionFilter(Permission = "recipe:query")]
|
||
public IActionResult GetRecipe(int Id)
|
||
{
|
||
var response = _RecipeService.GetInfo(Id);
|
||
|
||
var info = response.Adapt<RecipeDto>();
|
||
return SUCCESS(info);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加配方表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[ActionPermissionFilter(Permission = "recipe:add")]
|
||
[Log(Title = "配方表", BusinessType = BusinessType.INSERT)]
|
||
public IActionResult AddRecipe([FromBody] RecipeDto parm)
|
||
{
|
||
var modal = parm.Adapt<Recipee>().ToCreate(HttpContext);
|
||
|
||
var response = _RecipeService.AddRecipe(modal);
|
||
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新配方表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPut]
|
||
[ActionPermissionFilter(Permission = "recipe:edit")]
|
||
[Log(Title = "配方表", BusinessType = BusinessType.UPDATE)]
|
||
public IActionResult UpdateRecipe([FromBody] RecipeDto parm)
|
||
{
|
||
var modal = parm.Adapt<Recipee>().ToUpdate(HttpContext);
|
||
var response = _RecipeService.UpdateRecipe(modal);
|
||
|
||
return ToResponse(response);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除配方表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost("delete/{ids}")]
|
||
[ActionPermissionFilter(Permission = "recipe:delete")]
|
||
[Log(Title = "配方表", BusinessType = BusinessType.DELETE)]
|
||
public IActionResult DeleteRecipe([FromRoute] string ids)
|
||
{
|
||
var idArr = Tools.SplitAndConvert<int>(ids);
|
||
|
||
return ToResponse(_RecipeService.Delete(idArr));
|
||
}
|
||
|
||
|
||
|
||
// TODO 根据配方id 获取上下限列表
|
||
[HttpGet("get_recipe/{Id}")]
|
||
public IActionResult GetRecipebyLimit(int Id)
|
||
{
|
||
if (Id <= 0) {
|
||
throw new Exception("参数异常,请检查常数");
|
||
|
||
}
|
||
var response = _RecipeService.GetRecipebyLimit(Id);
|
||
return SUCCESS(response);
|
||
|
||
}
|
||
|
||
//TODO 获取公司
|
||
[HttpGet("get_company")]
|
||
public IActionResult GetAllCompany()
|
||
{
|
||
var response = _RecipeService.GetAllCompany();
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
//TODO 获取车间
|
||
[HttpGet("get_workshop")]
|
||
public IActionResult GetWorkShopByCompany(int company_id)
|
||
{
|
||
if (company_id <= 0)
|
||
{
|
||
throw new Exception("参数异常,请检查常数");
|
||
|
||
}
|
||
var response = _RecipeService.GetWorkShopByCompany(company_id);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
//TODO 获取产线和设备 children
|
||
[HttpGet("get_line_childen_device")]
|
||
public IActionResult GetLineChildenDevice(int workshop_id)
|
||
{
|
||
if (workshop_id <= 0)
|
||
{
|
||
throw new Exception("参数异常,请检查常数");
|
||
|
||
}
|
||
var response = _RecipeService.GetLineChildenDevice(workshop_id);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
//TODO 选中配方
|
||
[HttpGet("selected")]
|
||
public IActionResult SelectedRecipe(int recipe_id)
|
||
{
|
||
if (recipe_id <= 0)
|
||
{
|
||
throw new Exception("参数异常,请检查常数");
|
||
|
||
}
|
||
var response = _RecipeService.SelectedRecipe(recipe_id);
|
||
return SUCCESS(response);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
} |