package com.jwipc.sys.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.sys.dto.PrintTempBaseDTO;
import com.jwipc.sys.logic.PrintTempLogic;
import com.jwipc.sys.model.query.PrintTempQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

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

@RequestMapping(MODULE_ROOT + "/printTemp/rest")
@RequiredArgsConstructor
@RestController
public class PrintTempRestController {
    private final PrintTempLogic printTempLogic;

    /**
     * 列表
     *
     * @param query
     * @return
     */
    @GetMapping("/list")
    public PageView list(PrintTempQuery query) {
        return printTempLogic.findByPage(query);
    }

    /**
     * 保存
     *
     * @param saveOrUpdate
     * @return
     */
    @PostMapping("/saveOrUpdate")
    public ResponseEntity saveOrUpdate(@RequestBody PrintTempBaseDTO saveOrUpdate) {
        printTempLogic.saveOrUpdate(saveOrUpdate);
        return ResponseEntity.ok().body(null);
    }

    @PostMapping("del")
    public ResponseEntity del(Long id) {
        printTempLogic.del(id);
        return ResponseEntity.ok().body(null);
    }
}
