Search in sources :

Example 11 with AuthUser

use of com.mendmix.common.model.AuthUser in project jeesuite-libs by vakinge.

the class BaseMybatisTest method init.

@Before
public void init() {
    CurrentRuntimeContext.setTenantId("1");
    AuthUser user = new AuthUser();
    user.setId("user01");
    user.setDeptId("dept01");
    user.setName("admin");
    CurrentRuntimeContext.setAuthUser(user);
    MybatisRuntimeContext.addDataProfileMappings("type", "0");
    MybatisRuntimeContext.addDataProfileMappings("organization", MatchPolicy.exact.name());
}
Also used : AuthUser(com.mendmix.common.model.AuthUser) Before(org.junit.Before)

Example 12 with AuthUser

use of com.mendmix.common.model.AuthUser in project jeesuite-libs by vakinge.

the class LogMessageFormat method buildLogHeader.

/**
 * 生成日志消息
 * @param actionKey 操作关键词
 * @param bizKey 业务关键信息如:订单号
 * @return
 */
public static String buildLogHeader(String actionKey, Serializable bizKey) {
    StringBuilder builder = new StringBuilder();
    builder.append(actionKey);
    builder.append("<bizKey:").append(bizKey).append(">");
    String requestId = CurrentRuntimeContext.getRequestId();
    if (requestId != null)
        builder.append("<requestId:").append(requestId).append(">");
    String tenantId = CurrentRuntimeContext.getTenantId(false);
    if (tenantId != null)
        builder.append("<tenantId:").append(tenantId).append(">");
    AuthUser currentUser = CurrentRuntimeContext.getCurrentUser();
    if (currentUser != null)
        builder.append("<currentUser:").append(currentUser.getName()).append(">");
    return builder.toString();
}
Also used : AuthUser(com.mendmix.common.model.AuthUser)

Example 13 with AuthUser

use of com.mendmix.common.model.AuthUser in project jeesuite-libs by vakinge.

the class ActionLogCollector method onRequestStart.

public static ActionLog onRequestStart(String httpMethod, String uri, String requestIp) {
    ActionLog actionLog = new ActionLog();
    actionLog.setActionKey(String.format(ACTION_KEY_FORMAT, httpMethod, uri));
    actionLog.setRequestIp(requestIp);
    actionLog.setEnv(GlobalRuntimeContext.ENV);
    actionLog.setAppId(StringUtils.defaultIfBlank(GlobalRuntimeContext.SYSTEM_ID, GlobalRuntimeContext.APPID));
    actionLog.setModuleId(GlobalRuntimeContext.APPID);
    actionLog.setRequestAt(new Date());
    actionLog.setRequestId(CurrentRuntimeContext.getRequestId());
    AuthUser currentUser = CurrentRuntimeContext.getCurrentUser();
    if (currentUser != null) {
        actionLog.setUserId(currentUser.getId());
        actionLog.setUserName(currentUser.getName());
    }
    actionLog.setClientType(CurrentRuntimeContext.getClientType());
    actionLog.setPlatformType(CurrentRuntimeContext.getPlatformType());
    actionLog.setTenantId(CurrentRuntimeContext.getTenantId());
    return actionLog;
}
Also used : AuthUser(com.mendmix.common.model.AuthUser) Date(java.util.Date)

Aggregations

AuthUser (com.mendmix.common.model.AuthUser)13 JeesuiteBaseException (com.mendmix.common.JeesuiteBaseException)1 BaseEntity (com.mendmix.mybatis.core.BaseEntity)1 MybatisHanlerInitException (com.mendmix.mybatis.exception.MybatisHanlerInitException)1 RequestHeaderBuilder (com.mendmix.springweb.client.RequestHeaderBuilder)1 Serializable (java.io.Serializable)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BinaryExpression (net.sf.jsqlparser.expression.BinaryExpression)1 Expression (net.sf.jsqlparser.expression.Expression)1 Parenthesis (net.sf.jsqlparser.expression.Parenthesis)1 StringValue (net.sf.jsqlparser.expression.StringValue)1 AndExpression (net.sf.jsqlparser.expression.operators.conditional.AndExpression)1 OrExpression (net.sf.jsqlparser.expression.operators.conditional.OrExpression)1 EqualsTo (net.sf.jsqlparser.expression.operators.relational.EqualsTo)1 InExpression (net.sf.jsqlparser.expression.operators.relational.InExpression)1 LikeExpression (net.sf.jsqlparser.expression.operators.relational.LikeExpression)1 Column (net.sf.jsqlparser.schema.Column)1 Before (org.junit.Before)1