package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.jcgl.TbJcglShabllInsertAndEditDto;
import com.mosty.base.model.entity.jcgl.TbJcglShabll;
import com.mosty.base.model.query.jcgl.TbJcglShabllQuery;
import com.mosty.base.manager.service.TbJcglShabllService;
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/7/11
 **/
@Api(tags = "社会安保力量接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbJcglShabll")
public class TbJcglShabllController {

    private final TbJcglShabllService tbJcglShabllService;

    @ApiOperation("新增社会安保力量")
    @JwtSysUser
    @PostMapping
    @Log(title = "新增社会安保力量", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> addEntity(@RequestBody TbJcglShabllInsertAndEditDto dto) {
        return ResponseResult.success(this.tbJcglShabllService.addEntity(dto));
    }

    @ApiOperation("修改社会安保力量")
    @JwtSysUser
    @PutMapping
    @Log(title = "修改社会安保力量", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> editEntity(@RequestBody TbJcglShabllInsertAndEditDto dto) {
        return ResponseResult.success(this.tbJcglShabllService.editEntity(dto));
    }

    @ApiOperation("查询社会安保力量-分页")
    @JwtSysUser
    @GetMapping
    public ResponseResult<IPage<TbJcglShabll>> getPageList(TbJcglShabllQuery dto) {
        return ResponseResult.success(this.tbJcglShabllService.getPageList(dto));
    }

    @ApiOperation("删除社会安保力量-批量删除")
    @JwtSysUser
    @DeleteMapping
    @Log(title = "删除社会安保力量-批量删除", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> delEntity(@RequestBody List<String> ids) {
        return ResponseResult.success(this.tbJcglShabllService.delEntity(ids));
    }

    @ApiOperation("社会安保力量详情")
    @JwtSysUser
    @GetMapping("{id}")
    public ResponseResult<TbJcglShabll> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbJcglShabllService.getInfo(id));
    }
}
