using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Bowin.Common.ServiceToken.Permission; using Bowin.Common.WebModels; using YLShipBuildLandMap.Entity; using YLShipBuildLandMap.Entity.ViewModel; using YLShipBuildLandMap.Entity.ViewModel.SystemSetting; using YLShipBuildLandMap.Services.SystemSetting; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; namespace YLShipBuildLandMap.Web.Controllers.SystemSetting { [Route("api/systemsetting/[controller]/[action]")] [ApiController] [Authorize] public class UserRoleController : ControllerBase { private IUserRoleService UserRoleService { get; set; } public UserRoleController(IUserRoleService userRoleService) { UserRoleService = userRoleService; } [HttpPost] [FunctionCode("9902")] public ResultMessage GetUserListByRole([FromBody] dynamic inputObj) { try { Guid? roleID = inputObj.roleID; string name = inputObj.name; int? pageIndex = inputObj.pageIndex; int? pageSize = inputObj.pageSize; var userList = UserRoleService.GetUserViewListByRole(roleID, name, pageIndex, pageSize); return ResultMessage.Success(userList); } catch (Exception ex) { return ResultMessage.GetError(ex.Message); } } [HttpPost] [FunctionCode("990201")] public async Task SaveUserRoleList([FromBody] dynamic inputObj) { try { Guid? roleId = inputObj.roleId; List userIds = inputObj.userIds.ToObject>(); await UserRoleService.SaveUserRoleList(roleId, userIds); return ResultMessage.Success(); } catch (Exception ex) { return ResultMessage.GetError(ex.Message); } } [HttpPost] [FunctionCode("990203")] public async Task DeleteUserRole([FromBody] dynamic inputObj) { try { Guid UserId = inputObj.userId; Guid RoleId = inputObj.roleId; await UserRoleService.DeleteUserRole(UserId, RoleId); return ResultMessage.Success(); } catch (Exception ex) { return ResultMessage.GetError(ex.Message); } } } }