package com.huigou.topsun.sap.clientMaterials.controller;

import com.huigou.topsun.sap.clientMaterials.application.ClientMaterialsItemApplication;
import com.huigou.topsun.sap.clientMaterials.domain.query.ClientMaterialsQueryRequest;
import com.huigou.topsun.sap.componentSupply.application.ComponentSupplyItemApplication;
import com.huigou.topsun.sap.componentSupply.domain.query.ComponentSupplyQueryRequest;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.client.CommonController;
import com.huigou.util.SDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Map;

/**
 * @Auther: LXH
 * @Date:  2024/07/25 10:10
 * @Description:
 */
@Controller
@ControllerMapping("/clientMaterials")
public class ClientMaterialsItemController extends CommonController {
    @Autowired
    private ClientMaterialsItemApplication clientMaterialsItemApplication;

    public String queryClientMaterialsItems(){
        SDO sdo = this.getSDO();
        ClientMaterialsQueryRequest queryRequest = sdo.toQueryRequest(ClientMaterialsQueryRequest.class);
        Map<String, Object> map = clientMaterialsItemApplication.queryClientMaterialsItems(queryRequest);
        return toResult(map);
    }

    public String deleteClientMaterialsItems(){
        SDO sdo = this.getSDO();
        List<String> ids = sdo.getIds();
        clientMaterialsItemApplication.deleteByIds(ids);
        return success();
    }
}
