You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
4.3 KiB

  1. using EasyBL.WebApi.Filters;
  2. using EasyBL.WEBAPP;
  3. using EasyBL.WEBAPP.SYS;
  4. using Entity.ShowEasyDtos;
  5. using Entity.Sugar;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Net;
  10. using System.Net.Http;
  11. using System.Web;
  12. using System.Web.Http;
  13. namespace WebApp.Controllers
  14. {
  15. public class MembersController : ApiController
  16. {
  17. [HttpPost]
  18. //[SEApiSecurityFilter]
  19. public HttpResponseMessage Login([FromBody] Login dto)
  20. {
  21. //登陸並返回token
  22. return new MembersService().Login(dto);
  23. }
  24. [HttpPost]
  25. [SEApiSecurityFilter]
  26. public HttpResponseMessage Member([FromBody] MemberDTO Member)
  27. {
  28. var SEToken = SETokenUtil.GetToken(this.Request);
  29. Member.Account = SEToken.Account;
  30. return new MembersService().Update(Member);
  31. }
  32. /// <summary>
  33. /// 上傳文件
  34. /// </summary>
  35. /// <param name="dto"></param>
  36. /// <returns></returns>
  37. [HttpPost]
  38. public HttpResponseMessage UploadAvatar()
  39. {
  40. return new MembersService().UploadAvatar();
  41. }
  42. //註銷帳號
  43. [HttpGet]
  44. [SEApiSecurityFilter]
  45. public HttpResponseMessage DeactivateAccount()
  46. {
  47. var SEToken = SETokenUtil.GetToken(this.Request);
  48. return new MembersService().DeactivateAccount(SEToken.OrgID, SEToken.Account);
  49. }
  50. //會員個人訊息查詢
  51. [HttpGet]
  52. [SEApiSecurityFilter]
  53. public HttpResponseMessage Info()
  54. {
  55. //根據參數取得Member的詳細信息,調用時需要在Header中添加token相關信息,包括orgId,userid,timestamp,token
  56. //需要驗證的token相關信息的Api,添加上 [SEApiSecurityFilter]即可
  57. var SEToken = SETokenUtil.GetToken(this.Request);
  58. return new MembersService().GetMemberInfo(SEToken.OrgID, SEToken.Account);
  59. }
  60. //重設密碼
  61. [HttpPost]
  62. [SEApiSecurityFilter]
  63. public HttpResponseMessage ResetNewPassword(string Password)
  64. {
  65. var SEToken = SETokenUtil.GetToken(this.Request);
  66. return new MembersService().ResetNewPassword(SEToken.OrgID, SEToken.Account, Password);
  67. }
  68. [HttpGet]
  69. [SEApiSecurityFilter]
  70. public HttpResponseMessage Contacts()
  71. {
  72. var SEToken = SETokenUtil.GetToken(this.Request);
  73. return new ContactService().GetContacts(SEToken.OrgID, SEToken.Account);
  74. }
  75. [HttpPost]
  76. [SEApiSecurityFilter]
  77. public HttpResponseMessage Contact([FromBody] SETB_CRM_Contact Contact)
  78. {
  79. var SEToken = SETokenUtil.GetToken(this.Request);
  80. Contact.Account = SEToken.Account;
  81. Contact.OrgID = SEToken.OrgID;
  82. return new ContactService().SaveContact(Contact);
  83. }
  84. [HttpPost]
  85. [SEApiSecurityFilter]
  86. public HttpResponseMessage Contact(string ContactID)
  87. {
  88. var SEToken = SETokenUtil.GetToken(this.Request);
  89. var Contact = new SETB_CRM_Contact();
  90. Contact.ContactID = ContactID;
  91. Contact.Account = SEToken.Account;
  92. Contact.OrgID = SEToken.OrgID;
  93. return new ContactService().RemoveContact(Contact);
  94. }
  95. [HttpGet]
  96. [SEApiSecurityFilter]
  97. public HttpResponseMessage Companies(string Lang)
  98. {
  99. var SEToken = SETokenUtil.GetToken(this.Request);
  100. return new CompanyService().GetCompanies(SEToken.Account, Lang);
  101. }
  102. [HttpPost]
  103. [SEApiSecurityFilter]
  104. public HttpResponseMessage Company([FromBody] SETB_CRM_Company Company)
  105. {
  106. var SEToken = SETokenUtil.GetToken(this.Request);
  107. Company.Account = SEToken.Account;
  108. return new CompanyService().SaveCompany(Company);
  109. }
  110. [HttpPost]
  111. [SEApiSecurityFilter]
  112. public HttpResponseMessage Company(string CompanyID)
  113. {
  114. var SEToken = SETokenUtil.GetToken(this.Request);
  115. var Company = new SETB_CRM_Company();
  116. Company.CompanyID = CompanyID;
  117. Company.Account = SEToken.Account;
  118. return new CompanyService().RemoveCompany(Company);
  119. }
  120. }
  121. }