TTInfoServiceImpl.java 1.23 KB
package com.bsth.service.schedule;

import com.bsth.common.ResponseCode;
import com.bsth.entity.schedule.TTInfo;
import com.bsth.repository.schedule.TTInfoRepository;
import com.bsth.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by xu on 16/5/12.
 */
@Service
@Transactional
public class TTInfoServiceImpl extends BaseServiceImpl<TTInfo, Long> implements TTInfoService {
    @Autowired
    private TTInfoRepository ttInfoRepository;

    @Transactional
    @Override
    public Map<String, Object> delete(Long aLong) {
        // 获取待作废的数据
        TTInfo ttInfo = ttInfoRepository.findOne(aLong);

        toogleIsCancel(ttInfo);

        Map<String, Object> map = new HashMap<>();
        map.put("status", ResponseCode.SUCCESS);

        return map;
    }



    private void toogleIsCancel(TTInfo ttInfo) {
        boolean isCancel = ttInfo.getIsCancel();
        if (isCancel) {
            ttInfo.setIsCancel(false);
        } else {
            ttInfo.setIsCancel(true);
        }
    }
}