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

k.e.book.ddh.controller.CcUserMoneyLogController 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.CcUserMoneyLogAddDTO;
import k.e.book.ddh.entity.CcUserMoneyLogDO;
import k.e.book.ddh.entity.CcUserMoneyLogQueryDTO;
import k.e.book.ddh.entity.CcUserMoneyLogVO;
import k.e.book.ddh.service.CcUserMoneyLogService;
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 = "CcUserMoneyLog相关文档")
@RestController
@RequestMapping("/ccUserMoneyLog")
public class CcUserMoneyLogController {
    @Resource
    private CcUserMoneyLogService ccUserMoneyLogService;

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

    @ApiOperation("根据 id 查询CcUserMoneyLog信息")
    @GetMapping(value = "/get")
    public Result getCcUserMoneyLogById(@RequestParam("id") @ApiParam(value = "ccUserMoneyLogD") Long id) {
        return Result.success(CcUserMoneyLogDO.toVO(ccUserMoneyLogService.getById(id)));
    }

    @ApiOperation("新增CcUserMoneyLog")
    @PostMapping("/add")
    public Result addCcUserMoneyLog(@RequestBody @Valid CcUserMoneyLogAddDTO dto) {
        CcUserMoneyLogDO entity = CcUserMoneyLogDO.toDO(dto);
        ccUserMoneyLogService.save(entity);
        return getCcUserMoneyLogById(entity.getId());
    }

    @ApiOperation("删除CcUserMoneyLog")
    @DeleteMapping("/delete")
    public Result deleteCcUserMoneyLogById(@RequestParam("id") @ApiParam(value = "ccUserMoneyLogID") Long id) {
        ccUserMoneyLogService.removeById(id);
        return Result.success();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy