package com.cusc.nirvana.user.rnr.fp.controller;


import com.cusc.nirvana.common.result.Response;
import com.cusc.nirvana.user.rnr.fp.dto.EnterpriseChangeRnrPersonDTO;
import com.cusc.nirvana.user.rnr.fp.dto.EnterpriseH5CallBackRequestDTO;
import com.cusc.nirvana.user.rnr.fp.dto.EnterpriseRnrPersonNameReqDTO;
import com.cusc.nirvana.user.rnr.fp.dto.EnterpriseRnrPersonNameResponseDTO;
import com.cusc.nirvana.user.rnr.fp.service.IEnterpriseRnrService;
import com.cusc.nirvana.user.rnr.mg.dto.RnrRelationDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
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;

import javax.annotation.Resource;
import java.util.List;


@RestController
@RequestMapping("/enterpris")
public class EnterpriseRnrController {


    @Resource
    private IEnterpriseRnrService enterpriseRnrService;

    //企业实名
    @PostMapping("/enterpriseRnr/{requestId}")
    public Response enterpriseRnr(@RequestBody RnrRelationDTO dto, @PathVariable("requestId") String requestId) {
        return enterpriseRnrService.enterpriseRnr(dto, requestId);
    }

    @PostMapping("/enterpriseRnrFollowUp")
    @ApiOperation(value = "企业实名认证-后续，直接通过", notes = "企业实名认证-后续，直接通过")
    public Response enterpriseRnrFollowUp(@RequestBody RnrRelationDTO dto) {
        return enterpriseRnrService.enterpriseRnrFollowUp(dto);
    }

    @PostMapping("/uploadSecondary")
    public Response uploadSecondaryEnterprise(RnrRelationDTO dto) {
        //return enterpriseRnrService.uploadEnterpriseInfo(dto);
        return null;
    }

    /**
     * 查询企业的实名责任人姓名
     *
     * @param dto
     * @return
     */
    @PostMapping("/queryEnterpriseRnrPersonName")
    public Response<List<EnterpriseRnrPersonNameResponseDTO>> queryEnterpriseRnrPersonName(@Validated @RequestBody EnterpriseRnrPersonNameReqDTO dto) {
        return Response.createSuccess(enterpriseRnrService.queryEnterpriseRnrPersonName(dto));
    }

	/**
	 * 提交企业责任人变更
	 * @param serialNumber
	 * @param requestId
	 * @param dto
	 * @return
	 */
    @PostMapping("/changeEnterpriseRnrPerson/{serialNumber}/{requestId}")
    public Response changeEnterpriseRnrPerson(@PathVariable("serialNumber") String serialNumber,
                                              @PathVariable("requestId") String requestId,
                                              @RequestBody EnterpriseChangeRnrPersonDTO dto) {
        enterpriseRnrService.changeEnterpriseRnrPerson(serialNumber, requestId, dto);
        return Response.createSuccess();
    }

    @PostMapping("/changeEnterpriseRnrPersonNoSms/{serialNumber}/{requestId}")
    public Response changeEnterpriseRnrPersonNoSms(@PathVariable("serialNumber") String serialNumber,
                                                   @PathVariable("requestId") String requestId,
                                                   @RequestBody EnterpriseChangeRnrPersonDTO dto) {
        enterpriseRnrService.changeEnterpriseRnrPersonNoSms(serialNumber, requestId, dto);
        return Response.createSuccess("企业责任人变更成功");
    }

    @PostMapping("/submitH5")
	public Response submitH5(@RequestBody RnrRelationDTO rnrRelationDTO){
    	enterpriseRnrService.submitH5(rnrRelationDTO);
    	return Response.createSuccess();
	}

	@PostMapping("/enterpriseRnrH5CallBack")
	public Response<Integer> enterpriseRnrH5CallBack(@RequestBody EnterpriseH5CallBackRequestDTO dto) {
		return Response.createSuccess(enterpriseRnrService.personH5CallBack(dto));
	}


}
