예제 #1
0
        public async Task <IActionResult> GoUrl(int id = 0)
        {
            var response = await _blogArticleServices.QueryById(id);

            if (response != null && response.bsubmitter.IsNotEmptyOrNull())
            {
                response.btraffic += 1;
                await _blogArticleServices.Update(response);

                return(Redirect(response.bsubmitter));
            }

            return(Ok());
        }
        public async Task <MessageModel <string> > Put([FromBody] BlogArticle request)
        {
            var data = new MessageModel <string>();

            if (request.bID > 0)
            {
                data.success = await _blogArticleServices.Update(request);

                if (data.success)
                {
                    data.msg      = "更新成功";
                    data.response = request?.bID.ObjToString();
                }
            }

            return(data);
        }
예제 #3
0
        public async Task Execute(IJobExecutionContext context)
        {
            var article = await _blogArticleServices.QueryById(1);

            article.ArticleVisitNumber += 1;
            await _blogArticleServices.Update(article);

            Trace.WriteLine("定时任务 Test  " + DateTime.Now.ToString());
        }
예제 #4
0
        public async Task <IActionResult> GoUrl(int id = 0)
        {
            var response = await _blogArticleServices.QueryById(id);

            if (response != null && response.bsubmitter.IsNotEmptyOrNull())
            {
                string Url = @"^http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$";
                if (Regex.IsMatch(response.bsubmitter, Url))
                {
                    response.btraffic += 1;
                    await _blogArticleServices.Update(response);

                    return(Redirect(response.bsubmitter));
                }
            }

            return(Ok());
        }
예제 #5
0
        public async Task <MessageModel <ResponseEnum> > Get()
        {
            var data = new MessageModel <ResponseEnum>();

            /*
             *  测试 sql 查询
             */
            var queryBySql = await _blogArticleServices.QuerySql("SELECT bsubmitter,btitle,bcontent,bCreateTime FROM BlogArticle WHERE bID>5");

            /*
             *  测试按照指定列查询
             */
            var queryByColums = await _blogArticleServices
                                .Query <BlogViewModels>(it => new BlogViewModels()
            {
                btitle = it.btitle
            });

            /*
             *  测试 sql 更新
             *
             * 【SQL参数】:@bID:5
             *  @bsubmitter:laozhang619
             *  @IsDeleted:False
             * 【SQL语句】:UPDATE `BlogArticle`  SET
             *  `bsubmitter`=@bsubmitter,`IsDeleted`=@IsDeleted  WHERE `bID`=@bID
             */
            var updateSql = await _blogArticleServices.Update(new { bsubmitter = $"laozhang{DateTime.Now.Millisecond}", IsDeleted = false, bID = 5 });


            // 测试模拟异常,全局异常过滤器拦截
            var i = 0;
            var d = 3 / i;


            // 测试 AOP 缓存
            var blogArticles = await _blogArticleServices.GetBlogs();


            // 测试多表联查
            var roleModulePermissions = await _roleModulePermissionServices.QueryMuchTable();


            // 测试多个异步执行时间
            var roleModuleTask = _roleModulePermissionServices.Query();
            var listTask       = _advertisementServices.Query();
            var ad             = await roleModuleTask;
            var list           = await listTask;


            // 测试service层返回异常
            _advertisementServices.ReturnExp();

            return(data);
        }
예제 #6
0
        public async Task <MessageModel <string> > Delete(int id)
        {
            var data = new MessageModel <string>();

            if (id > 0)
            {
                var blogArticle = await _blogArticleServices.QueryById(id);

                blogArticle.IsDeleted = true;
                data.success          = await _blogArticleServices.Update(blogArticle);

                if (data.success)
                {
                    data.msg      = "删除成功";
                    data.response = blogArticle?.bID.ObjToString();
                }
            }

            return(data);
        }
예제 #7
0
        public async Task <MessageModel <ResponseEnum> > Get()
        {
            var data = new MessageModel <ResponseEnum>();

            await _redisBasketRepository.ListLeftPushAsync(RedisMqKey.Loging, "xxxxxxxxxxxxxxxxxxx");

            /*
             *  测试 sql 查询
             */
            var queryBySql = await _blogArticleServices.QuerySql("SELECT bsubmitter,btitle,bcontent,bCreateTime FROM BlogArticle WHERE bID>5");


            /*
             *  测试 sql 更新
             *
             * 【SQL参数】:@bID:5
             *  @bsubmitter:laozhang619
             *  @IsDeleted:False
             * 【SQL语句】:UPDATE `BlogArticle`  SET
             *  `bsubmitter`=@bsubmitter,`IsDeleted`=@IsDeleted  WHERE `bID`=@bID
             */
            var updateSql = await _blogArticleServices.Update(new { bsubmitter = $"laozhang{DateTime.Now.Millisecond}", IsDeleted = false, bID = 5 });


            // 测试模拟异常,全局异常过滤器拦截
            var i = 0;
            var d = 3 / i;


            // 测试 AOP 缓存
            var blogArticles = await _blogArticleServices.GetBlogs();


            // 测试多表联查
            var roleModulePermissions = await _roleModulePermissionServices.QueryMuchTable();


            // 测试多个异步执行时间
            var roleModuleTask = _roleModulePermissionServices.Query();
            var listTask       = _advertisementServices.Query();
            var ad             = await roleModuleTask;
            var list           = await listTask;


            // 测试service层返回异常
            _advertisementServices.ReturnExp();

            Love love = null;

            love.SayLoveU();

            return(data);
        }
        public async Task <MyBlogCommonResponse <bool> > UpdateBlogArticle([FromBody] BlogArticle blogArticle)
        {
            MyBlogCommonResponse <bool> response = new MyBlogCommonResponse <bool>();

            try
            {
                blogArticle.ArticleLastUpdateTime  = DateTime.Now;
                blogArticle.ArticleHtmlContent     = blogArticle.ArticleHtmlContent.Replace(Appsettings.app(new string[] { "ImageCommonPath", "ImageHttpAddress" }), Appsettings.app(new string[] { "ImageCommonPath", "MyBlogImageHttpAddressPlaceholder" }));
                blogArticle.ArticleMarkdownContent = blogArticle.ArticleMarkdownContent.Replace(Appsettings.app(new string[] { "ImageCommonPath", "ImageHttpAddress" }), Appsettings.app(new string[] { "ImageCommonPath", "MyBlogImageHttpAddressPlaceholder" }));
                blogArticle.ArticleCoverImage      = blogArticle.ArticleCoverImage?.Replace(Appsettings.app(new string[] { "ImageCommonPath", "ImageHttpAddress" }), Appsettings.app(new string[] { "ImageCommonPath", "MyBlogImageHttpAddressPlaceholder" }));
                var result = await _blogArticleServices.Update(blogArticle);

                response.code = 200; response.success = true;
                response.data = result;
                return(response);
            }
            catch (Exception ex)
            {
                response.message = ex.Message.ToString();
                response.code    = 500;
                return(response);
            }
        }
 public async Task <MessageModel> Update(BlogArticle model)
 {
     return(new MessageModel(await _BlogArticleServices.Update(model)));
 }