using Gs.Toolbox;
|
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Mvc;
|
using System;
|
using System.Collections.Generic;
|
using System.Data.SqlClient;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using Gs.User.Modes;
|
using System.Diagnostics;
|
|
namespace Gs.User.Service
|
{
|
|
[ApiGroup(ApiGroupNames.Auth)]
|
public class UserController : IRomteService
|
{
|
/// <summary>
|
/// 用户登录
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[RequestMethod(RequestMethods.POST)]
|
public ReturnDto<System.Dynamic.ExpandoObject> UserLogin([FromBody] UserLogin model)
|
{
|
string accountPwd = model.accountPwd;
|
string accountNo = model.accountNo;
|
Guid orgGuid = model.orgGuid;
|
string strPass = "";
|
DataSet dset = new DataSet();
|
dynamic m = new System.Dynamic.ExpandoObject();
|
using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn))
|
{
|
using (SqlCommand cmd = new SqlCommand("[prc_user_login]", conn))
|
{
|
try
|
{
|
conn.Open();
|
cmd.CommandType = CommandType.StoredProcedure;
|
SqlParameter[] parameters = new SqlParameter[] {
|
new SqlParameter("@accountNo",accountNo),
|
new SqlParameter("@accountPwd",strPass),
|
new SqlParameter("@orgGuid",orgGuid),
|
};
|
foreach (SqlParameter parameter in parameters)
|
{
|
cmd.Parameters.Add(parameter);
|
}
|
using (SqlDataAdapter dt = new SqlDataAdapter(cmd))
|
{
|
dt.Fill(dset, "0");
|
}
|
if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0)
|
{
|
System.Data.DataRow row = dset.Tables[0].Rows[0];
|
m.loginGuid = Guid.Parse(row["loginGuid"].ToString());
|
m.loginOrgGuid = row["loginOrgGuid"].ToString();
|
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "登录成功!");
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Debug(this.ToString(), "UserLogin error:" + ex.Message);
|
}
|
finally
|
{
|
conn.Close();
|
}
|
}
|
}
|
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, "登录失败!");
|
}
|
|
/// <summary>
|
/// 读取用户登录信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[RequestMethod(RequestMethods.POST)]
|
public ReturnDto<System.Dynamic.ExpandoObject> GetUserInfo([FromBody] UserLogin model)
|
{
|
Guid userGuid = model.userGuid;
|
DataSet dset = new DataSet();
|
dynamic m = new System.Dynamic.ExpandoObject();
|
using (SqlConnection conn = new SqlConnection(DbHelperSQL.strConn))
|
{
|
using (SqlCommand cmd = new SqlCommand("[prc_user_info]", conn))
|
{
|
try
|
{
|
conn.Open();
|
cmd.CommandType = CommandType.StoredProcedure;
|
SqlParameter[] parameters = new SqlParameter[] {
|
new SqlParameter("@userGuid",userGuid),
|
};
|
foreach (SqlParameter parameter in parameters)
|
{
|
cmd.Parameters.Add(parameter);
|
}
|
using (SqlDataAdapter dt = new SqlDataAdapter(cmd))
|
{
|
dt.Fill(dset, "0");
|
}
|
if (dset != null && dset.Tables.Count > 0 && dset.Tables[0].Rows.Count > 0)
|
{
|
System.Data.DataRow row = dset.Tables[0].Rows[0];
|
m.loginGuid = Guid.Parse(row["loginGuid"].ToString());
|
m.loginOrgGuid = row["loginOrgGuid"].ToString();
|
m.list = new List<MenuAction>();
|
if (dset.Tables.Count > 1 && dset.Tables[1].Rows.Count > 1)
|
{
|
foreach (DataRow dr in dset.Tables[1].Rows)
|
{
|
m.list.Add(
|
new MenuAction()
|
{
|
guid = Guid.Parse(dr["rightGuid"].ToString()),
|
upGuid = dr["upGuid"].ToString().Length > 0 ? Guid.Parse(dr["upGuid"].ToString()) : null,
|
name = dr["name"].ToString(),
|
icon = dr["icon"].ToString(),
|
fromPath = dr["fromPath"].ToString(),
|
category = int.Parse(dr["category"].ToString()),
|
}
|
);
|
}
|
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "登录成功!");
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Debug(this.ToString(), "GetUserInfo error:" + ex.Message);
|
}
|
finally
|
{
|
conn.Close();
|
}
|
}
|
}
|
return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Exception, "登录失败!");
|
}
|
}
|
}
|