package com.sckw.mine.controller;

import com.sckw.core.web.response.HttpResult;
import com.sckw.mine.entity.req.NodeInsertParam;
import com.sckw.mine.entity.req.NodePageListParam;
import com.sckw.mine.entity.req.NodeUpdateParam;
import com.sckw.mine.entity.res.NodeDetailRes;
import com.sckw.mine.service.NodeService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @desc:
 * @author: Lt
 * @date: 2024-05-31
 */
@RestController
@RequestMapping("/mine/node")
public class NodeController {

    @Autowired
    NodeService nodeService;

    /**
     * 新增
     * @author Lt
     * @date 2024/05/31
     **/
    @RequestMapping("/insert")
    public HttpResult insert(@RequestBody @Valid NodeInsertParam param){
        return nodeService.insert(param);
    }

    /**
     * 刪除
     * @author Lt
     * @date 2024/05/31
     **/
    @PostMapping("/delete")
    public HttpResult delete(@RequestParam("id") String id){
        return nodeService.nodeDelete(id);
    }

    /**
     * 更新
     * @author Lt
     * @date 2024/05/31
     **/
    @RequestMapping("/update")
    public HttpResult update(@RequestBody  @Valid NodeUpdateParam param){
        return nodeService.update(param);
    }

    /**
     * 查询 根据主键 id 查询
     *
     * @author Lt
     * @date 2024/05/31
     **/
    @RequestMapping("/detail")
    public HttpResult load(@RequestParam("id") String id){
        return HttpResult.ok(nodeService.detail(id));
    }

    /**
     * 查询 分页查询
     * @author Lt
     * @date 2024/05/31
     **/
    @PostMapping("/pageList")
    public HttpResult pageList(@RequestBody NodePageListParam nodePageListParam) {
        return nodeService.pageList(nodePageListParam);
    }

    /**
    * @Description: 状态操作
    * @Author: Lt
    * @Date: 2024/5/31 0031 14:46
    */
    @RequestMapping("/statusAction")
    public HttpResult statusAction(@RequestParam("id") String id , @RequestParam("status") Integer status) {
        return nodeService.statusAction(id, status);
    }




}
