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.DraftRevokeEntity;
import com.chinaweal.aiccs.aiccs.market.service.IDraftRevokeEntityService;
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-05-31
 */
@Api(tags = "拟撤销主体信息表")
@ApiSort(1)
@RestController
@RequestMapping("/market/draftRevokeEntity")
public class DraftRevokeEntityController {

    @Resource
    private IDraftRevokeEntityService iDraftRevokeEntityService;

    @ApiOperation(value = "1.新增拟撤销主体信息表", position = 1)
    @PostMapping("/save")
    public RestResult<DraftRevokeEntity> saveDraftRevokeEntity(@RequestBody @Valid DraftRevokeEntity draftRevokeEntity, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        draftRevokeEntity = iDraftRevokeEntityService.saveDraftRevokeEntity(draftRevokeEntity);
        return RestResult.ok(draftRevokeEntity);
    }

    @ApiOperation(value = "2.删除拟撤销主体信息表", position = 2)
    @PostMapping("/delete")
    public RestResult<String> removeDraftRevokeEntity(@RequestParam @ApiParam("id") Serializable id) {
        iDraftRevokeEntityService.removeById(id);
        return RestResult.ok();
    }

    @ApiOperation(value = "3.修改拟撤销主体信息表", position = 3)
    @PostMapping("/update")
    public RestResult<String> updateDraftRevokeEntity(@RequestBody @Valid DraftRevokeEntity draftRevokeEntity, BindingResult bindingResult) {
        AssertUtils.isBndingValidit(bindingResult);
        iDraftRevokeEntityService.updateDraftRevokeEntity(draftRevokeEntity);
        return RestResult.ok();
    }

    @ApiOperation(value = "4.查询拟撤销主体信息表", position = 4)
    @GetMapping("/get")
    public RestResult<DraftRevokeEntity> getDraftRevokeEntity(@RequestParam @ApiParam("id") Serializable id) {
        DraftRevokeEntity draftRevokeEntity = iDraftRevokeEntityService.getById(id);
        return RestResult.ok(draftRevokeEntity);
    }

    @ApiOperation(value = "5.分页查询拟撤销主体信息表", position = 5)
    @PostMapping("/list")
    public RestResult<IPage<DraftRevokeEntity>> listDraftRevokeEntity(@RequestBody PageRequestDto pageRequestDto) {
        IPage<DraftRevokeEntity> data = iDraftRevokeEntityService.defaultPaging(pageRequestDto, null, null);
        return RestResult.ok(data);
    }

}
