This commit is contained in:
27
Api/Ewide.Core/Ewide.Core.Service/Base/BaseService.cs
Normal file
27
Api/Ewide.Core/Ewide.Core.Service/Base/BaseService.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
public class BaseService
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置和读取异常信息。
|
||||
/// </summary>
|
||||
protected string _ErrorMessage = String.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 读取异常信息。
|
||||
/// </summary>
|
||||
public string ErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
50
Api/Ewide.Core/Ewide.Core.Service/Base/GateService.cs
Normal file
50
Api/Ewide.Core/Ewide.Core.Service/Base/GateService.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DapperExtensions;
|
||||
using Ewide.Core.Model;
|
||||
using Ewide.Core.Common;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
public class GateService : BaseService
|
||||
{
|
||||
public void Login(string account, string password)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string CreateAccount(string account, string password, string name)
|
||||
{
|
||||
using (var db = new Data.DapperTransactionHelper())
|
||||
{
|
||||
var user = new EC_User
|
||||
{
|
||||
ID = Guid.NewGuid().ToString(),
|
||||
Account = account,
|
||||
Password = AuthorizedHelper.GetPasswordMD5(password),
|
||||
Name = name,
|
||||
Type = 1,
|
||||
Sex = 1,
|
||||
Enabled = true,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
db.Conn.Insert(user);
|
||||
|
||||
try
|
||||
{
|
||||
db.Complete();
|
||||
return user.ID;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_ErrorMessage = ex.Message;
|
||||
db.RollBack();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,8 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Base\BaseService.cs" />
|
||||
<Compile Include="Base\GateService.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user