package com.chinaweal.aiccs.aiccs.market.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chinaweal.youfool.framework.springboot.base.query.BaseQuery;
import com.chinaweal.youfool.framework.springboot.mybatis.plus.page.PageRequestDto;
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.market.entity.TSUsualInspectEntList;
import com.chinaweal.aiccs.aiccs.market.service.ITSUsualInspectEntListService;
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 2022-08-09
 */
@Api(tags = "现场核查企业列表")
@ApiSort(1)
@RestController
@RequestMapping("/market/tSUsualInspectEntList")
public class TSUsualInspectEntListController {

    @Resource
    private ITSUsualInspectEntListService iTSUsualInspectEntListService;

    @ApiOperation(value = "1.新增现场核查企业列表", position = 1)
    @PostMapping("/save")
    public RestResult<TSUsualInspectEntList> saveTSUsualInspectEntList(@RequestBody @Valid TSUsualInspectEntList tSUsualInspectEntList, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        tSUsualInspectEntList = iTSUsualInspectEntListService.saveTSUsualInspectEntList(tSUsualInspectEntList);
        return RestResult.ok(tSUsualInspectEntList);
    }

    @ApiOperation(value = "2.删除现场核查企业列表", position = 2)
    @PostMapping("/delete")
    public RestResult<String> removeTSUsualInspectEntList(@RequestParam @ApiParam("id") Serializable id) {
        iTSUsualInspectEntListService.removeById(id);
        return RestResult.ok();
    }

    @ApiOperation(value = "3.修改现场核查企业列表", position = 3)
    @PostMapping("/update")
    public RestResult<String> updateTSUsualInspectEntList(@RequestBody @Valid TSUsualInspectEntList tSUsualInspectEntList, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        iTSUsualInspectEntListService.updateTSUsualInspectEntList(tSUsualInspectEntList);
        return RestResult.ok();
    }

    @ApiOperation(value = "4.查询现场核查企业列表", position = 4)
    @GetMapping("/get")
    public RestResult<TSUsualInspectEntList> getTSUsualInspectEntList(@RequestParam @ApiParam("id") Serializable id) {
        TSUsualInspectEntList tSUsualInspectEntList = iTSUsualInspectEntListService.getById(id);
        return RestResult.ok(tSUsualInspectEntList);
    }

    @ApiOperation(value = "5.分页查询现场核查企业列表", position = 5)
    @PostMapping("/list")
    public RestResult<IPage<TSUsualInspectEntList>> listTSUsualInspectEntList(@RequestBody PageRequestDto pageRequestDto) {
        IPage<TSUsualInspectEntList> data = iTSUsualInspectEntListService.defaultPaging(pageRequestDto, null, null);
        return RestResult.ok(data);
    }

}
