k.e.book.ddh.controller.CcUserTokenController 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.CcUserTokenAddDTO;
import k.e.book.ddh.entity.CcUserTokenDO;
import k.e.book.ddh.entity.CcUserTokenQueryDTO;
import k.e.book.ddh.entity.CcUserTokenVO;
import k.e.book.ddh.service.CcUserTokenService;
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 = "CcUserToken相关文档")
@RestController
@RequestMapping("/ccUserToken")
public class CcUserTokenController {
@Resource
private CcUserTokenService ccUserTokenService;
@ApiOperation("分页查询CcUserToken信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcUserTokenQueryDTO dto) {
IPage page = ccUserTokenService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcUserTokenDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcUserToken信息")
@GetMapping(value = "/get")
public Result getCcUserTokenById(@RequestParam("id") @ApiParam(value = "ccUserTokenD") Long id) {
return Result.success(CcUserTokenDO.toVO(ccUserTokenService.getById(id)));
}
@ApiOperation("新增CcUserToken")
@PostMapping("/add")
public Result addCcUserToken(@RequestBody @Valid CcUserTokenAddDTO dto) {
CcUserTokenDO entity = CcUserTokenDO.toDO(dto);
ccUserTokenService.save(entity);
return getCcUserTokenById(entity.getId());
}
@ApiOperation("删除CcUserToken")
@DeleteMapping("/delete")
public Result deleteCcUserTokenById(@RequestParam("id") @ApiParam(value = "ccUserTokenID") Long id) {
ccUserTokenService.removeById(id);
return Result.success();
}
}