package com.cpop.jambox.business.service.impl;

import com.cpop.jambox.business.vo.CooperationTypeVo;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.cpop.jambox.business.entity.website.CooperationType;
import com.cpop.jambox.business.mapper.CooperationTypeMapper;
import com.cpop.jambox.business.service.CooperationTypeService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 果酱模块化官网 合作类别表 服务层实现。
 *
 * @author Yxz
 * @since 2024-01-19
 */
@Service("cooperationTypeService")
public class CooperationTypeServiceImpl extends ServiceImpl<CooperationTypeMapper, CooperationType> implements CooperationTypeService {

    /**
     * 查询所有果酱模块化官网 合作类别表。
     *
     * @author: Yxz
     * @date: 2024/1/22 19:19
     * @param: []
     * @return: java.util.List<com.cpop.jambox.business.vo.CooperationTypeVo>
     **/
    @Override
    public List<CooperationTypeVo> getList() {
        List<CooperationTypeVo> cooperationTypeVoList = this.list().stream().map(entity -> {
            CooperationTypeVo vo = new CooperationTypeVo();
            BeanUtils.copyProperties(entity,vo,"updateTime");

            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            String updateTime = entity.getUpdateTime().format(formatter);

            vo.setUpdateTime(updateTime);
            return vo;
        }).collect(Collectors.toList());
        return cooperationTypeVoList;
    }
}
