winform+dev的前后台分离标准项目
lg
2024-08-27 94e53b9394aa981f0d6a1cd80edac9a9ba1ba97c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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;
 
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();
                            System.Text.StringBuilder sbR = new StringBuilder();
                            if (dset.Tables.Count > 1 && dset.Tables[1].Rows.Count > 1)
                            {
                                foreach (System.Data.DataRow r in dset.Tables[1].Rows)
                                {
                                    if (sbR.Length > 0)
                                        sbR.Append(",");
                                    sbR.Append(r["rightGuid"].ToString());
                                }
                            }
                            m.loginRightList = sbR.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, "登录失败!");
        }
    }
}