|
|
@ -1,42 +1,37 @@
|
|
|
|
package cn.estsh.i3plus.core.apiservice.controller;
|
|
|
|
package cn.estsh.i3plus.core.apiservice.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISystemResourceService;
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISystemResourceService;
|
|
|
|
import cn.estsh.i3plus.core.apiservice.mq.I3CoreQueue;
|
|
|
|
import cn.estsh.i3plus.platform.common.enumutil.ResourceEnumUtil;
|
|
|
|
import cn.estsh.i3plus.platform.common.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
import cn.estsh.i3plus.pojo.factory.bean.MachineFactory;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.model.busi.ResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleLanguage;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleLanguage;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleResource;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysLocaleResource;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.amqp.core.Message;
|
|
|
|
|
|
|
|
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
|
|
|
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.concurrent.TimeoutException;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description :
|
|
|
|
* @Description : 系统资源服务demo
|
|
|
|
* @Reference :
|
|
|
|
* @Reference :
|
|
|
|
* @Author : alwaysfrin
|
|
|
|
* @Author : alwaysfrin
|
|
|
|
* @CreateDate : 2018-09-26 10:34
|
|
|
|
* @CreateDate : 2018-09-26 10:34
|
|
|
|
* @Modify:
|
|
|
|
* @Modify:
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/demo-system")
|
|
|
|
@RequestMapping("/demo-system-service")
|
|
|
|
@Api(description="系统服务demo")
|
|
|
|
@Api(description="系统服务demo")
|
|
|
|
public class DemoSystemController {
|
|
|
|
public class DemoSystemController {
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(DemoSystemController.class);
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(DemoSystemController.class);
|
|
|
@ -44,8 +39,8 @@ public class DemoSystemController {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 缓存
|
|
|
|
* 缓存
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Resource(name="redisUtil")
|
|
|
|
@Resource(name="redisCore")
|
|
|
|
private ImppRedis imppRedis;
|
|
|
|
private ImppRedis redisCore;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* rabbitMQ队列
|
|
|
|
* rabbitMQ队列
|
|
|
@ -56,41 +51,101 @@ public class DemoSystemController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ISystemResourceService systemResourceService;
|
|
|
|
private ISystemResourceService systemResourceService;
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(value="/addlanguage")
|
|
|
|
@PutMapping(value="/language/add")
|
|
|
|
@ApiOperation(value="添加语言")
|
|
|
|
@ApiOperation(value="添加语言",notes = "添加系统语言,可用于国际化")
|
|
|
|
public ResultBean addlanguage(SysLocaleLanguage lang) {
|
|
|
|
public ResultBean addLanguage(SysLocaleLanguage lang) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//条件验证
|
|
|
|
|
|
|
|
ValidatorBean.beginValid(lang)
|
|
|
|
|
|
|
|
.notNull("languageName",lang.getLanguageName())
|
|
|
|
|
|
|
|
.notNull("languageCode",lang.getLanguageCode());
|
|
|
|
|
|
|
|
|
|
|
|
systemResourceService.saveSysLocaleLanguage(lang);
|
|
|
|
systemResourceService.saveSysLocaleLanguage(lang);
|
|
|
|
return new ResultBean(true,"操作成功");
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow()).build();
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
|
|
return ResultBean.fail(e.getMessage()).setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(value="/listlang")
|
|
|
|
@PutMapping(value="/language/query")
|
|
|
|
@ApiOperation(value="查询语言")
|
|
|
|
@ApiOperation(value="查询语言",notes = "添加系统语言,可用于国际化")
|
|
|
|
public ResultBean listlang(SysLocaleLanguage lang) {
|
|
|
|
public ResultBean queryLanguage(SysLocaleLanguage lang,Pager pager) {
|
|
|
|
return new ResultBean(true,"操作成功",systemResourceService.listSysLocaleLanguage(lang));
|
|
|
|
try {
|
|
|
|
|
|
|
|
ListPager listPager = systemResourceService.listSysLocaleLanguageByPager(lang,pager);
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow()).build();
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(value="/resource/insert")
|
|
|
|
|
|
|
|
@ApiOperation(value="添加资源",notes = "添加系统语言,可用于国际化")
|
|
|
|
|
|
|
|
public ResultBean insertResource(SysLocaleResource res) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//条件验证
|
|
|
|
|
|
|
|
ValidatorBean.beginValid(res)
|
|
|
|
|
|
|
|
.notNull("resourceKey",res.getResourceKey())
|
|
|
|
|
|
|
|
.notNull("resourceValue",res.getResourceValue());
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(value="/addres")
|
|
|
|
systemResourceService.insertSysLocaleResource(res);
|
|
|
|
@ApiOperation(value="添加资源")
|
|
|
|
return ResultBean.success("操作成功")
|
|
|
|
public ResultBean addres(SysLocaleResource res) {
|
|
|
|
.setResultObject(res)
|
|
|
|
systemResourceService.saveSysLocaleResource(res);
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
return new ResultBean(true,"操作成功");
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping(value="/listres")
|
|
|
|
@PutMapping(value="/resource/query")
|
|
|
|
@ApiOperation(value="查询资源")
|
|
|
|
@ApiOperation(value="查询资源",notes = "分页查询系统资源")
|
|
|
|
public ResultBean listres(SysLocaleResource res) {
|
|
|
|
public ResultBean queryResource(SysLocaleResource res,Pager pager) {
|
|
|
|
return new ResultBean(true,"操作成功",systemResourceService.listSysLocaleResource(res));
|
|
|
|
try{
|
|
|
|
|
|
|
|
ListPager listPager = systemResourceService.listSysLocaleResourceByPager(res,pager);
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功")
|
|
|
|
|
|
|
|
.setListPager(listPager)
|
|
|
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value="/getlocaleresource")
|
|
|
|
@GetMapping(value="/locale-resource/get")
|
|
|
|
@ApiOperation(value="语言资源匹配",notes="资源配置文件及国际化")
|
|
|
|
@ApiOperation(value="语言资源匹配",notes="资源配置文件及国际化")
|
|
|
|
public ResultBean getlocaleresource(int resourceType,String langCode,String resKey) {
|
|
|
|
public ResultBean getLocaleResource(int resourceType,String langCode,String resKey) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ValidatorBean.checkNotZero(resourceType,"请选择资源类型。");
|
|
|
|
|
|
|
|
ValidatorBean.checkNotNull(langCode,"请输入语言编码");
|
|
|
|
|
|
|
|
ValidatorBean.checkNotNull(resKey,"请输入资源编码");
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
Locale locale = LocaleContextHolder.getLocale();
|
|
|
|
System.out.println("当前语言:"+locale.getLanguage() + ",国家:" + locale.getCountry());
|
|
|
|
LOGGER.info("当前语言:" + locale.getLanguage() + ",国家:" + locale.getCountry());
|
|
|
|
|
|
|
|
|
|
|
|
SysLocaleResource res = systemResourceService.getSysLocaleResourceByLanguage(resourceType, langCode, resKey);
|
|
|
|
SysLocaleResource res = systemResourceService.getSysLocaleResourceByLanguage(resourceType, langCode, resKey);
|
|
|
|
System.out.println("获取的资源:" + res);
|
|
|
|
LOGGER.info("获取的资源:" + res);
|
|
|
|
|
|
|
|
|
|
|
|
return new ResultBean(true,"操作成功",res);
|
|
|
|
return ResultBean.success("保存成功")
|
|
|
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
|
|
|
|
|
|
|
|
.setResultObject(res);
|
|
|
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|