No Description

UserAccountController.cs 28KB

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