Пример #1
0
        public BaseItemRes <string> InitDB()
        {
            var result = this.manageTolls.InitDB();
            var data   = result ? "初始化数据库完成" : "初始化数据库失败";

            return(BaseItemRes <string> .Ok(data));
        }
Пример #2
0
        public BaseItemRes <InitDataInfo> Test()
        {
            var userDAL = new UserDAL();
            var lstUser = userDAL.AsQueryable().ToList();

            var roleDAL = new RoleDAL();
            var lstRole = roleDAL.AsQueryable().ToList();

            var authorityDAL = new AuthorityDAL();
            var lstAuthority = authorityDAL.AsQueryable().ToList();

            var roleAuthorityDAL = new RoleAuthorityDAL();
            var lstRoleAuthority = roleAuthorityDAL.AsQueryable().ToList();

            var userRoleDAL = new UserRoleDAL();
            var lstUserRole = userRoleDAL.AsQueryable().ToList();

            var initData = new InitDataInfo()
            {
                Users          = lstUser,
                Roles          = lstRole,
                Authoritys     = lstAuthority,
                RoleAuthoritys = lstRoleAuthority,
                UserRoles      = lstUserRole
            };

            return(BaseItemRes <InitDataInfo> .Ok(initData));
        }
Пример #3
0
        public BaseItemRes <UserInfo> GetUser([FromQuery] GetUserReq req)
        {
            var ip = HttpContext.Connection.RemoteIpAddress.ToString();

            var userInfo = this.userBLL.GetUser(req);

            return(BaseItemRes <UserInfo> .Ok(userInfo));
        }
Пример #4
0
        public BaseItemRes <UserInfo> GetMyUserInfo()
        {
            var req = new GetUserReq();

            req.LoginName = this.CurUser.LoginName;

            var userInfo = this.userBLL.GetUser(req);

            return(BaseItemRes <UserInfo> .Ok(userInfo));
        }
Пример #5
0
        public BaseItemRes <string> Login([FromBody] LoginReq req)
        {
            //用户信息
            var lstClaim = new List <Claim>();

            lstClaim.Add(new Claim(TdbClaimTypes.UID, req.UID));
            lstClaim.Add(new Claim(TdbClaimTypes.Name, req.Name));

            var tokenHandler    = new JwtSecurityTokenHandler();
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject            = new ClaimsIdentity(lstClaim),
                Expires            = DateTime.UtcNow.AddDays(1),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.ASCII.GetBytes("tangdabin20220108")), SecurityAlgorithms.HmacSha256Signature)
            };
            var token       = tokenHandler.CreateJwtSecurityToken(tokenDescriptor);
            var tokenString = tokenHandler.WriteToken(token);

            return(BaseItemRes <string> .Ok(tokenString));
        }
Пример #6
0
 public BaseItemRes <string> CreateDBModels()
 {
     this.manageTolls.CreateDBModels();
     return(BaseItemRes <string> .Ok("实体类已生成"));
 }
Пример #7
0
        public BaseItemRes <string> BackupConsulConfig()
        {
            var fullFileName = this.manageTolls.BackupConsulConfig();

            return(BaseItemRes <string> .Ok(fullFileName));
        }
Пример #8
0
 public BaseItemRes <string> RestoreConsulConfig(IFormFile file)
 {
     this.manageTolls.RestoreConsulConfig(file);
     return(BaseItemRes <string> .Ok("还原完成"));
 }
Пример #9
0
 public BaseItemRes <ConsulConfig> GetConsulConfig()
 {
     return(BaseItemRes <ConsulConfig> .Ok(AccConfig.Consul));
 }
Пример #10
0
 public BaseItemRes <AppConfig> GetAppConfig()
 {
     return(BaseItemRes <AppConfig> .Ok(AccConfig.App));
 }
Пример #11
0
        public BaseItemRes <bool> ExistUser([FromQuery] ExistUserReq req)
        {
            var exist = this.userBLL.ExistUser(req);

            return(BaseItemRes <bool> .Ok(exist));
        }
Пример #12
0
        /// <summary>
        /// 成功消息
        /// (IsOK=true,MsgID="OK",Msg="成功")
        /// </summary>
        /// <param name="data">结果</param>
        /// <returns></returns>
        public static BaseItemRes <T> OkItemRes <T>(T data)
        {
            var res = BaseItemRes <T> .Ok(data);

            return(res);
        }