Unverified Commit 324c8da3 authored by linlinjava's avatar linlinjava Committed by GitHub
Browse files

Merge branch 'master' into dev

parents 693cf5cd 4c46da9b
......@@ -101,7 +101,7 @@ export default {
getList() {
this.listLoading = true
listStorage(this.listQuery).then(response => {
this.list = response.data.data.items
this.list = response.data.data.list
this.total = response.data.data.total
this.listLoading = false
}).catch(() => {
......
......@@ -116,7 +116,7 @@ export default {
this.listLoading = true
listRole(this.listQuery)
.then(response => {
this.list = response.data.data.items
this.list = response.data.data.list
this.total = response.data.data.total
this.listLoading = false
})
......
......@@ -70,7 +70,7 @@ export default {
getList() {
this.listLoading = true
listAddress(this.listQuery).then(response => {
this.list = response.data.data.items
this.list = response.data.data.list
this.total = response.data.data.total
this.listLoading = false
}).catch(() => {
......@@ -86,7 +86,7 @@ export default {
handleDownload() {
this.downloadLoading = true
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['地址ID', '用户ID', '', '手机号', '', '', '', '地址', '是否默认']
const tHeader = ['地址ID', '用户ID', '', '手机号', '', '', '', '地址', '是否默认']
const filterVal = ['id', 'userId', 'name', 'tel', 'province', 'city', 'county', 'addressDetail', 'isDefault']
excel.export_json_to_excel2(tHeader, this.list, filterVal, '用户地址信息')
this.downloadLoading = false
......
......@@ -56,7 +56,7 @@ export default {
getList() {
this.listLoading = true
listCollect(this.listQuery).then(response => {
this.list = response.data.data.items
this.list = response.data.data.list
this.total = response.data.data.total
this.listLoading = false
}).catch(() => {
......
......@@ -24,7 +24,7 @@
<el-table-column align="center" label="反馈图片" prop="picUrls">
<template slot-scope="scope">
<img v-for="item in scope.row.picUrls" :key="item" :src="item" width="40">
<el-image v-for="item in scope.row.picUrls" :key="item" :src="item" :preview-src-list="scope.row.picUrls" :lazy="true" style="width: 40px; height: 40px; margin-right: 5px;"/>
</template>
</el-table-column>
......@@ -46,7 +46,7 @@ export default {
components: { Pagination },
data() {
return {
list: undefined,
list: [],
total: 0,
listLoading: true,
listQuery: {
......@@ -66,7 +66,7 @@ export default {
getList() {
this.listLoading = true
listFeedback(this.listQuery).then(response => {
this.list = response.data.data.items
this.list = response.data.data.list
this.total = response.data.data.total
this.listLoading = false
}).catch(() => {
......
......@@ -57,7 +57,7 @@ export default {
this.listLoading = true
listFootprint(this.listQuery)
.then(response => {
this.list = response.data.data.items
this.list = response.data.data.list
this.total = response.data.data.total
this.listLoading = false
})
......
......@@ -56,7 +56,7 @@ export default {
this.listLoading = true
listHistory(this.listQuery)
.then(response => {
this.list = response.data.data.items
this.list = response.data.data.list
this.total = response.data.data.total
this.listLoading = false
})
......
......@@ -77,7 +77,7 @@ export default {
getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
this.list = response.data.data.items
this.list = response.data.data.list
this.total = response.data.data.total
this.listLoading = false
}).catch(() => {
......
'use strict'
const path = require('path')
function resolve(dir) {
return path.join(__dirname, dir)
}
const name = 'litemall' // page title
// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
// You can change the port by the following method:
// port = 9527 npm run dev OR npm run dev --port = 9527
const port = process.env.port || process.env.npm_config_port || 9527 // dev port
// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
/**
* You will need to set publicPath if you plan to deploy your site under a sub path,
* for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
* then publicPath should be set to "/bar/".
* In most cases please use '/' !!!
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath: './',
outputDir: 'dist',
assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,
devServer: {
port: port
},
configureWebpack: {
// provide the app's title in webpack's name field, so that
// it can be accessed in index.html to inject the correct title.
name: name,
resolve: {
alias: {
'@': resolve('src')
}
}
},
chainWebpack(config) {
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
// set svg-sprite-loader
config.module
.rule('svg')
.exclude.add(resolve('src/icons'))
.end()
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('src/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]'
})
.end()
// set preserveWhitespace
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.preserveWhitespace = true
return options
})
.end()
config
// https://webpack.js.org/configuration/devtool/#development
.when(process.env.NODE_ENV === 'development',
config => config.devtool('cheap-source-map')
)
config
.when(process.env.NODE_ENV !== 'development',
config => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [{
// `runtime` must same as runtimeChunk name. default is `runtime`
inline: /runtime\..*\.js$/
}])
.end()
config
.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'initial' // only package third parties that are initially dependent
},
elementUI: {
name: 'chunk-elementUI', // split elementUI into a single package
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
},
commons: {
name: 'chunk-commons',
test: resolve('src/components'), // can customize your rules
minChunks: 3, // minimum common number
priority: 5,
reuseExistingChunk: true
}
}
})
config.optimization.runtimeChunk('single')
}
)
}
}
......@@ -58,22 +58,27 @@
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources-vue</id>
<phase>validate</phase>
<goals>
<goal>repackage</goal>
<goal>copy-resources</goal>
</goals>
<configuration>
<classifier>exec</classifier>
<outputDirectory>${basedir}/target/classes/static/vue</outputDirectory>
<resources>
<resource>
<directory>../litemall-vue/dist</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
......
......@@ -8,12 +8,4 @@ server:
port: 8080
logging:
level:
root: ERROR
org.springframework: ERROR
org.mybatis: ERROR
org.linlinjava.litemall.core: ERROR
org.linlinjava.litemall.db: ERROR
org.linlinjava.litemall.admin: ERROR
org.linlinjava.litemall.wx: ERROR
org.linlinjava.litemall: ERROR
\ No newline at end of file
config: classpath:logback-spring.xml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<contextName>logback</contextName>
<property name="log.path" value="logs" />
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
<encoder>
<pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/log.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/log-%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{36} [%file : %line] %msg%n
</pattern>
</encoder>
</appender>
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{36} [%file : %line] %msg%n
</pattern>
</encoder>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<root level="ERROR">
<appender-ref ref="console" />
<appender-ref ref="file" />
<appender-ref ref="error" />
</root>
<logger name="org.mybatis" level="ERROR" />
<logger name="org.springframework" level="ERROR" />
<logger name="org.linlinjava.litemall.core" level="DEBUG" />
  <logger name="org.linlinjava.litemall.db" level="DEBUG" />
<logger name="org.linlinjava.litemall.admin" level="DEBUG" />
<logger name="org.linlinjava.litemall.wx" level="DEBUG" />
<logger name="org.linlinjava.litemall" level="DEBUG" />
</configuration>
\ No newline at end of file
......@@ -16,6 +16,12 @@
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......
......@@ -8,11 +8,15 @@ import org.springframework.web.filter.CorsFilter;
@Configuration
public class CorsConfig {
// 当前跨域请求最大有效时长。这里默认30天
private long maxAge = 30 * 24 * 60 * 60;
private CorsConfiguration buildConfig() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址
corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头
corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法
corsConfiguration.setMaxAge(maxAge);
return corsConfiguration;
}
......
package org.linlinjava.litemall.core.config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.validator.internal.engine.path.PathImpl;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MissingServletRequestParameterException;
......@@ -17,41 +18,43 @@ import javax.validation.ValidationException;
import java.util.Set;
@ControllerAdvice
@Order( value = Ordered.LOWEST_PRECEDENCE )
@Order
public class GlobalExceptionHandler {
private Log logger = LogFactory.getLog(GlobalExceptionHandler.class);
@ExceptionHandler(IllegalArgumentException.class)
@ResponseBody
public Object badArgumentHandler(IllegalArgumentException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object badArgumentHandler(MethodArgumentTypeMismatchException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseBody
public Object badArgumentHandler(MissingServletRequestParameterException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseBody
public Object badArgumentHandler(HttpMessageNotReadableException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(ValidationException.class)
@ResponseBody
public Object badArgumentHandler(ValidationException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
if (e instanceof ConstraintViolationException) {
ConstraintViolationException exs = (ConstraintViolationException) e;
Set<ConstraintViolation<?>> violations = exs.getConstraintViolations();
......@@ -66,7 +69,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
@ResponseBody
public Object seriousHandler(Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
return ResponseUtil.serious();
}
}
......@@ -29,13 +29,18 @@ public class JacksonConfig {
return new Jackson2ObjectMapperBuilderCustomizer() {
@Override
public void customize(Jackson2ObjectMapperBuilder builder) {
builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
builder.serializerByType(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
builder.serializerByType(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
builder.deserializerByType(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
builder.deserializerByType(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
builder.serializerByType(LocalDateTime.class,
new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
builder.serializerByType(LocalDate.class,
new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
builder.serializerByType(LocalTime.class,
new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
builder.deserializerByType(LocalDateTime.class,
new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
builder.deserializerByType(LocalDate.class,
new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
builder.deserializerByType(LocalTime.class,
new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
builder.serializationInclusion(JsonInclude.Include.NON_NULL);
builder.failOnUnknownProperties(false);
builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
......
package org.linlinjava.litemall.core.express;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.express.config.ExpressProperties;
import org.linlinjava.litemall.core.express.dao.ExpressInfo;
import org.linlinjava.litemall.core.util.HttpUtil;
......@@ -9,14 +11,17 @@ import org.springframework.util.Base64Utils;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 物流查询服务
*
* <p>
* 快递鸟即时查询API http://www.kdniao.com/api-track
*/
public class ExpressService {
private final Log logger = LogFactory.getLog(ExpressService.class);
//请求url
private String ReqURL = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
......@@ -44,6 +49,10 @@ public class ExpressService {
return null;
}
public List<Map<String, String>> getVendors() {
return properties.getVendors();
}
/**
* 获取物流信息
*
......@@ -52,6 +61,10 @@ public class ExpressService {
* @return
*/
public ExpressInfo getExpressInfo(String expCode, String expNo) {
if (!properties.isEnable()) {
return null;
}
try {
String result = getOrderTracesByJson(expCode, expNo);
ObjectMapper objMap = new ObjectMapper();
......@@ -59,7 +72,7 @@ public class ExpressService {
ei.setShipperName(getVendorName(expCode));
return ei;
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
......@@ -71,10 +84,6 @@ public class ExpressService {
* @throws Exception
*/
private String getOrderTracesByJson(String expCode, String expNo) throws Exception {
if (!properties.isEnable()) {
return null;
}
String requestData = "{'OrderCode':'','ShipperCode':'" + expCode + "','LogisticCode':'" + expNo + "'}";
Map<String, String> params = new HashMap<String, String>();
......@@ -103,7 +112,7 @@ public class ExpressService {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(str.getBytes(charset));
byte[] result = md.digest();
StringBuffer sb = new StringBuffer(32);
StringBuilder sb = new StringBuilder(32);
for (int i = 0; i < result.length; i++) {
int val = result[i] & 0xff;
if (val <= 0xf) {
......@@ -126,12 +135,12 @@ public class ExpressService {
if (keyValue != null) {
content = content + keyValue;
}
byte[] src = new byte[0];
byte[] src;
try {
src = MD5(content, charset).getBytes(charset);
return Base64Utils.encodeToString(src);
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
......
package org.linlinjava.litemall.core.notify;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.util.JacksonUtil;
import java.util.HashMap;
import java.util.Map;
/*
* 阿里云短信服务
*/
public class AliyunSmsSender implements SmsSender {
private final Log logger = LogFactory.getLog(AliyunSmsSender.class);
private String regionId;
private String accessKeyId;
private String accessKeySecret;
private String sign;
public String getRegionId() {
return regionId;
}
public void setRegionId(String regionId) {
this.regionId = regionId;
}
public String getAccessKeyId() {
return accessKeyId;
}
public void setAccessKeyId(String accessKeyId) {
this.accessKeyId = accessKeyId;
}
public String getAccessKeySecret() {
return accessKeySecret;
}
public void setAccessKeySecret(String accessKeySecret) {
this.accessKeySecret = accessKeySecret;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
@Override
public SmsResult send(String phone, String content) {
SmsResult smsResult = new SmsResult();
smsResult.setSuccessful(false);
return smsResult;
}
@Override
public SmsResult sendWithTemplate(String phone, String templateId, String[] params) {
DefaultProfile profile = DefaultProfile.getProfile(this.regionId, this.accessKeyId, this.accessKeySecret);
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain("dysmsapi.aliyuncs.com");
request.setVersion("2017-05-25");
request.setAction("SendSms");
request.putQueryParameter("RegionId", this.regionId);
request.putQueryParameter("PhoneNumbers", phone);
request.putQueryParameter("SignName", this.sign);
request.putQueryParameter("TemplateCode", templateId);
/*
NOTE:阿里云短信和腾讯云短信这里存在不一致
腾讯云短信模板参数是数组,因此短信模板形式如 “短信参数{1}, 短信参数{2}”
阿里云短信模板参数是JSON,因此短信模板形式如“短信参数{param1}, 短信参数{param2}”
为了保持统一,我们假定阿里云短信里面的参数是code,code1,code2...
如果开发者在阿里云短信申请的模板参数是其他命名,请开发者自行调整这里的代码,或者直接写死。
*/
String templateParam = "{}";
if(params.length == 1){
Map<String, String> data = new HashMap<>();
data.put("code", params[0]);
templateParam = JacksonUtil.toJson(data);
}
else if(params.length > 1){
Map<String, String> data = new HashMap<>();
data.put("code", params[0]);
for(int i = 1; i < params.length; i++){
data.put("code" + i, params[i]);
}
templateParam = JacksonUtil.toJson(data);
}
request.putQueryParameter("TemplateParam", templateParam);
try {
CommonResponse response = client.getCommonResponse(request);
SmsResult smsResult = new SmsResult();
smsResult.setSuccessful(true);
smsResult.setResult(response);
return smsResult;
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
SmsResult smsResult = new SmsResult();
smsResult.setSuccessful(false);
return smsResult;
}
}
......@@ -66,8 +66,7 @@ public class NotifyService {
return;
}
int templateId = Integer.parseInt(templateIdStr);
smsSender.sendWithTemplate(phoneNumber, templateId, params);
smsSender.sendWithTemplate(phoneNumber, templateIdStr, params);
}
/**
......@@ -82,9 +81,7 @@ public class NotifyService {
if (smsSender == null)
return null;
int templateId = Integer.parseInt(getTemplateId(notifyType, smsTemplate));
return smsSender.sendWithTemplate(phoneNumber, templateId, params);
return smsSender.sendWithTemplate(phoneNumber, getTemplateId(notifyType, smsTemplate), params);
}
/**
......
......@@ -13,10 +13,9 @@ public interface SmsSender {
/**
* 通过短信模版发送短信息
*
* @param phone 接收通知的电话号码
* @param templateId 通知模板ID
* @param params 通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
*/
SmsResult sendWithTemplate(String phone, int templateId, String[] params);
SmsResult sendWithTemplate(String phone, String templateId, String[] params);
}
\ No newline at end of file
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