package com.crm.manager.controller;

import com.crm.manager.service.CustomKycApproveService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.dto.custom.CustomKycApproveListDto;
import com.crm.rely.backend.core.entity.base.BaseApproveEntity;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.custom.kyc.CustomKycApproveSearchEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/custom/kyc")
public class CustomKycApproveController {

    @Autowired
    private CustomKycApproveService customKycApproveService;

    @PostMapping("/search/list")
    public ResultWithPagerDto<CustomKycApproveListDto> pageList(@RequestBody CustomKycApproveSearchEntity entity) throws Exception {

        return customKycApproveService.searchPageList(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        CustomKycApproveListDto result = customKycApproveService.searchSingle(entity);
        return BaseResultDto.success(result);
    }

    @PostMapping("/approve")
    public BaseResultDto approve(@RequestBody @Validated BaseApproveEntity entity) throws Exception {
        customKycApproveService.approve(entity);
        return BaseResultDto.success();
    }

}
