k.e.book.ddh.controller.CceeeUserController 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.CceeeUserAddDTO;
import k.e.book.ddh.entity.CceeeUserDO;
import k.e.book.ddh.entity.CceeeUserQueryDTO;
import k.e.book.ddh.entity.CceeeUserVO;
import k.e.book.ddh.service.CceeeUserService;
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 = "CceeeUser相关文档")
@RestController
@RequestMapping("/cceeeUser")
public class CceeeUserController {
@Resource
private CceeeUserService cceeeUserService;
@ApiOperation("分页查询CceeeUser信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CceeeUserQueryDTO dto) {
IPage page = cceeeUserService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CceeeUserDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CceeeUser信息")
@GetMapping(value = "/get")
public Result getCceeeUserById(@RequestParam("id") @ApiParam(value = "cceeeUserD") Long id) {
return Result.success(CceeeUserDO.toVO(cceeeUserService.getById(id)));
}
@ApiOperation("新增CceeeUser")
@PostMapping("/add")
public Result addCceeeUser(@RequestBody @Valid CceeeUserAddDTO dto) {
CceeeUserDO entity = CceeeUserDO.toDO(dto);
cceeeUserService.save(entity);
return getCceeeUserById(entity.getId());
}
@ApiOperation("删除CceeeUser")
@DeleteMapping("/delete")
public Result deleteCceeeUserById(@RequestParam("id") @ApiParam(value = "cceeeUserID") Long id) {
cceeeUserService.removeById(id);
return Result.success();
}
}