package cn.lihongjie.coal.noteBookChapter.controller;

import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.noteBookChapter.dto.CreateNoteBookChapterDto;
import cn.lihongjie.coal.noteBookChapter.dto.NoteBookChapterDto;
import cn.lihongjie.coal.noteBookChapter.dto.NoteBookChapterTreeDto;
import cn.lihongjie.coal.noteBookChapter.dto.UpdateNoteBookChapterDto;
import cn.lihongjie.coal.noteBookChapter.service.NoteBookChapterService;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/noteBookChapter")
@SysLog(
    module = "章节管理"
)
@Slf4j
public class NoteBookChapterController {
  @Autowired
  private NoteBookChapterService service;

  @PostMapping("/create")
  public NoteBookChapterDto create(@RequestBody CreateNoteBookChapterDto request) {
    return this.service.create(request)
        ;
  }

  @PostMapping("/update")
  public NoteBookChapterDto update(@RequestBody UpdateNoteBookChapterDto request) {
    return this.service.update(request)
        ;
  }

  @PostMapping("/delete")
  public Object delete(@RequestBody IdRequest request) {
    this.service.delete(request);
        return true
        ;
  }

  @PostMapping("/getById")
  public NoteBookChapterDto getById(@RequestBody IdRequest request) {
    return this.service.getById(request.getId())
        ;
  }

  @PostMapping("/list")
  public Page<NoteBookChapterTreeDto> list(@RequestBody CommonQuery request) {
    return this.service.list(request)
        ;
  }
}
