package com.jwipc.supplier.controller.pc;

import cn.hutool.core.util.ObjectUtil;
import com.jwipc.supplier.constant.ModuleConst;
import com.jwipc.supplier.dto.SupplierAgreementDTO;
import com.jwipc.supplier.logic.SupplierAgreementLogic;
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;

/**
 * <p>
 * 注册协议表 前端控制器
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-02-02
 */
@Controller
@RequestMapping(ModuleConst.MODULE_ROOT + "/supplierAgreement")
@RequiredArgsConstructor
public class SupplierAgreementPageController {
    private final SupplierAgreementLogic supplierAgreementLogic;
    @GetMapping("/index")
    public String index() {
        return ModuleConst.MODULE_ROOT + "/supplierAgreement/list";
    }

    @GetMapping("/detail")
    public String detail(Model model, Long id,Integer type) {
        SupplierAgreementDTO supplierAgreementDTO = new SupplierAgreementDTO();
        if (ObjectUtil.isNotNull(id)) {
            supplierAgreementDTO = supplierAgreementLogic.getById(id);
        }
        model.addAttribute("data", supplierAgreementDTO);
        model.addAttribute("type", type);
        return ModuleConst.MODULE_ROOT + "/supplierAgreement/detail";
    }
}
