public JsonResponse AddCategory([FromBody] AccountCategoryDto dto)
        {
            //判断用户是否登录
            if (!TokenHelper.CheckLoginStateByUserId(dto.UserId))
            {
                return(BadResponse("用户未登录", null, false));
            }
            //查询有没有
            var model = AccountCategoryBll.GetModelByName(dto.Name);

            //有的话则UserNum+1
            if (model != null)
            {
                model.UserNum = model.UserNum + 1;
                if (!AccountCategoryBll.Update(model))
                {
                    return(BadResponse("网络错误,请重试!"));
                }
            }
            //没有则添加
            else
            {
                model = new AccountCategory
                {
                    Name         = dto.Name,
                    CreateUserId = dto.UserId
                };
                if (!AccountCategoryBll.Insert(model))
                {
                    return(BadResponse("网络错误,请重试!"));
                }
            }
            //将Category的Id添加到UserInfo的Category字段中
            model = AccountCategoryBll.GetModelByName(dto.Name);
            var user = UserInfoBll.GetModelById(dto.UserId);

            if (user == null)
            {
                return(BadResponse("用户信息出错,请重试!"));
            }
            user.Category += (model.Name + ",");
            if (!UserInfoBll.Update(user))
            {
                return(BadResponse("网络错误,请重试!"));
            }
            return(OkResponse(null, "添加成功!"));
        }
        public JsonResponse DeleteUserCategory([FromBody] AccountCategoryDto dto)
        {
            //判断用户是否登录
            if (!TokenHelper.CheckLoginStateByUserId(dto.UserId))
            {
                return(BadResponse("用户未登录", null, false));
            }
            //查询该类别的Id
            var categoryModel = AccountCategoryBll.GetModelByName(dto.Name);
            //从UserInfo中的Category字段里删除该类别
            var userModel = UserInfoBll.GetModelById(dto.UserId);

            if (userModel == null)
            {
                return(BadResponse("用户信息出错,请重试!"));
            }
            userModel.Category = userModel.Category.Replace((categoryModel.Name + ","), "");
            if (!UserInfoBll.Update(userModel))
            {
                return(BadResponse("网络错误,请重试!"));
            }
            if (categoryModel == null)
            {
                //此时代表数据库出问题了,应作出处理-----------------------------------------------------------------
                return(OkResponse(null, "删除成功!"));
            }
            //类别表中该类别使用数-1,若使用数为0则删除该类别
            if (categoryModel.UserNum == 1)
            {
                AccountCategoryBll.ExecuteSql("delete from AccountCategory where Name='" + categoryModel.Name + "'");
            }
            else
            {
                categoryModel.UserNum--;
                if (AccountCategoryBll.Update(categoryModel))
                {
                    return(BadResponse("网络错误,请重试!"));
                }
            }

            return(OkResponse(null, "删除成功!"));
        }