firts commit
This commit is contained in:
58
REPORT_API_ver6/Controllers/LogAPI.cs
Normal file
58
REPORT_API_ver6/Controllers/LogAPI.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user