@@ -0,0 +1,46 @@
|
||||
package com.bashi.dk.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.bashi.common.core.domain.AjaxResult;
|
||||
import com.bashi.common.core.domain.entity.Customer;
|
||||
import com.bashi.dk.domain.Borrow;
|
||||
import com.bashi.dk.service.BorrowService;
|
||||
import com.bashi.dk.service.CustomerService;
|
||||
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.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/dk/home")
|
||||
public class HomeController {
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
@Autowired
|
||||
private BorrowService borrowService;
|
||||
|
||||
@GetMapping("/index")
|
||||
public AjaxResult<Map<String,Long>> index() {
|
||||
Map<String,Long> map = new HashMap<>();
|
||||
LocalDate now = LocalDate.now();
|
||||
// 今日注册, 总注册
|
||||
long todayRegister = customerService.count(Wrappers.lambdaQuery(Customer.class).between(Customer::getCreateTime,
|
||||
now.atTime(LocalTime.MIN), now.atTime(LocalTime.MAX)));
|
||||
long totalRegister = customerService.count();
|
||||
// 今日订单, 总订单
|
||||
long todayBorrow = borrowService.count(Wrappers.lambdaQuery(Borrow.class).between(Borrow::getCreateTime,
|
||||
now.atTime(LocalTime.MIN), now.atTime(LocalTime.MAX)));
|
||||
long totalBorrow = borrowService.count();
|
||||
map.put("todayRegister",todayRegister);
|
||||
map.put("totalRegister",totalRegister);
|
||||
map.put("todayBorrow",todayBorrow);
|
||||
map.put("totalBorrow",totalBorrow);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user