啊鑫
2024-09-20 9c11d971c382d8ca8b9b0d893929e2973151bbdf
打印的后台接口
已添加2个文件
已修改1个文件
243 ■■■■■ 文件已修改
MES.Service/Modes/MesRfPrnbarcode.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
MES.Service/service/MesRfPrnbarcodeManager.cs 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
MESApplication/Controllers/MesRfPrnbarcodeController.cs 163 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
MES.Service/service/MesRfPrnbarcodeManager.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,78 @@
using 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>
    /// ä»“储方法满足不了复杂业务需求,业务代码请在这里面定义方法
    /// </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,我们可以用queryable实现复杂功能
        /*********插入*********/
        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);// åªæ›´æ–°ClassName列和CreateTime列,其它列不更新,条件id=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
 }
}
MESApplication/Controllers/MesRfPrnbarcodeController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,163 @@
using 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);
            }
        }
    }
}