package cn.wisenergy.service.app.impl;

import cn.wisenergy.mapper.LastAccountMapper;
import cn.wisenergy.service.app.LastMonthUserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class LastMonthUserInfoServiceImpl implements LastMonthUserInfoService {

    @Autowired
    private LastAccountMapper lastAccountMapper;


    @Override
    public void userInfoMirrorImage() {
        //把用户表user_info备份
        log.info("user_info表进行镜像开始");
        lastAccountMapper.copyTable("user_info","user_info_image");
        lastAccountMapper.deleteTable("user_info_backup");
        lastAccountMapper.updateTableName("user_info_image","user_info_backup");
        log.info("user_info表进行镜像成功");

        //recommend_user表备份
        log.info("user_info表进行镜像开始");
        lastAccountMapper.copyTable("recommend_user","recommend_user_image");
        lastAccountMapper.deleteTable("recommend_user_backup");
        lastAccountMapper.updateTableName("recommend_user_image","recommend_user_backup");
        log.info("user_info表进行镜像成功");

        //team_user_info表备份
        log.info("user_info表进行镜像开始");
        lastAccountMapper.copyTable("team_user_info","team_user_info_image");
        lastAccountMapper.deleteTable("team_user_info_backup");
        lastAccountMapper.updateTableName("team_user_info_image","team_user_info_backup");
        log.info("user_info表进行镜像成功");
    }
}
