using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Mini.Common; using Mini.Model.CrmModel; using Mini.Model.Entity; using Mini.Model.ViewModel; using Mini.Services.Bas; using Mini.Services.ww; using Mini.Web.WebHelper; namespace Mini.Web.Areas.Admin.Controllers { /// /// 我的企业微信员工管理 /// public class MyHHuserController : BaseController { private readonly Iww_hhuser_Service _iww_hhuser_service; private readonly IBasParameterService _bas_parameter; public MyHHuserController(Iww_hhuser_Service iww_hhuser_service, IBasParameterService bas_parameter) { this._iww_hhuser_service = iww_hhuser_service; this._bas_parameter = bas_parameter; } #region 企业微信聊天记录 [AuthorizeRedirect(Roles = InitRights.CONST_我的企微员工管理)] [Area("Admin")] public ActionResult Index() { //ToolBar ToolBar tool = new ToolBar(); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.我的企微员工管理, userRightId); tool.AllowButton(toolbtn); tool.AddOtherButton("Other1", "聊天记录", "", "", true); tool.AddOtherButton("Other2", "外部联系人", "", "", true); tool.AddOtherButton("Other3", "设置工号", "", "", true); ViewBag.ToolBar = tool; List list = _iww_hhuser_service.Corp_Get(); List selectlist = new List(); selectlist.Add(new SelectListItem() { Value = "", Text = "请选择" }); foreach (Ww_Corp item in list) { selectlist.Add(new SelectListItem() { Text = item.corpname, Value = item.corpid }); } ViewBag.Select = selectlist; return View(); } [HttpPost] [Area("Admin")] [AuthorizeRedirect(Roles = InitRights.CONST_我的企微员工管理)] public JsonResult GetWeWorktHtmlList(Laypage pager, string name, string corp,string eid, string columns) { var layUidata = new LayuiData(); try { var controldept = _iww_hhuser_service.GetMyControlDeptId(userRoleId); List list = _iww_hhuser_service.WorList_Get_ByCompany(1,ref pager, name, corp, eid, controldept); layUidata.msg = "数据加载成功"; layUidata.code = 0; layUidata.data = list; layUidata.count = pager.count; } catch (Exception ex) { LogHelper.Error(ex.ToString()); layUidata.SetFail(1, "出现错误!" + ex.Message); } return Json(layUidata); } [HttpGet] [Area("Admin")] [AuthorizeToolBar(InitRights.CONST_我的企微员工管理, InitToolBar.CONST_Other3)] public ActionResult SetEid(string corp, string userid) { Ww_hhuser_Eid model = new Ww_hhuser_Eid(); if (string.IsNullOrEmpty(userid) || string.IsNullOrEmpty(corp)) { ViewBag.isOK = "0"; ViewBag.Msg = "参数不对!"; } else { model = _iww_hhuser_service.GetHHuserEid(userid, corp); if (model == null) { model = new Ww_hhuser_Eid() { corpid = corp, userid = userid }; } } return View(model); } [HttpPost] [AuthorizeToolBar(InitRights.CONST_我的企微员工管理, InitToolBar.CONST_Other3)] [Area("Admin")] public JsonResult SetEidSave(Ww_hhuser_Eid model) { ValidationErrors erro = new ValidationErrors(); bool result = _iww_hhuser_service.UpdateHHuserEid(ref erro, model); retMsg ret = new retMsg() { result = result, retcode = 200, retmsg = "设置成功!" }; if (!result) { ret.retmsg = erro.Error; } return Json(ret); } #endregion } }