package com.zjt.web;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.zjt.entity.ProductionVarietyDetail;
import com.zjt.entity.ProductionVarietyDetailColour;
import com.zjt.entity.Productionheader;
import com.zjt.service.IProductionVarietyDetailService;
import com.zjt.service.IProductionVarietyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xxu
 * @since 2025-09-25
 */
@RestController
@RequestMapping("/entity")
public class ProductionVarietyDetailController {
    @Autowired
    private IProductionVarietyDetailService productionVarietyDetailService;
    @RequestMapping("varietyLists")
    public String selectvarietyList() {
        List<ProductionVarietyDetail> productionVarietyDetails = productionVarietyDetailService.selectvarietyList();
        return  JSONArray.toJSON(productionVarietyDetails).toString();
    }
    @RequestMapping("varietyDetailsLists")
    public String selectvarietyDetails(String variety) {
        if(variety!=null||variety!=""){
            List<ProductionVarietyDetail> productionVarietyDetails = productionVarietyDetailService.selectvarietyDetails(variety);
            return  JSONArray.toJSON(productionVarietyDetails).toString();
        }else{
            return  JSONArray.toJSON("").toString();
        }
    }

    @RequestMapping("productionheader")
    public String group(@RequestParam("id") String id){
        if(id!=null||id!=""){
            long l = Long.parseLong(id);
            List<Productionheader> productionVarietyDetails = productionVarietyDetailService.selectProductionheader(l);
            return  JSONArray.toJSON(productionVarietyDetails).toString();
        }else{
            return  JSONArray.toJSON("").toString();
        }
    }
    @RequestMapping("selectColour")
    public String selectColour(@RequestParam("id") String id){
        if(id!=null||id!=""){
            long l = Long.parseLong(id);
            List<ProductionVarietyDetailColour> productionVarietyDetails = productionVarietyDetailService.selectColour(l);
            return  JSONArray.toJSON(productionVarietyDetails).toString();
        }else{
            return  JSONArray.toJSON("").toString();
        }
    }
}
