/*
 * Author: Zev
 * 生成ServiceImpl
 */
package com.tofly.gpsboot.service.build.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.tofly.pojo.build.vo.BuildplanVo;
import com.tofly.gpsboot.mapper.build.BuildplanMapper;
import com.tofly.gpsboot.service.build.BuildplanService;
import com.tofly.pojo.plan.Plan;
import org.springframework.stereotype.Service;
import com.tofly.pojo.build.Buildplan;

import java.util.List;


/**
 * 工地巡查计划关联信息表
 *
 * @author admin
 * @date Thu Mar 18 00:00:00 CST 2021
 */
@Service("buildplanService")
public class BuildplanServiceImpl extends ServiceImpl<BuildplanMapper, Buildplan> implements BuildplanService {

    @Override
    public void saveBuildPlanRelation(List<Plan> planList, Long buildId){
        planList.forEach(info ->{
            Buildplan buildplan = new Buildplan();
            buildplan.setPlanId(info.getId());
            buildplan.setBuildId(buildId);
            this.save(buildplan);
        });
    }

    @Override
    public List<BuildplanVo> viewConversion(List<Buildplan> infoList) {
        // 无转换类型
        return JSONArray.parseArray(JSON.toJSONString(infoList), BuildplanVo.class);
    }
}
