package com.chinaweal.aiccs.aiccs.fraudreg.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chinaweal.youfool.framework.springboot.base.query.BaseQuery;
import com.chinaweal.youfool.framework.springboot.rest.RestResult;
import com.chinaweal.youfool.framework.springboot.util.AssertUtils;
import com.dtflys.forest.annotation.Request;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.chinaweal.aiccs.aiccs.fraudreg.entity.TBizFraud;
import com.chinaweal.aiccs.aiccs.fraudreg.service.ITBizFraudService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 涉嫌冒用登记业务表 控制器
 * </p>
 *
 * @author chinaweal
 * @since 2021-11-11
 */
@Api(tags = "涉嫌冒用登记业务表")
@ApiSort(1)
@RestController
@RequestMapping("/fraudReg/tBizFraud")
public class TBizFraudController {

    @Resource
    private ITBizFraudService iTBizFraudService;

    @ApiOperation(value = "1.新增涉嫌冒用登记业务表", position = 1)
    @PostMapping("/save")
    public RestResult<TBizFraud> saveTBizFraud(@RequestBody @Valid TBizFraud tBizFraud, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        tBizFraud = iTBizFraudService.saveTBizFraud(tBizFraud);
        return RestResult.ok(tBizFraud);
    }

    @ApiOperation(value = "2.删除涉嫌冒用登记业务表", position = 2)
    @PostMapping("/delete")
    public RestResult<String> removeTBizFraud(@RequestParam @ApiParam("id") Serializable id) {
        iTBizFraudService.removeById(id);
        return RestResult.ok();
    }

    @ApiOperation(value = "3.修改涉嫌冒用登记业务表", position = 3)
    @PostMapping("/update")
    public RestResult<String> updateTBizFraud(@RequestBody @Valid TBizFraud tBizFraud, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        iTBizFraudService.updateTBizFraud(tBizFraud);
        return RestResult.ok();
    }

    @ApiOperation(value = "4.查询涉嫌冒用登记业务表", position = 4)
    @GetMapping("/get")
    public RestResult<TBizFraud> getTBizFraud(@RequestParam @ApiParam("id") Serializable id) {
        TBizFraud tBizFraud = iTBizFraudService.getById(id);
        return RestResult.ok(tBizFraud);
    }

    @ApiOperation(value = "5.分页查询涉嫌冒用登记业务表", position = 5)
    @PostMapping("/list")
    public RestResult<IPage<TBizFraud>> listTBizFraud(@RequestBody BaseQuery<TBizFraud> query) {
        IPage<TBizFraud> data = iTBizFraudService.listTBizFraud(query);
        return RestResult.ok(data);
    }

    @ApiOperation(value = "6.获取业务投诉信息", position = 6)
    @GetMapping("/getTBizFraudByBizSeq")
    public RestResult<TBizFraud> getTBizFraudByBizSeq(@RequestParam String bizSeq) {
        AssertUtils.isNotBlank(bizSeq);
        return RestResult.ok(iTBizFraudService.getTBizFraudByBizSeq(bizSeq));
    }

    @ApiOperation(value = "7.涉嫌冒用登记统计", position = 7)
    @GetMapping("/statistics")
    public RestResult<List<Map<String, String>>> statistics() {
        return RestResult.ok(iTBizFraudService.statistics());
    }

}
