All Downloads are FREE. Search and download functionalities are using the official Maven repository.

k.e.book.ddh.controller.CcMigrationsController Maven / Gradle / Ivy


package k.e.book.ddh.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import k.e.book.common.model.Result;
import k.e.book.ddh.entity.CcMigrationsAddDTO;
import k.e.book.ddh.entity.CcMigrationsDO;
import k.e.book.ddh.entity.CcMigrationsQueryDTO;
import k.e.book.ddh.entity.CcMigrationsVO;
import k.e.book.ddh.service.CcMigrationsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author kk
 * @date 2023-05-21 11:13
 */

@Api(tags = "CcMigrations相关文档")
@RestController
@RequestMapping("/ccMigrations")
public class CcMigrationsController {
    @Resource
    private CcMigrationsService ccMigrationsService;

    @ApiOperation("分页查询CcMigrations信息")
    @PostMapping(value = "/page")
    public Result> queryPage(@RequestBody @Valid  CcMigrationsQueryDTO dto) {
        IPage page = ccMigrationsService.selectProductPage(dto);
        List records = page.getRecords();
        return Result.success(records.stream().map(CcMigrationsDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
    }

    @ApiOperation("根据 id 查询CcMigrations信息")
    @GetMapping(value = "/get")
    public Result getCcMigrationsById(@RequestParam("id") @ApiParam(value = "ccMigrationsD") Long id) {
        return Result.success(CcMigrationsDO.toVO(ccMigrationsService.getById(id)));
    }

    @ApiOperation("新增CcMigrations")
    @PostMapping("/add")
    public Result addCcMigrations(@RequestBody @Valid CcMigrationsAddDTO dto) {
        CcMigrationsDO entity = CcMigrationsDO.toDO(dto);
        ccMigrationsService.save(entity);
        return getCcMigrationsById(entity.getId());
    }

    @ApiOperation("删除CcMigrations")
    @DeleteMapping("/delete")
    public Result deleteCcMigrationsById(@RequestParam("id") @ApiParam(value = "ccMigrationsID") Long id) {
        ccMigrationsService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy