AccountController.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Cksoft.Data;
  2. using Cksoft.Data.Repository;
  3. using DllEapDal;
  4. using DllEapEntity;
  5. using DllEapEntity.Dtos;
  6. using Microsoft.AspNetCore.Authorization;
  7. using Microsoft.AspNetCore.Mvc;
  8. using Newtonsoft.Json;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Text;
  12. namespace DllUnityWebApi
  13. {
  14. /// <summary>
  15. /// 相关
  16. /// </summary>
  17. [Route("Eap/Api/[controller]/[action]")]
  18. [ApiController]
  19. public class AccountController : Controller
  20. {
  21. private IDatabase db = null;
  22. private StaffDal dal;
  23. [HttpPost]
  24. [AllowAnonymous]
  25. public string Login([FromBody] Staff staff)
  26. {
  27. using (IDatabase db = DbFactory.Base("sqlconn"))
  28. {
  29. dal = new StaffDal(db);
  30. string errorinfo = string.Empty;
  31. staff = dal.Login(staff, ref errorinfo);
  32. if (staff == null)
  33. return JsonConvert.SerializeObject(new
  34. {
  35. code = -1,
  36. msg = errorinfo,
  37. data = new Staff()
  38. });
  39. return JsonConvert.SerializeObject(new
  40. {
  41. code = 1,
  42. msg = "",
  43. data = staff
  44. });
  45. }
  46. }
  47. [HttpGet]
  48. public string SignOut()
  49. {
  50. try
  51. {
  52. return "1";
  53. }
  54. catch (Exception e)
  55. {
  56. return e.Message;
  57. }
  58. }
  59. }
  60. }