package com.xinelu.web.controller.familydoctor;

import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.familydoctor.entity.EvaluateAdviceTemplate;
import com.xinelu.familydoctor.service.EvaluateAdviceTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author gaoyu
 * @description 自我评估处方模板接口控制器
 * @date 2023-10-16 16:59
 */
@Api(tags = {"自我评估处方模板接口控制器"})
@RestController
@RequestMapping("/evaluate/advice/template")
public class EvaluateAdviceTemplateController extends BaseController {

    @Resource
    private EvaluateAdviceTemplateService evaluateAdviceTemplateService;

    @ApiOperation("模板列表")
    @GetMapping("list")
    public TableDataInfo list(EvaluateAdviceTemplate entity) {
        startPage();
        List<EvaluateAdviceTemplate> list = evaluateAdviceTemplateService.findList(entity);
        return getDataTable(list);
    }

    @ApiOperation("新增/编辑模板")
    @PostMapping("save")
    public AjaxResult save(@RequestBody EvaluateAdviceTemplate entity) {
        evaluateAdviceTemplateService.save(entity);
        return AjaxResult.success();
    }

    @ApiOperation("修改模板状态")
    @PostMapping("change/status")
    public AjaxResult changeStatus(@RequestBody EvaluateAdviceTemplate entity) {
        evaluateAdviceTemplateService.changeStatus(entity);
        return AjaxResult.success();
    }

    @ApiOperation("逻辑删除模板")
    @PostMapping("del/{id}")
    @ApiImplicitParam(name = "id", value = "模板ID", required = true)
    public AjaxResult del(@PathVariable Long id) {
        evaluateAdviceTemplateService.delTemplate(id);
        return AjaxResult.success();
    }

    @ApiOperation("根据自评结果获取处方模板")
    @GetMapping("get/{templateType}")
    @ApiImplicitParam(name = "templateType", value = "处方模板类型", required = true)
    public AjaxResult getTemplate(@PathVariable String templateType) {
        return AjaxResult.success(evaluateAdviceTemplateService.getTemplate(templateType));
    }
}
