
package com.tmerclub.cloud.user.service.impl;

import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.util.PageUtil;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.user.mapper.UserGrowthLogMapper;
import com.tmerclub.cloud.user.model.UserGrowthLog;
import com.tmerclub.cloud.user.service.UserGrowthLogService;
import com.tmerclub.cloud.user.vo.UserGrowthLogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户成长值记录
 *
 * @author YXF
 * @date 2020-12-08 10:16:53
 */
@Service
public class UserGrowthLogServiceImpl implements UserGrowthLogService {

    @Autowired
    private UserGrowthLogMapper userGrowthLogMapper;

    @Override
    public PageVO<UserGrowthLogVO> page(PageDTO pageDTO) {
        return PageUtil.doPage(pageDTO, () -> userGrowthLogMapper.list());
    }


    @Override
    public UserGrowthLog getByLogId(Long logId) {
        return userGrowthLogMapper.getByLogId(logId);
    }

    @Override
    public void save(UserGrowthLog userGrowthLog) {
        userGrowthLogMapper.save(userGrowthLog);
    }

    @Override
    public void update(UserGrowthLog userGrowthLog) {
        userGrowthLogMapper.update(userGrowthLog);
    }

    @Override
    public void deleteById(Long logId) {
        userGrowthLogMapper.deleteById(logId);
    }

    @Override
    public void saveBatch(List<UserGrowthLog> userGrowthLogs) {
        userGrowthLogMapper.saveBatch(userGrowthLogs);
    }

    @Override
    public PageVO<UserGrowthLogVO> getPageByUserId(PageDTO pageDTO, Long userId) {
        return PageUtil.doPage(pageDTO, () -> userGrowthLogMapper.getPageByUserId(userId));
    }

    @Override
    public UserGrowthLog getByBizId(Long bizId, Integer ioType) {
        return userGrowthLogMapper.getByBizId(bizId, ioType);
    }

    @Override
    public void deleteByUserId(Long userId) {
        userGrowthLogMapper.deleteByUserId(userId);
    }
}
