package sgc.portal.cw.cw0501.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sgc.portal.base.util.EasyHashMap;
import sgc.portal.cw.cw0501.dto.CW05010001USearch;
import sgc.portal.cw.cw0501.model.CW05010001U;
import sgc.portal.cw.cw0501.service.CW05010001UService;

import java.util.List;

@RestController
@RequestMapping("/cw/cw0501")
public class CW05010001UController {
    private final CW05010001UService service;

    public CW05010001UController(CW05010001UService service) {
        this.service = service;
    }

    @PostMapping("/CW05010001U/list")
    public List<EasyHashMap<String, Object>> getCW05010001UBy(@RequestBody CW05010001USearch search) {
    	if (service.getCW05010001UBy(search).size() < 1) {
    		return service.getCW05010002UBy(search);
    	} else {
            return service.getCW05010001UBy(search);
    	}
    }
}