Search in sources :

Example 96 with ModelMapper

use of org.modelmapper.ModelMapper in project paascloud-master by paascloud.

the class MdcProductServiceImpl method getProductVo.

@Override
public ProductVo getProductVo(final Long id) {
    MdcProduct mdcProduct = mdcProductMapper.selectByPrimaryKey(id);
    ProductVo productVo = new ModelMapper().map(mdcProduct, ProductVo.class);
    List<Long> categoryIdList = Lists.newArrayList();
    buildCategoryIdList(categoryIdList, mdcProduct.getCategoryId());
    // 获取分类节点集合
    Collections.reverse(categoryIdList);
    productVo.setCategoryIdList(categoryIdList);
    // 获取图片集合
    final OptBatchGetUrlRequest request = new OptBatchGetUrlRequest(mdcProduct.getProductCode());
    request.setEncrypt(true);
    List<ElementImgUrlDto> imgUrlList = opcRpcService.listFileUrl(request);
    productVo.setImgUrlList(imgUrlList);
    return productVo;
}
Also used : OptBatchGetUrlRequest(com.paascloud.provider.model.dto.oss.OptBatchGetUrlRequest) ProductVo(com.paascloud.provider.model.vo.ProductVo) MdcProduct(com.paascloud.provider.model.domain.MdcProduct) ModelMapper(org.modelmapper.ModelMapper) ElementImgUrlDto(com.paascloud.provider.model.dto.oss.ElementImgUrlDto)

Example 97 with ModelMapper

use of org.modelmapper.ModelMapper in project paascloud-master by paascloud.

the class MdcProductCategoryServiceImpl method getMdcCategoryVoById.

@Override
public MdcCategoryVo getMdcCategoryVoById(final Long categoryId) {
    MdcProductCategory category = mdcProductCategoryMapper.selectByPrimaryKey(categoryId);
    if (category == null) {
        logger.error("找不到数据字典信息id={}", categoryId);
        throw new MdcBizException(ErrorCodeEnum.MDC10023001, categoryId);
    }
    // 获取父级菜单信息
    MdcProductCategory parentCategory = mdcProductCategoryMapper.selectByPrimaryKey(category.getPid());
    ModelMapper modelMapper = new ModelMapper();
    MdcCategoryVo categoryVo = modelMapper.map(category, MdcCategoryVo.class);
    categoryVo.setId(category.getId());
    categoryVo.setPid(category.getPid());
    if (parentCategory != null) {
        categoryVo.setParentCategoryName(parentCategory.getName());
    }
    return categoryVo;
}
Also used : MdcBizException(com.paascloud.provider.exceptions.MdcBizException) MdcProductCategory(com.paascloud.provider.model.domain.MdcProductCategory) MdcCategoryVo(com.paascloud.provider.model.vo.MdcCategoryVo) ModelMapper(org.modelmapper.ModelMapper)

Example 98 with ModelMapper

use of org.modelmapper.ModelMapper in project paascloud-master by paascloud.

the class OmcOrderServiceImpl method queryOrderDtoByUserIdAndOrderNo.

@Override
public OrderDto queryOrderDtoByUserIdAndOrderNo(Long userId, String orderNo) {
    OmcOrder omcOrder = this.queryByUserIdAndOrderNo(userId, orderNo);
    if (omcOrder == null) {
        throw new OmcBizException(ErrorCodeEnum.OMC10031005, orderNo);
    }
    ModelMapper modelMapper = new ModelMapper();
    return modelMapper.map(omcOrder, OrderDto.class);
}
Also used : OmcBizException(com.paascloud.provider.exceptions.OmcBizException) OmcOrder(com.paascloud.provider.model.domain.OmcOrder) ModelMapper(org.modelmapper.ModelMapper)

Example 99 with ModelMapper

use of org.modelmapper.ModelMapper in project Settler by EmhyrVarEmreis.

the class UserService method getUsersWithValue.

public ResponseEntity<List<UserWithValueDTO>> getUsersWithValue(Long userId) {
    getPermissionManager().authorizeGlobalAdmin();
    if (Objects.isNull(userId) || userId < 0) {
        userId = Security.currentUser().getId();
    }
    QUser user = QUser.user;
    QTransaction transaction = QTransaction.transaction;
    List<Tuple> fetch = new JPAQuery<>(entityManager).from(user, transaction).select(user, transaction.value.sum()).where(transaction.creator.id.eq(userId)).where(user.id.ne(userId)).where(transaction.owners.any().id.user.eq(user).or(transaction.contractors.any().id.user.eq(user))).groupBy(user.id, user.firstName, user.lastName, user.email, user.created, user.avatar, user.login, user.accountExpireDate).orderBy(transaction.value.sum().desc()).fetch();
    ModelMapper preparedModelMapper = getModelMapper();
    List<UserWithValueDTO> userWithValueDTOList = new ArrayList<>(fetch.size());
    for (Tuple tuple : fetch) {
        User u = tuple.get(user);
        Double d = tuple.get(transaction.value.sum());
        if (Objects.nonNull(u)) {
            userWithValueDTOList.add(new UserWithValueDTO(userId, preparedModelMapper.map(u, String.class), d));
        }
    }
    return new ResponseEntity<>(userWithValueDTOList, HttpStatus.OK);
}
Also used : QUser(pl.morecraft.dev.settler.domain.QUser) QTransaction(pl.morecraft.dev.settler.domain.QTransaction) ResponseEntity(org.springframework.http.ResponseEntity) User(pl.morecraft.dev.settler.domain.User) QUser(pl.morecraft.dev.settler.domain.QUser) ArrayList(java.util.ArrayList) JPAQuery(com.querydsl.jpa.impl.JPAQuery) Tuple(com.querydsl.core.Tuple) ModelMapper(org.modelmapper.ModelMapper)

Example 100 with ModelMapper

use of org.modelmapper.ModelMapper in project Settler by EmhyrVarEmreis.

the class ListPageConverter method convert.

public <S, T> List<T> convert(List<S> source, Class<T> tClass) {
    List<T> content = new ArrayList<>();
    ModelMapper modelMapper = entityConvertersPack.getPreparedModelMapper();
    for (S s : source) {
        content.add(modelMapper.map(s, tClass));
    }
    return content;
}
Also used : ArrayList(java.util.ArrayList) ModelMapper(org.modelmapper.ModelMapper)

Aggregations

ModelMapper (org.modelmapper.ModelMapper)185 Bean (org.springframework.context.annotation.Bean)35 ArrayList (java.util.ArrayList)18 Date (java.util.Date)6 LocalDate (java.time.LocalDate)5 List (java.util.List)5 Map (java.util.Map)5 Optional (java.util.Optional)5 Actor (com.management.entities.Actor)4 CinemaTheatre (com.management.entities.CinemaTheatre)4 Event (com.management.entities.Event)4 Performance (com.management.entities.Performance)4 Props (com.management.entities.Props)4 User (com.management.entities.User)4 Collectors (java.util.stream.Collectors)4 PutMessageRequestType (no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Actorperformances (com.management.entities.Actorperformances)3 FanZone (com.management.entities.FanZone)3