From b91156e06b31aee5500b317930923cd13c1c06c6 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Mon, 30 Nov 2015 17:44:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=99=BB=E9=99=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=BC=80=E5=90=AF=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E9=9C=80=E8=A6=81=E5=8E=BB=E6=8E=89basecontroller?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=B3=A8=E9=87=8A=E5=B0=B1=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InitModule.sql | Bin 0 -> 3720 bytes OpenAuth.App/LoginApp.cs | 13 +- OpenAuth.Domain/Core/User.cs | 22 + OpenAuth.Domain/OpenAuth.Domain.csproj | 1 + OpenAuth.Mvc/AutofacExt.cs | 2 +- OpenAuth.Mvc/Controllers/BaseController.cs | 4 +- OpenAuth.Mvc/Controllers/HomeController.cs | 5 - OpenAuth.Mvc/Controllers/LoginController.cs | 39 ++ OpenAuth.Mvc/OpenAuth.Mvc.csproj | 3 +- OpenAuth.Mvc/Views/Home/Index.cshtml | 2 +- .../{Home/Login.cshtml => Login/Index.cshtml} | 469 +++++++++--------- 数据库设计关系图/PDM_OA.pdm | 6 +- 12 files changed, 310 insertions(+), 256 deletions(-) create mode 100644 InitModule.sql create mode 100644 OpenAuth.Domain/Core/User.cs create mode 100644 OpenAuth.Mvc/Controllers/LoginController.cs rename OpenAuth.Mvc/Views/{Home/Login.cshtml => Login/Index.cshtml} (85%) diff --git a/InitModule.sql b/InitModule.sql new file mode 100644 index 0000000000000000000000000000000000000000..87542859a76a736a5b88c29e3cb3e19f8ef837a7 GIT binary patch literal 3720 zcmeHK%Ps>^82(lk67Ntel?X)N7 z)NWO|A4l9jmwu)$hc#6xX{{p5*eG+&#>zt$w37u29m4{H-*bNAD0x*mH4=@AA0g2>A-bab{$7s{ zd;O++e8}q1Xk)DC@9`Wbj_By`^ta-L;*aWU)7?sEo`YP{7GZz4cgn{D3>dZ;@O1ff z<7Ysc=-_`~Uy| literal 0 HcmV?d00001 diff --git a/OpenAuth.App/LoginApp.cs b/OpenAuth.App/LoginApp.cs index 9cab5e34..52d89597 100644 --- a/OpenAuth.App/LoginApp.cs +++ b/OpenAuth.App/LoginApp.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using OpenAuth.Domain; using OpenAuth.Domain.Interface; +using System; +using Infrastructure.Helper; +using OpenAuth.Domain; namespace OpenAuth.App { @@ -16,15 +16,14 @@ namespace OpenAuth.App public void Login(string userName, string password) { - var user = _repository.FindSingle(u =>u.Account ==userName); + var user = _repository.FindSingle(u => u.Account == userName); if (user == null) { throw new Exception("ûʺŲ"); } - // user.CheckLogin(password); - - + user.CheckPassword(password); + SessionHelper.AddSessionUser(user); } } } \ No newline at end of file diff --git a/OpenAuth.Domain/Core/User.cs b/OpenAuth.Domain/Core/User.cs new file mode 100644 index 00000000..3c14a509 --- /dev/null +++ b/OpenAuth.Domain/Core/User.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; + +namespace OpenAuth.Domain +{ + /// + /// 用户ID + /// + public partial class User + { + public void CheckPassword(string password) + { + if (Password != password) + { + throw new Exception("密码错误"); + } + } + + } +} \ No newline at end of file diff --git a/OpenAuth.Domain/OpenAuth.Domain.csproj b/OpenAuth.Domain/OpenAuth.Domain.csproj index 0983502a..e6e982e1 100644 --- a/OpenAuth.Domain/OpenAuth.Domain.csproj +++ b/OpenAuth.Domain/OpenAuth.Domain.csproj @@ -42,6 +42,7 @@ + diff --git a/OpenAuth.Mvc/AutofacExt.cs b/OpenAuth.Mvc/AutofacExt.cs index 5b1203fd..40d4991e 100644 --- a/OpenAuth.Mvc/AutofacExt.cs +++ b/OpenAuth.Mvc/AutofacExt.cs @@ -21,7 +21,7 @@ using System.Web.Mvc; namespace OpenAuth.Mvc { - static internal class AutofacExt + internal static class AutofacExt { public static void InitAutofac() { diff --git a/OpenAuth.Mvc/Controllers/BaseController.cs b/OpenAuth.Mvc/Controllers/BaseController.cs index 14baed08..2f906f26 100644 --- a/OpenAuth.Mvc/Controllers/BaseController.cs +++ b/OpenAuth.Mvc/Controllers/BaseController.cs @@ -29,9 +29,9 @@ namespace OpenAuth.Mvc.Controllers base.OnActionExecuting(filterContext); //#region 当Session过期自动跳出登录画面 - //if (SessionHelper.GetSessionUser() == null) + //if (SessionHelper.GetSessionUser() == null) //{ - // Response.Redirect("~/Account/Login"); + // Response.Redirect("/Login/Index"); //} //#endregion } diff --git a/OpenAuth.Mvc/Controllers/HomeController.cs b/OpenAuth.Mvc/Controllers/HomeController.cs index 4b8654df..48edeb93 100644 --- a/OpenAuth.Mvc/Controllers/HomeController.cs +++ b/OpenAuth.Mvc/Controllers/HomeController.cs @@ -26,10 +26,5 @@ namespace OpenAuth.Mvc.Controllers { return View(); } - - public ActionResult Login() - { - return View(); - } } } \ No newline at end of file diff --git a/OpenAuth.Mvc/Controllers/LoginController.cs b/OpenAuth.Mvc/Controllers/LoginController.cs new file mode 100644 index 00000000..406dc91e --- /dev/null +++ b/OpenAuth.Mvc/Controllers/LoginController.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using OpenAuth.App; + +namespace OpenAuth.Mvc.Controllers +{ + public class LoginController : Controller + { + private LoginApp _app; + + public LoginController() + { + _app = (LoginApp)DependencyResolver.Current.GetService(typeof(LoginApp)); + } + // GET: Login + public ActionResult Index() + { + return View(); + } + + [HttpPost] + public ActionResult Index(string username, string password) + { + try + { + _app.Login(username, password); + return RedirectToAction("Index", "Home"); + + } + catch (Exception e) + { + return View(e.Message); + } + } + } +} \ No newline at end of file diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj index cd21d637..fc76ca1d 100644 --- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj +++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj @@ -126,6 +126,7 @@ + @@ -606,7 +607,7 @@ - + diff --git a/OpenAuth.Mvc/Views/Home/Index.cshtml b/OpenAuth.Mvc/Views/Home/Index.cshtml index 7dfd34cb..ea3225a9 100644 --- a/OpenAuth.Mvc/Views/Home/Index.cshtml +++ b/OpenAuth.Mvc/Views/Home/Index.cshtml @@ -18,7 +18,7 @@ - + diff --git a/OpenAuth.Mvc/Views/Home/Login.cshtml b/OpenAuth.Mvc/Views/Login/Index.cshtml similarity index 85% rename from OpenAuth.Mvc/Views/Home/Login.cshtml rename to OpenAuth.Mvc/Views/Login/Index.cshtml index ef897040..a31fc407 100644 --- a/OpenAuth.Mvc/Views/Home/Login.cshtml +++ b/OpenAuth.Mvc/Views/Login/Index.cshtml @@ -1,237 +1,234 @@ - - - - - 系统登录 - - - - - - - - - -
- - - -
- + + + + + 系统登录 + + + + + + + + + +
+ + + +
+ \ No newline at end of file diff --git a/数据库设计关系图/PDM_OA.pdm b/数据库设计关系图/PDM_OA.pdm index 52aa9f55..6aa233c4 100644 --- a/数据库设计关系图/PDM_OA.pdm +++ b/数据库设计关系图/PDM_OA.pdm @@ -1,5 +1,5 @@ - + @@ -12,7 +12,7 @@ PDM_OA 1430102287 yubaolee -1448847654 +1448850188 Administrator ORG {9C5FE510-8BFA-4205-BF00-FC94E77A24A2} DAT 1430102318 @@ -205,7 +205,7 @@ GenScriptName6= GenScriptName7= GenScriptName8= GenScriptName9= -GenPathName=F:\测试学习\OpenAuth.Net\ +GenPathName=E:\测试学习\OpenAuth.Net\ GenSingleFile=Yes GenODBC=Yes GenCheckModel=No