package com.jwipc.sys.controller.pc;

import com.jwipc.sys.logic.ValidationRuleSettingLogic;
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;

/**
 * <p>
 *  表单校验规则配置-页面控制层
 * </p>
 *
 * @author Chen Tianshi
 * @since 2025/8/26 10:23
 */
@Controller
@RequestMapping(MODULE_ROOT + "/validationRuleSetting")
@RequiredArgsConstructor
public class ValidationRuleSettingPageController {
    private final ValidationRuleSettingLogic validationRuleSettingLogic;

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

    @GetMapping("/detail")
    public String detail(Model model, Long id) {
        model.addAttribute("fieldList", validationRuleSettingLogic.getAllAllowedCharacterType(id));
        model.addAttribute("tRegexRule", validationRuleSettingLogic.getById(id));
        return MODULE_ROOT + "/validationRuleSetting/detail";
    }
    @GetMapping("/select/fields")
    public String selectFields() {
        return MODULE_ROOT + "/validationRuleSetting/select_fields";
    }
}
