1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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<ResultMessage> SaveUserRoleList([FromBody] dynamic inputObj)
- {
- try
- {
- Guid? roleId = inputObj.roleId;
- List<Guid> userIds = inputObj.userIds.ToObject<List<Guid>>();
- await UserRoleService.SaveUserRoleList(roleId, userIds);
- return ResultMessage.Success();
- }
- catch (Exception ex)
- {
- return ResultMessage.GetError(ex.Message);
- }
- }
- [HttpPost]
- [FunctionCode("990203")]
- public async Task<ResultMessage> 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);
- }
- }
- }
- }
|