package com.yifu.cloud.plus.v1.yifu.salary.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TSettleDomainSelectVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TConfigSalary;
import com.yifu.cloud.plus.v1.yifu.salary.mapper.TConfigSalaryMapper;
import com.yifu.cloud.plus.v1.yifu.salary.service.TConfigSalaryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author fxj
 * @Description 工资报账配置
 * @Date 13:17 2022/8/6
 * @Param
 * @return
**/
@Service("tConfigSalaryService")
public class TConfigSalaryServiceImpl extends ServiceImpl<TConfigSalaryMapper, TConfigSalary> implements TConfigSalaryService {


     /**
      * 工资报账配置简单分页查询
      * @param tConfigSalary 工资报账配置
      * @return
      */
     @Override
     public IPage<TConfigSalary> getTConfigSalaryPage(Page<TConfigSalary> page, TConfigSalary tConfigSalary){
          YifuUser user = SecurityUtils.getUser();
          List<TSettleDomainSelectVo> remoteSettleDomainVoData = null;
          if (Common.isNotNull(user)) {
			  // TODO
               R<List<TSettleDomainSelectVo>> remoteGetTSettleDomainVo = null;
               if (remoteGetTSettleDomainVo == null) {
                    throw new RuntimeException("调用结算服务失败");
               }
               if (CommonConstants.SUCCESS != remoteGetTSettleDomainVo.getCode()) {
                    throw new RuntimeException("调用结算服务返回失败");
               }
               remoteSettleDomainVoData = remoteGetTSettleDomainVo.getData();
               if (remoteSettleDomainVoData == null) {
                    throw new RuntimeException("未获取到相关结算信息");
               }
          }
          return baseMapper.getTConfigSalaryPage(page, tConfigSalary, remoteSettleDomainVoData);
     }

}
