| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  | <%--  | 
					
						
							|  |  |  | Name: Database Table Properties | 
					
						
							|  |  |  | Author: yubaolee | 
					
						
							|  |  |  | Description: Create a list of properties from a database table | 
					
						
							|  |  |  | --%> | 
					
						
							|  |  |  | <%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="控制器" %> | 
					
						
							|  |  |  | <%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %> | 
					
						
							|  |  |  | <%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %> | 
					
						
							|  |  |  | <%@ Assembly Name="SchemaExplorer" %> | 
					
						
							|  |  |  | <%@ Import Namespace="SchemaExplorer" %> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using System; | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  | using System.Linq; | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  | using Infrastructure; | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  | using Microsoft.AspNetCore.Mvc; | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  | using OpenAuth.App; | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  | using OpenAuth.App.Interface; | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  | using OpenAuth.App.Request; | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  | using OpenAuth.Repository.Domain; | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace OpenAuth.Mvc.Controllers | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-18 22:37:51 +08:00
										 |  |  |     public class <%=ModuleName%>sController : BaseController | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |         private readonly <%=ModuleName%>App _app; | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |          public <%=ModuleName%>sController(<%=ModuleName%>App app, IAuth auth) : base(auth) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             _app = app; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         //主页 | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         public ActionResult Index() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return View(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 23:38:53 +08:00
										 |  |  |         /// <summary> | 
					
						
							|  |  |  |         /// MVC界面添加 | 
					
						
							|  |  |  |         /// </summary> | 
					
						
							|  |  |  |         /// <param name="obj"></param> | 
					
						
							|  |  |  |         /// <returns></returns> | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |         [HttpPost] | 
					
						
							| 
									
										
										
										
											2021-05-07 23:38:53 +08:00
										 |  |  |         public string Add(AddOrUpdate<%=ModuleName%>Req obj) | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |                 _app.Add(obj); | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 Result.Code = 500; | 
					
						
							|  |  |  |                 Result.Message = ex.Message; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             return JsonHelper.Instance.Serialize(Result); | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 23:38:53 +08:00
										 |  |  |         /// <summary> | 
					
						
							|  |  |  |         /// MVC界面修改 | 
					
						
							|  |  |  |         /// </summary> | 
					
						
							|  |  |  |         /// <param name="obj"></param> | 
					
						
							|  |  |  |         /// <returns></returns> | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |         [HttpPost] | 
					
						
							| 
									
										
										
										
											2021-05-07 23:38:53 +08:00
										 |  |  |         public string Update(AddOrUpdate<%=ModuleName%>Req obj) | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |                 _app.Update(obj); | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |             } | 
					
						
							|  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  |                 Result.Code = 500; | 
					
						
							|  |  |  |                 Result.Message = ex.Message; | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  |             return JsonHelper.Instance.Serialize(Result); | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2017-12-18 22:37:51 +08:00
										 |  |  |         /// 加载列表 | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         /// </summary> | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |         public string Load([FromQuery]Query<%=ModuleName%>ListReq request) | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |             return JsonHelper.Instance.Serialize(_app.Load(request)); | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |         [HttpPost] | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  |         public string Delete(string[] ids) | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         { | 
					
						
							|  |  |  |             try | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2020-10-22 14:59:36 +08:00
										 |  |  |                 _app.Delete(ids); | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |             } | 
					
						
							|  |  |  |             catch (Exception e) | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  |                 Result.Code = 500; | 
					
						
							|  |  |  |                 Result.Message = e.Message; | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-15 00:03:06 +08:00
										 |  |  |             return JsonHelper.Instance.Serialize(Result); | 
					
						
							| 
									
										
										
										
											2017-11-29 18:26:36 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-11-22 23:54:21 +08:00
										 |  |  | } |