package com.base.biz.controller.rpc;


import com.base.api.model.TargetDemandRpcDTO;
import com.base.api.model.request.QueryStationAddRpcDTO;
import com.base.biz.model.dto.response.TargetDemandDTO;
import com.base.biz.model.entity.TargetDemand;
import com.base.biz.service.TargetDemandService;
import com.base.orbit.utils.BizUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@RestController

@RequestMapping("/rpc/tragetDemand")
public class TragetDemandRpcController {

    @Resource
    private TargetDemandService targetDemandService;

    // 根据parentIds查询目标信息
    @PostMapping("/selTargetDemandByParentId")
    public List<TargetDemandRpcDTO> selTargetDemandByParentId(@RequestBody Set<String> parents) {
        List<TargetDemandRpcDTO> targetDemands = targetDemandService.selTargetDemandByParentId(parents);
        return targetDemands;
    }

    // 根据parentIds查询目标信息
    @PostMapping("//demand/commit")
    public void batchStatus(@RequestBody List<TargetDemandRpcDTO> list) {
        List<TargetDemandDTO> targetDemandDTOS = BizUtils.copyEntityToDto(TargetDemandDTO.class, list);
        targetDemandService.batchStatus(targetDemandDTOS);
    }

}
