package com.ningdatech.kqapi.admin.controller;


import com.ningdatech.basic.model.IdVo;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.kqapi.admin.manage.WindowManage;
import com.ningdatech.kqapi.admin.model.req.ListWindowReq;
import com.ningdatech.kqapi.admin.model.req.WindowSaveReq;
import com.ningdatech.kqapi.admin.model.vo.WindowDetailVO;
import com.ningdatech.log.annotation.WebLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author WendyYang
 * @since 2024-04-20
 */
@Api(tags = "窗口管理")
@RestController
@AllArgsConstructor
@RequestMapping("/api/v1/window")
public class WindowController {

    private final WindowManage windowManage;

    @PostMapping("/save")
    @WebLog("窗口新增或修改")
    @ApiOperation("窗口新增或修改")
    public void saveOrUpdate(@RequestBody @Valid WindowSaveReq req) {
        windowManage.windowSaveOrUpdate(req);
    }

    @DeleteMapping("/del")
    @WebLog("窗口删除")
    @ApiOperation("窗口删除")
    public void delete(@RequestBody IdVo<Integer> id) {
        windowManage.delete(id);
    }

    @GetMapping("/page")
    @WebLog("窗口列表")
    @ApiOperation("窗口列表")
    public PageVo<WindowDetailVO> page(ListWindowReq req) {
        return windowManage.pageWindow(req);
    }

    @GetMapping("/option")
    @WebLog("窗口下拉选择")
    @ApiOperation("窗口下拉选择")
    public List<WindowDetailVO> option(ListWindowReq req) {
        return windowManage.windowOption(req);
    }

}
