59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Data;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Web;
|
|
using REPORT_API_ver6.Services;
|
|
using REPORT_API_ver6.Models;
|
|
using System.Net.Http;
|
|
|
|
namespace REPORT_API_ver6.Controllers
|
|
{
|
|
[Route("api/v1/log")]
|
|
[ApiController]
|
|
public class LogAPI : ControllerBase
|
|
{
|
|
[Route("visit")]
|
|
[HttpPost]
|
|
public IActionResult visitLog([FromHeader] string token ,[FromBody] VisitLogParam visitLog, [FromHeader] string skey)
|
|
{
|
|
UserInfo userInfo = Security.ValidateToken(token);
|
|
if(userInfo != null)
|
|
{
|
|
PkeyInfo pkeyInfo = new PkeyInfo();
|
|
if (String.IsNullOrEmpty(skey) == false)
|
|
{
|
|
pkeyInfo = new PkeyInfo(skey);
|
|
}
|
|
Log.InsertVisitLog(userInfo.ID, pkeyInfo.Pkey, visitLog.LogContent);
|
|
Response.StatusCode = (int)HttpStatusCode.OK;
|
|
return Content("PASS");
|
|
}
|
|
|
|
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
|
return Content(null);
|
|
}
|
|
|
|
[Route("site")]
|
|
[HttpPost]
|
|
public IActionResult siteLog([FromHeader] string token, [FromBody] SiteLogParam siteLog, [FromHeader] string skey)
|
|
{
|
|
UserInfo userInfo = Security.ValidateToken(token);
|
|
if (userInfo != null)
|
|
{
|
|
PkeyInfo pkeyInfo = new PkeyInfo(skey);
|
|
Log.InsertSiteLog(userInfo.ID, pkeyInfo.Pkey, siteLog.LogTitle, siteLog.LogContent);
|
|
|
|
Response.StatusCode = (int)HttpStatusCode.OK;
|
|
return Content("PASS");
|
|
}
|
|
|
|
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
|
return Content(null);
|
|
}
|
|
}
|
|
}
|