SysRoleController.cs 2.05 KB
using Hh.Mes.Common.Request;
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.Service;
using Hh.Mes.Service.SystemAuth;
using Hh.Mes.Service.WebService.Base;
using Microsoft.AspNetCore.Mvc;
using System;
using WebMvc.Aop;


namespace WebMvc
{
    [Area("base")]
    public class SysRoleController : BaseController
    {
        private readonly SysRoleService service;
        private readonly SysRelevanceService relevanceService;
        public SysRoleController(IAuth authUtil, SysRoleService service, SysRelevanceService revelanceService) : base(authUtil)
        {
            this.service = service;
            this.service.sysWebUser = authUtil.GetCurrentUser().User;
            this.relevanceService = revelanceService;
            this.relevanceService.sysWebUser = authUtil.GetCurrentUser().User;
        }
        //
        // GET: /SysUser/
        [Authenticate]
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Assign()
        {
            return View();
        }

        //添加或修改组织
        [HttpPost]
        [XSSFilter]
        public string Add(SysRoleView obj)
        {
            return Serialize(service.Ins(obj));
        }

        //添加或修改组织
        [HttpPost]
        [XSSFilter]
        public string Update(SysRoleView obj)
        {
            return Serialize(service.Upd(obj));
        }

        [HttpPost]
        public string Delete(int[] ids)
        {
            return Serialize(service.DelById(ids));
        }

        /// <summary>
        /// 加载用户的角色
        /// </summary>
        public string LoadForUser(int userId)
        {
            var result = relevanceService.Get(Define.USERROLE, true, userId);
            return Serialize(result);
        }

        /// <summary>
        /// 加载组织下面的所有用户
        /// </summary>
        [HttpPost]
        public string Load(PageReq pageRequest, int? orgId)
        {
            return Serialize(service.Load(pageRequest, orgId));
        }
    }
}