Ei kuvausta

UserAccountController.cs 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. using CallCenter.Utility;
  2. using CallCenterApi.Common;
  3. using CallCenterApi.DB;
  4. using CallCenterApi.Interface.Controllers.Base;
  5. using CallCenterApi.Interface.Models.Filter;
  6. using CallCenterApi.Interface.Models.Input;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.Linq;
  11. using System.Web;
  12. using System.Web.Mvc;
  13. namespace CallCenterApi.Interface.Controllers
  14. {
  15. [Authority]
  16. public class UserAccountController : BaseController
  17. {
  18. private BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
  19. private BLL.T_Sys_Department departmentBLL = new BLL.T_Sys_Department();
  20. private BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
  21. public ActionResult GetMaillist()
  22. {
  23. if (Request.IsAuthenticated)
  24. {
  25. int userId = CurrentUser.UserData.F_UserId;
  26. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  27. DataTable dt = new DataTable();
  28. string sql = " ";
  29. int dptid = 0;
  30. if (userModel != null)
  31. {
  32. if (userModel.F_RoleId == 51 || userModel.F_RoleId == 52)
  33. dptid = userModel.F_DeptId;
  34. }
  35. Model.T_Sys_Department deptModel = new BLL.T_Sys_Department().GetModel(dptid);
  36. if (deptModel != null)
  37. {
  38. sql += " and F_DeptId in ( select F_DeptId from T_Sys_Department where F_DeptCode like '" + deptModel.F_DeptCode + "%') ";
  39. }
  40. var modelList=new BLL.UserAccount().GetModelList(sql);
  41. var obj = new
  42. {
  43. rows = modelList.Select(x => new
  44. {
  45. F_UserId = x.F_UserId,
  46. F_UserCode = x.F_UserCode,
  47. F_ExtensionNumber = x.F_ExtensionNumber,
  48. F_UserName = x.F_UserName,
  49. F_GroupName = x.F_GroupName,
  50. F_DeptId = x.F_DeptId,
  51. F_RoleId = x.F_RoleId,
  52. F_GroupId = x.F_GroupId,
  53. F_SeatFlag = x.F_SeatFlag,
  54. F_SeatRight = x.F_SeatRight,
  55. F_SeatLevel = x.F_SeatLevel,
  56. F_SexFlag = x.F_SexFlag,
  57. F_RemindFlag = x.F_RemindFlag,
  58. F_Remark = x.F_Remark,
  59. F_Telephone = x.F_Telephone,
  60. F_Mobile = x.F_Mobile,
  61. F_HomePhone = x.F_HomePhone,
  62. F_Birthday = x.F_Birthday,
  63. F_CreateOn = x.F_CreateOn,
  64. F_CancelOn = x.F_CancelOn,
  65. F_DeleteFlag = x.F_DeleteFlag,
  66. F_APPOnFlag = x.F_APPOnFlag,
  67. F_LastActiveTime = x.F_LastActiveTime,
  68. F_See = x.F_See,
  69. F_HJType = x.F_HJType,
  70. F_PId = x.F_PId,
  71. F_TmId = x.F_TmId,
  72. F_RoleName = x.F_RoleName,
  73. F_DeptName = x.F_DeptName,
  74. F_WorkNumber = x.F_WorkNumber,
  75. F_Post = x.F_Post,
  76. //F_WXNo=x.F_WXNo,
  77. F_SeatGroup = x.F_SeartGroup
  78. }),
  79. total = modelList.Count
  80. };
  81. dt.Clear();
  82. dt.Dispose();
  83. return Content(obj.ToJson());
  84. }
  85. return NoToken("未知错误,请重新登录");
  86. }
  87. //[Authority]
  88. //用户列表
  89. public ActionResult GetList(FilterUserAccount filter)
  90. {
  91. if (Request.IsAuthenticated)
  92. {
  93. int userId = CurrentUser.UserData.F_UserId;
  94. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  95. DataTable dt = new DataTable();
  96. string sql = " ";
  97. //if (userModel.F_SeartGroupID != 0)
  98. //{
  99. // sql += " and F_SeartGroupID = '" + userModel.F_SeartGroupID + "' ";
  100. //}
  101. if (userModel != null)
  102. {
  103. if (userModel.F_RoleId == 51|| userModel.F_RoleId == 52)
  104. filter.dptid= userModel.F_DeptId;
  105. }
  106. if (filter.dptid > 0)
  107. {
  108. Model.T_Sys_Department deptModel = new BLL.T_Sys_Department().GetModel(filter.dptid);
  109. if (deptModel != null)
  110. {
  111. sql += " and F_DeptId in ( select F_DeptId from T_Sys_Department where F_DeptCode like '%" + deptModel.F_DeptCode + "%') ";
  112. }
  113. }
  114. if (!string.IsNullOrWhiteSpace(filter.Key))
  115. {
  116. sql = "";
  117. string str = string.Format(" and (F_UserCode like '%{0}%' or F_UserName like '%{1}%')", filter.Key, filter.Key);
  118. sql += str;
  119. }
  120. if (filter .type ==1)
  121. {
  122. sql += "and F_RoleId=52";
  123. }
  124. if (filter.type == 2)
  125. {
  126. sql += "and F_RoleId=53";
  127. }
  128. sql += "and F_See!='5'";
  129. int recordCount = 0;
  130. dt = BLL.PagerBLL.GetListPager(
  131. "T_Sys_UserAccount",
  132. "F_UserId",
  133. "*",
  134. sql,
  135. "ORDER BY F_UserId desc",
  136. filter.PageSize,
  137. filter.PageIndex,
  138. true,
  139. out recordCount);
  140. List<Model.UserAccount> modelList = new BLL.UserAccount().DataTableToList(dt);
  141. var obj = new
  142. {
  143. rows = modelList.Select(x => new
  144. {
  145. F_UserId = x.F_UserId,
  146. F_UserCode = x.F_UserCode,
  147. F_ExtensionNumber = x.F_ExtensionNumber,
  148. F_UserName = x.F_UserName,
  149. F_GroupName = x.F_GroupName,
  150. F_DeptId = x.F_DeptId,
  151. F_RoleId = x.F_RoleId,
  152. F_GroupId = x.F_GroupId,
  153. F_SeatFlag = x.F_SeatFlag,
  154. F_SeatRight = x.F_SeatRight,
  155. F_SeatLevel = x.F_SeatLevel,
  156. F_SexFlag = x.F_SexFlag,
  157. F_RemindFlag = x.F_RemindFlag,
  158. F_Remark = x.F_Remark,
  159. F_Telephone = x.F_Telephone,
  160. F_Mobile = x.F_Mobile,
  161. F_HomePhone = x.F_HomePhone,
  162. F_Birthday = x.F_Birthday,
  163. F_CreateOn = x.F_CreateOn,
  164. F_CancelOn = x.F_CancelOn,
  165. F_DeleteFlag = x.F_DeleteFlag,
  166. F_APPOnFlag = x.F_APPOnFlag,
  167. F_LastActiveTime = x.F_LastActiveTime,
  168. F_See = x.F_See,
  169. F_HJType = x.F_HJType,
  170. F_PId = x.F_PId,
  171. F_TmId = x.F_TmId,
  172. F_RoleName = x.F_RoleName,
  173. F_DeptName = x.F_DeptName,
  174. F_WorkNumber = x.F_WorkNumber,
  175. F_Post = x.F_Post,
  176. //F_WXNo=x.F_WXNo,
  177. F_SeatGroup = x.F_SeartGroup
  178. }),
  179. total = recordCount
  180. };
  181. dt.Clear();
  182. dt.Dispose();
  183. return Content(obj.ToJson());
  184. // return ;
  185. }
  186. return NoToken("未知错误,请重新登录");
  187. }
  188. //[Authority]
  189. //获取用户信息
  190. public ActionResult GetUser(int userId = 0, string userCode = "")
  191. {
  192. if (Request.IsAuthenticated)
  193. {
  194. string sql = "";
  195. if (userId > 0)
  196. {
  197. sql += " and F_UserId=" + userId;
  198. }
  199. if (!string.IsNullOrWhiteSpace(userCode))
  200. {
  201. sql += " and F_UserCode=" + userCode;
  202. }
  203. if (string.IsNullOrWhiteSpace(sql))
  204. return Error("获取失败");
  205. Model.T_Sys_UserAccount userModel = sysUserAccountBll.GetModelList(" 1=1 " + sql).FirstOrDefault();
  206. if (userModel == null) return Error("获取失败");
  207. var depModel = departmentBLL.GetModel(userModel.F_DeptId);
  208. var zxzModel = dicValueBLL.GetModel(userModel.F_GroupId ?? 0);
  209. return Success("获取成功", new
  210. {
  211. F_UserId = userModel.F_UserId,
  212. F_UserCode = userModel.F_UserCode,
  213. F_ExtensionNumber = userModel.F_ExtensionNumber,
  214. F_UserName = userModel.F_UserName,
  215. F_DeptId = userModel.F_DeptId,
  216. F_RoleId = userModel.F_RoleId,
  217. F_GroupId = userModel.F_GroupId,
  218. F_SeatFlag = userModel.F_SeatFlag,
  219. F_SeatRight = userModel.F_SeatRight,
  220. F_SeatLevel = userModel.F_SeatLevel,
  221. F_SexFlag = userModel.F_SexFlag,
  222. F_RemindFlag = userModel.F_RemindFlag,
  223. F_Remark = userModel.F_Remark,
  224. F_Telephone = userModel.F_Telephone,
  225. F_Mobile = userModel.F_Mobile,
  226. F_HomePhone = userModel.F_HomePhone,
  227. F_Birthday = (userModel.F_Birthday != null ? userModel.F_Birthday.Value.ToString("yyyy-MM-dd") : ""),
  228. F_CreateOn = userModel.F_CreateOn,
  229. F_CancelOn = userModel.F_CancelOn,
  230. F_DeleteFlag = userModel.F_DeleteFlag,
  231. F_APPOnFlag = userModel.F_APPOnFlag,
  232. F_LastActiveTime = userModel.F_LastActiveTime,
  233. F_See = userModel.F_See,
  234. F_HJType = userModel.F_HJType ?? 0,
  235. F_PId = userModel.F_PId,
  236. F_TmId = userModel.F_TmId,
  237. F_WorkNumber = userModel.F_WorkNumber,
  238. F_Post = userModel.F_Post ,
  239. //F_WXNo = userModel.F_WXNo,
  240. F_SeatGroup = userModel.F_SeartGroup,
  241. zxzname = zxzModel?.F_Name ?? "",
  242. depname = depModel?.F_DeptName ?? ""
  243. });
  244. }
  245. return NoToken("未知错误,请重新登录");
  246. }
  247. //[Authority]
  248. //添加用户信息
  249. public ActionResult AddUsers(UserAccountInput input)
  250. {
  251. if (Request.IsAuthenticated)
  252. {
  253. Model.T_Sys_UserAccount userAccountModel = new Model.T_Sys_UserAccount();
  254. //员工工号不能重复
  255. string ucode = input.Usercode.Trim();
  256. if (!string.IsNullOrEmpty(ucode))
  257. {
  258. Model.T_Sys_UserAccount uModel = new BLL.T_Sys_UserAccount().GetModel(ucode);
  259. if (uModel != null)
  260. {
  261. return Error("不能重复添加工号");
  262. }
  263. else
  264. {
  265. userAccountModel.F_UserCode = ucode;
  266. userAccountModel.F_WorkNumber = ucode;
  267. }
  268. }
  269. if (input.Username != null)
  270. userAccountModel.F_UserName = input.Username.Trim();
  271. if (input.Password != null)
  272. userAccountModel.F_Password = input.Password.Trim();
  273. if (input.Extno != null)
  274. userAccountModel.F_ExtensionNumber = input.Extno.Trim();
  275. if (input.DeptId != 0)
  276. userAccountModel.F_DeptId = input.DeptId;
  277. if (input.Pid != 0)
  278. userAccountModel.F_PId = input.Pid;
  279. if (input.RoleId != 0)
  280. {
  281. userAccountModel.F_RoleId = input.RoleId;
  282. if (input.RoleId==17|| input.RoleId == 50|| input.RoleId == 49)
  283. {
  284. userAccountModel.F_See = "0";
  285. }
  286. else if (input.RoleId == 1 || input.RoleId ==4)
  287. {
  288. userAccountModel.F_See = "1";
  289. }
  290. else if (input.RoleId == 51 || input.RoleId == 52 || input.RoleId == 55 || input.RoleId == 56)
  291. {
  292. userAccountModel.F_See = "2";
  293. }
  294. else if (input.RoleId ==53 || input.RoleId == 57|| input.RoleId ==58|| input.RoleId == 59 || input.RoleId == 60)
  295. {
  296. userAccountModel.F_See = "3";
  297. }
  298. }
  299. //if (input.GroupId != 0)
  300. // userAccountModel.F_GroupId = input.GroupId;
  301. if (input .Post!=null )
  302. userAccountModel.F_Post = input.Post;
  303. userAccountModel.F_SeatFlag = input.IsSeat;
  304. if (input.SearRight != null)
  305. userAccountModel.F_SeatRight = input.SearRight;
  306. if (input.Sex != null)
  307. userAccountModel.F_SexFlag = input.Sex;
  308. if (input.Remark != null)
  309. userAccountModel.F_Remark = input.Remark;
  310. if (input.Mobile != null)
  311. userAccountModel.F_Mobile = input.Mobile;
  312. if (input.Telphone != null)
  313. userAccountModel.F_Telephone = input.Telphone;
  314. if (input.Birth != null)
  315. userAccountModel.F_Birthday = input.Birth;
  316. userAccountModel.F_CreateOn = DateTime.Now;
  317. userAccountModel.F_DeleteFlag = 0;
  318. if (input.HjType != null)
  319. userAccountModel.F_HJType = input.HjType;
  320. //if (input.IsSeat)
  321. //{
  322. // userAccountModel.F_WXNo = input.WXNo.Trim();
  323. //}
  324. //if (input.SeartGroupID != 0)
  325. if (input.GroupId != 0)
  326. {
  327. userAccountModel.F_SeartGroupID = input.GroupId;
  328. Model.T_Sys_SeatGroup sm = new BLL.T_Sys_SeatGroup().GetModel(input.GroupId);
  329. if (sm != null)
  330. {
  331. userAccountModel.F_SeartGroup = sm.F_ZXZName;
  332. }
  333. }
  334. if (input.IsSeat)
  335. {
  336. SysConfigController sys = new SysConfigController();
  337. //话务人员限制权限判断
  338. if (sys.IsValidSeatPermission())
  339. {
  340. var model = sysUserAccountBll.GetModel(int.Parse(input.Usercode));
  341. if (model != null)
  342. return Error("当前员工工号存在,请更换!");
  343. if (sysUserAccountBll.Add(userAccountModel) > 0)
  344. return Success("新增成功!");
  345. else
  346. return Error("新增失败!");
  347. }
  348. else
  349. {
  350. return Error("话务人员数量已超!");
  351. }
  352. }
  353. else
  354. {
  355. if (sysUserAccountBll.Add(userAccountModel) > 0)
  356. return Success("新增成功!");
  357. else
  358. return Error("新增失败!");
  359. }
  360. }
  361. return NoToken("未知错误,请重新登录");
  362. }
  363. // [Authority]
  364. //修改用户信息
  365. public ActionResult EditUsers(UserAccountInput input)
  366. {
  367. if (Request.IsAuthenticated)
  368. {
  369. BLL.T_Sys_UserAccount sysUserAccountBll = new BLL.T_Sys_UserAccount();
  370. Model.T_Sys_UserAccount userAccountModel = sysUserAccountBll.GetModelList(" F_UserId = " + input.UserId).FirstOrDefault();
  371. if (userAccountModel == null)
  372. return Error("获取用户失败");
  373. //员工工号不能重复
  374. string ucode = input.Usercode.Trim();
  375. if (!string.IsNullOrEmpty(ucode))
  376. {
  377. var uModels = new BLL.T_Sys_UserAccount().GetModelList(" F_UserCode='" + ucode + "'");
  378. if (uModels.Count() > 1)
  379. {
  380. return Error("不能重复添加工号");
  381. }
  382. else
  383. {
  384. userAccountModel.F_UserCode = ucode;
  385. userAccountModel.F_WorkNumber = ucode;
  386. }
  387. }
  388. if (input.Username != null)
  389. userAccountModel.F_UserName = input.Username.Trim();
  390. if (input.Password != null)
  391. userAccountModel.F_Password = input.Password.Trim();
  392. if (input.Extno != null)
  393. userAccountModel.F_ExtensionNumber = input.Extno.Trim();
  394. //if (input.WXNo != null)
  395. // userAccountModel.F_WXNo = input.WXNo.Trim();
  396. if (input.DeptId != 0)
  397. userAccountModel.F_DeptId = input.DeptId;
  398. if (input.RoleId != 0)
  399. {
  400. userAccountModel.F_RoleId = input.RoleId;
  401. if (input.RoleId == 17 || input.RoleId == 50 || input.RoleId == 49)
  402. {
  403. userAccountModel.F_See = "0";
  404. }
  405. else if (input.RoleId == 1 || input.RoleId == 4)
  406. {
  407. userAccountModel.F_See = "1";
  408. }
  409. else if (input.RoleId == 51 || input.RoleId == 52 || input.RoleId == 55 || input.RoleId == 56)
  410. {
  411. userAccountModel.F_See = "2";
  412. }
  413. else if (input.RoleId == 53 || input.RoleId == 57 || input.RoleId == 58 || input.RoleId == 59 || input.RoleId == 60)
  414. {
  415. userAccountModel.F_See = "3";
  416. }
  417. }
  418. if (input.Pid!=0)
  419. userAccountModel.F_PId = input.Pid;
  420. //if (input.GroupId != 0)
  421. // userAccountModel.F_GroupId = input.GroupId;
  422. if (userAccountModel.F_RoleId==4|| userAccountModel.F_RoleId == 17 || userAccountModel.F_RoleId == 1)
  423. userAccountModel.F_SeatFlag = true ;
  424. else
  425. userAccountModel.F_SeatFlag = input.IsSeat;
  426. if (input.SearRight != null)
  427. userAccountModel.F_SeatRight = input.SearRight;
  428. if (input.Post != null)
  429. userAccountModel.F_Post = input.Post;
  430. if (input.Sex != null)
  431. userAccountModel.F_SexFlag = input.Sex;
  432. if (input.Remark != null)
  433. userAccountModel.F_Remark = input.Remark;
  434. if (input.Mobile != null)
  435. userAccountModel.F_Mobile = input.Mobile;
  436. if (input.Telphone != null)
  437. userAccountModel.F_Telephone = input.Telphone;
  438. if (input.Birth != null)
  439. userAccountModel.F_Birthday = input.Birth;
  440. //userAccountModel.F_CreateOn = DateTime.Now;
  441. //if (input.SeartGroupID != 0)
  442. if (input.GroupId != 0)
  443. {
  444. userAccountModel.F_SeartGroupID = input.GroupId;
  445. Model.T_Sys_SeatGroup sm = new BLL.T_Sys_SeatGroup().GetModel(input.GroupId);
  446. if (sm != null)
  447. {
  448. userAccountModel.F_SeartGroup = sm.F_ZXZName;
  449. }
  450. }
  451. userAccountModel.F_DeleteFlag = 0;
  452. if (input.HjType != null)
  453. userAccountModel.F_HJType = input.HjType;
  454. if (input.IsSeat)
  455. {
  456. SysConfigController sys = new SysConfigController();
  457. //话务人员限制权限判断
  458. if (sys.IsValidSeatPermission())
  459. {
  460. if (sysUserAccountBll.Update(userAccountModel))
  461. return Success("编辑成功!");
  462. else
  463. return Error("编辑失败!");
  464. }
  465. else
  466. {
  467. return Error("话务人员数量已超!");
  468. }
  469. }
  470. else
  471. {
  472. if (sysUserAccountBll.Update(userAccountModel))
  473. return Success("编辑成功!");
  474. else
  475. return Error("编辑失败!");
  476. }
  477. }
  478. return NoToken("未知错误,请重新登录");
  479. }
  480. //[Authority]
  481. //删除/禁用/启用 用户
  482. [Authority]
  483. public ActionResult DelUsers(string[] ids, int state = 0)
  484. {
  485. if (ids == null || ids.Length <= 0)
  486. return Error("请选择用户");
  487. var idStr = string.Join(",", ids);
  488. if (string.IsNullOrEmpty(idStr))
  489. return Error("请选择用户");
  490. SysConfigController sys = new SysConfigController();
  491. if (state == 0)
  492. {
  493. //话务人员限制权限判断
  494. if (sys.IsValidSeatPermission())
  495. {
  496. if (sysUserAccountBll.DeleteList(idStr, state))
  497. return Success("设置成功");
  498. else
  499. return Error("设置失败");
  500. }
  501. return Error("话务人员数量已超!");
  502. }
  503. if (sysUserAccountBll.DeleteList(idStr, state))
  504. return Success("设置成功");
  505. else
  506. return Error("设置失败");
  507. }
  508. //[Authority]
  509. //删除用户
  510. public ActionResult DeleteUsers(string[] ids)
  511. {
  512. if (Request.IsAuthenticated)
  513. {
  514. if (ids == null || ids.Length <= 0)
  515. return Error("请选择用户");
  516. var idStr = string.Join(",", ids);
  517. if (string.IsNullOrEmpty(idStr))
  518. return Error("请选择用户");
  519. if (sysUserAccountBll.DeleteList(idStr))
  520. return Success("删除成功");
  521. else
  522. return Error("删除失败");
  523. }
  524. return NoToken("未知错误,请重新登录");
  525. }
  526. //获取坐席列表
  527. public ActionResult GetSeatList()
  528. {
  529. if (Request.IsAuthenticated)
  530. {
  531. int userId = CurrentUser.UserData.F_UserId;
  532. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(userId);
  533. string sql = " f_seatflag=1 ";
  534. int roleid = CurrentUser.UserData.F_RoleId;
  535. int deptid = CurrentUser.UserData.F_DeptId;
  536. if (roleid != 0)
  537. {
  538. if (roleid != 17)
  539. {
  540. if (deptid != 0)
  541. sql += " and F_DeptId=" + deptid;
  542. }
  543. }
  544. if (userModel.F_SeartGroupID != 0)
  545. {
  546. sql += " and F_SeartGroupID = '" + userModel.F_SeartGroupID + "' ";
  547. }
  548. List<Model.T_Sys_UserAccount> userSeartList = sysUserAccountBll.GetModelList(sql + " order by f_userid desc ");
  549. if (userSeartList.Count > 0)
  550. return Success("列表加载成功", userSeartList);
  551. else
  552. return Error("列表加载失败");
  553. }
  554. return NoToken("未知错误,请重新登录");
  555. }
  556. //根据部门获取用户
  557. public ActionResult GetDeptUserList(int deptid = 0)
  558. {
  559. if (Request.IsAuthenticated)
  560. {
  561. List<Model.T_Sys_UserAccount> DeptUserList = sysUserAccountBll.GetModelList("F_DeptId='" + deptid + "' order by f_userid desc ");
  562. return Success("列表加载成功", DeptUserList);
  563. }
  564. return NoToken("未知错误,请重新登录");
  565. }
  566. public DataTable GetFileData(string ids, string prefix)
  567. {
  568. DataTable dt = new DataTable();
  569. if (!string.IsNullOrEmpty(ids))
  570. {
  571. dt = DbHelperSQL.Query("select * from T_Sys_Accessories where F_Id in (" + ids + ")").Tables[0];
  572. foreach (DataRow dr in dt.Rows)
  573. {
  574. dr["F_Url"] = prefix + dr["F_Url"].ToString();
  575. }
  576. }
  577. return dt;
  578. }
  579. //获取当前用户信息
  580. public ActionResult GetNowUser()
  581. {
  582. if (Request.IsAuthenticated)
  583. {
  584. string display = Configs.GetValue("display");
  585. Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(CurrentUser.UserData.F_UserId);
  586. if (userModel == null)
  587. return Error("获取失败");
  588. var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
  589. Model.T_Sys_RoleInfo roleModel = new BLL.T_Sys_RoleInfo().GetModel(userModel.F_RoleId);
  590. var FileUrl = GetFileData(userModel.F_PId.ToString () , configfj.F_ParamValue);
  591. var obj = new
  592. {
  593. user = userModel,
  594. role = roleModel,
  595. FileUrl = FileUrl,
  596. display= display
  597. };
  598. return Success("获取成功", obj);
  599. }
  600. return NoToken("未知错误,请重新登录");
  601. }
  602. // [Authority]
  603. /// <summary>
  604. /// 重置密码
  605. /// </summary>
  606. /// <param name="usercode"></param>
  607. /// <param name="pwd"></param>
  608. /// <returns></returns>
  609. public ActionResult ResetPwd(string usercode = "", string pwd = "")
  610. {
  611. if (Request.IsAuthenticated)
  612. {
  613. if (string.IsNullOrWhiteSpace(pwd))
  614. return Error("请输入密码");
  615. var model = sysUserAccountBll.GetModel(usercode);
  616. if (model == null) return Error("此用户不存在");
  617. model.F_Password = pwd;
  618. if (sysUserAccountBll.Update(model))
  619. return Success("重置密码成功");
  620. else
  621. return Error("重置密码失败");
  622. }
  623. return NoToken("未知错误,请重新登录");
  624. }
  625. public ActionResult UpdatePwd(string usercode = "", string pwd = "", string oldPwd = "", string mobile = "")
  626. {
  627. if (Request.IsAuthenticated)
  628. {
  629. if (string.IsNullOrWhiteSpace(pwd))
  630. return Error("请输入密码");
  631. if (string.IsNullOrWhiteSpace(usercode))
  632. return Error("账号错误");
  633. var model = sysUserAccountBll.GetModel(int.Parse(usercode));
  634. if (model == null) return Error("此用户不存在");
  635. if (!model.F_Password.Equals(oldPwd)) return Error("原密码不正确");
  636. model.F_Password = pwd;
  637. if (!string.IsNullOrWhiteSpace(mobile))
  638. model.F_Mobile = mobile;
  639. if (sysUserAccountBll.Update(model))
  640. return Success("重置密码成功");
  641. else
  642. return Error("重置密码失败");
  643. }
  644. return NoToken("未知错误,请重新登录");
  645. }
  646. }
  647. }