package cn.pluss.platform.controller.merchant;

import cn.pluss.platform.SubMerchantApplyOrderService;
import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.base.BaseModelController;
import cn.pluss.platform.entity.SubMerchantApplyOrder;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.userApp.UserAppService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DJH
 * 认证信息相关接口
 */
@RestController
@RequestMapping("/auditInfo")
public class MerchAuditController extends BaseModelController<SubMerchantApplyOrderService, SubMerchantApplyOrder> {

    @Setter(onMethod_ = {@Autowired})
    private UserAppService userAppService;

    /**
     * 查询商户微信认证信息
     */
    @GetMapping("/wxAuditInfo")
    public Result<Object> getWxAuditInfo() {
        UserApp userApp = userAppService.queryUserAppByToken();
        SubMerchantApplyOrder data = baseService.apiGetWxAuditInfo(userApp);
        return ResultGenerator.genSuccessResult("操作成功", data);
    }

    /** 微信认证记录标识为完成 */
    @PostMapping("/complete")
    public Result<Object> complete() {
        UserApp userApp = userAppService.queryUserAppByToken();
        baseService.complete(userApp);
        return ResultGenerator.genSuccessResult("操作成功", null);
    }
}
