2023-03-17 09:59:48 +08:00
|
|
|
|
using BLL;
|
|
|
|
|
|
using Model;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Web.Http;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WebAPI.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 质量样板
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class CQMSModelsController : ApiController
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据项目id获取质量样板列表集合
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
|
/// <param name="index"></param>
|
|
|
|
|
|
/// <param name="page"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
|
public ResponseData<List<Model_QualityModel>> getModelsList(string projectId, int index, int page)
|
|
|
|
|
|
{
|
|
|
|
|
|
ResponseData<List<Model_QualityModel>> res = new ResponseData<List<Model_QualityModel>>();
|
|
|
|
|
|
res.successful = true;
|
|
|
|
|
|
res.resultValue = BLL.QualityModelService.getListDataForApi(projectId, index, page);
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 根据id获取质量样板详情
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet]
|
2023-04-06 15:15:30 +08:00
|
|
|
|
public ResponseData<List<Model_QualityModel>> GetModelsById(string id)
|
2023-03-17 09:59:48 +08:00
|
|
|
|
{
|
2023-04-06 15:15:30 +08:00
|
|
|
|
ResponseData<List<Model_QualityModel>> res = new ResponseData<List<Model_QualityModel>>();
|
|
|
|
|
|
List<Model_QualityModel> cd = BLL.QualityModelService.GetQualityModelByIdForApi(id);
|
2023-03-17 09:59:48 +08:00
|
|
|
|
|
|
|
|
|
|
res.successful = true;
|
2023-04-06 15:15:30 +08:00
|
|
|
|
res.resultValue = cd;
|
2023-03-17 09:59:48 +08:00
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存质量样板
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="trainPlan"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
|
public ResponseData<string> AddModels([FromBody] Model.Model_QualityModel models)
|
|
|
|
|
|
{
|
|
|
|
|
|
ResponseData<string> res = new ResponseData<string>();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(models.QualityModelId))
|
|
|
|
|
|
{
|
|
|
|
|
|
models.QualityModelId = Guid.NewGuid().ToString();
|
|
|
|
|
|
BLL.QualityModelService.AddQualityModelForApi(models);
|
|
|
|
|
|
SaveAttachFile(models.QualityModelId, BLL.Const.QualityModelMenuId, models.AttachUrl);
|
|
|
|
|
|
res.resultValue = models.QualityModelId;
|
|
|
|
|
|
res.successful = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
BLL.QualityModelService.UpdateQualityModelForApi(models);
|
|
|
|
|
|
SaveAttachFile(models.QualityModelId, BLL.Const.QualityModelMenuId, models.AttachUrl);
|
|
|
|
|
|
res.resultValue = models.QualityModelId;
|
|
|
|
|
|
res.successful = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
res.successful = false;
|
|
|
|
|
|
res.resultHint = e.StackTrace;
|
|
|
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void SaveAttachFile(string dataId, string menuId, string url)
|
|
|
|
|
|
{
|
|
|
|
|
|
Model.ToDoItem toDoItem = new Model.ToDoItem
|
|
|
|
|
|
{
|
|
|
|
|
|
MenuId = menuId,
|
|
|
|
|
|
DataId = dataId,
|
|
|
|
|
|
UrlStr = url,
|
|
|
|
|
|
};
|
|
|
|
|
|
APIUpLoadFileService.SaveAttachUrl(toDoItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|