ComplianceServer/oldcode/WEB/Controllers/Base/RightController.cs

112 lines
3.8 KiB
C#

using System;
using System.Web.Mvc;
using WX.CRM.Common;
using WX.CRM.IBLL.Base;
using WX.CRM.Model.Entity;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.Base
{
public class RightController : Controller
{
private IBAS_RIGHT rightBiz;
private IBAS_RIGHT_Q rightBiz_Q;
ValidationErrors errors = new ValidationErrors();
public RightController(IBAS_RIGHT _rightBiz, IBAS_RIGHT_Q _rightBiz_Q)
{
this.rightBiz = _rightBiz;
this.rightBiz_Q = _rightBiz_Q;
}
#region
public ActionResult Details(string id)
{
WX.CRM.Model.Entity.BAS_RIGHT model = new WX.CRM.Model.Entity.BAS_RIGHT();
if (id != null)
model = rightBiz_Q.GetModel(id);
return View(model);
}
#endregion
#region
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_权限结构管理, InitToolBar.CONST_Edit)]
public ActionResult Edit(string id)
{
WX.CRM.Model.Entity.BAS_RIGHT model = new WX.CRM.Model.Entity.BAS_RIGHT();
if (id != null)
model = rightBiz_Q.GetModel(id);
string fid = Request.QueryString["fid"];
model.GROUPID = string.IsNullOrEmpty(model.RIGHTID) ? Convert.ToDecimal(fid) : model.GROUPID;
return View(model);
}
[HttpPost]
[AuthorizeToolBar(InitRights.CONST_权限结构管理, InitToolBar.CONST_Edit)]
public JsonResult Edit(WX.CRM.Model.Entity.BAS_RIGHT model)
{
if (!ModelState.IsValid)
return JsonHandler.ValidateFailMessage();
if (string.IsNullOrEmpty(model.RIGHTID))
{
model.CTIME = DateTime.Now;
bool result = rightBiz.Create(ref errors, model);
return JsonHandler.InsertMessage(errors, result);
}
else
{
bool result = rightBiz.Update(ref errors, model);
return JsonHandler.UpdateMessage(errors, result);
}
}
#endregion
#region
[HttpGet]
[AuthorizeToolBar(InitRights.CONST_权限结构管理, InitToolBar.CONST_Other4)]
public ActionResult Add()
{
WX.CRM.Model.Entity.BAS_RIGHT model = new WX.CRM.Model.Entity.BAS_RIGHT();
string fid = Request.QueryString["fid"];
model.GROUPID = string.IsNullOrEmpty(model.RIGHTID) ? Convert.ToDecimal(fid) : model.GROUPID;
return View(model);
}
[HttpPost]
[AuthorizeToolBar(InitRights.CONST_权限结构管理, InitToolBar.CONST_Other4)]
public JsonResult ADD(WX.CRM.Model.Entity.BAS_RIGHT model)
{
if (!ModelState.IsValid)
return JsonHandler.ValidateFailMessage();
BAS_RIGHT IsExist = rightBiz_Q.GetModel(model.map_RightId);
if (IsExist != null)
{
errors.Add("该权限已存在");
return JsonHandler.InsertMessage(errors, false);
}
else
{
model.CTIME = DateTime.Now;
model.map_PKID = model.map_PKID == 0 ? null : model.GROUPID;
bool result = rightBiz.Create(ref errors, model);
return JsonHandler.InsertMessage(errors, result);
}
}
#endregion
#region
[AuthorizeToolBar(InitRights.CONST_权限结构管理, InitToolBar.CONST_Delete)]
public JsonResult Delete(string id)
{
if (string.IsNullOrWhiteSpace(id))
{
return JsonHandler.ManageMessage("删除失败", false);
}
bool result = rightBiz.Delete(ref errors, id);
return JsonHandler.DeleteMessage(errors, result);
}
#endregion
}
}