package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mosty.base.model.entity.jcgl.TbJcglJwz;
import com.mosty.base.manager.service.TbJcglJwzService;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "警务站")
@RestController
@AllArgsConstructor
@RequestMapping("/tbJcglJwz")
public class TbJcglJwzController {

    private final TbJcglJwzService tbJcglJwzService;

    @GetMapping({"/selectJwzList"})
    @JwtSysUser
    @ApiOperation(value = "查询警务站列表")
    public ResponseResult<IPage<TbJcglJwz>> selectJwzList(TbJcglJwz jwz) {
        IPage<TbJcglJwz> page = new Page<>(jwz.getPageNo(), jwz.getPageSize());
        return ResponseResult.success(tbJcglJwzService.selectJwzList(jwz, page));
    }

    @PostMapping({"/addJwz"})
    @JwtSysUser
    @Log(title = "新增警务站", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增警务站")
    public ResponseResult<Void> addJwz(@RequestBody TbJcglJwz tbJcglJwz) {
        tbJcglJwzService.addJwz(tbJcglJwz);
        return ResponseResult.success();
    }

    @PostMapping({"/updateJwz"})
    @JwtSysUser
    @Log(title = "修改警务站", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改警务站")
    public ResponseResult<Void> updateJwz(@RequestBody TbJcglJwz jwz) {
        tbJcglJwzService.updateJwz(jwz);
        return ResponseResult.success();
    }

    @PostMapping({"/deleteJwz"})
    @JwtSysUser
    @Log(title = "删除警务站", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除警务站")
    public ResponseResult<Boolean> deleteJwz(@RequestBody List<String> id) {
        return ResponseResult.success(tbJcglJwzService.deleteJwz(id));
    }

    @GetMapping({"/selectByid"})
    @JwtSysUser
    @ApiOperation(value = "查询警务站详情")
    public ResponseResult selectByid(String id) {
        return ResponseResult.success(tbJcglJwzService.selectByid(id));
    }
}
