package com.izouma.jiashanxia.service;

import com.izouma.jiashanxia.domain.User;
import com.izouma.jiashanxia.dto.PageQuery;
import com.izouma.jiashanxia.exception.BusinessException;
import com.izouma.jiashanxia.repo.UserRepo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.test.context.junit4.SpringRunner;


@SpringBootTest
@RunWith(SpringRunner.class)
public class UserServiceTest {

    @Autowired
    private UserService userService;
    @Autowired
    private UserRepo    userRepo;

    @Test
    public void myPromotion() {
        Page<User> users = userService.myPromotion(new PageQuery(), 40L);
        users.getContent().forEach(System.out::println);
    }

    @Test
    public void test1() {
        User user = userRepo.findById(1L).orElseThrow(new BusinessException("无用户"));
        System.out.println(userService.myEmployee(new PageQuery(), user).getContent());
    }

    @Test
    public void test2() {
        System.out.println(userService.overview(102L));
//        System.out.println(1 * 0.01);
    }
}