Commit a5c2aff4 authored by Junling Bu's avatar Junling Bu
Browse files

chore[后端服务]: 后端服务代码基于IDEA的reformat code工具格式化代码,但是mybatis generator生成的代码除外。

parent 556f269d
...@@ -18,20 +18,20 @@ public class Traces { ...@@ -18,20 +18,20 @@ public class Traces {
@JsonProperty("AcceptTime") @JsonProperty("AcceptTime")
private String AcceptTime; private String AcceptTime;
public void setAcceptStation(String AcceptStation) {
this.AcceptStation = AcceptStation;
}
public String getAcceptStation() { public String getAcceptStation() {
return AcceptStation; return AcceptStation;
} }
public void setAcceptTime(String AcceptTime) { public void setAcceptStation(String AcceptStation) {
this.AcceptTime = AcceptTime; this.AcceptStation = AcceptStation;
} }
public String getAcceptTime() { public String getAcceptTime() {
return AcceptTime; return AcceptTime;
} }
public void setAcceptTime(String AcceptTime) {
this.AcceptTime = AcceptTime;
}
} }
\ No newline at end of file
...@@ -22,15 +22,15 @@ public class NotifyService { ...@@ -22,15 +22,15 @@ public class NotifyService {
private WxTemplateSender wxTemplateSender; private WxTemplateSender wxTemplateSender;
private List<Map<String, String>> wxTemplate = new ArrayList<>(); private List<Map<String, String>> wxTemplate = new ArrayList<>();
public boolean isMailEnable (){ public boolean isMailEnable() {
return mailSender != null; return mailSender != null;
} }
public boolean isSmsEnable (){ public boolean isSmsEnable() {
return smsSender != null; return smsSender != null;
} }
public boolean isWxEnable (){ public boolean isWxEnable() {
return wxTemplateSender != null; return wxTemplateSender != null;
} }
...@@ -62,7 +62,7 @@ public class NotifyService { ...@@ -62,7 +62,7 @@ public class NotifyService {
} }
String templateIdStr = getTemplateId(notifyType, smsTemplate); String templateIdStr = getTemplateId(notifyType, smsTemplate);
if (templateIdStr == null){ if (templateIdStr == null) {
return; return;
} }
......
...@@ -6,12 +6,12 @@ public enum NotifyType { ...@@ -6,12 +6,12 @@ public enum NotifyType {
REFUND("refund"), REFUND("refund"),
CAPTCHA("captcha"); CAPTCHA("captcha");
private String type;
NotifyType(String type) { NotifyType(String type) {
this.type = type; this.type = type;
} }
private String type;
public String getType() { public String getType() {
return this.type; return this.type;
} }
......
...@@ -5,7 +5,6 @@ import com.github.qcloudsms.SmsSingleSenderResult; ...@@ -5,7 +5,6 @@ import com.github.qcloudsms.SmsSingleSenderResult;
import com.github.qcloudsms.httpclient.HTTPException; import com.github.qcloudsms.httpclient.HTTPException;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import java.io.IOException; import java.io.IOException;
......
...@@ -64,7 +64,7 @@ public class WxTemplateSender { ...@@ -64,7 +64,7 @@ public class WxTemplateSender {
try { try {
wxMaService.getMsgService().sendTemplateMsg(msg); wxMaService.getMsgService().sendTemplateMsg(msg);
if(formIdService.updateUserFormId(userFormid) == 0){ if (formIdService.updateUserFormId(userFormid) == 0) {
logger.warn("更新数据已失效"); logger.warn("更新数据已失效");
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -21,24 +21,24 @@ public class NotifyAutoConfiguration { ...@@ -21,24 +21,24 @@ public class NotifyAutoConfiguration {
} }
@Bean @Bean
public NotifyService notifyService(){ public NotifyService notifyService() {
NotifyService notifyService = new NotifyService(); NotifyService notifyService = new NotifyService();
NotifyProperties.Mail mailConfig = properties.getMail(); NotifyProperties.Mail mailConfig = properties.getMail();
if(mailConfig.isEnable()) { if (mailConfig.isEnable()) {
notifyService.setMailSender(mailSender()); notifyService.setMailSender(mailSender());
notifyService.setSendFrom(mailConfig.getSendfrom()); notifyService.setSendFrom(mailConfig.getSendfrom());
notifyService.setSendTo(mailConfig.getSendto()); notifyService.setSendTo(mailConfig.getSendto());
} }
NotifyProperties.Sms smsConfig = properties.getSms(); NotifyProperties.Sms smsConfig = properties.getSms();
if(smsConfig.isEnable()){ if (smsConfig.isEnable()) {
notifyService.setSmsSender(tencentSmsSender()); notifyService.setSmsSender(tencentSmsSender());
notifyService.setSmsTemplate(smsConfig.getTemplate()); notifyService.setSmsTemplate(smsConfig.getTemplate());
} }
NotifyProperties.Wx wxConfig = properties.getWx(); NotifyProperties.Wx wxConfig = properties.getWx();
if(wxConfig.isEnable()){ if (wxConfig.isEnable()) {
notifyService.setWxTemplateSender(wxTemplateSender()); notifyService.setWxTemplateSender(wxTemplateSender());
notifyService.setWxTemplate(wxConfig.getTemplate()); notifyService.setWxTemplate(wxConfig.getTemplate());
} }
...@@ -46,7 +46,7 @@ public class NotifyAutoConfiguration { ...@@ -46,7 +46,7 @@ public class NotifyAutoConfiguration {
} }
@Bean @Bean
public JavaMailSender mailSender(){ public JavaMailSender mailSender() {
NotifyProperties.Mail mailConfig = properties.getMail(); NotifyProperties.Mail mailConfig = properties.getMail();
JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(mailConfig.getHost()); mailSender.setHost(mailConfig.getHost());
...@@ -56,13 +56,13 @@ public class NotifyAutoConfiguration { ...@@ -56,13 +56,13 @@ public class NotifyAutoConfiguration {
} }
@Bean @Bean
public WxTemplateSender wxTemplateSender(){ public WxTemplateSender wxTemplateSender() {
WxTemplateSender wxTemplateSender = new WxTemplateSender(); WxTemplateSender wxTemplateSender = new WxTemplateSender();
return wxTemplateSender; return wxTemplateSender;
} }
@Bean @Bean
public TencentSmsSender tencentSmsSender(){ public TencentSmsSender tencentSmsSender() {
NotifyProperties.Sms smsConfig = properties.getSms(); NotifyProperties.Sms smsConfig = properties.getSms();
TencentSmsSender smsSender = new TencentSmsSender(); TencentSmsSender smsSender = new TencentSmsSender();
smsSender.setSender(new SmsSingleSender(smsConfig.getAppid(), smsConfig.getAppkey())); smsSender.setSender(new SmsSingleSender(smsConfig.getAppid(), smsConfig.getAppkey()));
......
...@@ -97,7 +97,7 @@ public class NotifyProperties { ...@@ -97,7 +97,7 @@ public class NotifyProperties {
private boolean enable; private boolean enable;
private int appid; private int appid;
private String appkey; private String appkey;
private List<Map<String,String>> template = new ArrayList<>(); private List<Map<String, String>> template = new ArrayList<>();
public boolean isEnable() { public boolean isEnable() {
return enable; return enable;
...@@ -134,7 +134,7 @@ public class NotifyProperties { ...@@ -134,7 +134,7 @@ public class NotifyProperties {
public static class Wx { public static class Wx {
private boolean enable; private boolean enable;
private List<Map<String,String>> template = new ArrayList<>(); private List<Map<String, String>> template = new ArrayList<>();
public boolean isEnable() { public boolean isEnable() {
return enable; return enable;
......
...@@ -6,7 +6,8 @@ import org.springframework.core.io.ClassPathResource; ...@@ -6,7 +6,8 @@ import org.springframework.core.io.ClassPathResource;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL; import java.net.URL;
public class QCodeGoodShare extends QCodeBase { public class QCodeGoodShare extends QCodeBase {
......
...@@ -20,10 +20,10 @@ import java.util.stream.Stream; ...@@ -20,10 +20,10 @@ import java.util.stream.Stream;
*/ */
public class AliyunStorage implements Storage { public class AliyunStorage implements Storage {
private String endpoint; private String endpoint;
private String accessKeyId; private String accessKeyId;
private String accessKeySecret; private String accessKeySecret;
private String bucketName; private String bucketName;
public String getEndpoint() { public String getEndpoint() {
return endpoint; return endpoint;
...@@ -62,12 +62,12 @@ public class AliyunStorage implements Storage { ...@@ -62,12 +62,12 @@ public class AliyunStorage implements Storage {
* *
* @return ossClient * @return ossClient
*/ */
private OSSClient getOSSClient(){ private OSSClient getOSSClient() {
return new OSSClient(endpoint,accessKeyId, accessKeySecret); return new OSSClient(endpoint, accessKeyId, accessKeySecret);
} }
private String getBaseUrl() { private String getBaseUrl() {
return "https://" + bucketName + "." + endpoint + "/" ; return "https://" + bucketName + "." + endpoint + "/";
} }
/** /**
...@@ -119,7 +119,7 @@ public class AliyunStorage implements Storage { ...@@ -119,7 +119,7 @@ public class AliyunStorage implements Storage {
public void delete(String keyName) { public void delete(String keyName) {
try { try {
getOSSClient().deleteObject(bucketName, keyName); getOSSClient().deleteObject(bucketName, keyName);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -17,7 +17,7 @@ import java.util.stream.Stream; ...@@ -17,7 +17,7 @@ import java.util.stream.Stream;
public class QiniuStorage implements Storage { public class QiniuStorage implements Storage {
private String endpoint; private String endpoint;
private String accessKey; private String accessKey;
private String secretKey; private String secretKey;
private String bucketName; private String bucketName;
...@@ -62,8 +62,8 @@ public class QiniuStorage implements Storage { ...@@ -62,8 +62,8 @@ public class QiniuStorage implements Storage {
*/ */
@Override @Override
public void store(InputStream inputStream, long contentLength, String contentType, String keyName) { public void store(InputStream inputStream, long contentLength, String contentType, String keyName) {
if(uploadManager == null){ if (uploadManager == null) {
if(auth == null) { if (auth == null) {
auth = Auth.create(accessKey, secretKey); auth = Auth.create(accessKey, secretKey);
} }
uploadManager = new UploadManager(new Configuration()); uploadManager = new UploadManager(new Configuration());
...@@ -105,16 +105,16 @@ public class QiniuStorage implements Storage { ...@@ -105,16 +105,16 @@ public class QiniuStorage implements Storage {
@Override @Override
public void delete(String keyName) { public void delete(String keyName) {
if(bucketManager == null){ if (bucketManager == null) {
if(auth == null) { if (auth == null) {
auth = Auth.create(accessKey, secretKey); auth = Auth.create(accessKey, secretKey);
} }
bucketManager = new BucketManager(auth, new Configuration() ); bucketManager = new BucketManager(auth, new Configuration());
} }
try { try {
bucketManager.delete(bucketName, keyName); bucketManager.delete(bucketName, keyName);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
......
...@@ -13,10 +13,11 @@ public interface Storage { ...@@ -13,10 +13,11 @@ public interface Storage {
/** /**
* 存储一个文件对象 * 存储一个文件对象
* @param inputStream 文件输入流 *
* @param inputStream 文件输入流
* @param contentLength 文件长度 * @param contentLength 文件长度
* @param contentType 文件类型 * @param contentType 文件类型
* @param keyName 文件名 * @param keyName 文件名
*/ */
void store(InputStream inputStream, long contentLength, String contentType, String keyName); void store(InputStream inputStream, long contentLength, String contentType, String keyName);
......
...@@ -5,11 +5,9 @@ import org.linlinjava.litemall.db.domain.LitemallStorage; ...@@ -5,11 +5,9 @@ import org.linlinjava.litemall.db.domain.LitemallStorage;
import org.linlinjava.litemall.db.service.LitemallStorageService; import org.linlinjava.litemall.db.service.LitemallStorageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Path; import java.nio.file.Path;
import java.time.LocalDateTime;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
......
...@@ -122,7 +122,7 @@ public class TencentStorage implements Storage { ...@@ -122,7 +122,7 @@ public class TencentStorage implements Storage {
public void delete(String keyName) { public void delete(String keyName) {
try { try {
getCOSClient().deleteObject(bucketName, keyName); getCOSClient().deleteObject(bucketName, keyName);
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -5,9 +5,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties ...@@ -5,9 +5,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.HashMap;
import java.util.Map;
@Configuration @Configuration
@EnableConfigurationProperties(StorageProperties.class) @EnableConfigurationProperties(StorageProperties.class)
public class StorageAutoConfiguration { public class StorageAutoConfiguration {
...@@ -23,20 +20,16 @@ public class StorageAutoConfiguration { ...@@ -23,20 +20,16 @@ public class StorageAutoConfiguration {
StorageService storageService = new StorageService(); StorageService storageService = new StorageService();
String active = this.properties.getActive(); String active = this.properties.getActive();
storageService.setActive(active); storageService.setActive(active);
if(active.equals("local")){ if (active.equals("local")) {
storageService.setStorage(localStorage()); storageService.setStorage(localStorage());
} } else if (active.equals("aliyun")) {
else if(active.equals("aliyun")){
storageService.setStorage(aliyunStorage()); storageService.setStorage(aliyunStorage());
} } else if (active.equals("tencent")) {
else if(active.equals("tencent")){
storageService.setStorage(tencentStorage()); storageService.setStorage(tencentStorage());
} } else if (active.equals("qiniu")) {
else if(active.equals("qiniu")){
storageService.setStorage(qiniuStorage()); storageService.setStorage(qiniuStorage());
} } else {
else{ throw new RuntimeException("当前存储模式 " + active + " 不支持");
throw new RuntimeException("当前存储模式 " + active + " 不支持");
} }
return storageService; return storageService;
...@@ -53,7 +46,7 @@ public class StorageAutoConfiguration { ...@@ -53,7 +46,7 @@ public class StorageAutoConfiguration {
@Bean @Bean
public AliyunStorage aliyunStorage() { public AliyunStorage aliyunStorage() {
AliyunStorage aliyunStorage = new AliyunStorage(); AliyunStorage aliyunStorage = new AliyunStorage();
StorageProperties.Aliyun aliyun = this.properties.getAliyun(); StorageProperties.Aliyun aliyun = this.properties.getAliyun();
aliyunStorage.setAccessKeyId(aliyun.getAccessKeyId()); aliyunStorage.setAccessKeyId(aliyun.getAccessKeyId());
aliyunStorage.setAccessKeySecret(aliyun.getAccessKeySecret()); aliyunStorage.setAccessKeySecret(aliyun.getAccessKeySecret());
...@@ -75,7 +68,7 @@ public class StorageAutoConfiguration { ...@@ -75,7 +68,7 @@ public class StorageAutoConfiguration {
@Bean @Bean
public QiniuStorage qiniuStorage() { public QiniuStorage qiniuStorage() {
QiniuStorage qiniuStorage = new QiniuStorage(); QiniuStorage qiniuStorage = new QiniuStorage();
StorageProperties.Qiniu qiniu = this.properties.getQiniu(); StorageProperties.Qiniu qiniu = this.properties.getQiniu();
qiniuStorage.setAccessKey(qiniu.getAccessKey()); qiniuStorage.setAccessKey(qiniu.getAccessKey());
qiniuStorage.setSecretKey(qiniu.getSecretKey()); qiniuStorage.setSecretKey(qiniu.getSecretKey());
......
...@@ -111,10 +111,10 @@ public class StorageProperties { ...@@ -111,10 +111,10 @@ public class StorageProperties {
} }
public static class Aliyun { public static class Aliyun {
private String endpoint; private String endpoint;
private String accessKeyId; private String accessKeyId;
private String accessKeySecret; private String accessKeySecret;
private String bucketName; private String bucketName;
public String getEndpoint() { public String getEndpoint() {
return endpoint; return endpoint;
......
...@@ -13,13 +13,6 @@ abstract class BaseConfig { ...@@ -13,13 +13,6 @@ abstract class BaseConfig {
//所有的配置均保存在该 HashMap 中 //所有的配置均保存在该 HashMap 中
protected static Map<String, String> configs = new HashMap<>(); protected static Map<String, String> configs = new HashMap<>();
/**
* 子类实现该方法,并告知父类配置前缀,该前缀用来索引配置组用于简化访问和按组重读配置
*
* @return
*/
abstract String getPrefix();
/** /**
* 添加配置到公共Map中 * 添加配置到公共Map中
* *
...@@ -73,4 +66,11 @@ abstract class BaseConfig { ...@@ -73,4 +66,11 @@ abstract class BaseConfig {
protected static BigDecimal getConfigBigDec(String keyName) { protected static BigDecimal getConfigBigDec(String keyName) {
return new BigDecimal(configs.get(keyName)); return new BigDecimal(configs.get(keyName));
} }
/**
* 子类实现该方法,并告知父类配置前缀,该前缀用来索引配置组用于简化访问和按组重读配置
*
* @return
*/
abstract String getPrefix();
} }
...@@ -14,11 +14,6 @@ import java.util.List; ...@@ -14,11 +14,6 @@ import java.util.List;
@Component @Component
class ConfigService { class ConfigService {
private static ConfigService systemConfigService; private static ConfigService systemConfigService;
static ConfigService getSystemConfigService() {
return systemConfigService;
}
@Autowired @Autowired
private LitemallSystemConfigService litemallSystemConfigService; private LitemallSystemConfigService litemallSystemConfigService;
...@@ -27,6 +22,10 @@ class ConfigService { ...@@ -27,6 +22,10 @@ class ConfigService {
} }
static ConfigService getSystemConfigService() {
return systemConfigService;
}
@PostConstruct @PostConstruct
public void inist() { public void inist() {
systemConfigService = this; systemConfigService = this;
......
...@@ -3,8 +3,6 @@ package org.linlinjava.litemall.core.util; ...@@ -3,8 +3,6 @@ package org.linlinjava.litemall.core.util;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import org.springframework.util.StringUtils;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
...@@ -16,7 +14,7 @@ public class JacksonUtil { ...@@ -16,7 +14,7 @@ public class JacksonUtil {
try { try {
node = mapper.readTree(body); node = mapper.readTree(body);
JsonNode leaf = node.get(field); JsonNode leaf = node.get(field);
if(leaf != null) if (leaf != null)
return leaf.asText(); return leaf.asText();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -32,8 +30,9 @@ public class JacksonUtil { ...@@ -32,8 +30,9 @@ public class JacksonUtil {
node = mapper.readTree(body); node = mapper.readTree(body);
JsonNode leaf = node.get(field); JsonNode leaf = node.get(field);
if(leaf != null) if (leaf != null)
return mapper.convertValue(leaf, new TypeReference<List<String>>(){}); return mapper.convertValue(leaf, new TypeReference<List<String>>() {
});
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -46,7 +45,7 @@ public class JacksonUtil { ...@@ -46,7 +45,7 @@ public class JacksonUtil {
try { try {
node = mapper.readTree(body); node = mapper.readTree(body);
JsonNode leaf = node.get(field); JsonNode leaf = node.get(field);
if(leaf != null) if (leaf != null)
return leaf.asInt(); return leaf.asInt();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -61,8 +60,9 @@ public class JacksonUtil { ...@@ -61,8 +60,9 @@ public class JacksonUtil {
node = mapper.readTree(body); node = mapper.readTree(body);
JsonNode leaf = node.get(field); JsonNode leaf = node.get(field);
if(leaf != null) if (leaf != null)
return mapper.convertValue(leaf, new TypeReference<List<Integer>>(){}); return mapper.convertValue(leaf, new TypeReference<List<Integer>>() {
});
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -70,14 +70,13 @@ public class JacksonUtil { ...@@ -70,14 +70,13 @@ public class JacksonUtil {
} }
public static Boolean parseBoolean(String body, String field) { public static Boolean parseBoolean(String body, String field) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
JsonNode node = null; JsonNode node = null;
try { try {
node = mapper.readTree(body); node = mapper.readTree(body);
JsonNode leaf = node.get(field); JsonNode leaf = node.get(field);
if(leaf != null) if (leaf != null)
return leaf.asBoolean(); return leaf.asBoolean();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -91,7 +90,7 @@ public class JacksonUtil { ...@@ -91,7 +90,7 @@ public class JacksonUtil {
try { try {
node = mapper.readTree(body); node = mapper.readTree(body);
JsonNode leaf = node.get(field); JsonNode leaf = node.get(field);
if(leaf != null) { if (leaf != null) {
Integer value = leaf.asInt(); Integer value = leaf.asInt();
return value.shortValue(); return value.shortValue();
} }
...@@ -107,7 +106,7 @@ public class JacksonUtil { ...@@ -107,7 +106,7 @@ public class JacksonUtil {
try { try {
node = mapper.readTree(body); node = mapper.readTree(body);
JsonNode leaf = node.get(field); JsonNode leaf = node.get(field);
if(leaf != null) { if (leaf != null) {
Integer value = leaf.asInt(); Integer value = leaf.asInt();
return value.byteValue(); return value.byteValue();
} }
...@@ -131,7 +130,7 @@ public class JacksonUtil { ...@@ -131,7 +130,7 @@ public class JacksonUtil {
} }
public static Object toNode(String json) { public static Object toNode(String json) {
if(json == null){ if (json == null) {
return null; return null;
} }
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
......
...@@ -25,46 +25,46 @@ public class RegexUtil { ...@@ -25,46 +25,46 @@ public class RegexUtil {
* <p>global star: 1349</p> * <p>global star: 1349</p>
* <p>virtual operator: 170</p> * <p>virtual operator: 170</p>
*/ */
public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(16[6])|(17[0,1,3,5-8])|(18[0-9])|(19[8,9]))\\d{8}$"; public static final String REGEX_MOBILE_EXACT = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(16[6])|(17[0,1,3,5-8])|(18[0-9])|(19[8,9]))\\d{8}$";
/** /**
* Regex of telephone number. * Regex of telephone number.
*/ */
public static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}"; public static final String REGEX_TEL = "^0\\d{2,3}[- ]?\\d{7,8}";
/** /**
* Regex of id card number which length is 15. * Regex of id card number which length is 15.
*/ */
public static final String REGEX_ID_CARD15 = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$"; public static final String REGEX_ID_CARD15 = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$";
/** /**
* Regex of id card number which length is 18. * Regex of id card number which length is 18.
*/ */
public static final String REGEX_ID_CARD18 = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$"; public static final String REGEX_ID_CARD18 = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9Xx])$";
/** /**
* Regex of email. * Regex of email.
*/ */
public static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"; public static final String REGEX_EMAIL = "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$";
/** /**
* Regex of url. * Regex of url.
*/ */
public static final String REGEX_URL = "[a-zA-z]+://[^\\s]*"; public static final String REGEX_URL = "[a-zA-z]+://[^\\s]*";
/** /**
* Regex of Chinese character. * Regex of Chinese character.
*/ */
public static final String REGEX_ZH = "^[\\u4e00-\\u9fa5]+$"; public static final String REGEX_ZH = "^[\\u4e00-\\u9fa5]+$";
/** /**
* Regex of username. * Regex of username.
* <p>scope for "a-z", "A-Z", "0-9", "_", "Chinese character"</p> * <p>scope for "a-z", "A-Z", "0-9", "_", "Chinese character"</p>
* <p>can't end with "_"</p> * <p>can't end with "_"</p>
* <p>length is between 6 to 20</p> * <p>length is between 6 to 20</p>
*/ */
public static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(?<!_)$"; public static final String REGEX_USERNAME = "^[\\w\\u4e00-\\u9fa5]{6,20}(?<!_)$";
/** /**
* Regex of date which pattern is "yyyy-MM-dd". * Regex of date which pattern is "yyyy-MM-dd".
*/ */
public static final String REGEX_DATE = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$"; public static final String REGEX_DATE = "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$";
/** /**
* Regex of ip address. * Regex of ip address.
*/ */
public static final String REGEX_IP = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"; public static final String REGEX_IP = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)";
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// The following come from http://tool.oschina.net/regex // The following come from http://tool.oschina.net/regex
...@@ -73,31 +73,31 @@ public class RegexUtil { ...@@ -73,31 +73,31 @@ public class RegexUtil {
/** /**
* Regex of double-byte characters. * Regex of double-byte characters.
*/ */
public static final String REGEX_DOUBLE_BYTE_CHAR = "[^\\x00-\\xff]"; public static final String REGEX_DOUBLE_BYTE_CHAR = "[^\\x00-\\xff]";
/** /**
* Regex of blank line. * Regex of blank line.
*/ */
public static final String REGEX_BLANK_LINE = "\\n\\s*\\r"; public static final String REGEX_BLANK_LINE = "\\n\\s*\\r";
/** /**
* Regex of QQ number. * Regex of QQ number.
*/ */
public static final String REGEX_QQ_NUM = "[1-9][0-9]{4,}"; public static final String REGEX_QQ_NUM = "[1-9][0-9]{4,}";
/** /**
* Regex of postal code in China. * Regex of postal code in China.
*/ */
public static final String REGEX_CHINA_POSTAL_CODE = "[1-9]\\d{5}(?!\\d)"; public static final String REGEX_CHINA_POSTAL_CODE = "[1-9]\\d{5}(?!\\d)";
/** /**
* Regex of positive integer. * Regex of positive integer.
*/ */
public static final String REGEX_POSITIVE_INTEGER = "^[1-9]\\d*$"; public static final String REGEX_POSITIVE_INTEGER = "^[1-9]\\d*$";
/** /**
* Regex of negative integer. * Regex of negative integer.
*/ */
public static final String REGEX_NEGATIVE_INTEGER = "^-[1-9]\\d*$"; public static final String REGEX_NEGATIVE_INTEGER = "^-[1-9]\\d*$";
/** /**
* Regex of integer. * Regex of integer.
*/ */
public static final String REGEX_INTEGER = "^-?[1-9]\\d*$"; public static final String REGEX_INTEGER = "^-?[1-9]\\d*$";
/** /**
* Regex of non-negative integer. * Regex of non-negative integer.
*/ */
...@@ -109,12 +109,12 @@ public class RegexUtil { ...@@ -109,12 +109,12 @@ public class RegexUtil {
/** /**
* Regex of positive float. * Regex of positive float.
*/ */
public static final String REGEX_POSITIVE_FLOAT = "^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*$"; public static final String REGEX_POSITIVE_FLOAT = "^[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*$";
/** /**
* Regex of negative float. * Regex of negative float.
*/ */
public static final String REGEX_NEGATIVE_FLOAT = "^-[1-9]\\d*\\.\\d*|-0\\.\\d*[1-9]\\d*$"; public static final String REGEX_NEGATIVE_FLOAT = "^-[1-9]\\d*\\.\\d*|-0\\.\\d*[1-9]\\d*$";
private RegexUtil() { private RegexUtil() {
throw new UnsupportedOperationException("u can't instantiate me..."); throw new UnsupportedOperationException("u can't instantiate me...");
} }
......
...@@ -41,31 +41,31 @@ public class ResponseUtil { ...@@ -41,31 +41,31 @@ public class ResponseUtil {
return obj; return obj;
} }
public static Object badArgument(){ public static Object badArgument() {
return fail(401, "参数不对"); return fail(401, "参数不对");
} }
public static Object badArgumentValue(){ public static Object badArgumentValue() {
return fail(402, "参数值不对"); return fail(402, "参数值不对");
} }
public static Object updatedDateExpired(){ public static Object updatedDateExpired() {
return fail(403, "更新数据已经失效"); return fail(403, "更新数据已经失效");
} }
public static Object updatedDataFailed(){ public static Object updatedDataFailed() {
return fail(404, "更新数据失败"); return fail(404, "更新数据失败");
} }
public static Object unlogin(){ public static Object unlogin() {
return fail(501, "请登录"); return fail(501, "请登录");
} }
public static Object serious(){ public static Object serious() {
return fail(502, "系统内部错误"); return fail(502, "系统内部错误");
} }
public static Object unsupport(){ public static Object unsupport() {
return fail(503, "业务不支持"); return fail(503, "业务不支持");
} }
} }
......
Supports Markdown
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