AdminOrganizationController.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Common.Page;
  4. using GxPress.Repository.Interface.Organization;
  5. using GxPress.Request.OrganizationUser;
  6. using GxPress.Result.Organization;
  7. using GxPress.Service.Interface.OrganizationUser;
  8. using Microsoft.AspNetCore.Authorization;
  9. using Microsoft.AspNetCore.Mvc;
  10. namespace GxPress.Api.AdminControllers
  11. {
  12. [Route("api/admin/organization")]
  13. [ApiController]
  14. [Authorize]
  15. public class AdminOrganizationController : Controller
  16. {
  17. private readonly IOrganizationRepository repository;
  18. private readonly IOrganizationUserService service;
  19. private readonly IOrganizationUserRepository organizationUserRepository;
  20. public AdminOrganizationController(IOrganizationRepository repository, IOrganizationUserService service, IOrganizationUserRepository organizationUserRepository)
  21. {
  22. this.repository = repository;
  23. this.service = service;
  24. this.organizationUserRepository = organizationUserRepository;
  25. }
  26. /// <summary>
  27. /// 添加机构用户
  28. /// </summary>
  29. /// <param name="model"></param>
  30. /// <returns></returns>
  31. [HttpPost("add-user")]
  32. public async Task<bool> InsertOrganizationUserAsync(Entity.tede2.Organization.OrganizationUser model)
  33. {
  34. if (model.OrganizationId == 0)
  35. throw new Common.Exceptions.BusinessException("机构ID必填");
  36. if (string.IsNullOrEmpty(model.LoginAccountNumber))
  37. throw new Common.Exceptions.BusinessException("登陆账号必填");
  38. if (string.IsNullOrEmpty(model.UserName))
  39. throw new Common.Exceptions.BusinessException("用户名必填");
  40. if (string.IsNullOrEmpty(model.Phone))
  41. throw new Common.Exceptions.BusinessException("手机号码必填");
  42. if (model.Phone.Length != 11)
  43. throw new Common.Exceptions.BusinessException("手机号码有误");
  44. return await service.InsertAsync(model);
  45. }
  46. /// <summary>
  47. /// 机构用户启用停用
  48. /// </summary>
  49. /// <param name="request"></param>
  50. /// <returns></returns>
  51. [HttpPut("user-updat-disable")]
  52. public async Task<bool> UpdateDisableAsync(OrganizationUserDisableUpdateRequest request)
  53. {
  54. return await organizationUserRepository.UpdateDisableAsync(request);
  55. }
  56. /// <summary>
  57. /// 机构用户删除
  58. /// </summary>
  59. /// <param name="ids"></param>
  60. /// <returns></returns>
  61. [HttpDelete("user-delete")]
  62. public async Task<bool> UserDeleteAsync(List<int> ids)
  63. {
  64. return await service.DeleteAsync(ids);
  65. }
  66. /// <summary>
  67. /// 机构用户列表
  68. /// </summary>
  69. /// <param name="request"></param>
  70. /// <returns></returns>
  71. [HttpPost("user-list")]
  72. public async Task<PagedList<Entity.tede2.Organization.OrganizationUser>> GetSearchAllAsync(OrganizationUserSearchRequest request)
  73. {
  74. return await organizationUserRepository.GetSearchAllAsync(request);
  75. }
  76. /// <summary>
  77. /// 机构用户修改
  78. /// </summary>
  79. /// <param name="request"></param>
  80. /// <returns></returns>
  81. [HttpPut("user-updat")]
  82. public async Task<bool> UpdateAsync(OrganizationUserUpdateRequest request)
  83. {
  84. return await organizationUserRepository.UpdateAsync(request);
  85. }
  86. /// <summary>
  87. /// 机构列表
  88. /// </summary>
  89. /// <param name="request"></param>
  90. /// <returns></returns>
  91. [HttpPost]
  92. public async Task<PagedList<Entity.tede2.Organization.Organization>> GetAllAsync(OrganizationListRequest request)
  93. {
  94. return await repository.GetAllAsync(request);
  95. }
  96. /// <summary>
  97. /// 修改
  98. /// </summary>
  99. /// <param name="request"></param>
  100. /// <returns></returns>
  101. [HttpPut]
  102. public async Task<bool> UpdateAsync(OrganizationUpdateRequest request)
  103. {
  104. return await repository.UpdateAsync(request);
  105. }
  106. /// <summary>
  107. /// 删除
  108. /// </summary>
  109. /// <param name="ids"></param>
  110. /// <returns></returns>
  111. [HttpDelete]
  112. public async Task<bool> DeleteAsync(List<int> ids)
  113. {
  114. return await repository.DeleteAsync(ids);
  115. }
  116. /// <summary>
  117. /// 修改
  118. /// </summary>
  119. /// <param name="request"></param>
  120. /// <returns></returns>
  121. [HttpPut("update")]
  122. public async Task<bool> UpdateIsDisableAsync(OrganizationUpdateDisableRequest request)
  123. {
  124. return await repository.UpdateIsDisableAsync(request);
  125. }
  126. /// <summary>
  127. /// 添加
  128. /// /// </summary>
  129. /// <param name="model"></param>
  130. /// <returns></returns>
  131. [HttpPost("add")]
  132. public async Task<bool> InsertAsync(Entity.tede2.Organization.Organization model)
  133. {
  134. return await repository.InsertAsync(model);
  135. }
  136. }
  137. }