From 9c11d971c382d8ca8b9b0d893929e2973151bbdf Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期五, 20 九月 2024 17:41:56 +0800
Subject: [PATCH] 打印的后台接口
---
MES.Service/service/MesRfPrnbarcodeManager.cs | 78 +++++++++++++++
MESApplication/Controllers/MesRfPrnbarcodeController.cs | 163 ++++++++++++++++++++++++++++++++
MES.Service/Modes/MesRfPrnbarcode.cs | 2
3 files changed, 242 insertions(+), 1 deletions(-)
diff --git a/MES.Service/Modes/MesRfPrnbarcode.cs b/MES.Service/Modes/MesRfPrnbarcode.cs
index 042cb57..5ccb354 100644
--- a/MES.Service/Modes/MesRfPrnbarcode.cs
+++ b/MES.Service/Modes/MesRfPrnbarcode.cs
@@ -11,7 +11,7 @@
/// <summary>
/// ID
/// </summary>
- [SugarColumn(ColumnName = "ID")]
+ [SugarColumn(ColumnName = "ID",IsPrimaryKey = true)]
public decimal? Id { get; set; }
/// <summary>
diff --git a/MES.Service/service/MesRfPrnbarcodeManager.cs b/MES.Service/service/MesRfPrnbarcodeManager.cs
new file mode 100644
index 0000000..c88a84e
--- /dev/null
+++ b/MES.Service/service/MesRfPrnbarcodeManager.cs
@@ -0,0 +1,78 @@
+锘縰sing SqlSugar;
+using System;
+using System.Collections.Generic;
+using MES.Service.DB;
+using MES.Service.Modes;
+
+namespace MES.Service.service
+{
+public class MesRfPrnbarcodeManager : Repository<MesRfPrnbarcode>
+{
+
+ //褰撳墠绫诲凡缁忕户鎵夸簡 Repository 澧炪�佸垹銆佹煡銆佹敼鐨勬柟娉�
+
+ //杩欓噷闈㈠啓鐨勪唬鐮佷笉浼氱粰瑕嗙洊,濡傛灉瑕侀噸鏂扮敓鎴愯鍒犻櫎 MesRfPrnbarcodeManager.cs
+
+
+ #region 鏁欏鏂规硶
+ /// <summary>
+ /// 浠撳偍鏂规硶婊¤冻涓嶄簡澶嶆潅涓氬姟闇�姹傦紝涓氬姟浠g爜璇峰湪杩欓噷闈㈠畾涔夋柟娉�
+ /// </summary>
+ public void Study()
+ {
+
+ /*********鏌ヨ*********/
+
+ var data1 = base.GetById(1);//鏍规嵁ID鏌ヨ
+ var data2 = base.GetList();//鏌ヨ鎵�鏈�
+ var data3 = base.GetList(it => 1 == 1); //鏍规嵁鏉′欢鏌ヨ
+ //var data4 = base.GetSingle(it => 1 == 1);//鏍规嵁鏉′欢鏌ヨ涓�鏉�,濡傛灉瓒呰繃涓�鏉′細鎶ラ敊
+
+ var p = new PageModel() { PageIndex = 1, PageSize = 2 };// 鍒嗛〉鏌ヨ
+ var data5 = base.GetPageList(it => 1 == 1, p);
+ Console.Write(p.TotalCount);//杩斿洖鎬绘暟
+
+ var data6 = base.GetPageList(it => 1 == 1, p, it => SqlFunc.GetRandom(), OrderByType.Asc);// 鍒嗛〉鏌ヨ鍔犳帓搴�
+ Console.Write(p.TotalCount);//杩斿洖鎬绘暟
+
+ List<IConditionalModel> conModels = new List<IConditionalModel>(); //缁勮鏉′欢鏌ヨ浣滀负鏉′欢瀹炵幇 鍒嗛〉鏌ヨ鍔犳帓搴�
+ conModels.Add(new ConditionalModel() { FieldName= typeof(MesRfPrnbarcode).GetProperties()[0].Name, ConditionalType = ConditionalType.Equal, FieldValue = "1" });//id=1
+ var data7 = base.GetPageList(conModels, p, it => SqlFunc.GetRandom(), OrderByType.Asc);
+
+ base.AsQueryable().Where(x => 1 == 1).ToList();//鏀寔浜嗚浆鎹㈡垚queryable,鎴戜滑鍙互鐢╭ueryable瀹炵幇澶嶆潅鍔熻兘
+
+
+
+ /*********鎻掑叆*********/
+ var insertData = new MesRfPrnbarcode() { };//娴嬭瘯鍙傛暟
+ var insertArray = new MesRfPrnbarcode[] { insertData };
+ base.Insert(insertData);//鎻掑叆
+ base.InsertRange(insertArray);//鎵归噺鎻掑叆
+ var id = base.InsertReturnIdentity(insertData);//鎻掑叆杩斿洖鑷鍒�
+ base.AsInsertable(insertData).ExecuteCommand();//鎴戜滑鍙互杞垚 Insertable瀹炵幇澶嶆潅鎻掑叆
+
+
+
+ /*********鏇存柊*********/
+ var updateData = new MesRfPrnbarcode() { };//娴嬭瘯鍙傛暟
+ var updateArray = new MesRfPrnbarcode[] { updateData };//娴嬭瘯鍙傛暟
+ base.Update(updateData);//鏍规嵁瀹炰綋鏇存柊
+ base.UpdateRange(updateArray);//鎵归噺鏇存柊
+ //base.Update(it => new MesRfPrnbarcode() { ClassName = "a", CreateTime = DateTime.Now }, it => it.id==1);// 鍙洿鏂癈lassName鍒楀拰CreateTime鍒楋紝鍏跺畠鍒椾笉鏇存柊锛屾潯浠秈d=1
+ base.AsUpdateable(updateData).ExecuteCommand(); //杞垚Updateable鍙互瀹炵幇澶嶆潅鐨勬彃鍏�
+
+
+
+ /*********鍒犻櫎*********/
+ var deldata = new MesRfPrnbarcode() { };//娴嬭瘯鍙傛暟
+ base.Delete(deldata);//鏍规嵁瀹炰綋鍒犻櫎
+ base.DeleteById(1);//鏍规嵁涓婚敭鍒犻櫎
+ base.DeleteById(new int[] { 1,2});//鏍规嵁涓婚敭鏁扮粍鍒犻櫎
+ base.Delete(it=>1==2);//鏍规嵁鏉′欢鍒犻櫎
+ base.AsDeleteable().Where(it=>1==2).ExecuteCommand();//杞垚Deleteable瀹炵幇澶嶆潅鐨勬搷浣�
+ }
+ #endregion
+
+
+ }
+}
\ No newline at end of file
diff --git a/MESApplication/Controllers/MesRfPrnbarcodeController.cs b/MESApplication/Controllers/MesRfPrnbarcodeController.cs
new file mode 100644
index 0000000..6079721
--- /dev/null
+++ b/MESApplication/Controllers/MesRfPrnbarcodeController.cs
@@ -0,0 +1,163 @@
+锘縰sing Microsoft.AspNetCore.Mvc;
+using System.Dynamic;
+using MES.Service.Modes;
+using MES.Service.service;
+using MES.Service.util;
+
+namespace MESApplication.Controllers
+{
+ [ApiController]
+ [Route("api/[controller]")]
+ public class MesRfPrnbarcodeController : ControllerBase
+ {
+
+ private MesRfPrnbarcodeManager m = new MesRfPrnbarcodeManager();
+
+
+ /***杩涘叆妯$増绠$悊鍙互淇敼妯$増***/
+
+ /// <summary>
+ /// 鑾峰彇鎵�鏈�
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost("GetList")]
+ public ResponseResult GetList()
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ resultInfos.tbBillList = m.GetList();
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+
+ /// <summary>
+ /// 鏍规嵁涓婚敭鑾峰彇
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost("GetById")]
+ public ResponseResult GetById(int id)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ resultInfos.tbBillList = m.GetById(id);
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁涓婚敭鍒犻櫎
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost("DeleteByIds")]
+ public ResponseResult DeleteByIds([FromBody] object[] ids)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ resultInfos.tbBillList = m.DeleteByIds(ids);
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 娣诲姞
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost("Insert")]
+ public ResponseResult Add([FromBody] MesRfPrnbarcode data)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ resultInfos.tbBillList = m.Insert(data);
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+ /// <summary>
+ /// 娣诲姞杩斿洖鑷
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost("InsertReturnIdentity")]
+ public ResponseResult InsertReturnIdentity([FromBody] MesRfPrnbarcode data)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ resultInfos.tbBillList = m.InsertReturnIdentity(data);
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 淇敼
+ /// </summary>
+ /// <returns></returns>
+ [HttpPost("Update")]
+ public ResponseResult Update([FromBody] MesRfPrnbarcode data)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ resultInfos.tbBillList = m.Update(data);
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+ }
+}
--
Gitblit v1.9.3