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

k.e.book.ddh.controller.CcUserCreditsLogController 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.CcUserCreditsLogAddDTO;
import k.e.book.ddh.entity.CcUserCreditsLogDO;
import k.e.book.ddh.entity.CcUserCreditsLogQueryDTO;
import k.e.book.ddh.entity.CcUserCreditsLogVO;
import k.e.book.ddh.service.CcUserCreditsLogService;
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 = "CcUserCreditsLog相关文档")
@RestController
@RequestMapping("/ccUserCreditsLog")
public class CcUserCreditsLogController {
    @Resource
    private CcUserCreditsLogService ccUserCreditsLogService;

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

    @ApiOperation("根据 id 查询CcUserCreditsLog信息")
    @GetMapping(value = "/get")
    public Result getCcUserCreditsLogById(@RequestParam("id") @ApiParam(value = "ccUserCreditsLogD") Long id) {
        return Result.success(CcUserCreditsLogDO.toVO(ccUserCreditsLogService.getById(id)));
    }

    @ApiOperation("新增CcUserCreditsLog")
    @PostMapping("/add")
    public Result addCcUserCreditsLog(@RequestBody @Valid CcUserCreditsLogAddDTO dto) {
        CcUserCreditsLogDO entity = CcUserCreditsLogDO.toDO(dto);
        ccUserCreditsLogService.save(entity);
        return getCcUserCreditsLogById(entity.getId());
    }

    @ApiOperation("删除CcUserCreditsLog")
    @DeleteMapping("/delete")
    public Result deleteCcUserCreditsLogById(@RequestParam("id") @ApiParam(value = "ccUserCreditsLogID") Long id) {
        ccUserCreditsLogService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy