服务端的TigerApi 框架,基于.NET6 2024 版本
Ben Lin
2024-04-12 7d092e33fdb6f94443637cab2c0fe146b57846ea
盟祺API
已修改1个文件
已添加8个文件
468 ■■■■■ 文件已修改
Tiger.Api/Controllers/WMS/WMSController.MqCustomer.cs 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Api/Controllers/WMS/WMSController.User.cs 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Business/WMS/MengQi/Biz.User.cs 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.IBusiness/WMS/MengQi/ICustomer.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.IBusiness/WMS/MengQi/IUser.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Model.Net/Entitys/WMS/MengQi/Customer.cs 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Model.Net/Entitys/WMS/MengQi/User.cs 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Model.Net/Tiger.Model.Net.csproj 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Tiger.Api/Controllers/WMS/WMSController.MqCustomer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using Rhea.Common;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Api.Controllers.WMS
{
    public partial class WMSController : ControllerBase
    {
        /// <summary>
        /// å®¢æˆ·ç«¯ç”¨æˆ·ç™»å½•
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/[controller]/[action]")]
        public async Task<IActionResult> GetCustomerInfo([FromBody] ApiAction action)
        {
            ApiAction response = new();
            try
            {
                response = response.GetResponse(await DI.Resolve<ICustomer>().GetCustomerInfo());
            }
            catch (System.Exception ex)
            {
                response = response.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
    }
}
Tiger.Api/Controllers/WMS/WMSController.User.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using Rhea.Common;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Api.Controllers.WMS
{
    public partial class WMSController : ControllerBase
    {
        /// <summary>
        /// å®¢æˆ·ç«¯ç”¨æˆ·ç™»å½•
        /// </summary>
        /// <param name="userInfo"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("api/[controller]/[action]")]
        public async Task<IActionResult> Login(User userInfo)
        {
            ApiAction response = new();
            try
            {
                response = response.GetResponse(await DI.Resolve<IUser>().Login(userInfo));
            }
            catch (System.Exception ex)
            {
                response = response.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
    }
}
Tiger.Business/WMS/MengQi/Biz.Mq.Customer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,45 @@
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Business
{
    public partial class Biz
    {
        /// <summary>
        /// å®¢æˆ·
        /// </summary>
        public partial class MqCustomer : ICustomer
        {
            /// <summary>
            /// èŽ·å–å®¢æˆ·ä¿¡æ¯
            /// </summary>
            /// <returns></returns>
            public async Task<ApiAction<List<Customer>>> GetCustomerInfo()
            {
                var res = new ApiAction<List<Customer>>();
                try
                {
                    List<Customer> result = await Db.Queryable<Customer>().ToListAsync();
                    res.Data = result;
                }
                catch (Exception ex)
                {
                    res.CatchExceptionWithLog(ex, "获取客户信息异常");
                }
                return res;
            }
            public async Task<Result> SaveImportCustomerInfo(DataTable dt)
            {
                throw new NotImplementedException();
            }
        }
    }
}
Tiger.Business/WMS/MengQi/Biz.User.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,110 @@
using Rhea.Common;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
namespace Tiger.Business
{
    public partial class Biz
    {
        /// <summary>
        /// ç”¨æˆ·
        /// </summary>
        public partial class Users : IUser
        {
            /// <summary>
            /// èŽ·å–ç”¨æˆ·ä¿¡æ¯
            /// </summary>
            /// <param name="pageList"></param>
            /// <returns></returns>
            /// <exception cref="NotImplementedException"></exception>
            public async Task<PageAble<User>> GetUserInfo(PageAble<User> pageList)
            {
                RefAsync<int> total = 0;
                pageList.data = await Db.Queryable<User>().WhereIF(!string.IsNullOrEmpty(pageList.sqlcmd), x => x.UserCode.Contains(pageList.sqlcmd)).ToPageListAsync(pageList.pageIndex, pageList.pageSize, total);
                pageList.totals = total;
                return pageList;
            }
            /// <summary>
            /// ç”¨æˆ·ç™»å½•
            /// </summary>
            /// <param name="userInfo"></param>
            /// <returns></returns>
            public async Task<ApiAction<User>> Login(User userInfo)
            {
                var res = new ApiAction<User>();
                try
                {
                    string usercode = userInfo.UserCode;
                    if (userInfo.UserCode == "品质用户")
                    {
                        var user = await Db.Queryable<User>().Where(x => x.RoleCode == "品质").FirstAsync();
                        if (user != null) { usercode = user.UserCode; }
                    }
                    if (!Db.Queryable<User>().Where(x => x.UserCode == usercode && x.Password == userInfo.Password).Any())
                    {
                        //result = new(Result.Flags.Failed, "用户没有权限或者用户名和密码错误!");
                        userInfo = new();
                    }
                    else
                    {
                        userInfo = await Db.Queryable<User>().Where(x => x.UserCode == usercode && x.Password == userInfo.Password).FirstAsync();
                    }
                    res.Data = userInfo;
                }
                catch (Exception ex)
                {
                    res.CatchExceptionWithLog(ex, "登录异常");
                }
                return res;
            }
            /// <summary>
            ///
            /// </summary>
            /// <param name="dt"></param>
            /// <returns></returns>
            public async Task<Result> SaveImportUserInfo(DataTable dt)
            {
                Result result = new Result(Result.Flags.Success, $"导入成功");
                List<User> list = new();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    User item = new()
                    {
                        id = Guid.NewGuid().ToString("N"),
                        UserCode = dt.Rows[i]["用户ID"].ToString(),
                        UserName = dt.Rows[i]["用户名称"].ToString(),
                        RoleCode = dt.Rows[i]["用户角色"].ToString(),
                    };
                    var info = Db.Queryable<User>().Where(x => x.UserCode == dt.Rows[i]["用户ID"].ToString()).First();
                    if (info != null)
                    {
                        item.id = info.id;
                    }
                    list.Add(item);
                }
                //更新机型记录
                var db = Db;
                var dbTran = await db.UseTranAsync(async () =>
                {
                    await db.Saveable(list).ExecuteCommandAsync();
                });
                if (!dbTran.IsSuccess)
                {
                    result.Flag = Result.Flags.Failed;
                    result.Message = $"导入异常";
                }
                return result;
            }
        }
    }
}
Tiger.IBusiness/WMS/MengQi/ICustomer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.Model;
namespace Tiger.IBusiness
{
    public interface ICustomer
    {
        public Task<ApiAction<List<Customer>>> GetCustomerInfo();
        public Task<Result> SaveImportCustomerInfo(DataTable dt);
    }
}
Tiger.IBusiness/WMS/MengQi/IUser.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
using Rhea.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tiger.Model;
namespace Tiger.IBusiness
{
    public interface IUser
    {
        public Task<PageAble<User>> GetUserInfo(PageAble<User> pageList);
        public Task<Result> SaveImportUserInfo(DataTable dt);
        public Task<ApiAction<User>> Login(User userInfo);
    }
}
Tiger.Model.Net/Entitys/WMS/MengQi/Customer.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,124 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tiger.Model
{
    [Serializable]
    [Description("Primary:")]
    [SugarTable("Customer")]
    public class Customer
    {
        private string _id = null;
        private string _customercode = null;
        private string _customername = null;
        private string _Prefix = null;
        private int _SnLength = 0;
        private string _Separator = null;
        private int _SeparatorNum = 0;
        private string _remark = null;
        [SugarColumn(IsPrimaryKey = true)]
        public string id
        {
            get
            {
                return _id;
            }
            set
            {
                _id = value;
            }
        }
        public string CustomerCode
        {
            get
            {
                return _customercode;
            }
            set
            {
                _customercode = value;
            }
        }
        public string CustomerName
        {
            get
            {
                return _customername;
            }
            set
            {
                _customername = value;
            }
        }
        public string Prefix
        {
            get
            {
                return _Prefix;
            }
            set
            {
                _Prefix = value;
            }
        }
        public int SnLength
        {
            get
            {
                return _SnLength;
            }
            set
            {
                _SnLength = value;
            }
        }
        public string Separator
        {
            get
            {
                return _Separator;
            }
            set
            {
                _Separator = value;
            }
        }
        public int SeparatorNum
        {
            get
            {
                return _SeparatorNum;
            }
            set
            {
                _SeparatorNum = value;
            }
        }
        public string Remark
        {
            get
            {
                return _remark;
            }
            set
            {
                _remark = value;
            }
        }
    }
}
Tiger.Model.Net/Entitys/WMS/MengQi/User.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,88 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tiger.Model
{
    [Serializable]
    [Description("Primary:")]
    [SugarTable("User")]
    public class User
    {
        private string _id = null;
        private string _usercode = null;
        private string _username = null;
        private string _rolecode = null;
        private string _password = null;
        [SugarColumn(IsPrimaryKey = true)]
        public string id
        {
            get
            {
                return _id;
            }
            set
            {
                _id = value;
            }
        }
        public string UserCode
        {
            get
            {
                return _usercode;
            }
            set
            {
                _usercode = value;
            }
        }
        public string UserName
        {
            get
            {
                return _username;
            }
            set
            {
                _username = value;
            }
        }
        public string RoleCode
        {
            get
            {
                return _rolecode;
            }
            set
            {
                _rolecode = value;
            }
        }
        public string Password
        {
            get
            {
                return _password;
            }
            set
            {
                _password = value;
            }
        }
    }
}
Tiger.Model.Net/Tiger.Model.Net.csproj
@@ -102,6 +102,8 @@
    <Compile Include="Entitys\WMS\Api\ProdReqInput.cs" />
    <Compile Include="Entitys\WMS\Api\ReprintEntitys.cs" />
    <Compile Include="Entitys\WMS\BIZ_ERP_CUSTOMS.cs" />
    <Compile Include="Entitys\WMS\MengQi\Customer.cs" />
    <Compile Include="Entitys\WMS\MengQi\User.cs" />
    <Compile Include="Entitys\WMS\V_MONTH_IN_SUM.cs" />
    <Compile Include="Entitys\WMS\V_WH_ITEM_SUM.cs" />
    <Compile Include="Entitys\WMS\V_WMS_ITEM_Y.cs" />