93 lines
2.9 KiB
C#
93 lines
2.9 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Microsoft.AspNetCore.Cors;
|
|
using Dapper;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Web;
|
|
using System.Text;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Net.Http.Headers;
|
|
using Dapper.Contrib.Extensions;
|
|
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Dynamic;
|
|
using NPOI;
|
|
using NPOI.HPSF;
|
|
using NPOI.HSSF;
|
|
using NPOI.HSSF.UserModel;
|
|
using NPOI.XSSF;
|
|
using NPOI.XSSF.UserModel;
|
|
using NPOI.POIFS;
|
|
using NPOI.Util;
|
|
using Microsoft.Extensions.Configuration;
|
|
using System.Security.Policy;
|
|
using NPOI.SS.Formula.Functions;
|
|
using static DbTableClass;
|
|
using System.Runtime.InteropServices.ObjectiveC;
|
|
using static System.Net.WebRequestMethods;
|
|
using System.Diagnostics.Eventing.Reader;
|
|
using static Journeys_WantHome.Controllers.AuthApiController;
|
|
|
|
|
|
namespace Journeys_WantHome.Controllers
|
|
{
|
|
[Route("Api")]
|
|
public class ApiController : ControllerBase
|
|
{
|
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
|
|
|
DbConn dbConn = new DbConn();
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
SqlConnection elabConn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:ElabConnectionString"));
|
|
|
|
|
|
public ApiController(IHttpContextAccessor httpContextAccessor)
|
|
{
|
|
this._httpContextAccessor = httpContextAccessor;
|
|
}
|
|
|
|
[Route("optionItemList")]
|
|
public ActionResult OptionItemList(IFormCollection obj)
|
|
{
|
|
optionListResult ret = new optionListResult();
|
|
|
|
authToken token = new authToken(this._httpContextAccessor);
|
|
if (token.user_isLogin == false)
|
|
{
|
|
HttpContext.Response.Cookies.Delete("token_key");
|
|
ret.ret = "no";
|
|
ret.err_code = "99999";
|
|
ret.message = "非登入狀態!";
|
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
|
}
|
|
|
|
|
|
|
|
string option_uid = obj["option_uid"].ToString();
|
|
|
|
if (option_uid == "")
|
|
{
|
|
ret.ret = "no";
|
|
ret.err_code = "00001";
|
|
ret.message = "無option_uid資料!";
|
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
|
}
|
|
|
|
ret.optionItems = conn.Query<optionItem>("select * from optionItem where optionItem_ishide = 'N' and option_uid = @option_uid order by optionItem_order ", new { option_uid = option_uid }).ToList();
|
|
ret.ret = "yes";
|
|
return Content(JsonConvert.SerializeObject(ret), "application/json;charset=utf-8");
|
|
}
|
|
|
|
|
|
}
|
|
}
|