package com.bonus.zlpt.bigscreen.controller;

import com.bonus.zlpt.common.core.web.controller.BaseController;
import com.bonus.zlpt.common.core.web.domain.AjaxResult;
import com.bonus.zlpt.bigscreen.domain.vo.CompanyInfoVo;
import com.bonus.zlpt.bigscreen.service.BmMachinistInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 机手信息表(BmMachinistInfo)表控制层
 *
 * @author makejava
 * @since 2023-11-30 12:06:56
 */
@RestController
@RequestMapping("bmMachinistInfo")
public class BmMachinistInfoController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private BmMachinistInfoService bmMachinistInfoService;

    /**
     * 获取企业所属对应的机手数量以及机手总人数
     * @return
     */
    @GetMapping("/list")
    public AjaxResult list()
    {
        List<CompanyInfoVo> machinistInfos = bmMachinistInfoService.selectMachinistInfoList();
        int totalCount = 0;
        for (CompanyInfoVo companyInfo : machinistInfos) {
            totalCount += companyInfo.getCount();
        }
        Map<String, Object> map = new HashMap<>(2);
        map.put("total", totalCount);
        map.put("type", machinistInfos);
        return success(map);
    }

}

