package com.prolog.eis.service.shelves.impl;

import com.prolog.eis.service.shelves.UserService;
import com.prolog.framework.authority.core.dto.UserDTO;
import com.prolog.framework.authority.user.UserTemplate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: eis-kz-parent
 * @description:
 * @author: Xiong
 * @create: 2022-06-06 16:54
 **/
@Slf4j
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserTemplate userTemplate;

    @Override
    public String getUserInfo() {
        String userName = "user信息获取失败";
        UserDTO userDTO = null;
        try {
            userDTO = userTemplate.getUserDTO();
            log.info("拣选用户信息：" + userDTO);
            if (null != userDTO) {
                userName = StringUtils.isNotBlank(userDTO.getNickname()) ? userDTO.getNickname() : userDTO.getUsername();
                log.info("操作人信息：{}", userName);
            }
        } catch (Exception e) {
            log.error("作业获取user信息失败" + e.getMessage(), e);
        }
        return userName;
    }
}
