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

import com.mortals.framework.common.Rest;
import com.mortals.xhx.module.person.model.PersonEntity;
import com.mortals.xhx.module.person.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
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.appointment.dao.AppointmentConstraintDao;
import com.mortals.xhx.module.appointment.model.AppointmentConstraintEntity;
import com.mortals.xhx.module.appointment.service.AppointmentConstraintService;
import org.springframework.util.ObjectUtils;

/**
 * AppointmentConstraintService
 * 预约自动签到服务约束 service实现
 *
 * @author zxfei
 * @date 2023-04-09
 */
@Service("appointmentConstraintService")
public class AppointmentConstraintServiceImpl extends AbstractCRUDServiceImpl<AppointmentConstraintDao, AppointmentConstraintEntity, Long> implements AppointmentConstraintService {

    @Autowired
    private PersonService personService;

    @Override
    protected void saveBefore(AppointmentConstraintEntity entity, Context context) throws AppException {

        entity.setOperator(context.getUser()==null?"":context.getUser().getRealName());
        super.saveBefore(entity, context);
    }

    @Override
    protected void updateBefore(AppointmentConstraintEntity entity, Context context) throws AppException {
        entity.setOperator(context.getUser()==null?"":context.getUser().getRealName());
        super.updateBefore(entity, context);
    }

    @Override
    public Rest<String> constraintService(AppointmentConstraintEntity appointmentConstraintEntity, Context context) {
        //取消或者开启约束服务

        return Rest.ok("修改成功");
    }
}