package com.jwipc.sys.controller.pc;

import com.jwipc.sys.dto.PurchaseGroupDTO;
import com.jwipc.sys.logic.PurchaseGroupLogic;
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 static com.jwipc.sys.constant.ModuleConst.MODULE_ROOT;

/**
 * @author Al
 * @create 2024-01-29 16:21
 */
@Controller
@RequestMapping(MODULE_ROOT + "/purchaseGroup")
@RequiredArgsConstructor
public class PurchaseGroupPageController {
    private final PurchaseGroupLogic purchaseGroupLogic;
    @GetMapping("/index")
    public String index() {
        return MODULE_ROOT + "/purchaseGroup/list";
    }

    /**
     * 选择弹窗
     */
    @GetMapping("/dialog")
    public String dialog() {
        return MODULE_ROOT + "/purchaseGroup/dialog";
    }

    @GetMapping("/detail")
    public String detail(Model model, Long id) {
        PurchaseGroupDTO purchaseGroup;
        purchaseGroup = purchaseGroupLogic.getById(id);
        model.addAttribute("data", purchaseGroup);
        return MODULE_ROOT + "/purchaseGroup/detail";
    }
    @GetMapping("userPurchaseGroupAdd")
    public String userPurchaseGroupAdd(Model model, Long userId) {
        model.addAttribute("userId", userId);
        return MODULE_ROOT + "/purchaseGroup/user_purchase_group_add";
    }

    @GetMapping("factoryIndex")
    public String factoryIndex(){
        return MODULE_ROOT + "/purchaseGroup/factory_index";
    }
}
