lixiaojun
2022-08-17 d3024a7b50b35a8f24c1bfe0f13f4f86cc63a253
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
86
87
88
89
90
91
92
93
94
95
96
97
using Microsoft.AspNetCore.Mvc;
using IStation.Model.Api;
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.Hosting.Internal;
using Microsoft.AspNetCore.Http.Extensions;
using IStation.Untity;
 
namespace IStation.WebApi.Controllers.V1
{
    /// <summary>
    /// UserLogin标准Api
    /// </summary>
    [ApiController]
    [Route("v1/Standard/UserLogin")]
    [ApiExplorerSettings(GroupName = "v1")]
    public class UserLoginController : ControllerBase
    {
        private readonly Service.UserLogin _service = new Service.UserLogin();
 
        /// <summary>
        /// 标准登录
        /// </summary>
        [Route("FromStandard")]
        [HttpPost]
        public Result FromStandard(Model.UserLogin model)
        {
            if (model == null)
            {
                return new Result("参数错误");
            }
            if (string.IsNullOrEmpty(model.SoftTag))
            {
                return new Result("SoftTag 参数错误");
            }
            if (string.IsNullOrEmpty(model.LoginName))
            {
                return new Result("LoginName 参数错误");
            }
            if (string.IsNullOrEmpty(model.LoginPwd))
            {
                return new Result("LoginPwd 参数错误");
            }
 
            var response = _service.Login(model.SoftType, model.SoftTag, model.LoginName, model.LoginPwd, HttpContextHelper.GetRemoteIpAddress(HttpContext.Request), null);
            var vm = new Model.UserLoginSecretResponse()
            {
                Status=response.Status,
                User=response.User==null?null:new Model.UserSecret(response.User)
            };
            return new Result<Model.UserLoginSecretResponse>(vm);
        }
 
        /// <summary>
        /// 标准客户登录
        /// </summary>
        [Route("FromCorpStandard")]
        [HttpPost]
        public Result FromCorpStandard(Model.UserLoginCorp model)
        {
            if (model == null)
            {
                return new Result("参数错误");
            }
            if (model.CorpID < 1)
            {
                return new Result("CorpID 参数错误");
            }
            if (string.IsNullOrEmpty(model.SoftTag))
            {
                return new Result("SoftTag 参数错误");
            }
            if (string.IsNullOrEmpty(model.LoginName))
            {
                return new Result("LoginName 参数错误");
            }
            if (string.IsNullOrEmpty(model.LoginPwd))
            {
                return new Result("LoginPwd 参数错误");
            }
 
 
            var response = _service.LoginCorp(model.CorpID, model.SoftType, model.SoftTag, model.LoginName, model.LoginPwd, HttpContextHelper.GetRemoteIpAddress(HttpContext.Request), null);
            var vm = new Model.UserLoginSecretResponse()
            {
                Status = response.Status,
                User = response.User == null ? null : new Model.UserSecret(response.User)
            };
            return new Result<Model.UserLoginSecretResponse>(vm);
        }
 
 
 
 
 
    }
}