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