package com.ruoyi.web.controller.base;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.info.hospital.domain.vo.HospitalStatisticsVo;
import com.ruoyi.info.hospital.service.IHospitalService;
import com.ruoyi.info.order.service.IOrderService;
import com.ruoyi.info.service.domain.vo.ServiceCategorizeStatisticsVo;
import com.ruoyi.info.service.service.IServiceProductService;
import com.ruoyi.user.domain.vo.UserStatisticsVo;
import com.ruoyi.user.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 首页管理 Controller
 *
 * @author xiechao
 * @date 2023-12-21
 */
@Validated
@Api(value = "首页管理控制器", tags = {"首页管理"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/home")
public class HomeController extends BaseController {

    private final IUserService userService;
    private final IHospitalService hospitalService;
    private final IOrderService orderService;
    private final IServiceProductService serviceProductService;

    /**
     * 运营端首页
     */
    @ApiOperation("运营端首页")
    @GetMapping("/homeQuantity")
    public R<Map<String, Integer>> homeQuantity() {
        Map<String, Integer> map = new HashMap<>();
        map.put("userSum", userService.queryUserSumForHome());
        map.put("hospitalSum", hospitalService.querySumForHome());
        map.put("orderSum", orderService.querySumForHome());
        //护工数
        map.put("nurseSum", 0);
        return R.ok(map);
    }

    /**
     * 用户最近七日注册数
     */
    @ApiOperation("用户最近七日注册数")
    @GetMapping("/user-statistics")
    public R<List<UserStatisticsVo>> userStatistics() {
        List<UserStatisticsVo> list = userService.statisticsUserRegisterForHome();
        return R.ok(list);
    }

    /**
     * 医院订单数
     */
    @ApiOperation("医院订单数")
    @GetMapping("/hospital-order-statistics")
    public R<List<HospitalStatisticsVo>> hospitalOrderStatistics() {
        return R.ok(orderService.queryHospitalOrderStatistics());
    }

    /**
     * 服务分类下服务分布
     */
    @ApiOperation("服务分类下服务分布")
    @GetMapping("/service-categorize-statistics")
    public R<List<ServiceCategorizeStatisticsVo>> serviceCategorizeStatistics() {
        return R.ok(serviceProductService.queryServiceCategorizeStatistics());
    }

}
