package cn.lihongjie.coal.ipList.controller;

import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.ipList.dto.CreateIpListDto;
import cn.lihongjie.coal.ipList.dto.IpListDto;
import cn.lihongjie.coal.ipList.dto.UpdateIpListDto;
import cn.lihongjie.coal.ipList.service.IpListService;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ipList")
@SysLog(module = "IP名单")
@Slf4j
public class IpListController {
    @Autowired private IpListService service;

    @PostMapping("/create")
    public IpListDto create(@RequestBody CreateIpListDto request) {
        return this.service.create(request);
    }

    @PostMapping("/update")
    public IpListDto update(@RequestBody UpdateIpListDto request) {
        return this.service.update(request);
    }

    @PostMapping("/delete")
    public Object delete(@RequestBody IdRequest request) {
        this.service.delete(request);
        return true;
    }

    @PostMapping("/getById")
    public IpListDto getById(@RequestBody IdRequest request) {
        return this.service.getById(request.getId());
    }

    @PostMapping("/list")
    public Page<IpListDto> list(@RequestBody CommonQuery request) {
        return this.service.list(request);
    }
}
