package com.cool.store.vo.inspection.setting;

import com.cool.store.entity.HyInspectionSettingDO;
import com.github.pagehelper.Page;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author zhangchenbiao
 * @FileName: InspectionSettingPageVO
 * @Description:
 * @date 2023-07-17 14:32
 */
@Data
public class InspectionSettingPageVO {

    @ApiModelProperty("id")
    private Long inspectionSettingId;

    @ApiModelProperty("区域名称")
    private String zoneName;

    @ApiModelProperty("稽核人id")
    private String inspectionUserId;

    @ApiModelProperty("稽核人名称")
    private String inspectionUserName;

    @ApiModelProperty("更新时间")
    private Date updateTime;

    @ApiModelProperty("更新人名称")
    private String updateUserName;

    /**
     * dto转vo
     * @param pageList
     * @param userNameMap
     * @return
     */
    public static List<InspectionSettingPageVO> convert(Page<HyInspectionSettingDO> pageList, Map<String, String> userNameMap){
        if(CollectionUtils.isEmpty(pageList)){
            return Lists.newArrayList();
        }
        List<InspectionSettingPageVO> resultList = new ArrayList<>();
        for (HyInspectionSettingDO inspectionSetting : pageList) {
            InspectionSettingPageVO result = new InspectionSettingPageVO();
            result.setInspectionSettingId(inspectionSetting.getId());
            result.setZoneName(inspectionSetting.getZoneName());
            result.setInspectionUserId(inspectionSetting.getInspectionUserId());
            result.setInspectionUserName(userNameMap.get(inspectionSetting.getInspectionUserId()));
            result.setUpdateTime(inspectionSetting.getUpdateTime());
            result.setUpdateUserName(userNameMap.get(inspectionSetting.getUpdateUserId()));
            resultList.add(result);
        }
        return resultList;
    }

}
