public async Task <MessageModel <string> > Put(blogarticle blogarticle)
        {
            var data = new MessageModel <string>();

            if (blogarticle != null && blogarticle.Id > 0)
            {
                var model = await _blogarticleServices.QueryById(blogarticle.Id);

                if (model != null)
                {
                    model.btitle      = blogarticle.btitle;
                    model.bcategory   = blogarticle.bcategory;
                    model.isPublic    = blogarticle.isPublic;
                    model.isTop       = blogarticle.isTop;
                    model.digest      = blogarticle.digest;
                    model.bcontent    = blogarticle.bcontent;
                    model.bUpdateTime = DateTime.Now;
                    model.bRemark     = blogarticle.bRemark;
                    data.success      = await _blogarticleServices.Update(model);

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

            return(data);
        }
Esempio n. 2
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.ToString()));
            }

            return(Ok());
        }
Esempio n. 3
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");


            /*
             *  测试 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);
        }