package com.ho.business.service.impl;

import com.ho.business.entity.StrategyOverviewUserSet;
import com.ho.business.mapper.StrategyOverviewUserSetMapper;
import com.ho.business.service.StrategyOverviewUserSetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class StrategyOverviewUserSetServiceImpl implements StrategyOverviewUserSetService {
    
    @Autowired
    StrategyOverviewUserSetMapper setMapper;

    @Override
    public StrategyOverviewUserSet selectByUserId(String userId) {
        StrategyOverviewUserSet strategyOverviewUserSet = setMapper.selectByUserId(userId);
        return strategyOverviewUserSet;
    }

    @Override
    public int insertUserHabit(StrategyOverviewUserSet vo) {
        int count = setMapper.insertUserHabit(vo);
        return count;
    }

    @Override
    public int updateById(StrategyOverviewUserSet vo) {
        int count =  setMapper.updateById(vo);
        return count;
    }

    @Override
    public Integer setStrategyOverviewUserSet(StrategyOverviewUserSet vo) {
        Integer count;
        if(vo.getId() != null){
            count = updateById(vo);
        }else{
            count = insertUserHabit(vo);
        }
        return count;
    }
}
