package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.manager.service.TbJcglAbfcService;
import com.mosty.base.model.dto.jcgl.TbJcglAbfcDto;
import com.mosty.base.model.entity.jcgl.TbJcglAbfc;
import com.mosty.base.model.query.jcgl.TbJcglAbfcQuery;
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 javax.annotation.Resource;
import java.util.List;

/**
 * @author dw
 * @since 2022/9/26
 **/
@Api(tags = "安保风采相关接口")
@RestController
@AllArgsConstructor
@RequestMapping("/abfc")
public class TbJcglAbfcController {

    private final TbJcglAbfcService tbJcglAbfcService;

    @ApiOperation("添加安保风采")
    @JwtSysUser
    @PostMapping
    @Log(title = "添加安保风采", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> addEntity(@RequestBody TbJcglAbfcDto dto) {
        return ResponseResult.success(this.tbJcglAbfcService.addEntity(dto));
    }

    @ApiOperation("修改安保风采")
    @JwtSysUser
    @PutMapping
    @Log(title = "修改安保风采", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> editEntity(@RequestBody TbJcglAbfcDto dto) {
        return ResponseResult.success(this.tbJcglAbfcService.editEntity(dto));
    }

    @ApiOperation("批量删除安保风采")
    @JwtSysUser
    @DeleteMapping
    @Log(title = "批量删除安保风采", businessType = BusinessType.DELETE)
    public ResponseResult<Void> deleteEntity(@RequestParam List<String> ids) {
        this.tbJcglAbfcService.deleteEntity(ids);
        return ResponseResult.success();
    }

    @ApiOperation("查询安保风采列表")
    @JwtSysUser
    @GetMapping
    public ResponseResult<List<TbJcglAbfc>> getPageList(TbJcglAbfcQuery dto) {
        return ResponseResult.success(this.tbJcglAbfcService.getPageList(dto));
    }

    @ApiOperation("查询安保风采详情")
    @JwtSysUser
    @GetMapping("{id}")
    public ResponseResult<TbJcglAbfc> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbJcglAbfcService.getInfo(id));
    }
}
