# encyclopedia/models.py
from django.db import models

class DiseaseWiki(models.Model):
    CATEGORY_CHOICES = [
        ('PEST', '虫害百科'),
        ('DISEASE', '病害百科'),
        ('PHYSIO', '生理性病害'),
        ('SHAPE', '品相等级'),
    ]
    name = models.CharField(max_length=100, unique=True, verbose_name="名称")
    category = models.CharField(max_length=10, choices=CATEGORY_CHOICES, verbose_name="类别")
    symptoms = models.TextField(verbose_name="特征描述/发病症状")
    treatment = models.TextField(verbose_name="分级标准/防治建议")
    wiki_image = models.ImageField(upload_to='wiki/', null=True, blank=True, verbose_name="展示图片")
    create_time = models.DateTimeField(auto_now_add=True)

    class Meta:
        verbose_name = "农业知识百科"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name


class DiseaseExpertWeight(models.Model):
    label_name = models.CharField(max_length=50, unique=True, verbose_name="YOLO标签")
    display_name = models.CharField(max_length=100, verbose_name="病害名称")

    temp_weight = models.FloatField(default=0.4)
    hum_weight = models.FloatField(default=0.6)

    optimum_temp = models.FloatField(default=28.0)
    optimum_hum = models.FloatField(default=85.0)

    remedy = models.TextField(verbose_name="专家处方")

    def __str__(self):
        return self.display_name