| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- /*
- * 测试
- */
- using System;
- using System.Web;
- using System.Collections.Generic;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using MySystem.Models.Bs;
- using Library;
- using LitJson;
- using Microsoft.AspNetCore.Authorization;
- using MySystem.Service.Bs;
- using System.Linq;
- namespace MySystem.Areas.Api.Controllers.v1
- {
- [Area("Api")]
- [Route("Api/v1/[controller]/[action]")]
- public class TestController : BaseController
- {
- public TestController(IHttpContextAccessor accessor) : base(accessor)
- {
- }
- #region 测试方法
- /// <summary>
- /// 产品库列表
- /// </summary>
- /// <returns></returns>
- // [HttpPost]
- // [Authorize]
- [Route("/main/test/all")]
- public JsonResult List(string value)
- {
- value = PublicFunction.DesDecrypt(value);
- JsonData jsonObj = JsonMapper.ToObject(value);
- // Dictionary<string, object> obj = new Dictionary<string, object>(); //返回字段
- // var anths = BaseClass.GetRightJson();
- // obj.Add("AuthsTree", anths); //主token,用于刷新apiToken
- List<RelationData> relationData = new List<RelationData>();
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- var Other = new Dictionary<string, object>();
- int count = 0;
- List<Dictionary<string, object>> source = SysAdminService.List(relationData, "", out count, 1, 999);
- foreach (Dictionary<string, object> subdata in source)
- {
- Dictionary<string, object> curData = new Dictionary<string, object>();
- curData.Add("Id", subdata["Id"].ToString()); //Id
- curData.Add("AdminName", subdata["AdminName"].ToString()); //用户名
- curData.Add("RealName", subdata["RealName"].ToString()); //名称
- curData.Add("RoleId", subdata["Role"].ToString()); //角色
- curData.Add("LastLoginDate", subdata["LastLoginDate"] == null ? "" : DateTime.Parse(subdata["LastLoginDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); //最后登录时间
- dataList.Add(curData);
- }
- Other.Add("Count", count); //总数
- int SysAdminId = 6; //系统用户Id
- string AdminName = "AHHA"; //用户名
- string RealName = "ABBA"; //名称
- string PassWord = "123456"; //密码
- string RoleId = "1"; //角色
- var sysAdmin = bsdb.SysAdmin.FirstOrDefault(m => m.Id == SysAdminId) ?? new SysAdmin();
- if (sysAdmin.Id > 0)
- {
- if (!string.IsNullOrEmpty(AdminName))
- {
- sysAdmin.AdminName = AdminName;
- }
- if (!string.IsNullOrEmpty(RealName))
- {
- sysAdmin.RealName = RealName;
- }
- if (!string.IsNullOrEmpty(PassWord))
- {
- sysAdmin.Password = function.MD5_32(PassWord);
- }
- if (!string.IsNullOrEmpty(RoleId) && RoleId != sysAdmin.Role)
- {
- sysAdmin.Role = RoleId;
- }
- }
- bsdb.SaveChanges();
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
- }
- #endregion
- }
- }
|