package cn.iocoder.yudao.module.member.controller.admin.screen;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.controller.admin.customertraffic.vo.CustomerTrafficRespVO;
import cn.iocoder.yudao.module.member.controller.admin.screen.vo.DishVo;
import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDO;
import cn.iocoder.yudao.module.member.service.customertraffic.CustomerTrafficService;
import cn.iocoder.yudao.module.member.service.order.OrderService;
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
import cn.iocoder.yudao.module.member.service.storeevaluate.StoreEvaluateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;
import java.util.Map;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @author zt
 * @description <description class purpose>
 * @since 2024/4/16
 */
@Tag(name = "管理后台 - 大屏")
@RestController
@RequestMapping("/member/screen")
@PermitAll
public class ScreenController {

    @Resource
    private StoreEvaluateService storeEvaluateService;
    @Resource
    private CustomerTrafficService customerTrafficService;
    @Resource
    private OrderService orderService;
    @Resource
    private OrderDetailService orderDetailService;

    @GetMapping("/getEvaluate")
    @Operation(summary = "获得店铺评价,1-好评，2-差评")
    public Map<String,String> getEvaluate(){
        return storeEvaluateService.getEvaluate();
    }

    @GetMapping("/getData")
    @Operation(summary = "食堂今日顾客流量")
    public CommonResult<List<CustomerTrafficRespVO>> getData() {
        List<CustomerTrafficDO> data = customerTrafficService.getData();
        return success(BeanUtils.toBean(data, CustomerTrafficRespVO.class));
    }

    @GetMapping("/getUserCount")
    @Operation(summary = "获取总顾客流量")
    public CommonResult<Integer> getUserCount() {
        return success(orderService.selectTodayUser());
    }

    @GetMapping("/selectDishSale")
    @Operation(summary = "菜品今日销售")
    public CommonResult<List<DishVo>> selectDishSale() {
        return success(orderDetailService.selectDishSale());
    }
}
