You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.6 KiB
82 lines
1.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
|
|
using Sog;
|
|
using SimpleHttpServer;
|
|
using MySql.Data.MySqlClient;
|
|
using LitJson;
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
namespace SMWebServer
|
|
{
|
|
public class Q_menu
|
|
{ }
|
|
|
|
public class S_menu
|
|
{
|
|
public int code { get; set; }
|
|
public _menu_data data { get; set; }
|
|
|
|
public string msg { get; set; }
|
|
|
|
}
|
|
|
|
public class _menu_data
|
|
{
|
|
public List<string> menus { get; set; }
|
|
}
|
|
|
|
public class Menu
|
|
{
|
|
private MySqlDB db;
|
|
|
|
|
|
public void InitConnection()
|
|
{
|
|
SMWebServerConfig config = SMWebServerUtils.GetServerConfig();//配置
|
|
db = new MySqlDB(config.dbname,
|
|
config.dbip,
|
|
config.dbuser,
|
|
config.dbpassword);
|
|
}
|
|
private void DoSelect(Q_menu q, S_menu s, TokenInfo tokeninfo)
|
|
{
|
|
|
|
string authstrSql = string.Format("select menuname where account = \"{0}\"", tokeninfo.account);
|
|
|
|
s.data.menus = new List<string>();
|
|
|
|
MySqlDataReader readerauth = db.ExecReader(authstrSql);
|
|
|
|
|
|
while (readerauth.Read())
|
|
{
|
|
s.data.menus.Add(readerauth.GetString("menuname"));
|
|
}
|
|
readerauth.Close();
|
|
|
|
s.code = 20000;
|
|
s.msg = "ok";
|
|
|
|
}
|
|
|
|
|
|
public void ProccessRequest(Q_menu q, S_menu s, TokenInfo tokeninfo)
|
|
{
|
|
InitConnection();//初始化链接
|
|
|
|
|
|
DoSelect(q, s, tokeninfo);
|
|
|
|
db.Dispose();
|
|
|
|
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|