Commit 8cbee67e authored by 黄毅's avatar 黄毅

双语

parent 4cbe97dc
package com.egolm.shop.config;
import java.util.Locale;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
@Configuration
public class I18Config extends WebMvcConfigurerAdapter {
@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
// 默认语言
slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
return slr;
}
@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
// 参数名
lci.setParamName("langID");
return lci;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}
}
......@@ -18,6 +18,7 @@ import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.shop.service.BrandService;
import com.egolm.shop.util.I18NUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -50,7 +51,7 @@ public class BrandController {
String limit = request.getParameter("limit");
if(!StringUtil.isNotEmpty(orgNO,compNO,limit,index)) {
return Rjx.json().setCode(-1).setMessage("参数缺失").toJson();
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(langId, "Msg_Parameter_empty")).toJson();
}
Map<String, Object> param = new HashMap<String, Object>();
......
......@@ -19,6 +19,7 @@ import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.common.web.ServletUtil;
import com.egolm.shop.service.GoodsService;
import com.egolm.shop.util.I18NUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -60,7 +61,7 @@ public class GoodsController {
String limit = "10";
if(!StringUtil.isNotEmpty(orgNO,compNO,limit,index)) {
return Rjx.json().setCode(-1).setMessage("参数缺失").toJson();
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(langId, "Msg_Parameter_empty")).toJson();
}
Map<String, Object> param = new HashMap<String, Object>();
......@@ -161,15 +162,17 @@ public class GoodsController {
String reqJson = ServletUtil.readReqJson(request);
System.out.println("searchGoods-------"+reqJson);
Map<String, Object> argsMap = new HashMap<String,Object>();
argsMap = GsonUtil.toMap(reqJson);
String LangID = argsMap.get("langID")+"";
try {
argsMap = GsonUtil.toMap(reqJson);
if(!argsMap.containsKey("index") || !argsMap.containsKey("limit") || !argsMap.containsKey("userNO") || !argsMap.containsKey("shopNO") || !argsMap.containsKey("orgNO") || !argsMap.containsKey("langID")
|| !argsMap.containsKey("terminal") ) {
return Rjx.jsonErr().setCode(-100).setMessage("参数缺失").set("errorMsg", "index,limit,userNO,shopNO,orgNO,langID,terminal为必填项").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(LangID, "Msg_Parameter_empty")).set("errorMsg", "index,limit,userNO,shopNO,orgNO,langID,terminal " +I18NUtils.getMessage(LangID, "Msg_Must_enter")).toJson();
}
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setCode(-100).setMessage("查询参数格式错误").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(LangID, "Msg_QueryParam_error")).toJson();
}
return goodsService.searchGoods(argsMap);
}
......
......@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.StringUtil;
import com.egolm.common.bean.Rjx;
import com.egolm.shop.service.PageService;
import com.egolm.shop.util.I18NUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -36,7 +37,7 @@ public class PageController {
public String query(HttpServletRequest request) {
String LangID = request.getParameter("LangID");
if(!StringUtil.isNotEmpty(LangID)) {
return Rjx.json().setCode(-1).setMessage("参数不能为空").toJson();
return Rjx.json().setCode(-1).setMessage(I18NUtils.getMessage(LangID, "Msg_Parameter_empty")).toJson();
}
Map<String,Object> params = new HashMap<String,Object>();
List<Map<String,Object>> layoutList = pageService.query(params);
......
......@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.egolm.common.bean.Rjx;
import com.egolm.shop.service.SystemCtrlService;
import com.egolm.shop.util.I18NUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -42,7 +43,7 @@ public class SystemCtrlController {
if(result != null) {
return Rjx.jsonOk().setData(result).toJson();
}else {
return Rjx.jsonErr().setCode(-1).setMessage("数据字典查询出错").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_DataDictionary_query_error")).toJson();
}
}
}
......@@ -18,6 +18,7 @@ import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.shop.pojo.TCustAddress;
import com.egolm.shop.service.AddressService;
import com.egolm.shop.service.UserService;
import com.egolm.shop.util.I18NUtils;
@Service
public class AddressServiceImpl implements AddressService {
......@@ -61,6 +62,7 @@ public class AddressServiceImpl implements AddressService {
public String saveOrUpdate(Map<String,Object> params) {
String addId = params.get("addId")+"";
String langID = params.get("langID")+"";
boolean isEdit = false;
if(StringUtil.isNotEmpty(addId)) {
isEdit = true; //修改
......@@ -86,7 +88,7 @@ public class AddressServiceImpl implements AddressService {
boolean isShopExists = userService.checkShopExists(userNO, shopNO);
if(!isShopExists) {
return Rjx.jsonErr().setCode(-100).setMessage(isEdit?"更新失败":"新增失败").set("errorMsg","店铺不存在").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(isEdit?I18NUtils.getMessage(langID, "Msg_Update_failure"):I18NUtils.getMessage(langID, "Msg_Add_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_Shop_notExist")).toJson();
}
......@@ -123,19 +125,19 @@ public class AddressServiceImpl implements AddressService {
custAddress.setdLastUpdateTime(new Date());
}else {
return Rjx.jsonErr().setCode(-100).setMessage("更新失败").set("errorMsg","更新地址不存在").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Update_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_Update_Address_notExist")).toJson();
}
int i = jdbcTemplate.saveOrUpdate(custAddress);
if(i >0) {
return Rjx.jsonOk().setMessage(isEdit?"更新成功":"新增成功").toJson();
return Rjx.jsonOk().setMessage(isEdit?I18NUtils.getMessage(langID, "Msg_Update_success"):I18NUtils.getMessage(langID, "Msg_Add_success")).toJson();
}else {
return Rjx.jsonErr().setCode(-100).setMessage(isEdit?"新增失败":"更新失败").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(isEdit?I18NUtils.getMessage(langID, "Msg_Add_failure"):I18NUtils.getMessage(langID, "Msg_Update_failure")).toJson();
}
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setCode(-100).setMessage(isEdit?"更新操作异常":"新增操作异常").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(isEdit?I18NUtils.getMessage(langID, "Msg_Update_error"):I18NUtils.getMessage(langID, "Msg_Add_error")).toJson();
}
}
......@@ -157,7 +159,7 @@ public class AddressServiceImpl implements AddressService {
try {
boolean isShopExists = userService.checkShopExists(userNO, shopNO);
if(!isShopExists) {
return Rjx.jsonErr().setCode(-100).setMessage("设置失败").set("errorMsg","店铺不存在").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Set_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_Shop_notExist")).toJson();
}
......@@ -169,16 +171,16 @@ public class AddressServiceImpl implements AddressService {
custAddress.setdLastUpdateTime(new Date());
int i = jdbcTemplate.update(custAddress);
if(i >0) {
return Rjx.jsonOk().setMessage("删除成功").toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_Delete_success")).toJson();
}else {
return Rjx.jsonErr().setCode(-100).setMessage("删除失败").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Delete_failure")).toJson();
}
}else {
return Rjx.jsonErr().setMessage("删除失败").set("errorMsg", "地址不存在,请刷新后重试.").toJson();
return Rjx.jsonErr().setMessage(I18NUtils.getMessage(langID, "Msg_Delete_failure")).set("errorMsg", I18NUtils.getMessage(langID, "Msg_Address_notExist")).toJson();
}
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setCode(-100).setMessage("删除操作异常").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Delete_error")).toJson();
}
}
......@@ -198,7 +200,7 @@ public class AddressServiceImpl implements AddressService {
public String defaultAdd(String addId,String userNO,String shopNO,String type,String langID) {
boolean isShopExists = userService.checkShopExists(userNO, shopNO);
if(!isShopExists) {
return Rjx.jsonErr().setCode(-100).setMessage("设置失败").set("errorMsg","店铺不存在").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Set_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_Shop_notExist")).toJson();
}
......@@ -206,9 +208,9 @@ public class AddressServiceImpl implements AddressService {
String sql = " UPDATE tCustAddress SET nTag = 0, sConfirmUser = ? ,dConfirmDate = getdate(),dLastUpdateTime = getdate() WHERE sAddrID = ? AND sCustNO = ? AND sShopNO = ? ";
int i = jdbcTemplate.update(sql,userNO,addId,userNO,shopNO);
if(i >0) {
return Rjx.jsonOk().setMessage("取消默认成功").toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_Cancel_default_success")).toJson();
}else {
return Rjx.jsonErr().setCode(-100).setMessage("取消默认失败").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Cancel_default_failure")).toJson();
}
}else if(type.equals("2")) { //设为默认
//设置所有的地址为 非默认
......@@ -219,12 +221,12 @@ public class AddressServiceImpl implements AddressService {
String defaultSql = " UPDATE tCustAddress SET nTag = 2, sConfirmUser = ? ,dConfirmDate = getdate(),dLastUpdateTime = getdate() WHERE sAddrID = ? AND sCustNO = ? AND sShopNO = ? ";
int i = jdbcTemplate.update(defaultSql,userNO,addId,userNO,shopNO);
if(i >0) {
return Rjx.jsonOk().setMessage("设置默认成功").toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_Set_default_success")).toJson();
}else {
return Rjx.jsonErr().setCode(-100).setMessage("设置默认失败").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Set_default_failure")).toJson();
}
}else {
return Rjx.jsonErr().setCode(-100).setMessage("操作失败").set("errorMsg","参数类型错误 ").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Operate_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_Paramtype_error")).toJson();
}
}
}
......@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.shop.service.CategoryService;
import com.egolm.shop.util.I18NUtils;
@Service
public class CategoryServiceImpl implements CategoryService {
......@@ -30,6 +31,7 @@ public class CategoryServiceImpl implements CategoryService {
public String queryCategory(Map<String,Object> params) {
String orgNO = params.get("orgNO")+"";
String scopeTypeID = params.get("scopeTypeID")+"";
String langID = params.get("langID")+"";
String one="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='3'";
String two="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='2'";
......@@ -59,7 +61,7 @@ public class CategoryServiceImpl implements CategoryService {
}
return Rjx.jsonOk().setData(list1).toJson();
}catch(Exception e) {
return Rjx.jsonErr().setCode(-1).setMessage("分类查询出错").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Catefory_queryError")).toJson();
}
}
......
......@@ -15,6 +15,7 @@ import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.dialect.SqlServerDialect;
import com.egolm.shop.pojo.TCommon;
import com.egolm.shop.service.CommonService;
import com.egolm.shop.util.I18NUtils;
@Service
public class CommonServiceImpl implements CommonService{
......@@ -127,6 +128,6 @@ public class CommonServiceImpl implements CommonService{
e.printStackTrace();
}
return Rjx.jsonErr().setCode(-100).setMessage("省市区数据获取失败").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Province_getfailure")).toJson();
}
}
......@@ -16,6 +16,7 @@ import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.shop.pojo.TCustomer;
import com.egolm.shop.service.CouponService;
import com.egolm.shop.service.UserService;
import com.egolm.shop.util.I18NUtils;
@Service
public class CouponServiceImpl implements CouponService {
private static final Log logger = LogFactory.getLog(CouponServiceImpl.class);
......@@ -101,6 +102,7 @@ public class CouponServiceImpl implements CouponService {
String tradeDate = params.get("tradeDate")+""; //领取日期
String makePaperNO = params.get("makePaperNO")+""; //制券单号
Integer point = Integer.valueOf(params.get("point")+""); //消耗的金币
String langID = params.get("langID")+"";
boolean isGoldChange = false ; //是否积分换券
boolean canChange = true;
......@@ -116,11 +118,11 @@ public class CouponServiceImpl implements CouponService {
isGoldChange = true;
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setCode(-100).setMessage("操作异常,扣积分失败.").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Deduction_failure")).toJson();
}
}else {
canChange = false;
return Rjx.jsonErr().setCode(-100).setMessage("金币不足,兑换失败.").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Redemption_failure")).toJson();
}
}
......@@ -133,7 +135,7 @@ public class CouponServiceImpl implements CouponService {
+ "SELECT ResultCode=@ResultCode,ResultMsg=@ResultMsg,ConponNO=@ConponNO ";
List<Map<String, Object>> returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
if (Util.objTo(returnMap.get(0).get("ResultCode"), Integer.class) == 0 ) {
return Rjx.jsonOk().setMessage("优惠券兑换成功").toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_Coupon_Redemption_success")).toJson();
} else {
changeSuccess = false;
String errorMsg = "";
......@@ -143,7 +145,7 @@ public class CouponServiceImpl implements CouponService {
errorMsg = (String)returnMap.get(0).get("ResultMsg");
}
return Rjx.jsonErr().setCode(-100).setMessage("优惠券兑换失败").set("errorMsg", errorMsg).toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Coupon_Redemption_failure")).set("errorMsg", errorMsg).toJson();
}
}
......@@ -155,7 +157,7 @@ public class CouponServiceImpl implements CouponService {
jdbcTemplate.executeMutil(pointSql).getDatas().get(0);
}catch(Exception ex){
ex.printStackTrace();
return Rjx.jsonErr().setCode(-100).setMessage("金币返还失败").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Gold_return_failure")).toJson();
}
}
return Rjx.json().toJson();
......
......@@ -27,6 +27,7 @@ import com.egolm.shop.service.CommonService;
import com.egolm.shop.service.GoodsService;
import com.egolm.shop.service.SolrGoodsService;
import com.egolm.shop.service.UserService;
import com.egolm.shop.util.I18NUtils;
import com.egolm.shop.util.ShopContstrant;
@Service
public class GoodsServiceImpl implements GoodsService {
......@@ -181,6 +182,7 @@ public class GoodsServiceImpl implements GoodsService {
*/
@Override
public String searchGoods(Map<String, Object> map) {
String langID= (String) map.get("langID");
try {
String userNO=(String) map.get("userNO");
String orgNO=(String) map.get("orgNO");
......@@ -364,7 +366,7 @@ public class GoodsServiceImpl implements GoodsService {
} catch (Exception e) {
e.printStackTrace();
}
return Rjx.jsonErr().setCode(-100).setMessage("搜索失败").toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Search_failure")).toJson();
}
......@@ -482,6 +484,7 @@ public class GoodsServiceImpl implements GoodsService {
String goodsID=(String)params.get("goodsID");
String shopNO=(String)params.get("shopNO");
String override=(String)params.get("override");
String langID=(String) params.get("langID");
String sqlD="delete from tFlavorGoods where sShopNO =? and nGoodsID = ?";
String sqlIn=" if not exists (select 1 from tFlavorGoods where sShopNO = ? and nGoodsID = ?)"
......@@ -491,21 +494,21 @@ public class GoodsServiceImpl implements GoodsService {
if("0".equals(override)) {
try {
jdbcTemplate.executeUpdate(sqlD, shopNO,goodsID);
return Rjx.jsonOk().setMessage("取消收藏成功").toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_CancelCollect_success")).toJson();
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setCode(-1).setMessage("取消收藏失败").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_CancelCollect_failure")).toJson();
}
}else if("1".equals(override)) {
try {
jdbcTemplate.executeUpdate(sqlIn, shopNO,goodsID, shopNO,goodsID);
return Rjx.jsonOk().setMessage("收藏成功").toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_Collection_success")).toJson();
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setCode(-1).setMessage("收藏失败").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Collection_failure")).toJson();
}
}
return Rjx.jsonErr().setCode(-1).setMessage("操作失败").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Operate_failure")).toJson();
}
......
......@@ -28,6 +28,7 @@ import com.egolm.shop.pojo.TShop;
import com.egolm.shop.service.CommonService;
import com.egolm.shop.service.SystemCtrlService;
import com.egolm.shop.service.UserService;
import com.egolm.shop.util.I18NUtils;
import com.egolm.shop.util.ShopContstrant;
@Service
public class UserServiceImpl implements UserService {
......@@ -177,6 +178,7 @@ public class UserServiceImpl implements UserService {
String userNO = params.get("userNO")+"";
String password = params.get("password")+"";
String openID = params.get("openID")+"";
String langID = params.get("langID")+"";
jdbcTemplate.setDialect(new SqlServerDialect());
if(StringUtil.isNotEmpty(userNO)) { //优先用户
EgoPasswordEncoder epe = new EgoPasswordEncoder();
......@@ -191,9 +193,9 @@ public class UserServiceImpl implements UserService {
jdbcTemplate.update("update tCustomer set sOpenID=null,dLastUpdateTime=GETDATE() where sOpenID='"+openID+"' ");
jdbcTemplate.executeUpdate("update tCustomer set sOpenID=?, sBindOpenID=?, dLastUpdateTime=GETDATE() where sCustNO=?",openID,openID,userNO);
}
return Rjx.jsonOk().set("custNO", userNO).setMessage("登陆成功").toJson();
return Rjx.jsonOk().set("custNO", userNO).setMessage(I18NUtils.getMessage(langID, "Msg_Login_success")).toJson();
}else {
return Rjx.jsonErr().setCode(-1).setMessage("用户名或密码错误").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Password_UserName_error")).toJson();
}
}else {
if(StringUtil.isNotEmpty(openID)) { //openID登陆
......@@ -203,16 +205,16 @@ public class UserServiceImpl implements UserService {
if(list.size() == 1) {
Map<String,Object> map = list.get(0);
String custNO = map.get("sCustNO")+"";
return Rjx.jsonOk().setMessage("登陆成功").set("custNO",custNO).toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_Login_success")).set("custNO",custNO).toJson();
}else {
return Rjx.jsonErr().setCode(-1).setMessage("登陆失败").set("errorMsg","openID存在多条数据").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Login_failure")).set("errorMsg","openID "+I18NUtils.getMessage(langID, "Msg_Login_failure")).toJson();
}
}else {
return Rjx.jsonErr().setCode(-1).setMessage("登陆失败").set("errorMsg", "openId不存在").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Login_failure")).set("errorMsg", "openId "+I18NUtils.getMessage(langID, "Msg_OpenID_notExist")).toJson();
}
}
}
return Rjx.jsonErr().setCode(-1).setMessage("登陆失败").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Login_failure")).toJson();
}
......@@ -230,11 +232,12 @@ public class UserServiceImpl implements UserService {
String password = params.get("password")+"";
String smsCode = params.get("smsCode")+"";
String smsTmpID = params.get("smsTmpID")+"";
String langID = params.get("langID")+"";
//检查手机号是否存在
TCustomer customer = getCustomer(mobile);
if(customer == null) {
return Rjx.jsonErr().setCode(-1).setMessage("手机号不存在").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Mobile_notExist")).toJson();
}
//验证redis中是否在短信验证码
......@@ -243,7 +246,7 @@ public class UserServiceImpl implements UserService {
System.out.println("smsCode-----"+smsCode);
System.out.println("redisCode-----"+redisCode);
if(!smsCode.equals(redisCode)) {
return Rjx.jsonOk().setCode(-1).setMessage("验证码不匹配").toJson();
return Rjx.jsonOk().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_Verification_notMatch")).toJson();
}else {
redisTemplate.opsForHash().delete(smsCodeReidsKey, mobile+"_"+smsTmpID);
}
......@@ -257,9 +260,9 @@ public class UserServiceImpl implements UserService {
String updateSql = "UPDATE tCustomer SET sPassword = ? ,dLastUpdateTime = getdate() WHERE sMobile = ? AND nTag&1=0 ";
int i = jdbcTemplate.update(updateSql, newPwd,mobile);
if(i >0) {
return Rjx.jsonOk().setMessage("密码修改成功").toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_ModifyPassword_success")).toJson();
}else {
return Rjx.jsonOk().setCode(-1).setMessage("密码修改失败").toJson();
return Rjx.jsonOk().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_ModifyPassword_failure")).toJson();
}
}
......@@ -282,7 +285,7 @@ public class UserServiceImpl implements UserService {
content = getSmsContent(mobile,content, smsTmpID);
if(!StringUtil.isNotEmpty(content)) {
return Rjx.jsonErr().setCode(-1).setMessage("短信发送失败").set("errorMsg","短信内容不能为空").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_SMS_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_SMS_notEmpty")).toJson();
}
return sendCallSms(mobile, content, langID);
......@@ -327,19 +330,19 @@ public class UserServiceImpl implements UserService {
boolean flag = jsonObj.getBoolean("isValid");
System.out.println("jsonObj----"+jsonObj);
if(flag) {
return Rjx.jsonOk().setMessage("短信发送成功").toJson();
return Rjx.jsonOk().setMessage(I18NUtils.getMessage(langID, "Msg_SMS_success")).toJson();
}else {
return Rjx.jsonErr().setCode(-1).setMessage("短信发送失败").set("errorMsg", jsonObj.get("msg")).toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_SMS_failure")).set("errorMsg", jsonObj.get("msg")).toJson();
}
}else {
return Rjx.jsonErr().setCode(-1).setMessage("短信发送失败").set("errorMsg","短信网关未配置").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_SMS_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_SMS_gateway_notConfig")).toJson();
}
}else {
return Rjx.jsonErr().setCode(-1).setMessage("短信发送失败").set("errorMsg","短信选择器未配置").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_SMS_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_SMS_selector_notConfig")).toJson();
}
}else {
return Rjx.jsonErr().setCode(-1).setMessage("短信发送失败").set("errorMsg","短信选择器参数未配置").toJson();
return Rjx.jsonErr().setCode(-1).setMessage(I18NUtils.getMessage(langID, "Msg_SMS_failure")).set("errorMsg",I18NUtils.getMessage(langID, "Msg_SMS_selector_param_notConfig")).toJson();
}
}
......
package com.egolm.shop.util;
import java.text.MessageFormat;
import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
import com.egolm.common.StringUtil;
/**
*
* @ClassName: I18NUtil
* @Description: TODO( 图际化工具类)
* @author 张永
* @date 2018年4月11日 下午5:36:27
*
*/
@Component
public class I18NUtils {
private static MessageSource source;
public static void main(String[] args) {
System.out.println(getMessage("zh", "Msg_check_key_set","AAA"));
}
@Autowired
public void init(MessageSource source) {
I18NUtils.source = source;
}
/**
*
* <p>Title: </p>
* <p>Description: </p>
* @param LangID 语言标识 与IDC中设置 的对应
* @param key 获取的key
* @param values key中对应的值用于替换 里面的 {0} {1}...
* @return
* @author 张永
* @date 2018年4月11日 下午8:35:15
*/
public static String getMessage(String LangID,String key,Object...values){
if(StringUtil.isEmpty(LangID)){ //为空默认为中文
Locale.setDefault(Locale.CHINA);
}else{
if(LangID.equals("900")){ //英文
Locale.setDefault(Locale.ENGLISH);
}else{
Locale.setDefault(Locale.CHINA);
}
}
Locale locale = LocaleContextHolder.getLocale();
System.out.println("locale---------------"+locale);
String msg = source.getMessage(key, null, locale);
return MessageFormat.format(msg, values);
}
}
spring.profiles.active=dev
\ No newline at end of file
spring.profiles.active=dev
spring.messages.basename=messages
\ No newline at end of file
Msg_Parameter_empty=参数不能为空
Msg_DataDictionary_query_error=数据字典查询出错
Msg_Must_enter=为必填项
Msg_QueryParam_error=查询参数格式错误
Msg_Login_success=登陆成功
Msg_Password_UserName_error=用户名或密码错误
Msg_Login_failure=登陆失败
Msg_Many_openID=存在多条数据
Msg_OpenID_notExist=不存在
Msg_Mobile_notExist=手机号不存在
Msg_Verification_notMatch=验证码不匹配
Msg_ModifyPassword_success=密码修改成功
Msg_ModifyPassword_failure=密码修改失败
Msg_SMS_success=短信发送成功
Msg_SMS_failure=短信发送失败
Msg_SMS_notEmpty=短信内容不能为空
Msg_SMS_gateway_notConfig=短信网关未配置
Msg_SMS_selector_notConfig=短信选择器未配置
Msg_SMS_selector_param_notConfig=短信选择器参数未配置
Msg_Search_failure=搜索失败
Msg_CancelCollect_success=取消收藏成功
Msg_CancelCollect_failure=取消收藏失败
Msg_Collection_success=收藏成功
Msg_Collection_failure=收藏失败
Msg_Operate_failure=操作失败
Msg_Province_getfailure=省市区数据获取失败
Msg_Update_failure=更新失败
Msg_Add_failure=新增失败
Msg_Shop_notExist=店铺不存在
Msg_Update_Address_notExist=更新地址不存在
Msg_Update_success=更新成功
Msg_Add_success=新增成功
Msg_Update_error=更新操作异常
Msg_Add_error=新增操作异常
Msg_Set_failure=设置失败
Msg_Delete_success=删除成功
Msg_Delete_failure=删除失败
Msg_Address_notExist=地址不存在,请刷新后重试.
Msg_Delete_error=删除操作异常
Msg_Cancel_default_success=取消默认成功
Msg_Cancel_default_failure=取消默认失败
Msg_Set_default_success=设置默认成功
Msg_Set_default_failure=设置默认失败
Msg_Paramtype_error=参数类型错误
Msg_Catefory_queryError=分类查询出错
Msg_Deduction_failure=操作异常,扣积分失败.
Msg_Redemption_failure=金币不足,兑换失败.
Msg_Coupon_Redemption_success=优惠券兑换成功
Msg_Coupon_Redemption_failure=优惠券兑换失败
Msg_Gold_return_failure=金币返还失败
I18NUtils.getMessage(langId, "Msg_Parameter_empty")
\ No newline at end of file
Msg_Parameter_empty= Parameters can not be empty
Msg_DataDictionary_query_error=Data dictionary query error
Msg_Must_enter=must be entered
Msg_QueryParam_error=Query parameters format error
Msg_Login_success=Login success
Msg_Password_UserName_error=UserName or Password error
Msg_Login_failure=Login failure
Msg_Many_openID=has multiple pieces of data
Msg_OpenID_notExist=does not exist
Msg_Mobile_notExist=Mobile number does not exist
Msg_Verification_notMatch=Verification code does not match
Msg_ModifyPassword_success=Modify password success
Msg_ModifyPassword_failure=Modify password failure
Msg_SMS_success=SMS send success
Msg_SMS_failure=SMS send failure
Msg_SMS_notEmpty=SMS content can not be empty
Msg_SMS_gateway_notConfig=SMS gateway is not configured
Msg_SMS_selector_notConfig=SMS selector is not configured
Msg_SMS_selector_param_notConfig=SMS selector parameters are not configured
Msg_Search_failure=Search failure
Msg_CancelCollect_success=Cancel collection success
Msg_CancelCollect_failure=Cancel collection failure
Msg_Collection_success=Collect success
Msg_Collection_failure=Collect failure
Msg_Operate_failure=Operate failure
Msg_Province_getfailure=Provincial data get failed
Msg_Update_failure=Update failure
Msg_Add_failure=Add failure
Msg_Shop_notExist=Shop does not exist
Msg_Update_Address_notExist=Update address does not exist
Msg_Update_success=Update success
Msg_Add_success=Add success
Msg_Update_error=Update exception
Msg_Add_error=Add exception
Msg_Set_failure=Setup failure
Msg_Delete_success=Delete success
Msg_Delete_failure=Delete failure
Msg_Address_notExist=Address does not exist, please refresh and try again.
Msg_Delete_error=Delete exception
Msg_Cancel_default_success=Cancel the default success
Msg_Cancel_default_failure=Cancel the default failure
Msg_Set_default_success=Set default success
Msg_Set_default_failure=Set default failure
Msg_Paramtype_error=Parameter type error
Msg_Catefory_queryError=Category query error
Msg_Deduction_failure=Operation is abnormal, deduction of points fails.
Msg_Redemption_failure=The gold coin is insufficient and the redemption failed.
Msg_Coupon_Redemption_success=Coupon redemption success
Msg_Coupon_Redemption_failure=Coupon redemption failure
Msg_Gold_return_failure=Gold coin return failed
Msg_Parameter_empty=\u53C2\u6570\u4E0D\u80FD\u4E3A\u7A7A
Msg_DataDictionary_query_error=\u6570\u636E\u5B57\u5178\u67E5\u8BE2\u51FA\u9519
Msg_Must_enter=\u4E3A\u5FC5\u586B\u9879
Msg_QueryParam_error=\u67E5\u8BE2\u53C2\u6570\u683C\u5F0F\u9519\u8BEF
Msg_Login_success=\u767B\u9646\u6210\u529F
Msg_Password_UserName_error=\u7528\u6237\u540D\u6216\u5BC6\u7801\u9519\u8BEF
Msg_Login_failure=\u767B\u9646\u5931\u8D25
Msg_Many_openID=\u5B58\u5728\u591A\u6761\u6570\u636E
Msg_OpenID_notExist=\u4E0D\u5B58\u5728
Msg_Mobile_notExist=\u624B\u673A\u53F7\u4E0D\u5B58\u5728
Msg_Verification_notMatch=\u9A8C\u8BC1\u7801\u4E0D\u5339\u914D
Msg_ModifyPassword_success=\u5BC6\u7801\u4FEE\u6539\u6210\u529F
Msg_ModifyPassword_failure=\u5BC6\u7801\u4FEE\u6539\u5931\u8D25
Msg_SMS_success=\u77ED\u4FE1\u53D1\u9001\u6210\u529F
Msg_SMS_failure=\u77ED\u4FE1\u53D1\u9001\u5931\u8D25
Msg_SMS_notEmpty=\u77ED\u4FE1\u5185\u5BB9\u4E0D\u80FD\u4E3A\u7A7A
Msg_SMS_gateway_notConfig=\u77ED\u4FE1\u7F51\u5173\u672A\u914D\u7F6E
Msg_SMS_selector_notConfig=\u77ED\u4FE1\u9009\u62E9\u5668\u672A\u914D\u7F6E
Msg_SMS_selector_param_notConfig=\u77ED\u4FE1\u9009\u62E9\u5668\u53C2\u6570\u672A\u914D\u7F6E
Msg_Search_failure=\u641C\u7D22\u5931\u8D25
Msg_CancelCollect_success=\u53D6\u6D88\u6536\u85CF\u6210\u529F
Msg_CancelCollect_failure=\u53D6\u6D88\u6536\u85CF\u5931\u8D25
Msg_Collection_success=\u6536\u85CF\u6210\u529F
Msg_Collection_failure=\u6536\u85CF\u5931\u8D25
Msg_Operate_failure=\u64CD\u4F5C\u5931\u8D25
Msg_Province_getfailure=\u7701\u5E02\u533A\u6570\u636E\u83B7\u53D6\u5931\u8D25
Msg_Update_failure=\u66F4\u65B0\u5931\u8D25
Msg_Add_failure=\u65B0\u589E\u5931\u8D25
Msg_Shop_notExist=\u5E97\u94FA\u4E0D\u5B58\u5728
Msg_Update_Address_notExist=\u66F4\u65B0\u5730\u5740\u4E0D\u5B58\u5728
Msg_Update_success=\u66F4\u65B0\u6210\u529F
Msg_Add_success=\u65B0\u589E\u6210\u529F
Msg_Update_error=\u66F4\u65B0\u64CD\u4F5C\u5F02\u5E38
Msg_Add_error=\u65B0\u589E\u64CD\u4F5C\u5F02\u5E38
Msg_Set_failure=\u8BBE\u7F6E\u5931\u8D25
Msg_Delete_success=\u5220\u9664\u6210\u529F
Msg_Delete_failure=\u5220\u9664\u5931\u8D25
Msg_Address_notExist=\u5730\u5740\u4E0D\u5B58\u5728,\u8BF7\u5237\u65B0\u540E\u91CD\u8BD5.
Msg_Delete_error=\u5220\u9664\u64CD\u4F5C\u5F02\u5E38
Msg_Cancel_default_success=\u53D6\u6D88\u9ED8\u8BA4\u6210\u529F
Msg_Cancel_default_failure=\u53D6\u6D88\u9ED8\u8BA4\u5931\u8D25
Msg_Set_default_success=\u8BBE\u7F6E\u9ED8\u8BA4\u6210\u529F
Msg_Set_default_failure=\u8BBE\u7F6E\u9ED8\u8BA4\u5931\u8D25
Msg_Paramtype_error=\u53C2\u6570\u7C7B\u578B\u9519\u8BEF
Msg_Catefory_queryError=\u5206\u7C7B\u67E5\u8BE2\u51FA\u9519
Msg_Deduction_failure=\u64CD\u4F5C\u5F02\u5E38\uFF0C\u6263\u79EF\u5206\u5931\u8D25.
Msg_Redemption_failure=\u91D1\u5E01\u4E0D\u8DB3,\u5151\u6362\u5931\u8D25.
Msg_Coupon_Redemption_success=\u4F18\u60E0\u5238\u5151\u6362\u6210\u529F
Msg_Coupon_Redemption_failure=\u4F18\u60E0\u5238\u5151\u6362\u5931\u8D25
Msg_Gold_return_failure=\u91D1\u5E01\u8FD4\u8FD8\u5931\u8D25
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment