package com.mortals.xhx.module.perform.service.impl;

import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.check.model.CheckComplainRecordEntity;
import com.mortals.xhx.module.check.service.CheckComplainRecordService;
import com.mortals.xhx.module.perform.dao.PerformComplainRecordDao;
import com.mortals.xhx.module.perform.model.PerformComplainRecordEntity;
import com.mortals.xhx.module.perform.service.PerformComplainRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* PerformComplainRecordService
* 评价绩效投诉记录信息 service实现
*
* @author zxfei
* @date 2023-05-18
*/
@Service("performComplainRecordService")
@Slf4j
public class PerformComplainRecordServiceImpl extends AbstractCRUDServiceImpl<PerformComplainRecordDao, PerformComplainRecordEntity, Long> implements PerformComplainRecordService {

    @Autowired
    private CheckComplainRecordService checkComplainRecordService;

    @Override
    protected void saveAfter(PerformComplainRecordEntity entity, Context context) throws AppException {
        CheckComplainRecordEntity checkComplainRecordEntity = new CheckComplainRecordEntity();
        checkComplainRecordEntity.initAttrValue();
        BeanUtils.copyProperties(entity,checkComplainRecordEntity, BeanUtil.getNullPropertyNames(entity));
        checkComplainRecordEntity.setRecordId(entity.getId());
        if(entity.getSubMethod()==1){
            checkComplainRecordEntity.setCheckStatus(2);     //自动扣分相设置为已处理
        }else {
            checkComplainRecordEntity.setCheckStatus(1);      //非自动扣分相设置为未处理
        }
        checkComplainRecordService.save(checkComplainRecordEntity,context);
    }
}