Skip to content

Commit

Permalink
完善事件权限管理
Browse files Browse the repository at this point in the history
  • Loading branch information
hogenwang committed Jun 25, 2024
1 parent 2543005 commit 3328ba0
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 8 deletions.
79 changes: 79 additions & 0 deletions COMCMS.Web/Areas/AdminCP/Controllers/PermissionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,85 @@ public IActionResult AddEventKey(IFormCollection fc)

return Json(tip);
}

#region 编辑事件详情
[HttpGet]
[MyAuthorize("add", "eventkey")]
public IActionResult EditEventKey(int id)
{
TargetEvent entity = TargetEvent.Find(TargetEvent._.Id == id);
if (entity == null)
{
return EchoTipPage("系统找不到本记录!");
}
Admin.WriteLogActions("查看/编辑事件详情(id:" + entity.Id + ");");
return View(entity);
}

[HttpPost]
[MyAuthorize("add", "eventkey","JSON")]
public IActionResult EditEventKey(TargetEvent model)
{
if (string.IsNullOrWhiteSpace(model.EventKey))
{
tip.Message = "请填写事件KEY";
return Json(tip);
}
if (string.IsNullOrWhiteSpace(model.EventName))
{
tip.Message = "请填写事件名称";
return Json(tip);
}
TargetEvent entity = TargetEvent.Find(TargetEvent._.Id == model.Id);
if (entity == null)
{
tip.Message = "系统找不到本记录!";
return Json(tip);
}
if (entity.EventKey != model.EventKey)
{
if (TargetEvent.FindCount(TargetEvent._.EventKey == model.EventKey, null, null, 0, 0) > 0)
{
tip.Message = "事件key已经存在,请重新填写一个";
return Json(tip);
}
}
entity.EventKey = model.EventKey;
entity.EventName = model.EventName;
entity.Rank = model.Rank;
if (string.IsNullOrWhiteSpace(Request.Form["IsDisable"]) || Request.Form["IsDisable"] != "1")
entity.IsDisable = 0;
else
entity.IsDisable = 1;
entity.Update();
Admin.WriteLogActions("编辑事件详情(id:" + entity.Id + ");");
tip.Status = JsonTip.SUCCESS;
tip.Message = "编辑事件权限详情成功";
tip.ReturnUrl = "close";
return Json(tip);
}
#endregion

#region 删除事件权限
[HttpPost]
[MyAuthorize("del", "eventkey", "JSON")]
public JsonResult DelEventKey(int id)
{
TargetEvent entity = TargetEvent.Find(TargetEvent._.Id == id);
if (entity == null)
{
tip.Message = "系统找不到本记录!";
return Json(tip);
}
Admin.WriteLogActions("删除事件详情(" + JsonConvert.SerializeObject(entity) + ");");
entity.Delete();
tip.Status = JsonTip.SUCCESS;
tip.Message = "删除事件权限详情成功";
return Json(tip);
}

#endregion

#endregion

#region 后台栏目管理
Expand Down
2 changes: 1 addition & 1 deletion COMCMS.Web/Areas/AdminCP/Views/Index/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
{
var l2 = Model.FindAll(s => s.PId == m1.Id && s.IsHide != 1);
<li>
<a href="/AdminCP/@(m1.Link)" id="@m1.MenuKey" @(m1.Link != "#" ? "class=J_menuItem" : "") >
<a href="@(m1.Link=="#"?"javascript:;":"/AdminCP/"+m1.Link)" id="@m1.MenuKey" @(m1.Link != "#" ? "class=J_menuItem" : "")>
@if (!string.IsNullOrWhiteSpace(m1.ClassName))
{
<i class="fa @m1.ClassName"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">禁用:</label>
<div class="col-sm-8">
<label>
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsDisable" id="IsDisable"> 禁用
</label>
</div>
Expand Down
56 changes: 56 additions & 0 deletions COMCMS.Web/Areas/AdminCP/Views/Permission/EditEventKey.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@model TargetEvent
@{
ViewBag.title = "查看/编辑权限事件";
}

<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>@(ViewBag.title)</h5>
<div class="ibox-tools">
</div>
</div>
<div class="ibox-content">
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editEventKeyForm", @class = "form-horizontal m-t" }))
{
<div class="form-group">
<label class="col-sm-3 control-label">事件key:</label>
<div class="col-sm-8">
<input id="EventKey" name="EventKey" minlength="2" maxlength="50" type="text" class="form-control" required aria-required="true" value="@Model.EventKey">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">事件名称:</label>
<div class="col-sm-8">
<input id="EventName" type="text" class="form-control" name="EventName" required aria-required="true" value="@Model.EventName">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">排序:</label>
<div class="col-sm-8">
<input id="Rank" type="number" class="form-control" name="Rank" value="@Model.Rank" required aria-required="true">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">禁用:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks">
<input type="checkbox" value="1" name="IsDisable" id="IsDisable" @(Model.IsDisable == 1 ? "checked" : "")> 禁用
</label>
</div>
</div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-3">
<button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 提交 </button>
<button class="btn btn-default" type="button" onclick="closethisdialog();"><i class="fa fa-close"></i> 取消 </button>
</div>
</div>
}
</div>
</div>
</div>
<script>
$(function () {
DoPost("editEventKeyForm");
})
</script>
27 changes: 22 additions & 5 deletions COMCMS.Web/Areas/AdminCP/Views/Permission/EventKey.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
columns: [{
checkbox: true
}, {
field: 'EventName',
title: '事件名称'
}, {
Expand All @@ -80,8 +78,22 @@
title: '排序'
}, {
field: 'IsDisable',
title: '是否禁用'
}, ]
title: '是否禁用',
formatter: function (value, row, index) {
if (value == 0) {
return '<span class="label label-primary">启用</span>';
} else {
return '<span class="label label-danger">禁用</span>';
}
}
},
{
field: 'Id',
title: '操作',
formatter: 'actionFormatter',
width: 140
}
]
});
};
Expand All @@ -96,7 +108,12 @@
};
return oTableInit;
};
function actionFormatter(value, row, index) {
return [
'<a href="javascript:;" class="btn btn-xs btn-primary" title="编辑" onclick="top.showDialog(\'eidtEventKey\', \'编辑事件权限详情\', \'/AdminCP/Permission/EditEventKey/' + value + '\', 0, 0)"><i class="fa fa-edit"></i> 编辑</a>',
'<a href="javascript:;" class="btn btn-xs btn-danger m-l-xs" title="删除" onclick="doDel(\'/AdminCP/Permission/DelEventKey\',' + value + ');"><i class="fa fa-close"></i> 删除</a>',
].join('');
}
var ButtonInit = function () {
var oInit = new Object();
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# COMCMS_NETCORE
COMCMS NETCORE版本,一个简单的CMS后台管理系统,带前台演示。
主要是演示了.net core 一个系统后台如何搭建。前台如何使用。可以简单的完成一个企业站。通过二次开发,可以支持商城系统、小程序、app服务器端等...
主要是演示了.net 8 一个系统后台如何搭建。前台如何使用。可以简单的完成一个企业站。通过二次开发,可以支持商城系统、小程序、app服务器端等...


### 更新日志
- 2024-06-26 升级到.net 8 调整后台UI,精简js插件
- 2022-11-23 升级到.net 7 和使用SkiaSharp 替换掉System.Drawing
- 2021-02-02 升级组件,删除ZKWeb组件,增加文章Tag标签
- 2020-12-02 升级到.net5;增加文章栏目、商品分类快速修改排序;增加jwt授权登录
Expand Down

0 comments on commit 3328ba0

Please sign in to comment.