Search in sources :

Example 1 with MdcDict

use of com.paascloud.provider.model.domain.MdcDict in project paascloud-master by paascloud.

the class MdcDictServiceImpl method getMdcDictVoById.

@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public MdcDictVo getMdcDictVoById(Long dictId) {
    MdcDict dict = mdcDictMapper.selectByPrimaryKey(dictId);
    if (dict == null) {
        logger.error("找不到数据字典信息id={}", dictId);
        throw new MdcBizException(ErrorCodeEnum.MDC10021018, dictId);
    }
    // 获取父级菜单信息
    MdcDict parentDict = mdcDictMapper.selectByPrimaryKey(dict.getPid());
    ModelMapper modelMapper = new ModelMapper();
    MdcDictVo dictVo = modelMapper.map(dict, MdcDictVo.class);
    if (parentDict != null) {
        dictVo.setParentDictName(parentDict.getDictName());
    }
    return dictVo;
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) MdcDictVo(com.paascloud.provider.model.vo.MdcDictVo) MdcDict(com.paascloud.provider.model.domain.MdcDict) ModelMapper(org.modelmapper.ModelMapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with MdcDict

use of com.paascloud.provider.model.domain.MdcDict in project paascloud-master by paascloud.

the class MdcDictServiceImpl method updateMdcDictStatusById.

@Override
public void updateMdcDictStatusById(UpdateStatusDto updateStatusDto, LoginAuthDto loginAuthDto) {
    Long id = updateStatusDto.getId();
    Integer status = updateStatusDto.getStatus();
    // 要处理的菜单集合
    List<MdcDict> mdcDictList = Lists.newArrayList();
    int result;
    if (status.equals(MdcDictStatusEnum.DISABLE.getType())) {
        // 获取菜单以及子菜单
        mdcDictList = this.getAllDictFolder(id, MdcDictStatusEnum.ENABLE.getType());
    } else {
        // 获取菜单、其子菜单以及父菜单
        MdcDict uacMenu = new MdcDict();
        uacMenu.setPid(id);
        result = this.selectCount(uacMenu);
        // 此菜单含有子菜单
        if (result > 0) {
            mdcDictList = this.getAllDictFolder(id, MdcDictStatusEnum.DISABLE.getType());
        }
        List<MdcDict> dictListTemp = this.getAllParentDictFolderByMenuId(id);
        for (MdcDict dict : dictListTemp) {
            if (!mdcDictList.contains(dict)) {
                mdcDictList.add(dict);
            }
        }
    }
    this.updateDictStatus(mdcDictList, loginAuthDto, status);
}
Also used : MdcDict(com.paascloud.provider.model.domain.MdcDict)

Example 3 with MdcDict

use of com.paascloud.provider.model.domain.MdcDict in project paascloud-master by paascloud.

the class MdcDictServiceImpl method updateDictStatus.

private void updateDictStatus(List<MdcDict> mdcDictList, LoginAuthDto loginAuthDto, int status) {
    MdcDict update = new MdcDict();
    for (MdcDict dict : mdcDictList) {
        update.setId(dict.getId());
        update.setVersion(dict.getVersion() + 1);
        update.setStatus(status);
        update.setUpdateInfo(loginAuthDto);
        int result = mapper.updateByPrimaryKeySelective(update);
        if (result < 1) {
            throw new MdcBizException(ErrorCodeEnum.MDC10021019, dict.getId());
        }
    }
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) MdcDict(com.paascloud.provider.model.domain.MdcDict)

Example 4 with MdcDict

use of com.paascloud.provider.model.domain.MdcDict in project paascloud-master by paascloud.

the class MdcDictServiceImpl method buildParentNote.

/**
 * 递归获取菜单的父菜单
 */
private List<MdcDict> buildParentNote(List<MdcDict> mdcDictList, MdcDict mdcDict) {
    List<MdcDict> mdcDictQueryList = mapper.select(mdcDict);
    MdcDict uacMenuQuery;
    for (MdcDict dict : mdcDictQueryList) {
        if (MdcDictStatusEnum.DISABLE.getType() == dict.getStatus()) {
            mdcDictList.add(dict);
        }
        uacMenuQuery = new MdcDict();
        uacMenuQuery.setId(dict.getPid());
        buildParentNote(mdcDictList, uacMenuQuery);
    }
    return mdcDictList;
}
Also used : MdcDict(com.paascloud.provider.model.domain.MdcDict)

Example 5 with MdcDict

use of com.paascloud.provider.model.domain.MdcDict in project paascloud-master by paascloud.

the class MdcDictServiceImpl method getAllDictFolder.

private List<MdcDict> getAllDictFolder(Long id, int dictStatus) {
    MdcDict mdcDict = new MdcDict();
    mdcDict.setId(id);
    mdcDict = mapper.selectOne(mdcDict);
    List<MdcDict> mdcDictList = Lists.newArrayList();
    mdcDictList = buildNode(mdcDictList, mdcDict, dictStatus);
    return mdcDictList;
}
Also used : MdcDict(com.paascloud.provider.model.domain.MdcDict)

Aggregations

MdcDict (com.paascloud.provider.model.domain.MdcDict)10 MdcBizException (com.paascloud.provider.exceptions.MdcBizException)3 Transactional (org.springframework.transaction.annotation.Transactional)2 LoginAuthDto (com.paascloud.base.dto.LoginAuthDto)1 MdcDictVo (com.paascloud.provider.model.vo.MdcDictVo)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ModelMapper (org.modelmapper.ModelMapper)1