ClientController.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System.Threading.Tasks;
  2. using System.Web.Mvc;
  3. using Abp.Web.Mvc.Authorization;
  4. using Abp.Runtime.Caching;
  5. using Abp.UI;
  6. using ContractService.Authorization;
  7. using ContractService.BaseSystem.Query;
  8. using ContractService.Configuration;
  9. using ContractService.LegalContract;
  10. using IwbZero.Runtime.Session;
  11. using IwbZero.ToolCommon.StringModel;
  12. namespace ContractService.Controllers
  13. {
  14. [AbpMvcAuthorize]
  15. public class ClientController : IwbControllerBase
  16. {
  17. public ClientController( ICacheManager cacheManager, LegalManager legalManager, QueryAppService queryApp)
  18. {
  19. LegalManager = legalManager;
  20. QueryApp = queryApp;
  21. CacheManager = cacheManager;
  22. }
  23. public LegalManager LegalManager { get; }
  24. public QueryAppService QueryApp { get; }
  25. [AbpMvcAuthorize]
  26. public ActionResult Company()
  27. {
  28. if (AbpSession.AccountType == AccountTypeDefinition.System)
  29. {
  30. return View();
  31. }
  32. if (AbpSession.AccountType == AccountTypeDefinition.Client && LegalManager.IsCompanyMaster(AbpSession.AccountNo,out var companyNo))
  33. {
  34. ViewBag.CompanyNo = companyNo;
  35. return View("CompanyDetail");
  36. }
  37. if (AbpSession.AccountType == AccountTypeDefinition.Client && AbpSession.GetClaimValue(IwbConsts.UserCompanyLawFirmClaimType).Empty())
  38. {
  39. throw new UserFriendlyException("当前账号未绑定企业员工,不能访问!");
  40. }
  41. CheckErrors("非法账号,不能访问!");
  42. return View();
  43. }
  44. [AbpMvcAuthorize]
  45. public ActionResult Staff()
  46. {
  47. if (AbpSession.AccountType != AccountTypeDefinition.Client&&AbpSession.AccountType != AccountTypeDefinition.System)
  48. {
  49. CheckErrors("非法账号,不能访问!");
  50. }
  51. if (AbpSession.AccountType == AccountTypeDefinition.Client && AbpSession.GetClaimValue(IwbConsts.UserCompanyLawFirmClaimType).Empty())
  52. {
  53. throw new UserFriendlyException("当前账号未绑定企业员工,不能访问!");
  54. }
  55. ViewBag.CompanyNo = AbpSession.AccountType == AccountTypeDefinition.Client
  56. ? AbpSession.GetClaimValue(IwbConsts.UserCompanyLawFirmClaimType)
  57. : null;
  58. return View();
  59. }
  60. [AbpMvcAuthorize]
  61. public ActionResult Organization()
  62. {
  63. if (AbpSession.AccountType != AccountTypeDefinition.Client)
  64. {
  65. CheckErrors("非法账号,不能访问!");
  66. }
  67. if (AbpSession.AccountType == AccountTypeDefinition.Client && AbpSession.GetClaimValue(IwbConsts.UserCompanyLawFirmClaimType).Empty())
  68. {
  69. throw new UserFriendlyException("当前账号未绑定企业员工,不能访问!");
  70. }
  71. ViewBag.CompanyNo = AbpSession.AccountType == AccountTypeDefinition.Client
  72. ? AbpSession.GetClaimValue(IwbConsts.UserCompanyLawFirmClaimType)
  73. : null;
  74. return View();
  75. }
  76. }
  77. }