CollectionTaskController.java 1.54 KB
package com.viontech.fanxing.collect.controller;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.viontech.fanxing.collect.model.CollectionTask;
import com.viontech.fanxing.collect.service.CollectionTaskService;
import com.viontech.fanxing.collect.vo.CollectionTaskVo;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * .
 *
 * @author 谢明辉
 * @date 2022/3/9
 */

@RestController
@RequestMapping("/collectionTask")
public class CollectionTaskController {

    @Resource
    private CollectionTaskService collectionTaskService;

    @GetMapping
    public JsonMessageUtil.JsonMessage page(CollectionTaskVo vo) {
        Page<CollectionTask> page = collectionTaskService.lambdaQuery()
                .page(Page.<CollectionTask>of(vo.getPage(), vo.getPageSize()).addOrder(OrderItem.desc("create_time")));
        return JsonMessageUtil.getSuccessJsonMsg(page);
    }

    @PostMapping
    public JsonMessageUtil.JsonMessage add(CollectionTaskVo vo) throws IOException {
        if (vo.getFile() != null) {
            vo.setConfigFile(vo.getFile().getBytes());
        }
        collectionTaskService.save(vo);
        return JsonMessageUtil.getSuccessJsonMsg(vo);
    }
}