封装文言提示
This commit is contained in:
@@ -4,6 +4,9 @@ import org.springframework.context.MessageSource;
|
|||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
|
||||||
import com.core.common.utils.spring.SpringUtils;
|
import com.core.common.utils.spring.SpringUtils;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取i18n资源文件
|
* 获取i18n资源文件
|
||||||
@@ -22,4 +25,10 @@ public class MessageUtils {
|
|||||||
MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
|
MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
|
||||||
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
|
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String createMessage(String id, @Nullable Object[] params) {
|
||||||
|
MessageSource messageSource = (MessageSource) SpringContextUtils.getApplicationContext().getBean(MessageSource.class);
|
||||||
|
String messageConvert = messageSource.getMessage(id, params, Locale.getDefault());
|
||||||
|
return messageConvert;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.core.common.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SpringContextUtils implements ApplicationContextAware {
|
||||||
|
|
||||||
|
private static ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
public SpringContextUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
SpringContextUtils.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ApplicationContext getApplicationContext() {
|
||||||
|
return applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HttpServletRequest getHttpServletRequest() {
|
||||||
|
return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HttpServletResponse getHttpServletResponse() {
|
||||||
|
return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@ package com.openhis.web.InventoryManage.controller;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import com.core.common.utils.MessageUtils;
|
||||||
|
import com.openhis.common.constant.PromptMsgConstant;
|
||||||
import com.openhis.web.InventoryManage.dto.SupplySaveRequestDto;
|
import com.openhis.web.InventoryManage.dto.SupplySaveRequestDto;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -38,6 +40,12 @@ public class PurchaseInventoryController {
|
|||||||
|
|
||||||
private final IChargeItemService chargeItemService;
|
private final IChargeItemService chargeItemService;
|
||||||
|
|
||||||
|
@GetMapping(value = "/test")
|
||||||
|
public R<?> test(){
|
||||||
|
//return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002,new Object[] {"12345"})) ;
|
||||||
|
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00002,new Object[] {"12345"})) ;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入库单据分页列表
|
* 入库单据分页列表
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ spring:
|
|||||||
max-active: 8
|
max-active: 8
|
||||||
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
# #连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
max-wait: -1ms
|
max-wait: -1ms
|
||||||
|
# 文言
|
||||||
|
messages:
|
||||||
|
basename: i18n/general_message/messages
|
||||||
|
encoding: utf-8
|
||||||
|
|
||||||
# token配置
|
# token配置
|
||||||
token:
|
token:
|
||||||
|
|||||||
@@ -31,3 +31,7 @@ no.update.permission=您没有修改数据的权限,请联系管理员添加
|
|||||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
apl.common.M00002={0}保存成功
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.openhis.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APL消息ID常量类
|
||||||
|
*/
|
||||||
|
public interface PromptMsgConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 共用
|
||||||
|
*/
|
||||||
|
interface Common {
|
||||||
|
/**
|
||||||
|
* {0}添加成功
|
||||||
|
*/
|
||||||
|
String M00001 = "apl.common.M00001";
|
||||||
|
/**
|
||||||
|
* {0}保存成功
|
||||||
|
*/
|
||||||
|
String M00002 = "apl.common.M00002";
|
||||||
|
/**
|
||||||
|
* {0}已经存在
|
||||||
|
*/
|
||||||
|
String M00003 = "apl.common.M00003";
|
||||||
|
/**
|
||||||
|
* {0}操作成功
|
||||||
|
*/
|
||||||
|
String M00004 = "apl.common.M00004";
|
||||||
|
/**
|
||||||
|
* {0}删除成功
|
||||||
|
*/
|
||||||
|
String M00005 = "apl.common.M00005";
|
||||||
|
/**
|
||||||
|
* 操作失败,该数据已被他人删除,请刷新后重试
|
||||||
|
*/
|
||||||
|
String M00006 = "apl.common.M00006";
|
||||||
|
/**
|
||||||
|
* 操作失败,该数据已被他人更改,请刷新后重试
|
||||||
|
*/
|
||||||
|
String M00007 = "apl.common.M00007";
|
||||||
|
/**
|
||||||
|
* 请勿重复提交
|
||||||
|
*/
|
||||||
|
String M00008 = "apl.common.M00008";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user