k.e.book.ddh.controller.CcSmsController 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.CcSmsAddDTO;
import k.e.book.ddh.entity.CcSmsDO;
import k.e.book.ddh.entity.CcSmsQueryDTO;
import k.e.book.ddh.entity.CcSmsVO;
import k.e.book.ddh.service.CcSmsService;
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 = "CcSms相关文档")
@RestController
@RequestMapping("/ccSms")
public class CcSmsController {
@Resource
private CcSmsService ccSmsService;
@ApiOperation("分页查询CcSms信息")
@PostMapping(value = "/page")
public Result> queryPage(@RequestBody @Valid CcSmsQueryDTO dto) {
IPage page = ccSmsService.selectProductPage(dto);
List records = page.getRecords();
return Result.success(records.stream().map(CcSmsDO::toVO).filter(Objects::nonNull).collect(Collectors.toList()), page.getTotal());
}
@ApiOperation("根据 id 查询CcSms信息")
@GetMapping(value = "/get")
public Result getCcSmsById(@RequestParam("id") @ApiParam(value = "ccSmsD") Long id) {
return Result.success(CcSmsDO.toVO(ccSmsService.getById(id)));
}
@ApiOperation("新增CcSms")
@PostMapping("/add")
public Result addCcSms(@RequestBody @Valid CcSmsAddDTO dto) {
CcSmsDO entity = CcSmsDO.toDO(dto);
ccSmsService.save(entity);
return getCcSmsById(entity.getId());
}
@ApiOperation("删除CcSms")
@DeleteMapping("/delete")
public Result deleteCcSmsById(@RequestParam("id") @ApiParam(value = "ccSmsID") Long id) {
ccSmsService.removeById(id);
return Result.success();
}
}