package com.izouma.dingdong.service;

import com.izouma.dingdong.dto.MerchantDTO;
import com.izouma.dingdong.dto.PageQuery;
import com.izouma.dingdong.repo.merchant.MerchantRepo;
import com.izouma.dingdong.service.merchant.MerchantService;
import com.izouma.dingdong.web.merchant.MerchantController;
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.test.context.junit4.SpringRunner;

import java.time.LocalTime;
import java.util.HashMap;
import java.util.Map;

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

    @Autowired
    private MerchantService merchantService;

    @Autowired
    private MerchantController merchantController;

    @Test
    public void testChange(){
        MerchantDTO merchantDTO = MerchantDTO.builder()
                .mid(421L)
                .address("测试测试")
                .aliAccount("11111")
                .aliName("测试")
                .logo("https://idingdong.oss-cn-hangzhou.aliyuncs.com/image/2020-05-14-10-01-57oAziBRXO.jpg")
                .phone("222333")
                .password("222333")
                .build();
        merchantService.change(merchantDTO);
    }

    @Test
    public void testAll(){
        PageQuery pageQuery = new PageQuery();
        pageQuery.setPage(0);
        pageQuery.setSize(50);
        pageQuery.setSearch(null);
        pageQuery.setSort("");
        Map<String,Object> map = new HashMap<>();
        map.put("startTime","2020-05-14 13:49:11,2020-5-30 23:59:59");
        pageQuery.setQuery(map);
        System.out.println(merchantController.all(pageQuery));
    }
}
