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.rest.RestResult;
import com.chinaweal.youfool.framework.springboot.util.AssertUtils;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.chinaweal.aiccs.aiccs.market.entity.EntAddressChangeLog;
import com.chinaweal.aiccs.aiccs.market.service.IEntAddressChangeLogService;
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-07-07
 */
@Api(tags = "企业主体地址更新审计表")
@ApiSort(1)
@RestController
@RequestMapping("/market/ebaseinfoUpdateAudit")
public class EbaseinfoUpdateAuditController {

    @Resource
    private IEntAddressChangeLogService iEntAddressChangeLogService;

    @ApiOperation(value = "1.新增企业主体地址更新审计表", position = 1)
    @PostMapping("/save")
    public RestResult<EntAddressChangeLog> saveEbaseinfoUpdateAudit(@RequestBody @Valid EntAddressChangeLog entAddressChangeLog, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        entAddressChangeLog = iEntAddressChangeLogService.saveEntAddressChangeLog(entAddressChangeLog);
        return RestResult.ok(entAddressChangeLog);
    }

    @ApiOperation(value = "2.删除企业主体地址更新审计表", position = 2)
    @PostMapping("/delete")
    public RestResult<String> removeEbaseinfoUpdateAudit(@RequestParam @ApiParam("id") Serializable id) {
        iEntAddressChangeLogService.removeById(id);
        return RestResult.ok();
    }

    @ApiOperation(value = "3.修改企业主体地址更新审计表", position = 3)
    @PostMapping("/update")
    public RestResult<String> updateEbaseinfoUpdateAudit(@RequestBody @Valid EntAddressChangeLog entAddressChangeLog, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        iEntAddressChangeLogService.updateEntAddressChangeLog(entAddressChangeLog);
        return RestResult.ok();
    }

    @ApiOperation(value = "4.查询企业主体地址更新审计表", position = 4)
    @GetMapping("/get")
    public RestResult<EntAddressChangeLog> getEbaseinfoUpdateAudit(@RequestParam @ApiParam("id") Serializable id) {
        EntAddressChangeLog entAddressChangeLog = iEntAddressChangeLogService.getById(id);
        return RestResult.ok(entAddressChangeLog);
    }

    @ApiOperation(value = "5.分页查询企业主体地址更新审计表", position = 5)
    @PostMapping("/list")
    public RestResult<IPage<EntAddressChangeLog>> listEbaseinfoUpdateAudit(@RequestBody BaseQuery<EntAddressChangeLog> query) {
        IPage<EntAddressChangeLog> data = iEntAddressChangeLogService.listEntAddressChangeLog(query);
        return RestResult.ok(data);
    }

//    @ApiOperation(value = "test", position = 4)
//    @GetMapping("/test")
//    public RestResult<?> test() {
//        sliceAutoClaimScheduled.autoClaimAIForAddressChange();
//        return RestResult.ok();
//    }

}
