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