package com.jwipc.spe.controller;

import com.jwipc.spe.dto.SupAppraiseTemplateBaseDTO;
import com.jwipc.spe.logic.SupAppraiseTemplateLogic;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
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 static com.jwipc.spe.constant.ModuleConst.MODULE_ROOT;

/**
 * @author Al
 * @create 2024-02-28 15:36
 * 考核指标
 */
@Controller
@RequestMapping(MODULE_ROOT + "/supAppraiseTemplate")
@RequiredArgsConstructor
public class SupAppraiseTemplatePageController {
    private final SupAppraiseTemplateLogic supAppraiseTemplateLogic;

    @GetMapping("/index")
    public String index() {
        return MODULE_ROOT + "/supAppraiseTemplate/list";
    }

    @GetMapping("/detail")
    public String detail(Model model, Integer id) {
        SupAppraiseTemplateBaseDTO supAppraiseTemplate;
        supAppraiseTemplate = supAppraiseTemplateLogic.getById(id);
        model.addAttribute("data", supAppraiseTemplate);
        return MODULE_ROOT + "/supAppraiseTemplate/detail";
    }
    @GetMapping("/dimension/chose")
    public String dimensionChose(String selected,Model model){
        model.addAttribute("selected",selected);
        return MODULE_ROOT + "/supAppraiseTemplate/dimension_chose";
    }
    @GetMapping("/quota/chose")
    public String quotaChose(Model model, @RequestParam(required = false) String quotaCodes, @RequestParam(required = false) String choseDimCodes){
        if (StringUtils.isNotEmpty(quotaCodes)) {
            model.addAttribute("quotaCodes", quotaCodes);
        }
        if (StringUtils.isNotEmpty(choseDimCodes)) {
            model.addAttribute("choseDimCodes", choseDimCodes);
        }
        return MODULE_ROOT + "/supAppraiseTemplate/quota_chose";
    }
}
