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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations