FollowRecordServiceImpl.java 1.78 KB
package cn.fw.valhalla.service.data.impl;

import cn.fw.valhalla.dao.mapper.FollowRecordMapper;
import cn.fw.valhalla.domain.db.follow.FollowRecord;
import cn.fw.valhalla.domain.enums.FollowTypeEnum;
import cn.fw.valhalla.service.data.FollowRecordService;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author : kurisu
 * @className : FollowRecordImpl
 * @description : 跟进记录
 * @date: 2020-08-12 11:10
 */
@Slf4j
@Service
public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, FollowRecord> implements FollowRecordService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean overdue(final Long id) {
        return this.update(Wrappers.<FollowRecord>lambdaUpdate()
                .set(FollowRecord::getOutTime, Boolean.TRUE)
                .eq(FollowRecord::getId, id)
        );
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void removeRecordByCustId(Long customerId, List<FollowTypeEnum> list) {
        remove(Wrappers.<FollowRecord>lambdaQuery()
                .eq(FollowRecord::getCustomerId, customerId)
                .eq(FollowRecord::getOutTime, Boolean.FALSE)
                .eq(FollowRecord::getAddTodo, Boolean.FALSE)
                .in(!CollectionUtils.isEmpty(list), FollowRecord::getType, list)
        );
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateById(final FollowRecord entity) {
        return super.updateById(entity);
    }
}