package com.jwipc.spe.controller;

import com.jwipc.log.annotation.AuditLogInter;
import lombok.RequiredArgsConstructor;
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;

/**
 * <p> 考核管理相关页面</p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@Controller
@RequestMapping(MODULE_ROOT + "/supAppraisePlan/page")
@RequiredArgsConstructor
public class SupAppraisePlanPageController {

    /**
     * 考核管理主页面
     *
     * @return
     */
    @GetMapping("index")
    public String index() {
        return MODULE_ROOT + "/supAppraisePlan/index";
    }

    /**
     * 考核管理详情页面
     *
     * @param model
     * @param id    考核计划主键
     * @return
     */
    @AuditLogInter(value = "新增/编辑详情页", module = "考核计划")
    @GetMapping("detail")
    public String detail(Model model,
                         Long id)
    {
        model.addAttribute("id", id);
        return MODULE_ROOT + "/supAppraisePlan/detail";
    }

    /**
     * 考核计划评分页面
     *
     * @param model
     * @param id    考核计划主键
     * @return
     */
    @AuditLogInter(value = "详情数据", module = "考核计划")
    @GetMapping("scoreDetail")
    public String scoreDetail(Model model,
                              Long id)
    {
        model.addAttribute("id", id);
        return MODULE_ROOT + "/supAppraisePlan/score_detail";
    }

    /**
     * 考核计划评分列表页面
     *
     * @return
     */
    @GetMapping("scoring")
    public String scoring()
    {
        return MODULE_ROOT + "/supAppraisePlan/scoring";
    }

    /**
     * 考核计划评分详情页面
     *
     * @param model
     * @param id    考核计划主键
     * @param type  1:查看;0:评分
     * @return
     */
    @AuditLogInter(value = "详情页面", module = "考核评分")
    @GetMapping("scoringDetail")
    public String scoringDetail(Model model, Long id, @RequestParam(defaultValue = "0", required = false) Integer type)
    {
        model.addAttribute("type", type);
        model.addAttribute("id", id);
        return MODULE_ROOT + "/supAppraisePlan/scoring_detail";
    }

    /**
     * 考核整改单查看
     *
     * @param model
     * @param id    考核计划主键
     * @return
     */
    @GetMapping("rectificationView")
    public String rectificationView(Model model,
                              Long id)
    {
        model.addAttribute("id", id);
        return MODULE_ROOT + "/supAppraisePlan/rectification_view";
    }
}
