Commit eed69812 authored by Quxl's avatar Quxl

优化代码

parent f4cae881
package com.egolm.film.common; package com.egolm.film.common;
import java.util.Locale;
public interface Messages { public interface Messages {
public String get(String name, String... args); public String get(String name, String... args);
public Locale getLocale();
} }
...@@ -7,41 +7,26 @@ import java.util.Map; ...@@ -7,41 +7,26 @@ import java.util.Map;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.egolm.film.common.CountryService; import com.egolm.film.common.CountryService;
@Service @Service
public class CountryServiceImpl implements CountryService { public class CountryServiceImpl implements CountryService {
public List<Map<String, String>> queryCountryList() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
String[] ary1 = str1.split(",");
String[] ary2 = str2.split(",");
if(ary1.length == ary2.length) {
for(int i = 0; i < ary1.length; i++) {
Map<String, String> map = new HashMap<String, String>();
map.put(ary2[i], ary1[i]);
list.add(map);
}
}
return list;
}
static String str1 = "阿尔巴尼亚,阿尔及利亚,阿富汗,阿根廷,阿拉伯联合酋长国,阿卢巴岛,阿曼,阿塞拜疆,埃及,埃塞俄比亚,爱尔兰,爱沙尼亚,安道尔,安哥拉,安提,奥地利,澳大利亚,巴巴多斯,巴布亚新几内亚,巴哈马,巴基斯坦,巴拉圭,巴勒斯坦,巴林,巴拿马,巴西,白俄罗斯,百慕大群岛,保加利亚,贝宁,比利时,冰岛,波多黎各,波兰,波斯尼亚和黑塞哥维那共和国,玻利维亚,伯里兹,博茨瓦纳,不丹,布基纳法索,布隆迪,朝鲜,赤道几内亚,丹麦,德国,东帝汶,多哥,多米尼加共和国,俄罗斯,厄瓜多尔,法国,菲律宾,斐济,芬兰,佛得角,冈比亚,刚果,哥伦比亚,哥斯达黎加,格林纳达,格鲁吉亚,古巴,关岛,圭亚那,哈萨克斯坦,海地,韩国,荷兰,荷属安的列斯,吉布提,吉尔吉斯斯坦,几内亚,加拿大,加纳,加蓬,柬埔寨,捷克共和国,津巴布韦,喀麦隆,卡塔尔,开曼群岛,科摩多,科特迪瓦,科威特,克罗地亚共和国,肯尼亚,库尔德斯坦共和国,库克群岛,拉脱维亚,莱索托,老挝,黎巴嫩,立陶宛,利比里亚,利比亚,列支敦士登,卢森堡,卢旺达,罗马尼亚,马达加斯加,马尔代夫,马耳他,马拉维,马来西亚,马里,马其顿,毛里求斯,毛里塔尼亚,美国,美属萨摩亚,蒙古,孟加拉国,秘鲁,缅甸,摩尔多瓦,摩洛哥,摩纳哥,莫桑比克,墨西哥,纳米比亚,南非,南斯拉夫,瑙鲁,尼泊尔,尼加拉瓜,尼日尔,尼日利亚,挪威,葡萄牙,千里达岛和托贝哥岛,日本,瑞典,瑞士,萨尔瓦多,塞尔维亚,塞拉里昂,塞内加尔,塞浦路斯,沙特阿拉伯,圣多美和普林西代,圣路西亚,圣马力诺,斯里兰卡,斯洛伐克,斯洛文尼亚,斯威士兰,苏丹,苏里南,所罗门群岛,索马里,塔吉克斯坦,泰国,坦桑尼亚,汤加,突尼斯,土耳其,土库曼斯坦,瓦努阿图,危地马拉,维尔京群岛,委内瑞拉,文莱,乌干达,乌克兰,乌拉圭,乌兹别克斯坦,西班牙,西属萨摩亚,希腊,新加坡,新西兰,匈牙利,叙利亚,牙买加,亚美尼亚,也门,伊拉克,伊朗,以色列,意大利,印度,印度尼西亚,英国,英属维尔京群岛,约旦,越南,赞比亚,扎伊尔,乍得,智利,中非,澳门,台湾,香港,中国,黑山,科索沃"; private static final String en = "Albania,Algeria,Afghanistan,Argentina,The United Arab Emirates,Aruba,Oman,Azerbaijan,Egypt,Ethiopia,Ireland,Estonia,Andorra,Angola,Antigua,Austria,Australia,Barbados,papua new guinea,Bahamas,Pakistan,Paraguay,Palestine,Bahrain,Panama,Brazil,Belarus,Bermuda,Bulgaria,Benin,Belgium,Iceland,Puerto Rico,poland,Republic of Bosnia and Herzegovina,bolivia,belize,botswana,Bhutan,burkina faso,burundi,North Korea,Equatorial Guinea,Denmark,Germany,Timor-Leste,Togo,Dominican Republic,Russia,Ecuador,France,The Philippines,Fiji,Finland,Cape Verde,Gambia,Congo,Columbia,Costa Rica,Grenada,Georgia,Cuba,Guam,Guyana,Kazakhstan,Haiti,The Republic of Korea,Netherlands,The Netherlands Antilles,Djibouti,Kyrgyzstan,Guinea,Canada,Ghana,Gabon,Cambodia,Czech Republic,zimbabwe,Cameroon,Qatar,Cayman Islands,comodo,Ivory Coast,Kuwait,Republic of Croatia,Kenya,The Republic of Kurdistan,Cook Islands,Latvia,Lesotho,Laos,Lebanon,Lithuania,Liberia,Libya,Liechtenstein,Luxembourg,Rwanda,Romania,Madagascar,Maldives,Malta,Malawi,Malaysia,Mali,Macedonia,Mauritius,Mauritania,U.S.A,American Samoa,Mongolia,bangladesh,Peru,Myanmar,Moldova,Morocco,Monaco,Mozambique,Mexico,Namibia,South Africa,Yugoslavia,Nauru,Nepal,Nicaragua,Niger,Nigeria,Norway,Portugal,Trinidad island and Tobey Island,Japan,Sweden,Switzerland,Salvatore,Serbia,Sierra leone,Senegal,Cyprus,Saudi Arabia,Sao Tome and Principe generation,Saint Lucia,San Marino,Sri Lanka,Slovakia,Slovenia,Swaziland,Sultan,Suriname,Solomon Islands,Somalia,Tajikistan,Thailand,Tanzania,Tonga,Tunisia,Turkey,Turkmenistan,Vanuatu,Guatemala,Virgin Islands,Venezuela,Brunei,Uganda,Ukraine,Uruguay,Uzbekistan,Spain,Samoa,Greece,Singapore,New Zealand,Hungary,Syria,Jamaica,Armenia,Yemen,Iraq,Iran,Israel,Italy,India,Indonesia,Britain,British Virgin Islands,Jordan,Vietnam,Zambia,zaire,Chad,Chile,Central African,Macao,Taiwan,Hong Kong,China,Montenegro,Kosovo";
static String str2 = "Albania,Algeria,Afghanistan,Argentina,The United Arab Emirates,Aruba,Oman,Azerbaijan,Egypt,Ethiopia,Ireland,Estonia,Andorra,Angola,Antigua,Austria,Australia,Barbados,papua new guinea,Bahamas,Pakistan,Paraguay,Palestine,Bahrain,Panama,Brazil,Belarus,Bermuda,Bulgaria,Benin,Belgium,Iceland,Puerto Rico,poland,Republic of Bosnia and Herzegovina,bolivia,belize,botswana,Bhutan,burkina faso,burundi,North Korea,Equatorial Guinea,Denmark,Germany,Timor-Leste,Togo,Dominican Republic,Russia,Ecuador,France,The Philippines,Fiji,Finland,Cape Verde,Gambia,Congo,Columbia,Costa Rica,Grenada,Georgia,Cuba,Guam,Guyana,Kazakhstan,Haiti,The Republic of Korea,Netherlands,The Netherlands Antilles,Djibouti,Kyrgyzstan,Guinea,Canada,Ghana,Gabon,Cambodia,Czech Republic,zimbabwe,Cameroon,Qatar,Cayman Islands,comodo,Ivory Coast,Kuwait,Republic of Croatia,Kenya,The Republic of Kurdistan,Cook Islands,Latvia,Lesotho,Laos,Lebanon,Lithuania,Liberia,Libya,Liechtenstein,Luxembourg,Rwanda,Romania,Madagascar,Maldives,Malta,Malawi,Malaysia,Mali,Macedonia,Mauritius,Mauritania,U.S.A,American Samoa,Mongolia,bangladesh,Peru,Myanmar,Moldova,Morocco,Monaco,Mozambique,Mexico,Namibia,South Africa,Yugoslavia,Nauru,Nepal,Nicaragua,Niger,Nigeria,Norway,Portugal,Trinidad island and Tobey Island,Japan,Sweden,Switzerland,Salvatore,Serbia,Sierra leone,Senegal,Cyprus,Saudi Arabia,Sao Tome and Principe generation,Saint Lucia,San Marino,Sri Lanka,Slovakia,Slovenia,Swaziland,Sultan,Suriname,Solomon Islands,Somalia,Tajikistan,Thailand,Tanzania,Tonga,Tunisia,Turkey,Turkmenistan,Vanuatu,Guatemala,Virgin Islands,Venezuela,Brunei,Uganda,Ukraine,Uruguay,Uzbekistan,Spain,Samoa,Greece,Singapore,New Zealand,Hungary,Syria,Jamaica,Armenia,Yemen,Iraq,Iran,Israel,Italy,India,Indonesia,Britain,British Virgin Islands,Jordan,Vietnam,Zambia,zaire,Chad,Chile,Central African,Macao,Taiwan,Hong Kong,China,Montenegro,Kosovo"; private static final String zh = "阿尔巴尼亚,阿尔及利亚,阿富汗,阿根廷,阿拉伯联合酋长国,阿卢巴岛,阿曼,阿塞拜疆,埃及,埃塞俄比亚,爱尔兰,爱沙尼亚,安道尔,安哥拉,安提,奥地利,澳大利亚,巴巴多斯,巴布亚新几内亚,巴哈马,巴基斯坦,巴拉圭,巴勒斯坦,巴林,巴拿马,巴西,白俄罗斯,百慕大群岛,保加利亚,贝宁,比利时,冰岛,波多黎各,波兰,波斯尼亚和黑塞哥维那共和国,玻利维亚,伯里兹,博茨瓦纳,不丹,布基纳法索,布隆迪,朝鲜,赤道几内亚,丹麦,德国,东帝汶,多哥,多米尼加共和国,俄罗斯,厄瓜多尔,法国,菲律宾,斐济,芬兰,佛得角,冈比亚,刚果,哥伦比亚,哥斯达黎加,格林纳达,格鲁吉亚,古巴,关岛,圭亚那,哈萨克斯坦,海地,韩国,荷兰,荷属安的列斯,吉布提,吉尔吉斯斯坦,几内亚,加拿大,加纳,加蓬,柬埔寨,捷克共和国,津巴布韦,喀麦隆,卡塔尔,开曼群岛,科摩多,科特迪瓦,科威特,克罗地亚共和国,肯尼亚,库尔德斯坦共和国,库克群岛,拉脱维亚,莱索托,老挝,黎巴嫩,立陶宛,利比里亚,利比亚,列支敦士登,卢森堡,卢旺达,罗马尼亚,马达加斯加,马尔代夫,马耳他,马拉维,马来西亚,马里,马其顿,毛里求斯,毛里塔尼亚,美国,美属萨摩亚,蒙古,孟加拉国,秘鲁,缅甸,摩尔多瓦,摩洛哥,摩纳哥,莫桑比克,墨西哥,纳米比亚,南非,南斯拉夫,瑙鲁,尼泊尔,尼加拉瓜,尼日尔,尼日利亚,挪威,葡萄牙,千里达岛和托贝哥岛,日本,瑞典,瑞士,萨尔瓦多,塞尔维亚,塞拉里昂,塞内加尔,塞浦路斯,沙特阿拉伯,圣多美和普林西代,圣路西亚,圣马力诺,斯里兰卡,斯洛伐克,斯洛文尼亚,斯威士兰,苏丹,苏里南,所罗门群岛,索马里,塔吉克斯坦,泰国,坦桑尼亚,汤加,突尼斯,土耳其,土库曼斯坦,瓦努阿图,危地马拉,维尔京群岛,委内瑞拉,文莱,乌干达,乌克兰,乌拉圭,乌兹别克斯坦,西班牙,西属萨摩亚,希腊,新加坡,新西兰,匈牙利,叙利亚,牙买加,亚美尼亚,也门,伊拉克,伊朗,以色列,意大利,印度,印度尼西亚,英国,英属维尔京群岛,约旦,越南,赞比亚,扎伊尔,乍得,智利,中非,澳门,台湾,香港,中国,黑山,科索沃";
public static void main(String[] args) { public List<Map<String, String>> queryCountryList() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>(); List<Map<String, String>> list = new ArrayList<Map<String, String>>();
String[] ary1 = str1.split(","); String[] keys = en.split(",");
String[] ary2 = str2.split(","); String[] vals = zh.split(",");
if(ary1.length == ary2.length) { if(vals.length == keys.length) {
for(int i = 0; i < ary1.length; i++) { for(int i = 0; i < vals.length; i++) {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put(ary2[i], ary1[i]); map.put(keys[i], vals[i]);
list.add(map); list.add(map);
} }
} }
System.out.println(JSON.toJSONString(list, true)); return list;
} }
} }
...@@ -28,5 +28,12 @@ public class DefaultMessages implements Messages { ...@@ -28,5 +28,12 @@ public class DefaultMessages implements Messages {
throw new XException("", e); throw new XException("", e);
} }
} }
@Override
public Locale getLocale() {
Locale locale = LocaleContextHolder.getLocale();
locale = locale == null ? Locale.CHINA : locale;
return locale;
}
} }
...@@ -7,41 +7,26 @@ import java.util.Map; ...@@ -7,41 +7,26 @@ import java.util.Map;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.egolm.film.common.LanguageService; import com.egolm.film.common.LanguageService;
@Service @Service
public class LanguageServiceImpl implements LanguageService { public class LanguageServiceImpl implements LanguageService {
public List<Map<String, String>> queryLanguageList() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
String[] ary1 = str1.split(",");
String[] ary2 = str2.split(",");
if(ary1.length == ary2.length) {
for(int i = 0; i < ary1.length; i++) {
Map<String, String> map = new HashMap<String, String>();
map.put(ary2[i], ary1[i]);
list.add(map);
}
}
return list;
}
static String str1 = "中文,法语,俄罗斯语,日文,葡萄牙语,波斯语,意大利语,英语,德语,西班牙语,阿拉伯语,印第语,韩语,其他"; static String en = "Chinese,French,Russian,Japanese,Portugal,Farsi,Italian,English,German,Spanish,Arabic,Hindi,Korean,Other";
static String str2 = "Chinese,French,Russian,Japanese,Portugal,Farsi,Italian,English,German,Spanish,Arabic,Hindi,Korean,Other"; static String zh = "中文,法语,俄罗斯语,日文,葡萄牙语,波斯语,意大利语,英语,德语,西班牙语,阿拉伯语,印第语,韩语,其他";
public static void main(String[] args) { public List<Map<String, String>> queryLanguageList() {
List<Map<String, String>> list = new ArrayList<Map<String, String>>(); List<Map<String, String>> list = new ArrayList<Map<String, String>>();
String[] ary1 = str1.split(","); String[] keys = en.split(",");
String[] ary2 = str2.split(","); String[] vals = zh.split(",");
if(ary1.length == ary2.length) { if(keys.length == vals.length) {
for(int i = 0; i < ary1.length; i++) { for(int i = 0; i < keys.length; i++) {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();
map.put(ary2[i], ary1[i]); map.put(vals[i], keys[i]);
list.add(map); list.add(map);
} }
} }
System.out.println(JSON.toJSONString(list, true)); return list;
} }
} }
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