package com.izouma.dingdong.service.backstage;

import com.izouma.dingdong.domain.OrderInfo;
import com.izouma.dingdong.enums.Identity;
import com.izouma.dingdong.repo.OrderInfoRepo;
import com.izouma.dingdong.repo.UserRepo;
import com.izouma.dingdong.repo.backstage.VoiceRepo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

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

@Service
@AllArgsConstructor
public class VoiceService {

    private VoiceRepo     voiceRepo;
    private UserRepo      userRepo;
    private OrderInfoRepo orderInfoRepo;

    public Map<String, Object> index() {
        Map<String, Object> map = new HashMap<>();

        //总人数
        Long user = userRepo.countAllByIdentity(Identity.USER);
        Long rider = userRepo.countAllByIdentity(Identity.RIDER);
        Long merchant = userRepo.countAllByIdentity(Identity.MERCHANT);
        Long admin = userRepo.countAllByIdentity(Identity.ADMIN);
        map.put("user", user);
        map.put("rider", rider);
        map.put("merchant", merchant);
        map.put("admin", admin);

        //总订单数
        long order = orderInfoRepo.count();

        return map;

    }

}
