using Cksoft.Data; using Cksoft.Data.Repository; using DllEapDal; using DllEapEntity; using DllEapEntity.Dtos; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Text; namespace DllUnityWebApi { /// /// 相关 /// [Route("Eap/Api/[controller]/[action]")] [ApiController] public class AccountController : Controller { private IDatabase db = null; private StaffDal dal; [HttpPost] [AllowAnonymous] public string Login([FromBody] Staff staff) { using (IDatabase db = DbFactory.Base("sqlconn")) { dal = new StaffDal(db); string errorinfo = string.Empty; staff = dal.Login(staff, ref errorinfo); if (staff == null) return JsonConvert.SerializeObject(new { code = -1, msg = errorinfo, data = new Staff() }); return JsonConvert.SerializeObject(new { code = 1, msg = "", data = staff }); } } [HttpGet] public string SignOut() { try { return "1"; } catch (Exception e) { return e.Message; } } } }