package com.iailab.module.system.framework.operatelog.core; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; import com.iailab.module.system.dal.dataobject.user.AdminUserDO; import com.iailab.module.system.service.user.AdminUserService; import com.mzt.logapi.service.IParseFunction; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.annotation.Resource; /** * 管理员名字的 {@link IParseFunction} 实现类 * * @author HUIHUI */ @Slf4j @Component public class AdminUserParseFunction implements IParseFunction { public static final String NAME = "getAdminUserById"; @Resource private AdminUserService adminUserService; @Override public String functionName() { return NAME; } @Override public String apply(Object value) { if (StrUtil.isEmptyIfStr(value)) { return ""; } // 获取用户信息 AdminUserDO user = adminUserService.getUser(Convert.toLong(value)); if (user == null) { log.warn("[apply][获取用户{{}}为空", value); return ""; } // 返回格式 iailab(13888888888) String nickname = user.getNickname(); if (StrUtil.isEmpty(user.getMobile())) { return nickname; } return StrUtil.format("{}({})", nickname, user.getMobile()); } }