public OkObjectResult Post(string sName, string sModuleid, string sLinkurl, string sController, string sAction)
        {
            VsSysModule pExistModule = _moduleService.QueryByID(sModuleid);

            if (pExistModule == null)
            {
                return(JsonRes.Fail("模块不存在"));
            }
            VsSysApiModule entity = new VsSysApiModule
            {
                Id          = System.Guid.NewGuid().ToString(),
                SName       = sName,
                SModuleid   = sModuleid,
                SLinkurl    = sLinkurl,
                SController = sController,
                SAction     = sAction,
            };
            string error = "";
            int    res   = _apiModuleService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }
예제 #2
0
        public OkObjectResult Put(string id, DateTime dTime, double dRmb, string sCode, string sDesc, string sOwner)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsIncomeDetail pExist = _incomeDetailService.QueryByID(id);

            if (pExist == null)
            {
                return(JsonRes.Fail("数据不存在"));
            }

            pExist.DTime  = dTime;
            pExist.FRmb   = dRmb;
            pExist.SCode  = sCode;
            pExist.SDesc  = sDesc;
            pExist.SOwner = sOwner;

            string error = "";
            int    res   = _incomeDetailService.TryUpdate(out error, pExist);

            if (res == 0)
            {
                return(JsonRes.Fail(pExist, error));
            }
            return(JsonRes.Success(pExist));
        }
예제 #3
0
        public OkObjectResult Delete(string username)
        {
            VsSysUser pExist = _userService.QueryByID(username);

            if (pExist == null)
            {
                return(JsonRes.Fail("用户名不存在"));
            }
            // 循环删除权限表的数据
            List <VsSysPower> pFindPower = _powerService.Query(d => d.SUserid == username);

            foreach (var power in pFindPower)
            {
                string powerError = "";
                int    powerRes   = _powerService.TryDelete(out powerError, power);
                if (powerRes == 0)
                {
                    return(JsonRes.Fail(power, powerError));
                }
            }
            string error = "";
            int    res   = _userService.TryDelete(out error, pExist);

            if (res == 0)
            {
                return(JsonRes.Fail(pExist, error));
            }
            // TODO:注销用户时同时删除掉此用户的对应数据
            return(JsonRes.Success(pExist));
        }
        public OkObjectResult Put(string id, string sName, string sMoudleid, string sLinkurl, string sController, string sAction)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsSysApiModule pExist = _apiModuleService.QueryByID(id);

            if (pExist == null)
            {
                return(JsonRes.Fail("接口不存在"));
            }
            pExist.SName       = sName;
            pExist.SModuleid   = sMoudleid;
            pExist.SLinkurl    = sLinkurl;
            pExist.SController = sController;
            pExist.SAction     = sAction;
            string error = "";
            int    res   = _apiModuleService.TryUpdate(out error, pExist);

            if (res == 0)
            {
                return(JsonRes.Fail(pExist, error));
            }
            return(JsonRes.Success(pExist));
        }
예제 #5
0
        public OkObjectResult Put(string id, string sName, string sLinkurl, int iOrder, string sIcon, bool bIsshow = true, int iLevel = 0, string sParentid = "-1")
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsSysModule pExit = _moduleService.QueryByID(id);

            if (pExit == null)
            {
                return(JsonRes.Fail("模块不存在"));
            }
            pExit.SName     = sName;
            pExit.SLinkurl  = sLinkurl;
            pExit.IOrder    = iOrder;
            pExit.SIcon     = sIcon;
            pExit.BIsshow   = bIsshow;
            pExit.ILevel    = iLevel;
            pExit.SParentid = sParentid;
            string error = "";
            int    res   = _moduleService.TryUpdate(out error, pExit);

            if (res == 0)
            {
                return(JsonRes.Fail(pExit, error));
            }
            return(JsonRes.Success(pExit));
        }
예제 #6
0
        public OkObjectResult Put(string username, string name, string logo, string desc, string email, string phone)
        {
            if (string.IsNullOrEmpty(username))
            {
                return(JsonRes.Fail("用户名无效"));
            }

            VsSysUser pExist = _userService.QueryByID(username);

            if (pExist == null)
            {
                return(JsonRes.Fail("用户名不存在"));
            }


            pExist.SUsername   = username;
            pExist.SName       = name;
            pExist.DUpdatetime = DateTime.Now.ToLocalTime();
            pExist.SLogo       = logo;
            pExist.SDesc       = desc;
            pExist.SEmail      = email;
            pExist.SPhone      = phone;
            string error = "";
            int    res   = _userService.TryUpdate(out error, pExist);

            if (res == 0)
            {
                return(JsonRes.Fail(pExist, error));
            }
            return(JsonRes.Success(pExist));
        }
예제 #7
0
        public OkObjectResult Put(string id, string sName, string sCode, string sType, string sDesc)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsTallyType pExit = _tallyTypeService.QueryByID(id);

            if (pExit == null)
            {
                return(JsonRes.Fail("类型不存在"));
            }
            pExit.SName = sName;
            pExit.SCode = sCode;
            pExit.SDesc = sDesc;
            pExit.SType = sType;
            string error = "";
            int    res   = _tallyTypeService.TryUpdate(out error, pExit);

            if (res == 0)
            {
                return(JsonRes.Fail(pExit, error));
            }
            return(JsonRes.Success(pExit));
        }
예제 #8
0
        public OkObjectResult Post(string sName, string sLinkurl, int iOrder, string sIcon, bool bIsshow = true, int iLevel = 0, string sParentid = "-1")
        {
            // 判断模块是否存在 根据SLinkurl
            VsSysModule pExist = _moduleService.Query(d => d.SLinkurl == sLinkurl).FirstOrDefault();

            if (pExist != null)
            {
                return(JsonRes.Fail("模块已存在"));
            }
            VsSysModule entity = new VsSysModule
            {
                Id        = Guid.NewGuid().ToString(),
                SName     = sName,
                SLinkurl  = sLinkurl,
                IOrder    = iOrder,
                SIcon     = sIcon,
                BIsshow   = bIsshow,
                ILevel    = iLevel,
                SParentid = sParentid,
            };
            string error = "";
            int    res   = _moduleService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }
        public OkObjectResult GetByModule(string sMoudleid)
        {
            if (string.IsNullOrEmpty(sMoudleid))
            {
                return(JsonRes.Fail("id无效"));
            }
            List <VsSysApiModule> pFind = _apiModuleService.Query(d => d.SModuleid == sMoudleid);

            return(JsonRes.Success(pFind.ToArray()));
        }
예제 #10
0
        public OkObjectResult Post(string username, string password, string name, string logo, string desc, string email, string phone)
        {
            VsSysUser pExist = _userService.QueryByID(username);

            if (pExist != null)
            {
                return(JsonRes.Fail("用户名已存在"));
            }
            // 循环将所有接口写入权限表
            List <VsSysApiModule> pFindModule = _apiModuleService.Query();

            foreach (var module in pFindModule)
            {
                VsSysPower powerEntity = new VsSysPower
                {
                    Id           = System.Guid.NewGuid().ToString(),
                    SUserid      = username,
                    SModuleid    = module.SModuleid,
                    SApimoduleid = module.Id,
                    BIsdeleted   = false,
                };
                string powerError = "";
                int    powerRes   = _powerService.TryAdd(out powerError, powerEntity);
                if (powerRes == 0)
                {
                    return(JsonRes.Fail(powerEntity, powerError));
                }
            }
            VsSysUser entity = new VsSysUser
            {
                SUsername   = username,
                SPassword   = MD5Generate.Encrypt(password),
                SName       = name,
                DCreatetime = DateTime.Now.ToLocalTime(),
                SLogo       = logo,
                SDesc       = desc,
                SEmail      = email,
                SPhone      = phone
            };
            string error = "";
            int    res   = _userService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }
예제 #11
0
        public OkObjectResult Post(string sName, string sCode, string sType, string sDesc)
        {
            VsTallyType entity = new VsTallyType
            {
                Id    = System.Guid.NewGuid().ToString(),
                SName = sName,
                SCode = sCode,
                SDesc = sDesc,
                SType = sType,
            };
            string error = "";
            int    res   = _tallyTypeService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }
예제 #12
0
        public OkObjectResult Put(string sUserid, string sQuestionid, string sAnswer)
        {
            VsSysSecureUser pExitUser = _secureUserService.QuerySingle(d => d.SUserid == sUserid);

            if (pExitUser == null)
            {
                return(JsonRes.Fail("用户不存在"));
            }
            pExitUser.SQuestionid = sQuestionid;
            pExitUser.SAnswer     = sAnswer;
            string error = "";
            int    res   = _secureUserService.TryUpdate(out error, pExitUser);

            if (res == 0)
            {
                return(JsonRes.Fail(pExitUser, error));
            }
            return(JsonRes.Success(pExitUser));
        }
예제 #13
0
        public OkObjectResult Post(DateTime dTime, double dRmb, string sCode, string sDesc, string sOwner)
        {
            VsIncomeDetail entity = new VsIncomeDetail
            {
                DTime  = dTime,
                FRmb   = dRmb,
                SCode  = sCode,
                SDesc  = sDesc,
                SOwner = sOwner,
            };
            string error = "";
            int    res   = _incomeDetailService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }
예제 #14
0
        public OkObjectResult Post(string sUserid, string sModuleid, string sApiModuleid, bool bIsdeleted = false)
        {
            VsSysUser pFindUser = _userService.QueryByID(sUserid);

            if (pFindUser == null)
            {
                return(JsonRes.Fail("用户不存在"));
            }
            VsSysModule pFindModule = _moduleService.QueryByID(sModuleid);

            if (pFindModule == null)
            {
                return(JsonRes.Fail("模块不存在"));
            }
            VsSysApiModule pFindApi = _apiModuleService.QueryByID(sApiModuleid);

            if (pFindApi == null)
            {
                return(JsonRes.Fail("接口不存在"));
            }
            VsSysPower pExit = _powerService.QuerySingle(d => d.SUserid == sUserid && d.SApimoduleid == sApiModuleid);

            if (pExit != null)
            {
                return(JsonRes.Fail("接口已存在"));
            }
            VsSysPower entity = new VsSysPower
            {
                Id           = System.Guid.NewGuid().ToString(),
                SUserid      = sUserid,
                SModuleid    = sModuleid,
                SApimoduleid = sApiModuleid,
                BIsdeleted   = bIsdeleted,
            };
            string error = "";
            int    res   = _powerService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }
예제 #15
0
        public OkObjectResult GetAnswer(string sUserid, string sQuestionid, string sAnswer)
        {
            VsSysSecureUser pExitUser = _secureUserService.QuerySingle(d => d.SUserid == sUserid);

            if (pExitUser == null)
            {
                return(JsonRes.Fail("用户不存在"));
            }
            VsSysSecureUser pExit = _secureUserService.QuerySingle(d => d.SUserid == sUserid && d.SQuestionid == sQuestionid);

            if (pExit == null)
            {
                return(JsonRes.Fail("密保问题不存在"));
            }
            if (pExit.SAnswer != sAnswer)
            {
                return(JsonRes.Fail("密保答案不正确"));
            }
            return(JsonRes.Success("验证成功"));
        }
예제 #16
0
        public OkObjectResult Delete(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsSysModule pExit = _moduleService.QueryByID(id);

            if (pExit == null)
            {
                return(JsonRes.Fail("模块不存在"));
            }
            string error = "";
            int    res   = _moduleService.TryDelete(out error, pExit);

            if (res == 0)
            {
                return(JsonRes.Fail(pExit, error));
            }
            return(JsonRes.Success(pExit));
        }
예제 #17
0
        public OkObjectResult Delete(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsIncomeDetail pExist = _incomeDetailService.QueryByID(id);

            if (pExist == null)
            {
                return(JsonRes.Fail("数据不存在"));
            }
            string error = "";
            int    res   = _incomeDetailService.TryDelete(out error, pExist);

            if (res == 0)
            {
                return(JsonRes.Fail(pExist, error));
            }
            return(JsonRes.Success(pExist));
        }
예제 #18
0
        public OkObjectResult ModifyPassword(string username, string oldPassword, string newPassword)
        {
            VsSysUser pExist = _userService.QueryByID(username);

            if (pExist == null)
            {
                return(JsonRes.Fail("用户名不存在"));
            }
            if (pExist.SPassword != oldPassword)
            {
                return(JsonRes.Fail("原密码不正确"));
            }
            pExist.SPassword = newPassword;
            string error = "";
            int    res   = _userService.TryUpdate(out error, pExist);

            if (res == 0)
            {
                return(JsonRes.Fail(pExist, error));
            }
            return(JsonRes.Success(pExist));
        }
예제 #19
0
        public OkObjectResult Post(string question)
        {
            VsSysSecure pExist = _vsSysSecureService.QuerySingle(d => d.SQuestion == question);

            if (pExist != null)
            {
                return(JsonRes.Fail("问题已存在"));
            }
            VsSysSecure entity = new VsSysSecure
            {
                Id        = System.Guid.NewGuid().ToString(),
                SQuestion = question
            };
            string error = "";
            int    res   = _vsSysSecureService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }
예제 #20
0
        public OkObjectResult Delete(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(JsonRes.Fail("id无效"));
            }
            VsSysApiModule pExist = _apiModuleService.QueryByID(id);

            if (pExist == null)
            {
                return(JsonRes.Fail("接口不存在"));
            }
            // TODO:先去接口权限表里删除此接口对应的权限信息,再删掉此接口
            string error = "";
            int    res   = _apiModuleService.TryDelete(out error, pExist);

            if (res == 0)
            {
                return(JsonRes.Fail(pExist, error));
            }
            return(JsonRes.Success(pExist));
        }
예제 #21
0
        public object GetJWTToken3(string username, string password)
        {
            string jwtStr = string.Empty;
            bool   suc    = false;

            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                return(JsonRes.Fail("用户名或密码不能为空"));
            }

            var enPassword = MD5Generate.Encrypt(password);
            var user       = _userService.QuerySingle(d => d.SUsername == username);

            if (user != null)
            {
                //更新用户最近登录时间
                user.DLastlogin = DateTime.Now.ToLocalTime();
                string error = "";
                int    res   = _userService.TryUpdate(out error, user);
                if (res == 0)
                {
                    return(JsonRes.Fail(user, error));
                }
                //如果是基于用户的授权策略,这里要添加用户;如果是基于角色的授权策略,这里要添加角色
                var claims = new List <Claim> {
                    new Claim(ClaimTypes.UserData, username), // 使用用户id认证授权
                    new Claim(JwtRegisteredClaimNames.Jti, username),
                    new Claim(ClaimTypes.Expiration, DateTime.Now.AddSeconds(_requirement.Expiration.TotalSeconds).ToString())
                };

                var token = JwtToken.BuildJwtToken(claims.ToArray(), _requirement);
                return(JsonRes.Success(token));
            }
            else
            {
                return(JsonRes.Fail("认证失败"));
            }
        }
예제 #22
0
        public object RefreshToken(string token = "")
        {
            string jwtStr = string.Empty;
            bool   suc    = false;

            if (string.IsNullOrEmpty(token))
            {
                return(JsonRes.Fail("token无效,请重新登录!"));
            }

            var jwtHandler            = new JwtSecurityTokenHandler();
            JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);

            if (!string.IsNullOrEmpty(jwtToken.Id))
            {
                var user = _userService.QueryByID(jwtToken.Id);
                if (user != null)
                {
                    //如果是基于用户的授权策略,这里要添加用户;如果是基于角色的授权策略,这里要添加角色
                    var claims = new List <Claim> {
                        new Claim(ClaimTypes.UserData, user.SUsername),// 使用用户id认证授权
                        new Claim(JwtRegisteredClaimNames.Jti, jwtToken.Id.ObjToString()),
                        new Claim(ClaimTypes.Expiration, DateTime.Now.AddSeconds(_requirement.Expiration.TotalSeconds).ToString())
                    };


                    //用户标识
                    var identity = new ClaimsIdentity(JwtBearerDefaults.AuthenticationScheme);
                    identity.AddClaims(claims);

                    var refreshToken = JwtToken.BuildJwtToken(claims.ToArray(), _requirement);
                    return(JsonRes.Success(refreshToken));
                }
            }

            return(JsonRes.Fail("认证失败"));
        }
예제 #23
0
        public OkObjectResult Post(string sUserid, string sQuestionid, string sAnswer)
        {
            VsSysSecureUser pExitUser = _secureUserService.QuerySingle(d => d.SUserid == sUserid);

            if (pExitUser != null)
            {
                return(JsonRes.Fail("用户密保问题已存在"));
            }
            VsSysSecureUser entity = new VsSysSecureUser
            {
                Id          = System.Guid.NewGuid().ToString(),
                SUserid     = sUserid,
                SQuestionid = sQuestionid,
                SAnswer     = sAnswer,
            };
            string error = "";
            int    res   = _secureUserService.TryAdd(out error, entity);

            if (res == 0)
            {
                return(JsonRes.Fail(entity, error));
            }
            return(JsonRes.Success(entity));
        }