package com.jwipc.sys.controller.pc;

import com.jwipc.sys.dto.AttachmentTypeConfigDTO;
import com.jwipc.sys.dto.BusinessAttachmentDTO;
import com.jwipc.sys.entity.AttachmentTypeConfig;
import com.jwipc.sys.entity.BusinessAttachment;
import com.jwipc.sys.logic.AttachmentTypeConfigLogic;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

import static com.jwipc.sys.constant.ModuleConst.MODULE_ROOT;

/**
 * <p>
 * 电子印章配置表 前端控制器
 * </p>
 *
 * @author shenyang.ou
 * @since 2024-06-19
 */
@Controller
@RequestMapping(MODULE_ROOT +"/attachmentTypeConfig/rest")
@RequiredArgsConstructor
public class AttachmentTypeConfigRestController {

    private final AttachmentTypeConfigLogic attachmentTypeConfigLogic;
    @GetMapping("/index")
    public String index(Model  model) {
        model.addAttribute("list", attachmentTypeConfigLogic.list());
        return MODULE_ROOT + "/attachmentTypeConfig/list";
    }

    @PostMapping("saveOrUpdate")
    public ResponseEntity saveOrUpdate(@RequestBody List<AttachmentTypeConfig> saveList) {
        attachmentTypeConfigLogic.saveOrUpdate(saveList);
        return ResponseEntity.ok(true);
    }
}
