ChannelServiceTest.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.qs.mp.service;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.qs.mp.MpApplication;
  4. import com.qs.mp.channel.domain.Channel;
  5. import com.qs.mp.channel.domain.vo.ChannelVO;
  6. import com.qs.mp.channel.service.IChannelService;
  7. import com.qs.mp.channel.service.IChannelUserRelService;
  8. import java.util.ArrayList;
  9. import java.util.List;
  10. import org.apache.commons.lang3.StringUtils;
  11. import org.junit.jupiter.api.Test;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
  14. import org.springframework.boot.test.context.SpringBootTest;
  15. import org.springframework.test.context.ActiveProfiles;
  16. import org.springframework.test.context.TestPropertySource;
  17. @AutoConfigureMockMvc
  18. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = MpApplication.class)
  19. @TestPropertySource(locations = "classpath:application-dev.yml")
  20. @ActiveProfiles("dev")
  21. public class ChannelServiceTest {
  22. @Autowired
  23. private IChannelService channelService;
  24. @Autowired
  25. private IChannelUserRelService channelUserRelService;
  26. @Test
  27. public void testListChannel() {
  28. Channel channel = new Channel();
  29. channel.setParentId(1L);
  30. List<ChannelVO> list = new ArrayList<ChannelVO>();
  31. QueryWrapper<Channel> queryWrapper = new QueryWrapper<>();
  32. queryWrapper.eq("t1.parent_id", channel.getParentId());
  33. queryWrapper.gt("t1.level", 0);
  34. queryWrapper.orderByAsc("t1.channel_id");
  35. list = channelService.selectChannelVoList(queryWrapper);
  36. if(null != list && list.size() > 0) {
  37. for(ChannelVO channelVO : list) {
  38. if(null != channelVO && StringUtils.isNotBlank(channelVO.getChannelNo())) {
  39. int siteCnt = channelService.getChannelSiteCnt(channelVO.getChannelNo());
  40. int userCnt = channelUserRelService.getChannelUserCnt(channelVO.getChannelNo());
  41. channelVO.setSiteCnt(siteCnt);
  42. channelVO.setUserCnt(userCnt);
  43. }
  44. }
  45. }
  46. System.out.println("result:"+list.toString());
  47. }
  48. @Test
  49. public void testAddChannel() {
  50. Channel channel = new Channel();
  51. }
  52. @Test
  53. public void testEditChannel() {
  54. Channel channel = new Channel();
  55. }
  56. }