112 lines
3.8 KiB
C#
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
|
|
}
|
|
}
|