package com.cim.idm.controller;

import com.cim.idm.model.CostCenter;
import com.cim.idm.response.BaseResponse;
import com.cim.idm.response.RespGenerator;
import com.cim.idm.service.CostCenterService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

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


@RestController
@RequestMapping("/CostCenter")
@Slf4j
@Api(tags = "成本中心")
public class CostCenterController {

    @Autowired
    private CostCenterService costCenterService;

    /**
     * 获取成本中心
     * @return
     */
    @RequestMapping(value = "/getCostCenter", method = RequestMethod.GET)
    public BaseResponse<Object> getCostCenter(String erpFactory)  {
        List<CostCenter> costCenters = costCenterService.getCostCenter(erpFactory);
        return RespGenerator.returnOK(costCenters);
    }

    /**
     * 获取用户信息
     * @return
     */
    @RequestMapping(value = "/getUserInfo", method = RequestMethod.GET)
    public BaseResponse<Object> getUserInfo()  {
        List<Map<String, Object>> userInfos = costCenterService.getUserInfo();
        return RespGenerator.returnOK(userInfos);
    }
}
