jar
jinlin
2025-03-04 23f02e6b45dd7cf0ab2e7827144913ca59575ea4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.example.client.utils; /**
 * Copyright (c) 2018 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有,侵权必究!
 */
 
 
 
import com.example.client.entity.ErrorCode;
import com.example.server.utils.SpringContextUtils;
import org.springframework.context.MessageSource;
 
/**
 * 修改为通过枚举获取message信息
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0
 */
public class MessageUtils {
    private static MessageSource messageSource;
    static {
        messageSource = (MessageSource) SpringContextUtils.getBean("messageSource");
    }
 
 
 
    public static String getMessage(int code){
        return getMessage(code, new String[0]);
    }
 
 
    //修改为通过枚举获取message信息
    public static String getMessage(int code, String... params){
        String message = ErrorCode.getMessage(code,params);
        return message;
//        return messageSource.getMessage(code+"", params, LocaleContextHolder.getLocale());
    }
 
 
}