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.
92 lines
3.5 KiB
92 lines
3.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
|
|
using Operation;
|
|
using Sog;
|
|
using LitJson;
|
|
using SimpleHttpServer;
|
|
using MySql.Data.MySqlClient;
|
|
using ProtoCSStruct;
|
|
|
|
namespace Operation
|
|
{
|
|
public class AddUserName
|
|
{
|
|
[RequestMapping("添加用户名",PermissionCode.ADD_USER_NAME, toLog: true)]
|
|
public static int OnAddUserNameHttpReq(string httpApiCmd, JsonData jsonData, HttpResponse rsp, HttpRequest request, HttpQueryParams query, uint httpContextId)
|
|
{
|
|
TraceLog.Trace("AddUserName.OnAddUserNameHttpReq url {0} ,param count {1} ,httpContextId {2}", request.Url, query.Count, httpContextId);
|
|
|
|
string account = query.GetValue("account") == null ? "" : query.GetValue("account");
|
|
string token = query.GetValue("token") == null ? "" : query.GetValue("token");
|
|
string user = query.GetValue("user") == null ? "" : query.GetValue("user");
|
|
string pass = query.GetValue("pass") == null ? "" : query.GetValue("pass");
|
|
string jurisdiction = query.GetValue("jurisdiction") == null ? "" : query.GetValue("jurisdiction");
|
|
|
|
TraceLog.Trace("AddUserName.OnAddUserNameHttpReq account {0} ,token {1}, user {2}, pass {3} jurisdiction {4}", account, token, user, pass, jurisdiction);
|
|
|
|
if (user == null && user == "" && pass == "")
|
|
{
|
|
jsonData["ret"] = 4;
|
|
jsonData["msg"] = "用户名和密码不能为空!";
|
|
return 4;
|
|
}
|
|
|
|
RepeatedFixedStructString128_10 data = new RepeatedFixedStructString128_10();
|
|
data.Add(account);
|
|
data.Add(token);
|
|
data.Add(user);
|
|
data.Add(pass);
|
|
data.Add(jurisdiction);
|
|
HttpApiRootHandler.FillHttpApiDbReq2MessageTaskDistributor(httpApiCmd, httpContextId, ref data);
|
|
|
|
rsp.IsWaitFor = true;
|
|
|
|
return 0;
|
|
}
|
|
|
|
public static int DoAddUserName(string httpApiCmd, SSHttpApiDbReq req, DBOperator dbOperator)
|
|
{
|
|
TraceLog.Trace("AddUserName.DoAddUserName HttpContextId {0}", req.HttpContextId);
|
|
|
|
HttpRequestInfo m_request = null;
|
|
LitJson.JsonData builder = new LitJson.JsonData();
|
|
|
|
try
|
|
{
|
|
var httpContextId = req.HttpContextId;
|
|
m_request = OperationServer.m_httpService.m_requestList.Find(f => f.Http.id == httpContextId);
|
|
|
|
if (req.Data.Count < 5)
|
|
{
|
|
TraceLog.Error("AddUserName.DoAddUserName param error");
|
|
builder["ret"] = 2;
|
|
builder["msg"] = "参数错误";
|
|
}
|
|
else
|
|
{
|
|
dbOperator.DBAddUserName(req.Data[0].ToString(), req.Data[1].ToString(), req.Data[2].ToString(), req.Data[3].ToString(), req.Data[4].ToString(), builder);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
TraceLog.Error("AddUserName.DoAddUserName Error Msg {0}", ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (m_request != null)
|
|
{
|
|
m_request.Http.httpResponse.ContentAsUTF8 = builder.ToJson();
|
|
m_request.ProcessEnd = true;
|
|
}
|
|
}
|
|
|
|
TraceLog.Trace("AddUserName.DoAddUserName success httpContextId {0}", req.HttpContextId);
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
|