package sgc.portal.cw.cw0202.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sgc.portal.base.util.EasyHashMap;
import sgc.portal.base.websquare.GridRowStatus;
import sgc.portal.cw.cw0202.dto.CW02020001USearch;
import sgc.portal.cw.cw0202.model.CW02020001U;
import sgc.portal.cw.cw0202.persistence.CW02020001UMapper;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CW02020001UService {
    private final CW02020001UMapper mapper;

    public CW02020001UService(CW02020001UMapper mapper) {
        this.mapper = mapper;
    }

    public List<EasyHashMap<String, Object>> getList(CW02020001USearch search) {
        return mapper.getList(search);
    }

    @Transactional
    public Map<String, String> approve(List<CW02020001U> CW02020001U) {
    	
    	Map<String,String> result = new HashMap<>();
    	
    	for (CW02020001U cW02020001U : CW02020001U) {
        	approve(cW02020001U);
        }
    	
    	return result;
    }
    
    private void approve(CW02020001U cW02020001U) {
        mapper.approve(cW02020001U);
    }
    
    @Transactional
    public Map<String, String> reject(List<CW02020001U> CW02020001U) {
    	
    	Map<String,String> result = new HashMap<>();
    	
    	for (CW02020001U cW02020001U : CW02020001U) {
        	reject(cW02020001U);
        }
    	
    	return result;
    }
    
    private void reject(CW02020001U cW02020001U) {
        mapper.reject(cW02020001U);
    }
}
