package cn.pluss.platform.user.impl;

import cn.pluss.platform.entity.UserExtra;
import cn.pluss.platform.mapper.UserExtraMapper;
import cn.pluss.platform.user.UserExtraService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户额外字段关联表信息 服务实现类
 * </p>
 *
 * @author Djh
 * @since 2022-05-31
 */
@Service
public class UserExtraServiceImpl extends ServiceImpl<UserExtraMapper, UserExtra> implements UserExtraService {


    @Override
    public void followUpStart(Long userId) {
        followUp(userId, "2");
    }

    @Override
    public void followUp(Long userId, String status) {
        UserExtra entity = new UserExtra();
        entity.setUserId(userId);
        entity.setKey(FU);

        UserExtra existData = getOne(new QueryWrapper<>(entity));
        if (existData == null) {
            existData = entity;
        }

        existData.setValue(status);
        saveOrUpdate(existData);
    }

    @Override
    public void followUpMark(Long userId) {
        followUp(userId, "1");
    }
}
