6 changed files with 267 additions and 18 deletions
@ -0,0 +1,126 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// PLM轉入料號說明
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class PlmMeterialInfoeController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
public PlmMeterialInfoeController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
// GET: api/PlmMeterialInfoe
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<PlmMeterialInfo>>> GetPlmMeterialInfos() |
||||
|
{ |
||||
|
return await _context.PlmMeterialInfos.ToListAsync(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">PLM料號</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<PlmMeterialInfo>> GetPlmMeterialInfo(string id) |
||||
|
{ |
||||
|
var plmMeterialInfo = await _context.PlmMeterialInfos.FindAsync(id); |
||||
|
return plmMeterialInfo; |
||||
|
} |
||||
|
|
||||
|
// PUT: api/PlmMeterialInfoe/5
|
||||
|
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
||||
|
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
|
||||
|
[HttpPut("{id}")] |
||||
|
public async Task<IActionResult> PutPlmMeterialInfo(string id, PlmMeterialInfo plmMeterialInfo) |
||||
|
{ |
||||
|
if (id != plmMeterialInfo.MeterialNo) |
||||
|
{ |
||||
|
return BadRequest(); |
||||
|
} |
||||
|
|
||||
|
_context.Entry(plmMeterialInfo).State = EntityState.Modified; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateConcurrencyException) |
||||
|
{ |
||||
|
if (!PlmMeterialInfoExists(id)) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return NoContent(); |
||||
|
} |
||||
|
|
||||
|
// POST: api/PlmMeterialInfoe
|
||||
|
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
||||
|
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
|
||||
|
[HttpPost] |
||||
|
public async Task<ActionResult<PlmMeterialInfo>> PostPlmMeterialInfo(PlmMeterialInfo plmMeterialInfo) |
||||
|
{ |
||||
|
_context.PlmMeterialInfos.Add(plmMeterialInfo); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (DbUpdateException) |
||||
|
{ |
||||
|
if (PlmMeterialInfoExists(plmMeterialInfo.MeterialNo)) |
||||
|
{ |
||||
|
return Conflict(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return CreatedAtAction("GetPlmMeterialInfo", new { id = plmMeterialInfo.MeterialNo }, plmMeterialInfo); |
||||
|
} |
||||
|
|
||||
|
// DELETE: api/PlmMeterialInfoe/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ActionResult<PlmMeterialInfo>> DeletePlmMeterialInfo(string id) |
||||
|
{ |
||||
|
var plmMeterialInfo = await _context.PlmMeterialInfos.FindAsync(id); |
||||
|
if (plmMeterialInfo == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
_context.PlmMeterialInfos.Remove(plmMeterialInfo); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
return plmMeterialInfo; |
||||
|
} |
||||
|
|
||||
|
private bool PlmMeterialInfoExists(string id) |
||||
|
{ |
||||
|
return _context.PlmMeterialInfos.Any(e => e.MeterialNo == id); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,97 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using System.Runtime.Serialization; |
||||
|
|
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// PLM轉入料號說明
|
||||
|
/// </summary>
|
||||
|
[Table("PLM_METERIAL_INFO", Schema = "JHAMES")] |
||||
|
public partial class PlmMeterialInfo |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 物料
|
||||
|
/// </summary>
|
||||
|
[Key] |
||||
|
[Column("METERIALNO")] |
||||
|
[StringLength(18)] |
||||
|
[Required] |
||||
|
[DataMember] |
||||
|
public string MeterialNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 物料描述
|
||||
|
/// </summary>
|
||||
|
[Required] |
||||
|
[DataMember] |
||||
|
[Column("METERIAL_DESC")] |
||||
|
[StringLength(100)] |
||||
|
public string MeterialDesc { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 機種系列
|
||||
|
/// </summary>
|
||||
|
[Required] |
||||
|
[DataMember] |
||||
|
[Column("MODELNAME")] |
||||
|
[StringLength(18)] |
||||
|
public string ModelName { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 生產備忘錄
|
||||
|
/// </summary>
|
||||
|
[Column("PRODUCTION_MEMO")] |
||||
|
[StringLength(500)] |
||||
|
[DataMember] |
||||
|
public string ProductionMemo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 狀態
|
||||
|
/// </summary>
|
||||
|
[Required] |
||||
|
[DataMember] |
||||
|
[Column("STATUS")] |
||||
|
[StringLength(1)] |
||||
|
public string Status { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// EAN
|
||||
|
/// </summary>
|
||||
|
[Column("EAN")] |
||||
|
[StringLength(20)] |
||||
|
[DataMember] |
||||
|
public string EAN { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 長文
|
||||
|
/// </summary>
|
||||
|
[DataMember] |
||||
|
[Column("LONG_TEXT")] |
||||
|
[StringLength(500)] |
||||
|
public string LongText { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 建立日期
|
||||
|
/// </summary>
|
||||
|
[Required] |
||||
|
[Column("CREATE_DATE")] |
||||
|
[DataMember] |
||||
|
public DateTime CreateDate { get; set; } = DateTime.Now; |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新日期
|
||||
|
/// </summary>
|
||||
|
[Column("UPDATE_DATE")] |
||||
|
[DataMember] |
||||
|
public DateTime? UpdateDate { get; set; } = DateTime.Now; |
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue