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

import com.mortals.xhx.common.code.CreateMethodEnum;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.care.dao.CareConstraintTrackDao;
import com.mortals.xhx.module.care.model.CareConstraintTrackEntity;
import com.mortals.xhx.module.care.service.CareConstraintTrackService;

import java.util.Date;

/**
 * CareConstraintTrackService
 * 主动关怀服务追踪 service实现
 *
 * @author zxfei
 * @date 2023-04-09
 */
@Service("careConstraintTrackService")
public class CareConstraintTrackServiceImpl extends AbstractCRUDServiceImpl<CareConstraintTrackDao, CareConstraintTrackEntity, Long> implements CareConstraintTrackService {


    @Override
    protected void saveBefore(CareConstraintTrackEntity entity, Context context) throws AppException {
        super.saveBefore(entity, context);
        entity.setFeedbackId(this.getContextUserId(context));
        entity.setFeedbackName(context.getUser().getRealName());
        entity.setCreateMethod(CreateMethodEnum.手动创建.getDesc());
        entity.setFeedbackTime(new Date());

    }
}