package com.mosty.yszx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
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.yszx.TbYsAjDelDto;
import com.mosty.base.model.dto.yszx.TbYsAjDto;
import com.mosty.base.model.query.yszx.TbYsAjNoPageQuery;
import com.mosty.base.model.query.yszx.TbYsAjQuery;
import com.mosty.base.model.vo.yszx.TbYsAjVo;
import com.mosty.yszx.service.TbYsAjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author dw
 * @since 2022/7/18
 * 要素中心-案件接口
 **/
@Api(tags = "要素中心-案件接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbYsAj")
public class TbYsAjController {

    private final TbYsAjService tbYsAjService;

    @ApiOperation("案件新增")
    @JwtSysUser
    @Log(title = "案件新增", businessType = BusinessType.INSERT)
    @PostMapping("addAj")
    public ResponseResult<Void> addAj(@RequestBody TbYsAjDto dto) {
        this.tbYsAjService.addAj(dto);
        return ResponseResult.success();
    }

    @ApiOperation("案件修改")
    @JwtSysUser
    @Log(title = "案件修改", businessType = BusinessType.UPDATE)
    @PutMapping("updateAj")
    public ResponseResult<Void> updateAj(@RequestBody TbYsAjDto dto) {
        this.tbYsAjService.updateAj(dto);
        return ResponseResult.success();
    }

    @ApiOperation("案件查询-分页")
    @JwtSysUser
    @GetMapping("getPageList")
    public ResponseResult<IPage<TbYsAjVo>> getPageList(TbYsAjQuery dto) {
        return ResponseResult.success(this.tbYsAjService.getPageList(dto));
    }

    @ApiOperation("案件查询-不分页")
    @JwtSysUser
    @GetMapping("getList")
    public ResponseResult<List<TbYsAjVo>> getList(TbYsAjNoPageQuery dto) {
        return ResponseResult.success(this.tbYsAjService.getList(dto));
    }

    @ApiOperation("删除案件信息")
    @JwtSysUser
    @DeleteMapping("delAj")
    public ResponseResult<Void> delAj(TbYsAjDelDto dto) {
        this.tbYsAjService.delAj(dto);
        return ResponseResult.success();
    }

    @ApiOperation("获取案件信息的数据--热力图")
    @JwtSysUser
    @GetMapping("getAjHotMap")
    public ResponseResult<List<Map<String,Object>>> getAjHotMap(TbYsAjNoPageQuery dto) {
        return ResponseResult.success(this.tbYsAjService.getAjHotMap(dto));
    }

    @ApiOperation("查询案件案件详情")
    @JwtSysUser
    @GetMapping("getInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true),
            @ApiImplicitParam(name = "ajfl", value = "--D_BB_AJLB（案件类别）案件分类：1-刑事案件，2-行政案件", required = true)
    })
    public ResponseResult<TbYsAjVo> getInfo(String id, String ajfl) {
        return ResponseResult.success(this.tbYsAjService.getInfo(id, ajfl));
    }

}
