package com.xiaoniu.subsystem.system.provider;

import com.xiaoniu.api.dto.ApiLogininforDTO;
import com.xiaoniu.api.dto.ApiOperLogDTO;
import com.xiaoniu.api.feign.IUserProvider;
import com.xiaoniu.api.vo.ApiLoginUserVO;
import com.xiaoniu.common.core.domain.R;
import com.xiaoniu.subsystem.system.service.ISysLogininforService;
import com.xiaoniu.subsystem.system.service.ISysOperLogService;
import com.xiaoniu.subsystem.system.service.ISysUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author haoxuyang
 * @Date 2024/11/29 9:31
 */
@RestController
public class UserProvider implements IUserProvider {

    @Resource
    private ISysUserService sysUserService;
    @Resource
    private ISysLogininforService sysLogininforService;
    @Resource
    private ISysOperLogService sysOperLogService;

    @Override
    public R<ApiLoginUserVO> getUserInfo(String username) {
        ApiLoginUserVO apiLoginUserVO = sysUserService.selectUserByUserName(username);
        return R.ok(apiLoginUserVO);
    }

    @Override
    public R<Boolean> saveOperLog(ApiOperLogDTO dto) {
        sysOperLogService.saveOperLog(dto);
        return R.ok();
    }

    @Override
    public R<Boolean> saveLogininfor(ApiLogininforDTO dto) {
        sysLogininforService.add(dto);
        return R.ok();
    }
}
