package org.wfc.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.common.log.annotation.Log;
import org.wfc.common.log.enums.BusinessType;
import org.wfc.user.api.domain.UKyc;
import org.wfc.user.domain.constant.KycStatusEnum;
import org.wfc.user.domain.vo.UKycUserVo;
import org.wfc.user.service.IUKycService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * User Portal-User KYC table contorller
 * </p>
 *
 * @since 2025-01-06
 */
@RestController
@RequestMapping("/kyc")
public class UKycController extends BaseController {

    @Autowired
    private IUKycService uKycService;

    // @RequiresPermissions("Utem:kyc:query")
    @GetMapping("/page")
    public TableDataInfo page() {
        startPage();
        List<UKycUserVo> list = uKycService.selectKycByUserId();
        return getDataTable(list);
    }

    // @RequiresPermissions("Utem:kyc:query")
    @GetMapping("/list")
    public AjaxResult list() {
        List<UKycUserVo> kyc = uKycService.selectKycByUserId();
        return AjaxResult.success(kyc);
    }

    // @RequiresPermissions("Utem:kyc:add")
    // @Log(title = "User Management", businessType = BusinessType.INSERT)    
    @PostMapping("/verify")
    public AjaxResult add(@Validated @RequestBody UKyc uKyc) {
        uKyc.setStatus(KycStatusEnum.PENDING.getCode());
        return toAjax(uKycService.insertUserKyc(uKyc));
    }

    // @RequiresPermissions("Utem:kyc:edit")
    // @Log(title = "User Management", businessType = BusinessType.UPDATE)
    @PutMapping("/verify")
    public AjaxResult edit(@Validated @RequestBody UKyc uKyc) {
        uKyc.setStatus(KycStatusEnum.PENDING.getCode());
        return toAjax(uKycService.updateUserKyc(uKyc));
    }
 
}
