package com.unis.base.server.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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 com.github.pagehelper.PageInfo;
import com.unis.base.common.vo.EnterpriseQualificationInformationHisVO;
import com.unis.base.common.vo.EnterpriseQualificationInformationHisqueryVO;
import com.unis.base.common.vo.QyzgQyzgxxVO;
import com.unis.base.common.vo.TyCrkxxVO;
import com.unis.base.common.vo.TyHtxxVO;
import com.unis.base.server.service.EnterpriseQualificationInformationHisService;
import com.unis.base.server.service.TyCrkxxService;
import com.unis.base.server.service.TyHtxxService;
import com.unis.common.utils.ResponseWrapper;


@RestController
@Api(value = "企业历史信息 ", tags = "企业历史信息维护")
@Slf4j
public class EnterpriseQualificationInformationHisController {

	@Autowired
	private EnterpriseQualificationInformationHisService qyzgQyzgxxHisService;

	/**
	 * 企业历史信息列表
	 * @param companyQueryVO
	 * @return
	 */
	@ApiOperation(value = "企业历史信息列表", notes = "参数：企业历史")
	@PostMapping(value = "/getPageList/{pageNum}/{pageSize}")
    public ResponseWrapper getPageList(@RequestBody EnterpriseQualificationInformationHisqueryVO qyzgQyzgxxHisqueryVO,@PathVariable("pageNum")Integer pageNum,@PathVariable("pageSize")Integer pageSize){
        try {
        	PageInfo<EnterpriseQualificationInformationHisVO> pageInfo = qyzgQyzgxxHisService.getPage(qyzgQyzgxxHisqueryVO,pageNum, pageSize);
            return ResponseWrapper.success(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), pageInfo);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }
        return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(),"服务错误，请联系管理员");
    }
	
	/**
	 * 新增企业历史信息
	 * @param qyzgQyzgxxVO
	 * @return
	 */
	@ApiOperation(value = "新增企业历史信息", notes = "参数：企业历史")
	@PostMapping(value = "/QyzgQyzgxxHis")
    public ResponseWrapper insertQyzgQyzgxxHis(@RequestBody EnterpriseQualificationInformationHisVO qyzgQyzgxxHisVO ) {
		try{
			int QyzgQyzgxxHis = qyzgQyzgxxHisService.insert(qyzgQyzgxxHisVO);
            return ResponseWrapper.success(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), QyzgQyzgxxHis);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }
        return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(),"服务错误，请联系管理员");
    }
	
	
	/**
	 * 查看企业资格历史
	 * @param id
	 * @return
	 */
	@ApiOperation(value = "查看企业资格历史", notes = "参数：企业历史id")
	@PostMapping(value = "/QyzgQyzgxxHis/{id}")
    public ResponseWrapper getEnterpriseQualificationInformationHisVO(@PathVariable String id ) {
		try{
			EnterpriseQualificationInformationHisVO QyzgQyzgxxHis = qyzgQyzgxxHisService.selectByPerimkey(id);
            return ResponseWrapper.success(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), QyzgQyzgxxHis);
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }
        return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(),"服务错误，请联系管理员");
    }
	
	
	
    
	
	
}