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 {
......
...@@ -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();
} }
......
...@@ -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,6 +13,7 @@ public interface Storage { ...@@ -13,6 +13,7 @@ public interface Storage {
/** /**
* 存储一个文件对象 * 存储一个文件对象
*
* @param inputStream 文件输入流 * @param inputStream 文件输入流
* @param contentLength 文件长度 * @param contentLength 文件长度
* @param contentType 文件类型 * @param contentType 文件类型
......
...@@ -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,19 +20,15 @@ public class StorageAutoConfiguration { ...@@ -23,19 +20,15 @@ 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 + " 不支持");
} }
......
...@@ -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();
......
...@@ -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