RerunServiceImpl.java 880 Bytes
package com.bsth.service.schedule.impl;

import com.bsth.entity.schedule.rule.RerunRule;
import com.bsth.service.schedule.RerunService;
import com.bsth.service.schedule.exception.ScheduleException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by xu on 16/10/20.
 */
@Service
public class RerunServiceImpl extends BServiceImpl<RerunRule, Long> implements RerunService {

    @Transactional
    @Override
    public void delete(Long aLong) throws ScheduleException {
        toggleCancel(aLong);
    }

    private void toggleCancel(Long id) throws ScheduleException {
        RerunRule rerunRule = findById(id);
        if (rerunRule.getIsCancel()) {
            rerunRule.setIsCancel(false);
        } else {
            rerunRule.setIsCancel(true);
        }
    }
}