package com.zkqy.web.controller.homepagestatistics;

import com.zkqy.common.config.datasource.constant.DataSourceType;
import com.zkqy.common.core.domain.AjaxResult;
import com.zkqy.common.utils.SecurityUtils;
import com.zkqy.system.entity.DragForm;
import com.zkqy.system.entity.DragTable;
import com.zkqy.system.entity.DragTableGroup;
import com.zkqy.system.service.impl.DragFormServiceImpl;
import com.zkqy.system.service.impl.DragTableGroupServiceImpl;
import com.zkqy.system.service.impl.DragTableServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
@RequestMapping("/statistics/info")
public class StatisticsController {


    @Autowired
    DragTableServiceImpl dragTableService;

    @Autowired
    DragFormServiceImpl dragFormService;


    @Autowired
    DragTableGroupServiceImpl dragTableGroupService;

    /**
     * 表单表格统计
     * DataModelingStatistics
     */
    @GetMapping("/getTabularStatistics")
    public AjaxResult getTabularStatistics(){
        //表单
        DragForm dragForm =new DragForm();
        int dragFormsCount = dragFormService.selectDragFormListCount(dragForm);
        //表格
        DragTable dragTable =new DragTable();
        int dragTablesCount = dragTableService.selectDragTableListCount(dragTable);

        //三级联动
        DragTableGroup dragTableGroup =new DragTableGroup();
        int dragTableGroupsCount = dragTableGroupService.selectDragTableGroupListCount(dragTableGroup);

        List<Map> list=new ArrayList<>();
        HashMap dragFormsMap=new HashMap();
        dragFormsMap.put("name","表单");
        dragFormsMap.put("value",dragFormsCount);
        list.add(dragFormsMap);

        HashMap dragTableSMap=new HashMap();
        dragTableSMap.put("name","表格");
        dragTableSMap.put("value",dragTablesCount);
        list.add(dragTableSMap);

        HashMap dragTableGroupsSMap=new HashMap();
        dragTableGroupsSMap.put("name","三级联动");
        dragTableGroupsSMap.put("value",dragTableGroupsCount);
        list.add(dragTableGroupsSMap);

        return AjaxResult.success(list);
    }

}
