package jnpf.cultivate.v2.controller.app.teaching;

import jnpf.base.ActionResult;
import jnpf.cultivate.service.V2TeachingService;
import jnpf.model.cultivate.dto.teaching.RecordQueryDto;
import jnpf.model.cultivate.dto.teaching.TeachingApproveDto;
import jnpf.model.cultivate.v2.teaching.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 带教管理[app]
 */
@Slf4j
@RestController
@RequestMapping("/v2/app/teachingRecord")
public class V2TeachingAppController {

    @Resource
    private V2TeachingService v2TeachingService;

    /**
     * 带教/练习记录[分页]
     * @param queryDto 查询条件封装对象，包含分页参数和查询条件
     * @return 分页查询结果，包含带教记录列表和分页信息
     */
    @PostMapping("/page")
    public ActionResult<List<StoreTeachingVo>> page(@RequestBody RecordQueryDto queryDto) {

        List<StoreTeachingVo> list = v2TeachingService.getPage(queryDto);
        return ActionResult.success(list);
    }

    /**
     * 带教/练习详情
     * @param bizId 带教/练习id
     * @return jnpf.base.ActionResult<jnpf.model.cultivate.v2.teaching.vo.TeachingDetailVo>
     */
    @GetMapping(value = "/detail/{bizId}")
    public ActionResult<TeachingDetailVo> getTeachingDetail(@PathVariable(value = "bizId") String bizId) {

        TeachingDetailVo vo = v2TeachingService.getTeachingDetail(bizId);
        return ActionResult.success(vo);
    }

    /**
     * 带教 - 审核
     * @param approveDto 审核dto
     * @return java.lang.Object
     */
    @PutMapping(value = "/approve")
    public Object approveTeachingRecord(@RequestBody @Valid TeachingApproveDto approveDto) throws Exception {

        v2TeachingService.approveTeachingRecord(approveDto);
        return ActionResult.success();
    }
}