package com.zanxiang.game.module.manage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zanxiang.game.module.manage.pojo.vo.UserAddressVO;
import com.zanxiang.game.module.manage.service.IUserAddressService;
import com.zanxiang.game.module.mybatis.entity.UserAddress;
import com.zanxiang.game.module.mybatis.mapper.UserAddressMapper;
import com.zanxiang.module.util.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author : lingfeng
 * @time : 2022-07-05
 * @description : 用户地址
 */
@Slf4j
@Service
public class UserAddressServiceImpl extends ServiceImpl<UserAddressMapper, UserAddress> implements IUserAddressService {

    @Override
    public List<UserAddressVO> list(Long userId) {
        return super.list(new LambdaQueryWrapper<UserAddress>().eq(UserAddress::getUserId, userId))
                .stream().map(userAddress -> BeanUtil.copy(userAddress, UserAddressVO.class))
                .collect(Collectors.toList());
    }

}
