package org.springblade.modules.ldt.statistic.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;

import org.springblade.core.tool.api.R;

import org.springblade.modules.ldt.activity.service.IActivityService;
import org.springblade.modules.ldt.agenter.entity.Agenter;
import org.springblade.modules.ldt.agenter.service.IAgenterService;
import org.springblade.modules.ldt.billrecord.service.IBillRecordService;

import org.springblade.modules.ldt.loginuser.entity.LoginUser;
import org.springblade.modules.ldt.loginuser.service.ILoginUserService;
import org.springblade.modules.ldt.mall.entity.Mall;
import org.springblade.modules.ldt.mall.service.IMallService;
import org.springblade.modules.ldt.member.service.IMemberService;
import org.springblade.modules.ldt.shop.entity.Shop;
import org.springblade.modules.ldt.shop.service.IShopService;
import org.springblade.modules.ldt.statistic.vo.StatisticVO;
import org.springframework.web.bind.annotation.*;
import sun.management.Agent;


/**
 * Created By lidexi in 2021/7/30
 **/
@RestController
@AllArgsConstructor
@RequestMapping("cyzh-static")
@Api(value = "后台首页统计", tags = "后台首页统计")
public class StaticController {

	private final IMallService mallService;
	private final IShopService shopService;
	private final IAgenterService agenterService;
	private final ILoginUserService loginUserService;



	/**
	 * 首页统计
	 * @return
	 */
	@GetMapping("/staticAccountStatic")
	@ApiOperation(value = "首页统计", notes = "首页统计")
	public R<StatisticVO> staticAccountStatic() {

		StatisticVO statisticVO = new StatisticVO();
		//商场总数
		Integer mallCount = mallService.getBaseMapper().selectCount(new QueryWrapper<>(new Mall()));
		//商店总数
		Integer shopCount = shopService.getBaseMapper().selectCount(new QueryWrapper<>(new Shop()));
		//用户总数
		Integer userCount = loginUserService.getBaseMapper().selectCount(new QueryWrapper<>(new LoginUser()));
		//代理总数
		Integer agenterCount = agenterService.getBaseMapper().selectCount(new QueryWrapper<>(new Agenter()));

		return R.data(statisticVO.setAgenterCount(agenterCount)
									.setMallCount(mallCount)
									.setShopCount(shopCount)
									.setUserCount(userCount));
	}


}
