package com.xingxi.api.service.impl;

import com.xingxi.api.common.UserContext;
import com.xingxi.api.model.WxLogoutRequest;
import com.xingxi.api.service.WxmaUserServiceI;
import com.xingxi.common.core.domain.entity.SysUser;
import com.xingxi.system.mapper.SysUserMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
@Slf4j
@RequiredArgsConstructor
class WxmaUserServiceImpl implements WxmaUserServiceI {
    private final SysUserMapper sysUserMapper;

    @Override
    public void userExit(UserContext userContext, WxLogoutRequest request) {
        SysUser currentUser = userContext.getCurrentUser();
        Long userId = currentUser.getUserId();
        SysUser sysUser = new SysUser();
        sysUser.setUserId(userId);
        sysUser.setLoginDate(new Date());
        sysUser.setUpdateTime(sysUser.getLoginDate());
        sysUser.setUpdateUser(userId + "");
        sysUserMapper.updateUser(sysUser);
    }




}
