160 lines
5.3 KiB
C#
160 lines
5.3 KiB
C#
using Ninject;
|
|
using System;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.IBLL.Wx;
|
|
using WX.CRM.Model.Entity;
|
|
using WX.CRM.WebHelper;
|
|
|
|
namespace WX.CRM.WEB.Controllers.WeiXin
|
|
{
|
|
public class NoticeController : BaseController
|
|
{
|
|
private ValidationErrors errors = new ValidationErrors();
|
|
|
|
[Inject]
|
|
public IWX_USERIMEI wx_userIMEI_BL { get; set; }
|
|
|
|
[Inject]
|
|
public IBAS_NOTICE bas_Notice_BL { get; set; }
|
|
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_内部公告)]
|
|
public ActionResult Index()
|
|
{
|
|
ToolBar tool = new ToolBar();
|
|
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.内部公告, userRightId);
|
|
tool.AllowButton(toolbtn);
|
|
ViewBag.ToolBar = tool;
|
|
Pager pager = new Pager() { page = 1, rows = 20 };
|
|
var tableId = "tablist";
|
|
Table tab = new Table(tableId);
|
|
tab.AddHiddenHeadCol("PKID", "编号");
|
|
tab.AddHeadCol("TITLE", "32%", "标题");
|
|
tab.AddHeadCol("CTIME", "32%", "创建时间");
|
|
tab.AddHeadCol("INNERUSER", "32%", "操作人");
|
|
tab.AddHeadRow();
|
|
ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, tableId, "5,10,15,20");
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_内部公告)]
|
|
public JsonResult GetHtmlList(Pager pager, string title, string stime, string etime, string columns)
|
|
{
|
|
var list = bas_Notice_BL.GetList(ref pager, title, stime, etime);
|
|
Table table = new Table(columns, true);
|
|
foreach (var model in list)
|
|
{
|
|
table.AddHiddenCol(model.PKID);
|
|
table.AddCol(model.TITLE);
|
|
table.AddCol(model.CTIME);
|
|
table.AddCol(InnerUserHelper.Instance.GetEidAndTrueName(model.INNERUSERID));
|
|
table.AddRow();
|
|
}
|
|
var json = new
|
|
{
|
|
totalPages = pager.totalPages,
|
|
totalRows = pager.totalRows,
|
|
rowsList = table.GetRows()
|
|
};
|
|
return Json(json, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_内部公告)]
|
|
public ActionResult Add()
|
|
{
|
|
BAS_NOTICE model = new BAS_NOTICE();
|
|
return View(model);
|
|
}
|
|
|
|
|
|
[AuthorizeRedirect(Roles = InitRights.CONST_内部公告)]
|
|
public ActionResult Edit(string id)
|
|
{
|
|
decimal i = 0;
|
|
decimal.TryParse(id, out i);
|
|
BAS_NOTICE model;
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
model = new BAS_NOTICE();
|
|
}
|
|
else
|
|
{
|
|
model = bas_Notice_BL.Get(m => m.PKID == i);
|
|
}
|
|
return View(model);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ValidateInput(false)]
|
|
[AuthorizeToolBar(Roles = InitRights.CONST_内部公告, TooBarId = InitToolBar.CONST_Add)]
|
|
public JsonResult Add(BAS_NOTICE model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
errors.Add("参数不能为空!");
|
|
return JsonHandler.InsertMessage(errors, false);
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.TITLE))
|
|
{
|
|
errors.Add("标题不能为空!");
|
|
return JsonHandler.InsertMessage(errors, false);
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.CONTENT))
|
|
{
|
|
errors.Add("内容不能为空!");
|
|
return JsonHandler.InsertMessage(errors, false);
|
|
}
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
model.CTIME = DateTime.Now;
|
|
model.INNERUSERID = UserId;
|
|
var flag = bas_Notice_BL.Add(model);
|
|
return JsonHandler.InsertMessage(errors, flag == 1);
|
|
}
|
|
|
|
[HttpPost]
|
|
[ValidateInput(false)]
|
|
[AuthorizeToolBar(Roles = InitRights.CONST_内部公告, TooBarId = InitToolBar.CONST_Edit)]
|
|
public JsonResult Edit(BAS_NOTICE model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
errors.Add("参数不能为空!");
|
|
return JsonHandler.InsertMessage(errors, false);
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.TITLE))
|
|
{
|
|
errors.Add("标题不能为空!");
|
|
return JsonHandler.InsertMessage(errors, false);
|
|
}
|
|
if (string.IsNullOrWhiteSpace(model.CONTENT))
|
|
{
|
|
errors.Add("内容不能为空!");
|
|
return JsonHandler.InsertMessage(errors, false);
|
|
}
|
|
model.INNERUSERID = UserId;
|
|
var flag = bas_Notice_BL.Update(model);
|
|
return JsonHandler.UpdateMessage(errors, flag);
|
|
}
|
|
|
|
public ActionResult Detail(string id)
|
|
{
|
|
decimal i = 0;
|
|
decimal.TryParse(id, out i);
|
|
BAS_NOTICE model;
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
model = new BAS_NOTICE();
|
|
}
|
|
else
|
|
{
|
|
model = bas_Notice_BL.Get(m => m.PKID == i);
|
|
}
|
|
return View(model);
|
|
}
|
|
}
|
|
} |