package com.mosty.qwzx.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mosty.base.model.dto.qwzx.AppSearchQuery;
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 com.mosty.base.model.dto.qwzx.TbQwQwbcEditDto;
import com.mosty.base.model.entity.qwzx.TbQwQwbc;
import com.mosty.base.model.query.qwzx.TbQwQwbcQuery;
import com.mosty.qwzx.service.TbQwQwbcService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 勤务班次表 前端控制器
 * </p>
 *
 * @author zengbo
 * @since 2022-06-27
 */
@Api(tags = "勤务班次表接口")
@AllArgsConstructor
@RestController
@RequestMapping("/tbQwQwbc")
public class TbQwQwbcController {

    private TbQwQwbcService tbQwQwbcService;


    @ApiOperation("通过ID查询单条数据")
    @JwtSysUser
    @GetMapping("{id}")
    @Log(title = "勤务班次表单条数据", businessType = BusinessType.OTHER)
    @ApiImplicitParam(name = "id", value = "报备ID", paramType = "path", required = true, dataType = "String")
    public ResponseResult<TbQwQwbc> queryById(@PathVariable String id) {
        return ResponseResult.success(tbQwQwbcService.selectById(id));
    }

    @ApiOperation("分页查询")
    @JwtSysUser
    @GetMapping
    public ResponseResult<IPage<TbQwQwbc>> paginQuery(TbQwQwbcQuery tbQwQwbcQuery) {
        IPage<TbQwQwbc> page = new Page<>(tbQwQwbcQuery.getPageCurrent(), tbQwQwbcQuery.getPageSize());
        return ResponseResult.success(tbQwQwbcService.getQwbc(tbQwQwbcQuery, page));
    }

    @ApiOperation("新增数据")
    @JwtSysUser
    @PostMapping
    @Log(title = "勤务班次表新增", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> add(@RequestBody TbQwQwbc qwbc) {
        return ResponseResult.success(tbQwQwbcService.addQwbc(qwbc));
    }

    @ApiOperation("更新数据")
    @JwtSysUser
    @PutMapping
    @Log(title = "勤务班次表更新", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> edit(@RequestBody TbQwQwbcEditDto qwbc) {
        return ResponseResult.success(tbQwQwbcService.editQwbc(qwbc));
    }

    @ApiOperation("通过主键删除数据")
    @DeleteMapping("{id}")
    @Log(title = "勤务班次表删除", businessType = BusinessType.UPDATE)
    @ApiImplicitParam(name = "id", value = "标签主键", paramType = "path", required = true, dataType = "String")
    public ResponseResult<Boolean> deleteById(@PathVariable("id") String id) {
        return ResponseResult.success(tbQwQwbcService.deleteById(id));
    }

    @ApiOperation("通过主键删除数据")
    @DeleteMapping("/bacth")
    @Log(title = "勤务班次表删除", businessType = BusinessType.UPDATE)
    @ApiImplicitParam(name = "id", value = "标签主键", paramType = "path", required = true, dataType = "String")
    public ResponseResult<Boolean> deleteByIds(@RequestParam List<String> id) {
        return ResponseResult.success(tbQwQwbcService.deleteBatch(id));
    }

    @ApiOperation("app查询班次信息")
    @GetMapping("/getBcList")
    @JwtSysUser
    public ResponseResult<Page<TbQwQwbc>> getBcList(AppSearchQuery dto) {
        return ResponseResult.success(tbQwQwbcService.getBcList(dto));
    }
}

