package com.playlet.web.service.app.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.playlet.system.domain.PlayletUserExpandAccount;
import com.playlet.system.service.IPlayletUserExpandAccountService;
import com.playlet.web.service.app.PlayletExpandService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PlayletExpandServiceImpl implements PlayletExpandService {

    private final IPlayletUserExpandAccountService iPlayletUserExpandAccountService;

    @Override
    public PageInfo<PlayletUserExpandAccount> getPageList(PlayletUserExpandAccount expandAccount, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<PlayletUserExpandAccount> list = iPlayletUserExpandAccountService.selectPlayletUserExpandAccountList(expandAccount);
        return PageInfo.of(list);
    }

    @Override
    public List<PlayletUserExpandAccount> getList(PlayletUserExpandAccount expandAccount) {
        return iPlayletUserExpandAccountService.selectPlayletUserExpandAccountList(expandAccount);
    }

    @Override
    public void addAccount(PlayletUserExpandAccount expandAccount) {
        expandAccount.setCreateTime(new Date());
        iPlayletUserExpandAccountService.insertPlayletUserExpandAccount(expandAccount);
    }
}
