perf:优化部分代码
This commit is contained in:
@@ -1,6 +1,17 @@
|
|||||||
stages:
|
stages:
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
|
qodana:
|
||||||
|
stage: deploy
|
||||||
|
tags:
|
||||||
|
- zengos
|
||||||
|
image:
|
||||||
|
name: jetbrains/qodana-jvm
|
||||||
|
entrypoint: [ "" ]
|
||||||
|
script:
|
||||||
|
- qodana --save-report --baseline=qodana.sarif.json --results-dir=$CI_PROJECT_DIR/.qodana
|
||||||
|
|
||||||
|
|
||||||
deploy-jar:
|
deploy-jar:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
79447
qodana.sarif.json
Normal file
79447
qodana.sarif.json
Normal file
File diff suppressed because it is too large
Load Diff
24
qodana.yaml
Normal file
24
qodana.yaml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#-------------------------------------------------------------------------------#
|
||||||
|
# Qodana analysis is configured by qodana.yaml file #
|
||||||
|
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
|
||||||
|
#-------------------------------------------------------------------------------#
|
||||||
|
version: "1.0"
|
||||||
|
#Specify inspection profile for code analysis
|
||||||
|
profile:
|
||||||
|
name: qodana.starter
|
||||||
|
#Enable inspections
|
||||||
|
#include:
|
||||||
|
# - name: <SomeEnabledInspectionId>
|
||||||
|
#Disable inspections
|
||||||
|
#exclude:
|
||||||
|
# - name: <SomeDisabledInspectionId>
|
||||||
|
# paths:
|
||||||
|
# - <path/where/not/run/inspection>
|
||||||
|
projectJDK: 1.8 #(Applied in CI/CD pipeline)
|
||||||
|
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
|
||||||
|
#bootstrap: sh ./prepare-qodana.sh
|
||||||
|
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
|
||||||
|
#plugins:
|
||||||
|
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
|
||||||
|
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
|
||||||
|
linter: jetbrains/qodana-jvm:latest
|
||||||
@@ -31,9 +31,6 @@ public class DemoWebConfigurer implements TieshengWebConfigurer {
|
|||||||
TokenBean tokenBean = null;
|
TokenBean tokenBean = null;
|
||||||
if (!StrUtil.isEmpty(platformUnique.getUserId())) {
|
if (!StrUtil.isEmpty(platformUnique.getUserId())) {
|
||||||
tokenBean = new TokenBean(platformUnique.getUserId(), "", globalConfig.getService());
|
tokenBean = new TokenBean(platformUnique.getUserId(), "", globalConfig.getService());
|
||||||
} else {
|
|
||||||
// 获取用户信息判断是否可登录
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokenBean;
|
return tokenBean;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import cn.hutool.core.lang.TypeReference;
|
|||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@@ -125,9 +126,11 @@ public class PlatformDingConfig {
|
|||||||
* @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a>
|
* @see <a href="https://open.dingtalk.com/document/isvapp-server/obtain-the-userid-of-a-user-by-using-the-log-free"></a>
|
||||||
*/
|
*/
|
||||||
public String getUserIdByCode(String service, String code) {
|
public String getUserIdByCode(String service, String code) {
|
||||||
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + getAccessToken(service))
|
HttpRequest request = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/getuserinfo?access_token=" + getAccessToken(service))
|
||||||
.body(JSONUtil.createObj().putOpt("code", code).toString()).execute().body();
|
.body(JSONUtil.createObj().putOpt("code", code).toString());
|
||||||
return JSONUtil.parseObj(response).getJSONObject("result").getStr("userid");
|
try (HttpResponse response = request.execute()) {
|
||||||
|
return JSONUtil.parseObj(response.body()).getJSONObject("result").getStr("userid");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -141,15 +144,16 @@ public class PlatformDingConfig {
|
|||||||
*/
|
*/
|
||||||
public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
|
public DingUserInfo topapiV2UserGet(String service, String ddUserId) {
|
||||||
DingConfigBean dingConfigBean = getConfigBean(service);
|
DingConfigBean dingConfigBean = getConfigBean(service);
|
||||||
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/get?access_token=" + getAccessToken(service))
|
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/get?access_token="
|
||||||
.body(JSONUtil.createObj().putOpt("userid", ddUserId).toString()).execute().body();
|
+ getAccessToken(service))
|
||||||
JSONObject resultJson = JSONUtil.parseObj(response).getJSONObject("result");
|
.body(JSONUtil.createObj().putOpt("userid", ddUserId).toString()).execute()) {
|
||||||
DingUserInfo userInfo = JSONUtil.toBean(resultJson, DingUserInfo.class);
|
JSONObject resultJson = JSONUtil.parseObj(response.body()).getJSONObject("result");
|
||||||
|
DingUserInfo userInfo = JSONUtil.toBean(resultJson, DingUserInfo.class);
|
||||||
// 设置一下job_number
|
// 设置一下job_number
|
||||||
userInfo.setJobNumber(resultJson.getStr("job_number"));
|
userInfo.setJobNumber(resultJson.getStr("job_number"));
|
||||||
userInfo.setAppId(dingConfigBean.getAppKey());
|
userInfo.setAppId(dingConfigBean.getAppKey());
|
||||||
return userInfo;
|
return userInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,15 +168,16 @@ public class PlatformDingConfig {
|
|||||||
if (StrUtil.isEmpty(token)) {
|
if (StrUtil.isEmpty(token)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + token)
|
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token=" + token)
|
||||||
.body(JSONUtil.createObj().putOpt("dept_id", deptId).toString()).execute().body();
|
.body(JSONUtil.createObj().putOpt("dept_id", deptId).toString()).execute()) {
|
||||||
DingResponse<List<DingDeptVo>> result = JSONUtil.toBean(response, new TypeReference<DingResponse<List<DingDeptVo>>>() {
|
DingResponse<List<DingDeptVo>> result = JSONUtil.toBean(response.body(), new TypeReference<DingResponse<List<DingDeptVo>>>() {
|
||||||
}.getType(), true);
|
}.getType(), true);
|
||||||
|
|
||||||
if (!result.isOk()) {
|
if (!result.isOk()) {
|
||||||
result.setResult(new ArrayList<>());
|
result.setResult(new ArrayList<>());
|
||||||
|
}
|
||||||
|
return result.getResult();
|
||||||
}
|
}
|
||||||
return result.getResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,16 +192,16 @@ public class PlatformDingConfig {
|
|||||||
if (StrUtil.isEmpty(token)) {
|
if (StrUtil.isEmpty(token)) {
|
||||||
return DingUserListVo.fail();
|
return DingUserListVo.fail();
|
||||||
}
|
}
|
||||||
|
try (HttpResponse response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/list?access_token=" + token)
|
||||||
String response = HttpRequest.post("https://oapi.dingtalk.com/topapi/v2/user/list?access_token=" + token)
|
|
||||||
.body(JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100).toString())
|
.body(JSONUtil.createObj().putOpt("dept_id", deptId).putOpt("cursor", cursor).putOpt("size", 100).toString())
|
||||||
.execute().body();
|
.execute()) {
|
||||||
DingResponse<DingUserListVo> result = JSONUtil.toBean(response, new TypeReference<DingResponse<DingUserListVo>>() {
|
DingResponse<DingUserListVo> result = JSONUtil.toBean(response.body(), new TypeReference<DingResponse<DingUserListVo>>() {
|
||||||
}.getType(), true);
|
}.getType(), true);
|
||||||
if (!result.isOk()) {
|
if (!result.isOk()) {
|
||||||
result.setResult(DingUserListVo.fail());
|
result.setResult(DingUserListVo.fail());
|
||||||
|
}
|
||||||
|
return result.getResult();
|
||||||
}
|
}
|
||||||
return result.getResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.tiesheng.platform.config.wxmini;
|
|||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
|
import com.tiesheng.platform.config.wxmp.bean.WxConfigBean;
|
||||||
@@ -50,12 +51,13 @@ public class PlatformWxminiConfig {
|
|||||||
*/
|
*/
|
||||||
public String jscode2session(String service, String code) {
|
public String jscode2session(String service, String code) {
|
||||||
WxConfigBean configBean = getConfigBean(service);
|
WxConfigBean configBean = getConfigBean(service);
|
||||||
String body = HttpRequest.get("https://api.weixin.qq.com/sns/jscode2session"
|
try (HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/sns/jscode2session"
|
||||||
+ "?appid=" + configBean.getAppId()
|
+ "?appid=" + configBean.getAppId()
|
||||||
+ "&secret=" + configBean.getAppSecret()
|
+ "&secret=" + configBean.getAppSecret()
|
||||||
+ "&js_code=" + code + "&grant_type=authorization_code").execute().body();
|
+ "&js_code=" + code + "&grant_type=authorization_code").execute()) {
|
||||||
JSONObject object = JSONUtil.parseObj(body);
|
JSONObject object = JSONUtil.parseObj(response.body());
|
||||||
return object.getStr("openid");
|
return object.getStr("openid");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,11 +67,12 @@ public class PlatformWxminiConfig {
|
|||||||
*/
|
*/
|
||||||
public String getAccessToken(String service) {
|
public String getAccessToken(String service) {
|
||||||
WxConfigBean configBean = getConfigBean(service);
|
WxConfigBean configBean = getConfigBean(service);
|
||||||
String body = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token"
|
try (HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token"
|
||||||
+ "?grant_type=client_credential&appid=" + configBean.getAppId()
|
+ "?grant_type=client_credential&appid=" + configBean.getAppId()
|
||||||
+ "&secret=" + configBean.getAppSecret()).execute().body();
|
+ "&secret=" + configBean.getAppSecret()).execute()) {
|
||||||
JSONObject object = JSONUtil.parseObj(body);
|
JSONObject object = JSONUtil.parseObj(response.body());
|
||||||
return object.getStr("access_token");
|
return object.getStr("access_token");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ public class ServletKit extends ServletUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getClientIP() {
|
public static String getClientIP() {
|
||||||
return getClientIP(getRequest());
|
HttpServletRequest request = getRequest();
|
||||||
|
return getClientIP(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class Searcher {
|
|||||||
this.ioCount = 0;
|
this.ioCount = 0;
|
||||||
|
|
||||||
// locate the segment index block based on the vector index
|
// locate the segment index block based on the vector index
|
||||||
int sPtr = 0, ePtr = 0;
|
int sPtr, ePtr;
|
||||||
int il0 = (int) ((ip >> 24) & 0xFF);
|
int il0 = (int) ((ip >> 24) & 0xFF);
|
||||||
int il1 = (int) ((ip >> 16) & 0xFF);
|
int il1 = (int) ((ip >> 16) & 0xFF);
|
||||||
int idx = il0 * VectorIndexCols * VectorIndexSize + il1 * VectorIndexSize;
|
int idx = il0 * VectorIndexCols * VectorIndexSize + il1 * VectorIndexSize;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.tiesheng.core.pojos.dao.CoreJobUser;
|
|||||||
import com.tiesheng.util.pojos.IdName;
|
import com.tiesheng.util.pojos.IdName;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -35,6 +36,7 @@ public class CoreJobService extends TsServiceBase<CoreJobMapper, CoreJob> {
|
|||||||
* @param remark
|
* @param remark
|
||||||
* @param isSystem
|
* @param isSystem
|
||||||
*/
|
*/
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void refresh(String id, String name, String remark, Integer isSystem) {
|
public void refresh(String id, String name, String remark, Integer isSystem) {
|
||||||
CoreJob coreJob = new CoreJob();
|
CoreJob coreJob = new CoreJob();
|
||||||
coreJob.setId(id);
|
coreJob.setId(id);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.tiesheng.login.pojos.DoLoginInfo;
|
|||||||
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
import com.tiesheng.login.service.TieshengLoginConfigurer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
|||||||
CoreLogService coreLogService;
|
CoreLogService coreLogService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public TokenBean doLogin(DoLoginInfo loginInfo) {
|
public TokenBean doLogin(DoLoginInfo loginInfo) {
|
||||||
|
|
||||||
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.io.File;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,12 +160,7 @@ public class FileUploadService {
|
|||||||
//将文件数组转成list,并排序
|
//将文件数组转成list,并排序
|
||||||
List<File> chunkFileList = new ArrayList<>(Arrays.asList(chunkFiles));
|
List<File> chunkFileList = new ArrayList<>(Arrays.asList(chunkFiles));
|
||||||
//排序
|
//排序
|
||||||
chunkFileList.sort((o1, o2) -> {
|
chunkFileList.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getName())));
|
||||||
if (Integer.parseInt(o1.getName()) > Integer.parseInt(o2.getName())) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
return chunkFileList;
|
return chunkFileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user