package com.qs.mp.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.qs.mp.MpApplication; import com.qs.mp.channel.domain.Channel; import com.qs.mp.channel.domain.vo.ChannelVO; import com.qs.mp.channel.service.IChannelService; import com.qs.mp.channel.service.IChannelUserRelService; import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; @AutoConfigureMockMvc @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = MpApplication.class) @TestPropertySource(locations = "classpath:application-dev.yml") @ActiveProfiles("dev") public class ChannelServiceTest { @Autowired private IChannelService channelService; @Autowired private IChannelUserRelService channelUserRelService; @Test public void testListChannel() { Channel channel = new Channel(); channel.setParentId(1L); List list = new ArrayList(); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("t1.parent_id", channel.getParentId()); queryWrapper.gt("t1.level", 0); queryWrapper.orderByAsc("t1.channel_id"); list = channelService.selectChannelVoList(queryWrapper); if(null != list && list.size() > 0) { for(ChannelVO channelVO : list) { if(null != channelVO && StringUtils.isNotBlank(channelVO.getChannelNo())) { int siteCnt = channelService.getChannelSiteCnt(channelVO.getChannelNo()); int userCnt = channelUserRelService.getChannelUserCnt(channelVO.getChannelNo()); channelVO.setSiteCnt(siteCnt); channelVO.setUserCnt(userCnt); } } } System.out.println("result:"+list.toString()); } @Test public void testAddChannel() { Channel channel = new Channel(); } @Test public void testEditChannel() { Channel channel = new Channel(); } }