package com.jwipc.sys.controller.pc;

import com.jwipc.log.annotation.AuditLogInter;
import com.jwipc.sys.dto.MoldFormDTO;
import com.jwipc.sys.dto.MoldMoveDTO;
import com.jwipc.sys.logic.MoldFormLogic;
import com.jwipc.sys.logic.MoldMoveLogic;
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-31 10:23
 * @desc 模具
 */
@Controller
@RequestMapping(MODULE_ROOT + "/mold/moldForm")
@RequiredArgsConstructor
public class MoldFormPageController {
    private final MoldMoveLogic moldMoveLogic;
    private final MoldFormLogic moldFormLogic;


    //模具列表主页
    @GetMapping("/index")
    public String index() {
        return MODULE_ROOT + "/mold/moldForm/list";
    }
    //模具列表详情页
    @AuditLogInter(value = "详情数据查询", module = "模具列表")
    @GetMapping("/detail")
    public String detail(Model model, Long id, Integer flag) {
        MoldFormDTO moldForm;
        moldForm = moldFormLogic.getById(id);
        model.addAttribute("moldForm", moldForm);
        model.addAttribute("flag", flag);
        return MODULE_ROOT + "/mold/moldForm/detail";
    }
    @GetMapping("/del")
    public String del(Model model, Long id) {
        MoldFormDTO moldForm;
        moldForm = moldFormLogic.getById(id);
        model.addAttribute("moldForm", moldForm);
        return MODULE_ROOT + "/mold/moldForm/del";
    }
    @AuditLogInter(value = "查看数据", module = "模具列表")
    @GetMapping("/look")
    public String look(Model model, Long id, Integer flag) {
        MoldFormDTO moldForm;
        moldForm = moldFormLogic.getById(id);
        model.addAttribute("moldForm", moldForm);
        model.addAttribute("flag", flag);
        return MODULE_ROOT + "/mold/moldForm/look";
    }
    //移模主页
    @GetMapping("/moldMove/index")
    public String moldMoveIndex(Model model,Long id) {
//        MoldMoveDTO moldMoveDTO;
//        moldMoveDTO = moldMoveLogic.getById(id);
//        model.addAttribute("moldMove", moldMoveDTO);
        model.addAttribute("id", id);
        return MODULE_ROOT + "/mold/moldForm/moldMove/list";
    }
    //移模详情页
    @GetMapping("/moldMove/detail")
    public String moldMoveDetail(Model model, Long id,Long moldId) {
        MoldMoveDTO moldMove;
        moldMove = moldFormLogic.moldMoveGetById(id);
        model.addAttribute("moldId", moldId);
        model.addAttribute("moldMove", moldMove);
        return MODULE_ROOT + "/mold/moldForm/moldMove/detail";
    }

    //移模详情页
    @GetMapping("/moldMove/del")
    public String del(Model model, Long id,Long moldId) {
        MoldMoveDTO moldMove;
        moldMove = moldFormLogic.moldMoveGetById(moldId);
        model.addAttribute("moldId", moldId);
        model.addAttribute("moldMove", moldMove);
        return MODULE_ROOT + "/mold/moldForm/moldMove/del";
    }
}
