package org.dromara.pet.controller;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.pet.domain.vo.BizTriageMessagesVo;
import org.dromara.pet.domain.bo.BizTriageMessagesBo;
import org.dromara.pet.service.IBizTriageMessagesService;
import org.dromara.common.mybatis.core.page.TableDataInfo;

/**
 * 多模态问诊对话明细
 *
 * @author shuo
 * @date 2026-02-26
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/pet/triageMessages")
public class BizTriageMessagesController extends BaseController {

    private final IBizTriageMessagesService bizTriageMessagesService;

/**
 * 查询多模态问诊对话明细列表
 */
@SaCheckPermission("pet:triageMessages:list")
@GetMapping("/list")
    public TableDataInfo<BizTriageMessagesVo> list(BizTriageMessagesBo bo, PageQuery pageQuery) {
        return bizTriageMessagesService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出多模态问诊对话明细列表
     */
    @SaCheckPermission("pet:triageMessages:export")
    @Log(title = "多模态问诊对话明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(BizTriageMessagesBo bo, HttpServletResponse response) {
        List<BizTriageMessagesVo> list = bizTriageMessagesService.queryList(bo);
        ExcelUtil.exportExcel(list, "多模态问诊对话明细", BizTriageMessagesVo.class, response);
    }

    /**
     * 获取多模态问诊对话明细详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("pet:triageMessages:query")
    @GetMapping("/{id}")
    public R<BizTriageMessagesVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(bizTriageMessagesService.queryById(id));
    }

    /**
     * 新增多模态问诊对话明细
     */
    @SaCheckPermission("pet:triageMessages:add")
    @Log(title = "多模态问诊对话明细", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody BizTriageMessagesBo bo) {
        return toAjax(bizTriageMessagesService.insertByBo(bo));
    }

    /**
     * 修改多模态问诊对话明细
     */
    @SaCheckPermission("pet:triageMessages:edit")
    @Log(title = "多模态问诊对话明细", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody BizTriageMessagesBo bo) {
        return toAjax(bizTriageMessagesService.updateByBo(bo));
    }

    /**
     * 删除多模态问诊对话明细
     *
     * @param ids 主键串
     */
    @SaCheckPermission("pet:triageMessages:remove")
    @Log(title = "多模态问诊对话明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(bizTriageMessagesService.deleteWithValidByIds(List.of(ids), true));
    }
}
