package com.trade.client.enterprise.customer.controller;

import com.trade.client.enterprise.customer.dto.EnterpriseStatusDto;
import com.trade.client.enterprise.customer.service.EnterpriseService;
import com.trade.common.core.domain.ResponseResult;
import com.trade.service.enterprise.customer.dto.EnterpriseDto;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 企业信息接口
 *
 * @author hlb
 * @since 2024-05-29 15:02:09
 */
@RestController
@RequestMapping("/enterprise")
public class EnterpriseController {

    @Resource
    private EnterpriseService enterpriseService;

    /**
     * 客户企业认证状态查询
     */
    @GetMapping("/certificationStatus")
    public ResponseResult<EnterpriseStatusDto> queryCertificationStatus() {
        EnterpriseStatusDto enterpriseStatusDto = enterpriseService.queryCertificationStatus();
        return ResponseResult.success(enterpriseStatusDto);
    }

    /**
     * 客户更新企业页面数据查询
     */
    @GetMapping("/forUpdate")
    public ResponseResult<EnterpriseDto> queryForUpdate() {
        EnterpriseDto enterpriseDto = enterpriseService.queryForUpdate();
        return ResponseResult.success(enterpriseDto);
    }

    /**
     * "我的企业"页面数据查询
     */
    @GetMapping("/myEnterprise")
    public ResponseResult<EnterpriseDto> queryMyEnterprise() {
        EnterpriseDto enterpriseDto = enterpriseService.queryMyEnterprise();
        return ResponseResult.success(enterpriseDto);
    }

    /**
     * 新增企业信息
     *
     * @param operate 操作：保存（save）；或提交（submit）
     * @param enterpriseDto 实体对象
     * @return 变更记录id
     */
    @PostMapping("/upsert")
    public ResponseResult<Long> saveEnterprise(@RequestParam String operate, @RequestBody EnterpriseDto enterpriseDto) {
        Long changeRecordId = enterpriseService.saveEnterprise(operate, enterpriseDto);
        return ResponseResult.success(changeRecordId);
    }

    /**
     * 申请出口退税权限
     *
     * @return
     */
    @PostMapping("/apply/taxRebate/permission")
    @ResponseBody
    public ResponseResult<Boolean> applyTaxRebatePermission() {
        return ResponseResult.success(enterpriseService.applyTaxRebatePermission());
    }
}
