package com.emoon.tongue.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 舌诊H5页面控制器
 *
 * @author system
 * @date 2025-12-24
 */
@Slf4j
@Controller
@RequestMapping("/tongue-diagnosis/h5/v1")
public class TongueDiagnosisH5Controller {

    /**
     * H5舌诊详情页面
     *
     * @param project_id 医院编码（URL参数）
     * @param patient_id 患者ID（URL参数）
     * @return H5页面
     */
    @GetMapping("/detail")
    public String tongueDiagnosisH5Page(@RequestParam(value = "project_id", required = false) String project_id,
                                       @RequestParam(value = "patient_id", required = false) String patient_id,
                                       Model model) {
        log.info("========== 访问H5页面 ==========");
        log.info("project_id: {}", project_id);
        log.info("patient_id: {}", patient_id);
        log.info("请求路径: /tongue-diagnosis/h5/v1/detail");

        model.addAttribute("projectId", project_id != null ? project_id : "");
        model.addAttribute("patientId", patient_id != null ? patient_id : "");

        log.info("返回视图: tongue-diagnosis");
        return "tongue-diagnosis";
    }

    @Configuration
    public static class WebConfig implements WebMvcConfigurer {
        // 这个配置确保Controller路径优先于静态资源处理器
    }
}
