Ejemplo n.º 1
0
        public async Task <IResultModel> Edit(Guid id)
        {
            var entity = await _repository.GetAsync(id);

            if (entity == null)
            {
                return(ResultModel.NotExists);
            }

            var model = _mapper.Map <DictUpdateModel>(entity);

            return(ResultModel.Success(model));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取字典
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <SysDict> Get(long id)
        {
            var dict = await _dictRep.GetAsync(id);

            H_AssertEx.That(dict == null, "字典数据不存在");
            H_AssertEx.That(dict.IsDeleted, "字典数据已删除");

            return(dict);
        }
Ejemplo n.º 3
0
        public async Task <IResultModel> Delete(int id)
        {
            var entity = await _repository.GetAsync(id);

            if (entity == null)
            {
                return(ResultModel.NotExists);
            }

            if (await _itemRepository.ExistsDict(entity.GroupCode, entity.Code))
            {
                return(ResultModel.Failed("请先删除关联的数据项"));
            }

            var result = await _repository.DeleteAsync(id);

            if (result)
            {
                await _cacheHandler.RemoveAsync($"{CacheKeys.DictSelect}{entity.GroupCode.ToUpper()}_{entity.Code.ToUpper()}");
            }
            return(ResultModel.Result(result));
        }
Ejemplo n.º 4
0
        public async Task <PopularResult <DictDto> > GetAsync(int id)
        {
            var result = new PopularResult <DictDto>();

            var dict = await _dictRepository.GetAsync(id);

            if (dict == null)
            {
                result.Failed("数据不存在");
                return(result);
            }
            var dto = ObjectMapper.Map <DictEntity, DictDto>(dict);

            result.Success(dto);
            return(result);
        }