Skip to content
Permalink
Browse files

feat: 0526 update notes.

  • Loading branch information...
alterhu2020 committed May 27, 2019
1 parent 036c722 commit 9741ca99ee4081d4d1333f4484c027f79d973a9d
Showing with 58 additions and 1 deletion.
  1. +1 −0 docs/.vuepress/sidebar.js
  2. +57 −1 docs/blog/2019/05-26-what.md
@@ -12,6 +12,7 @@ module.exports ={
title: '2019年',
collapsable: false,
children: [
'2019/05-26-what',
'2019/05-25-what',
'2019/05-24-what',
'2019/05-22-what',
@@ -18,7 +18,7 @@ show variables like "%time_zone%";
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.00 sec)
#time_zone说明mysql使用system的时区,system_time_zone说明system使用CST时区
#time_zone说明mysql使用system的时区,system_time_zone说明system使用CST时区


- 修改mysql的时区:
@@ -32,4 +32,60 @@ show variables like "%time_zone%";
# vim /etc/my.cnf ##在[mysqld]区域中加上
default-time_zone = '+08:00'
# /etc/init.d/mysqld restart ##重启mysql使新时区生效
```

## springboot 如何接受前台axios传过来的array数据

默认情况下,axios传过来的array数据格式是: http://test.com/abc?params[]=test&params[]=testw3w3, 需要特殊转换springboot才能解析成对应的`List<String>` 格式的参数

- axios端传递的方法如下:

```js
// 此处ids是数组类型,主要用到了paramsSerializer,或者设置地址: var queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&');
axios.post(urls.PERMISSION_BATCH_ID_URL, null, { params: { ids: ids },
paramsSerializer: params => {
const keys = Object.keys(params)
let options = ''
keys.forEach((key) => {
const isParamTypeObject = typeof params[key] === 'object'
const isParamTypeArray = isParamTypeObject && (params[key].length >= 0)
if (!isParamTypeObject) {
options += `${key}=${params[key]}&`
}
if (isParamTypeObject && isParamTypeArray) {
params[key].forEach((element) => {
options += `${key}=${element}&`
})
}
})
return options ? options.slice(0, -1) : options
} }).then(res => {
}).catch(error => {
console.error(error)
})
```

- `springboot`接受数组参数的方法如下,需要格式为`ids=123&ids=456&ids=8743434&ids=4546573424`

```java
// 经测试此处的List<String> ids 也可以为 List[] ids
@PostMapping("/batch")
public WebResponse deletePermissionsBatch(@RequestParam("ids") List<String> ids) {
WebResponse response = WebResponse.getResponse();
if (ids.size() > 0) {
ServiceResponse serviceResponse = permissionService.removePermissionBatch(ids);
boolean serviceResponseSuccess = serviceResponse.isSuccess();
if (!serviceResponseSuccess) {
response.fail(serviceResponse.getResponseCode());
}
} else {
log.warn("至少输入一个权限ID: {}", ids.toString());
response.fail(PermissionResponseCode.PERMISSION_BATCH_MISSING);
}
return response;
}
```

0 comments on commit 9741ca9

Please sign in to comment.
You can’t perform that action at this time.