package com.unis.base.server.controller;

import java.util.List;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import com.github.pagehelper.PageInfo;
import com.unis.common.utils.ResponseWrapper;
import com.unis.base.common.vo.TzQyjgVO;
import com.unis.base.common.vo.CompanyQueryVO;
import com.unis.base.common.vo.CompanyVO;
import com.unis.base.common.vo.PersonnelRecordsHisVO;
import com.unis.base.common.vo.PersonnelRecordsHisqueryVO;
import com.unis.base.common.vo.DRyxxsjyVO;
import com.unis.base.common.vo.RandomCompanyQuery;
import com.unis.base.server.entity.TzSlqyDO;
import com.unis.base.server.service.CompanyService;
import com.unis.base.server.service.PersonnelRecordsHisService;

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

@RestController
@Api(value = "人员历史信息", tags = "人员历史信息维护")
@Slf4j
public class PersonnelRecordsHisController {
	
	@Autowired
	private PersonnelRecordsHisService dRyxxsjyHisService;

	/**
	 * 获取人员历史信息列表
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@ApiOperation(value = "获取人员历史信息列表")
	@PostMapping(value = "/getPageOnList/{pageNum}/{pageSize}")
    public ResponseWrapper getPageOnList(@RequestBody PersonnelRecordsHisqueryVO dRyxxsjyHisqueryVO,@PathVariable("pageNum")Integer pageNum,@PathVariable("pageSize") Integer pageSize) {
		try{
        	PageInfo<PersonnelRecordsHisVO> pageInfo = dRyxxsjyHisService.getDRyxxsjyPage(dRyxxsjyHisqueryVO,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 dRyxxsjyVO
	 * @return
	 */
	@ApiOperation(value = "新增历史人员信息", notes = "参数：历史人员")
	@PostMapping(value = "/DRyxxsjyHis")
    public ResponseWrapper insert(@RequestBody PersonnelRecordsHisVO dRyxxsjyHisVO) {
		int dRyxxsjy = dRyxxsjyHisService.insert(dRyxxsjyHisVO);
		if (dRyxxsjy>0) {
			return ResponseWrapper.success(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), dRyxxsjy);
		}
        return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(),"服务错误，请联系管理员");
    }
	
	
	/**
	 * 查看人员历史
	 * @param rybajlId
	 * @return
	 */
	@ApiOperation(value = "查看人员历史信息", notes = "参数：历史人员主键")
	@PostMapping(value = "/getDRyxxsjyHis/{rybajlId}")
    public ResponseWrapper getPersonnelRecordsHisVO(@PathVariable String rybajlId) {
		
		PersonnelRecordsHisVO selectByPerimkey = dRyxxsjyHisService.selectByPerimkey(rybajlId);
		if (selectByPerimkey !=null) {
			return ResponseWrapper.success(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), selectByPerimkey);
		}
		return ResponseWrapper.error(HttpStatus.INTERNAL_SERVER_ERROR.value(), HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase(),"服务错误，请联系管理员");
		    
	}
	
	
	
	
	
}