package jnpf.cultivate.controller.app.casebase;

import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.cultivate.service.FtbCultivateCaseBaseService;
import jnpf.model.cultivate.dto.casebase.FtbCultivateCaseBaseDTO;
import jnpf.model.cultivate.dto.casebase.app.FtbCultivateCaseBaseCreatDTO;
import jnpf.model.cultivate.vo.casebase.FtbCultivateCaseBaseVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * app案例库
 * @Author: peng.hao
 * @create: 2024/7/22:11:28
 */
@RestController
@RequestMapping("/app/case-base")
public class FtbCultivateCaseBaseAppController {

    @Resource
    FtbCultivateCaseBaseService caseBaseService;

    /**
     * 列表展示
     * @param dto
     * @return
     */
    @GetMapping("/listDisplay")
    public ActionResult<PageListVO<FtbCultivateCaseBaseVO>> listDisplay(FtbCultivateCaseBaseDTO dto){
        return ActionResult.success(caseBaseService.listDisplayForApp(dto));
    }

    /**
     * 详情
     * @param id
     * @return
     */
    @GetMapping("/getDetail/{id}")
    public ActionResult<FtbCultivateCaseBaseVO> getDetail(@PathVariable("id") String id){
        return ActionResult.success(caseBaseService.getDetail(id));
    }
    /**
     *  删除案例
     * @param id
     * @return
     */
    @GetMapping("/deleteCase/{id}")
    public ActionResult<Object> deleteCase(@PathVariable("id") String id){
        caseBaseService.removeById(id);
        return ActionResult.success();
    }


    /**
     * 创建案例库
     * @return
     */
    @PostMapping("/createCaseLibrary")
    public ActionResult<String> createCaseLibrary(@RequestBody @Validated FtbCultivateCaseBaseCreatDTO caseBaseCreatDTO){
        caseBaseService.caseBaseCreatDTO(caseBaseCreatDTO);
        return ActionResult.success();
    }
    /**
     * 修改案例库
     * @return
     */
    @PutMapping("/updateCaseLibrary")
    public ActionResult<String> updateCaseLibrary(@RequestBody @Validated FtbCultivateCaseBaseCreatDTO caseBaseCreatDTO){
        caseBaseService.updateCaseLibrary(caseBaseCreatDTO);
        return ActionResult.success();
    }
}


