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

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.github.xiaoymin.knife4j.annotations.ApiSort;
import com.chinaweal.aiccs.aiccs.fraudreg.entity.TFraudPerson;
import com.chinaweal.aiccs.aiccs.fraudreg.service.ITFraudPersonService;
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 java.io.Serializable;

/**
 * <p>
 * 涉嫌冒用他人身份取得登记责任人信息表 控制器
 * </p>
 *
 * @author chinaweal
 * @since 2021-11-11
 */
@Api(tags = "涉嫌冒用他人身份取得登记责任人信息表")
@ApiSort(1)
@RestController
@RequestMapping("/fraudReg/tFraudPerson")
public class TFraudPersonController {

    @Resource
    private ITFraudPersonService iTFraudPersonService;

    @ApiOperation(value = "1.新增涉嫌冒用他人身份取得登记责任人信息表", position = 1)
    @PostMapping("/save")
    public RestResult<TFraudPerson> saveTFraudPerson(@RequestBody @Valid TFraudPerson tFraudPerson, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        tFraudPerson = iTFraudPersonService.saveTFraudPerson(tFraudPerson);
        return RestResult.ok(tFraudPerson);
    }

    @ApiOperation(value = "2.删除涉嫌冒用他人身份取得登记责任人信息表", position = 2)
    @PostMapping("/delete")
    public RestResult<String> removeTFraudPerson(@RequestParam @ApiParam("id") Serializable id) {
        iTFraudPersonService.removeById(id);
        return RestResult.ok();
    }

    @ApiOperation(value = "3.修改涉嫌冒用他人身份取得登记责任人信息表", position = 3)
    @PostMapping("/update")
    public RestResult<String> updateTFraudPerson(@RequestBody @Valid TFraudPerson tFraudPerson, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        iTFraudPersonService.updateTFraudPerson(tFraudPerson);
        return RestResult.ok();
    }

    @ApiOperation(value = "4.查询涉嫌冒用他人身份取得登记责任人信息表", position = 4)
    @GetMapping("/get")
    public RestResult<TFraudPerson> getTFraudPerson(@RequestParam @ApiParam("id") Serializable id) {
        TFraudPerson tFraudPerson = iTFraudPersonService.getById(id);
        return RestResult.ok(tFraudPerson);
    }

    @ApiOperation(value = "5.分页查询涉嫌冒用他人身份取得登记责任人信息表", position = 5)
    @PostMapping("/list")
    public RestResult<IPage<TFraudPerson>> listTFraudPerson(@RequestBody BaseQuery<TFraudPerson> query) {
        IPage<TFraudPerson> data = iTFraudPersonService.listTFraudPerson(query);
        return RestResult.ok(data);
    }

}
