package com.njzscloud.supervisory.sys.operationManual.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.supervisory.sys.operationManual.pojo.OperationManualEntity;
import com.njzscloud.supervisory.sys.operationManual.service.OperationManualService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 操作手册表
 */
@Slf4j
@RestController
@RequestMapping("/operationManual")
@RequiredArgsConstructor
public class OperationManualController {

    private final OperationManualService operationManualService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody OperationManualEntity operationManualEntity) {
        operationManualService.add(operationManualEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody OperationManualEntity operationManualEntity) {
        operationManualService.modify(operationManualEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        operationManualService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<OperationManualEntity> detail(@RequestParam Long id) {
        return R.success(operationManualService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<OperationManualEntity>> paging(PageParam pageParam, OperationManualEntity operationManualEntity) {
        return R.success(operationManualService.paging(pageParam, operationManualEntity));
    }

    /**
     * 启用/禁用
     */
    @GetMapping("/enable")
    public R<?> enable(@RequestParam Long id, @RequestParam Boolean enable) {
        operationManualService.enabled(id, enable);
        return R.success();
    }

    /**
     * 操作手册查询
     */
    @GetMapping("/appShow")
    public R<List<OperationManualEntity>> appShow() {
        return R.success(operationManualService.appShow());
    }
}
