Search in sources :

Example 1 with TransferDO

use of org.saxing.a0041_wemedia.domain.entity.TransferDO in project java-example by saxingz.

the class CRUDTest method testInsert.

@Test
@Transactional
public void testInsert() {
    TransferDO transferDO = new TransferDO().setVideoId(1L).setUrl("https://www.baidu.com").setPublishTime(new Date()).setPlatform(Platform.BILIBILI.getName());
    int insert = transferMapper.insert(transferDO);
    for (int i = 0; i < 100; i++) {
        transferMapper.insert(transferDO);
    }
    System.out.println(insert);
}
Also used : TransferDO(org.saxing.a0041_wemedia.domain.entity.TransferDO) Date(java.util.Date) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with TransferDO

use of org.saxing.a0041_wemedia.domain.entity.TransferDO in project java-example by saxingz.

the class CRUDTest method testUpdate.

@Test
@Transactional
public void testUpdate() {
    TransferDO transferDO = new TransferDO().setId(1L);
    int insert = transferMapper.updateById(transferDO);
    System.out.println(insert);
}
Also used : TransferDO(org.saxing.a0041_wemedia.domain.entity.TransferDO) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with TransferDO

use of org.saxing.a0041_wemedia.domain.entity.TransferDO in project java-example by saxingz.

the class WrapperTest method wrapQueryOne.

@Test
void wrapQueryOne() {
    QueryWrapper<TransferDO> wrapper = new QueryWrapper<>();
    wrapper.eq("id", 10);
    TransferDO transferDO = transferMapper.selectOne(wrapper);
    System.out.println(transferDO);
}
Also used : QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) TransferDO(org.saxing.a0041_wemedia.domain.entity.TransferDO) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with TransferDO

use of org.saxing.a0041_wemedia.domain.entity.TransferDO in project java-example by saxingz.

the class VideoController method listVideos.

/**
 * 查看原始视频
 */
@ApiOperation("查看原始视频")
@ApiImplicitParams({ @ApiImplicitParam(name = "page", value = "页码", defaultValue = "1"), @ApiImplicitParam(name = "pageNum", value = "每页条数", defaultValue = "1") })
@PostMapping("/list")
public Page<VideoVO> listVideos(@RequestBody VideoDO video, @RequestParam @Min(value = 1, message = "页码不得少于1") Integer page, @RequestParam @Min(value = 1, message = "每页条数不得少于1") @Max(value = 100, message = "每页条数不大于100") Integer pageNum) {
    LambdaQueryWrapper<VideoDO> queryWrapper = Wrappers.lambdaQuery();
    queryWrapper.setEntity(video);
    queryWrapper.like(StringUtils.isNotBlank(video.getChannelId()), VideoDO::getChannelId, video.getChannelId());
    queryWrapper.like(StringUtils.isNotBlank(video.getChannelTitle()), VideoDO::getChannelTitle, video.getChannelTitle());
    queryWrapper.like(StringUtils.isNotBlank(video.getVideoId()), VideoDO::getVideoId, video.getVideoId());
    queryWrapper.like(StringUtils.isNotBlank(video.getVideoTitle()), VideoDO::getVideoTitle, video.getVideoTitle());
    queryWrapper.like(StringUtils.isNotBlank(video.getDescription()), VideoDO::getDescription, video.getDescription());
    queryWrapper.like(StringUtils.isNotBlank(video.getDownloadedUrl()), VideoDO::getDownloadedUrl, video.getDownloadedUrl());
    video.setChannelId(null).setChannelTitle(null).setVideoId(null).setVideoTitle(null).setDescription(null).setDownloadedUrl(null);
    Page<VideoDO> videoDOPage = videoLogic.page(new Page<>(page, pageNum), queryWrapper).addOrder(OrderItem.desc(TableInfoHelper.getTableInfo(VideoDO.class).getKeyProperty()));
    Page<VideoVO> result = beanMapper.map(videoDOPage, new TypeBuilder<Page<VideoDO>>() {
    }.build(), new TypeBuilder<Page<VideoVO>>() {
    }.build());
    if (result.getSize() > 0) {
        result.getRecords().forEach(r -> r.setTransferList(transferLogic.list(new QueryWrapper<>(new TransferDO().setVideoId(r.getId())))));
    }
    return result;
}
Also used : VideoVO(org.saxing.a0041_wemedia.domain.vo.VideoVO) VideoDO(org.saxing.a0041_wemedia.domain.entity.VideoDO) TypeBuilder(ma.glasnost.orika.metadata.TypeBuilder) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) TransferDO(org.saxing.a0041_wemedia.domain.entity.TransferDO) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

TransferDO (org.saxing.a0041_wemedia.domain.entity.TransferDO)4 Test (org.junit.jupiter.api.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Transactional (org.springframework.transaction.annotation.Transactional)2 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)1 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)1 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Date (java.util.Date)1 TypeBuilder (ma.glasnost.orika.metadata.TypeBuilder)1 VideoDO (org.saxing.a0041_wemedia.domain.entity.VideoDO)1 VideoVO (org.saxing.a0041_wemedia.domain.vo.VideoVO)1