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.base.model.dto.qwzx.TbQwQwbcEditDto;
import com.mosty.base.model.entity.qwzx.TbQwJjr;
import com.mosty.base.model.entity.qwzx.TbQwQwbc;
import com.mosty.base.model.query.qwzx.TbQwJjrQuery;
import com.mosty.base.model.query.qwzx.TbQwQwbcQuery;
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.qwzx.service.TbQwJjrService;
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;

@Api(tags = "节假日相关接口")
@AllArgsConstructor
@RestController
@RequestMapping("/tbQwJjr")
public class TbQwJjrController {

    private final TbQwJjrService tbQwJjrService;


    @ApiOperation("新增节假日")
    @JwtSysUser
    @PostMapping("add")
    @Log(title = "新增节假日", businessType = BusinessType.INSERT)
    public ResponseResult<Void> add(@RequestBody TbQwJjr jjr) {
        this.tbQwJjrService.add(jjr);
        return ResponseResult.success();
    }

    @ApiOperation("修改节假日")
    @JwtSysUser
    @PostMapping("update")
    @Log(title = "修改节假日", businessType = BusinessType.UPDATE)
    public ResponseResult<Void> update(@RequestBody TbQwJjr jjr) {
        this.tbQwJjrService.update(jjr);
        return ResponseResult.success();
    }

    @ApiOperation("批量删除节假日")
    @JwtSysUser
    @PostMapping("deleteBatch")
    @Log(title = "批量删除节假日", businessType = BusinessType.DELETE)
    @ApiImplicitParam(name = "ids", value = "标签主键", paramType = "path", required = true, dataType = "String")
    public ResponseResult<Boolean> deleteBatch(@RequestParam List<String> ids) {
        tbQwJjrService.deleteBatch(ids);
        return ResponseResult.success();
    }

    @ApiOperation("单条删除节假日")
    @JwtSysUser
    @PostMapping("del/{id}")
    @Log(title = "单条删除节假日", businessType = BusinessType.DELETE)
    @ApiImplicitParam(name = "id", value = "标签主键", paramType = "path", required = true, dataType = "String")
    public ResponseResult<Boolean> deleteByIds(@PathVariable("id") String id) {
        tbQwJjrService.deleteByIds(id);
        return ResponseResult.success();
    }

    @ApiOperation("分页查询节假日信息")
    @JwtSysUser
    @PostMapping("getPageList")
    public ResponseResult<IPage<TbQwJjr>> getPageList(@RequestBody TbQwJjrQuery dto) {
        return ResponseResult.success(tbQwJjrService.getPageList(dto));
    }
}

