Blame view

web/WebMvc/Areas/base/Controllers/SysUserController.cs 5.47 KB
HuXiYu authored
1
2
using Autofac.Core;
using Hh.Mes.Common.Request;
赖素文 authored
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.Entity;
using Hh.Mes.Service;
using Hh.Mes.Service.SystemAuth;
using Hh.Mes.Service.WebService.Base;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using WebMvc.Aop;


namespace WebMvc
{
    [Area("base")]
    public class SysUserController : BaseController
    {
        private readonly SysUserService service;
        private readonly AuthStrategyContext _authStrategyContext;
        private readonly FaceLoginService faceLoginService;
24
        private readonly IWebHostEnvironment environment;
赖素文 authored
25
26
        public SysUserController(IAuth authUtil, SysUserService service, FaceLoginService faceLogin, IWebHostEnvironment hostingEnvironment) : base(authUtil)
赖素文 authored
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
        {
            _authStrategyContext = authUtil.GetCurrentUser();
            environment = hostingEnvironment;
            this.service = service;
            this.service.sysWebUser = authUtil.GetCurrentUser().User;
            this.faceLoginService = faceLogin;
            this.faceLoginService.sysWebUser = authUtil.GetCurrentUser().User;
        }

        //
        // GET: /SysUser/
        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 用户列表没有组织 树形形状的
        /// </summary>
        /// <returns></returns>
        public ActionResult UserList()
        {
            return View();
        }

        /// <summary>
        /// 加载组织下面的所有用户
        /// </summary>
        [HttpPost]
        public string LoadUserListByTeamCode(string teamCode)
        {
            return Serialize(service.LoadUserListByTeamCode(teamCode));
        }

        /// <summary>
        /// 加载组织下面的所有用户
        /// </summary>
        [HttpPost]
        public string Load(PageReq request, int? orgId, string Name, string Idcard)
        {
            return Serialize(service.Load(request, orgId, Name, Idcard));
        }

        //添加用户
        [HttpPost]
        [XSSFilter]
        public string Add(SysUserView view)
        {
            return Serialize(service.Ins(view));
        }

        //修改用户
        [HttpPost]
        [XSSFilter]
        public string Update(SysUserView view)
        {
            return Serialize(service.Upd(view));
        }

        [HttpPost]
        public string Delete(int[] ids)
        {
            return Serialize(service.DeleteById(ids));
        }

        #region 获取权限数据

        /// <summary>
        /// 获取用户可访问的账号
        /// </summary>
        public string GetAccessedUsers()
        {
            IEnumerable<SysUserView> users = service.Load(new PageReq(), null, null, null).Result;
            var result = new Dictionary<int, object>();
            foreach (var user in users)
            {
                var item = new
                {
                    Account = user.Account,
                    RealName = user.Name,
                    id = user.Id,
                    text = user.Name,
                    value = user.Account,
                    parentId = "0",
                    showcheck = true,
                    img = "fa fa-user",
                };
                result.Add(user.Id, item);
            }

            return Serialize(result);
        }
        #endregion

        public ActionResult ChangePassword()
        {
            return View();
        }

        //修改个人密码
        [HttpPost]
        [XSSFilter]
        public string ChangeUserPassword(string OldPassword, string Password)
        {
            return Serialize(service.ChangeUserPassword(OldPassword, Password, _authStrategyContext.User));
        }

        //重设用户密码
        [HttpPost]
        [XSSFilter]
        public string ResetPassword(SysUser user)
        {
            return Serialize(service.ResetPassword(user));
        }


        [Authenticate]
        public ActionResult Binding()
        {
            return View();
        }

        //绑定登录方式 string account, string userImage,string jobCard ,bool edit
        [HttpPost]
        public string BindingAdd(IFormFileCollection excelfile)
        {
            var account = Request.Form["account"];
            var userImage = Request.Form["userImage"];
            var jobCard = Request.Form["jobCard"];
            var edit =bool.Parse(Request.Form["edit"]) ;
            byte[] imageBytes = { };
            if (excelfile.Count>0)
            {
                string[] str = userImage[0].Split(',');
                 imageBytes = Convert.FromBase64String(str[1]);
            }      
163
            Result = faceLoginService.FaceSearchAdd(account, userImage, jobCard, edit, imageBytes, environment.ContentRootPath); 
赖素文 authored
164
165
166
            //_app.CreateBinding(account, userImage,jobCard);
            return Serialize(Result);
        }
HuXiYu authored
167
168
169
170
171
        /// <summary>
        /// 用户绑定项目
        /// </summary>
HuXiYu authored
172
173
        [HttpPost]
        [XSSFilter]
174
        public string UserBindProjectRel(string userAccount, bool checkeds, string projectKeys)
HuXiYu authored
175
        {
176
            return Serialize(service.UserBindProjectRel(userAccount, checkeds, projectKeys));
HuXiYu authored
177
178
        }
179
180
181
        /// <summary>
        /// 用户关联绑定的 项目信息
        /// </summary>
HuXiYu authored
182
183
184
185
        public string GetUserBindClient(string userAccount)
        {
            return Serialize(service.GetUserBindClient(userAccount));
        }
赖素文 authored
186
187
    }
}