Beispiel #1
0
        public async Task <ApiResult> SetCurrent([FromBody] SiteCurrentInput siteCurrentInput)
        {
            //把之前缓存存储的站点拿出来设置为不是当前的。
            var model = await _service.GetModelAsync(d => d.Id == siteCurrentInput.Id && d.IsDel == false && d.IsCurrent == false);

            if (model == null)
            {
                throw new FriendlyException("当前站点实体信息为空!");
            }
            var currentSite = _cacheHelper.Get <Site>(KeyHelper.Cms.CurrentSite);

            if (currentSite != null)
            {
                currentSite.IsCurrent = false;
                //不要使用全部更新  有可能缓存的实体比较旧
                await _service.UpdateAsync(d => new Site()
                {
                    IsCurrent = false
                }, d => d.Id == currentSite.Id);
            }

            model.IsCurrent = true;
            await _service.UpdateAsync(model);

            //这里最好更新下缓存
            _cacheHelper.Set(KeyHelper.Cms.CurrentSite, model);
            return(new ApiResult());
        }
Beispiel #2
0
        public virtual async Task <ApiResult> Detail([FromQuery] TDetailQuery detailQuery)
        {
            var res = await _service.GetModelAsync(d => d.Id == detailQuery.Id);

            return(new ApiResult(data: res));
        }