using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Common.Page; using GxPress.Repository.Interface.Organization; using GxPress.Request.OrganizationUser; using GxPress.Result.Organization; using GxPress.Service.Interface.OrganizationUser; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AdminControllers { [Route("api/admin/organization")] [ApiController] [Authorize] public class AdminOrganizationController : Controller { private readonly IOrganizationRepository repository; private readonly IOrganizationUserService service; private readonly IOrganizationUserRepository organizationUserRepository; public AdminOrganizationController(IOrganizationRepository repository, IOrganizationUserService service, IOrganizationUserRepository organizationUserRepository) { this.repository = repository; this.service = service; this.organizationUserRepository = organizationUserRepository; } /// /// 添加机构用户 /// /// /// [HttpPost("add-user")] public async Task InsertOrganizationUserAsync(Entity.tede2.Organization.OrganizationUser model) { if (model.OrganizationId == 0) throw new Common.Exceptions.BusinessException("机构ID必填"); if (string.IsNullOrEmpty(model.LoginAccountNumber)) throw new Common.Exceptions.BusinessException("登陆账号必填"); if (string.IsNullOrEmpty(model.UserName)) throw new Common.Exceptions.BusinessException("用户名必填"); if (string.IsNullOrEmpty(model.Phone)) throw new Common.Exceptions.BusinessException("手机号码必填"); if (model.Phone.Length != 11) throw new Common.Exceptions.BusinessException("手机号码有误"); return await service.InsertAsync(model); } /// /// 机构用户启用停用 /// /// /// [HttpPut("user-updat-disable")] public async Task UpdateDisableAsync(OrganizationUserDisableUpdateRequest request) { return await organizationUserRepository.UpdateDisableAsync(request); } /// /// 机构用户删除 /// /// /// [HttpDelete("user-delete")] public async Task UserDeleteAsync(List ids) { return await service.DeleteAsync(ids); } /// /// 机构用户列表 /// /// /// [HttpPost("user-list")] public async Task> GetSearchAllAsync(OrganizationUserSearchRequest request) { return await organizationUserRepository.GetSearchAllAsync(request); } /// /// 机构用户修改 /// /// /// [HttpPut("user-updat")] public async Task UpdateAsync(OrganizationUserUpdateRequest request) { return await organizationUserRepository.UpdateAsync(request); } /// /// 机构列表 /// /// /// [HttpPost] public async Task> GetAllAsync(OrganizationListRequest request) { return await repository.GetAllAsync(request); } /// /// 修改 /// /// /// [HttpPut] public async Task UpdateAsync(OrganizationUpdateRequest request) { return await repository.UpdateAsync(request); } /// /// 删除 /// /// /// [HttpDelete] public async Task DeleteAsync(List ids) { return await repository.DeleteAsync(ids); } /// /// 修改 /// /// /// [HttpPut("update")] public async Task UpdateIsDisableAsync(OrganizationUpdateDisableRequest request) { return await repository.UpdateIsDisableAsync(request); } /// /// 添加 /// /// /// /// [HttpPost("add")] public async Task InsertAsync(Entity.tede2.Organization.Organization model) { return await repository.InsertAsync(model); } } }