初始化
This commit is contained in:
@@ -1,149 +0,0 @@
|
||||
package com.gxwebsoft.common.core.utils;
|
||||
|
||||
import com.gxwebsoft.oa.entity.Assets;
|
||||
import com.gxwebsoft.oa.service.AssetsService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 宝塔工具类
|
||||
* @author 科技小王子
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class BtUtil {
|
||||
public static Integer tenantId;
|
||||
public static String server;
|
||||
public static String token;
|
||||
private static String timestamp;
|
||||
@Resource
|
||||
private AssetsService assetsService;
|
||||
|
||||
// 实例化客户端
|
||||
public BtUtil client(Integer id) {
|
||||
Assets assets = assetsService.getByIdRel(id);
|
||||
try {
|
||||
String btSign = assets.getBtSign();
|
||||
server = "http://".concat(assets.getCode()).concat(":9003");
|
||||
String url = "http://".concat(assets.getCode()) + ":9003/system?action=GetSystemTotal";
|
||||
timestamp = (new Date().getTime()+"");
|
||||
String md5Sign = getMd5(btSign);
|
||||
String temp = timestamp+md5Sign;
|
||||
token = getMd5(temp);
|
||||
|
||||
String json = "request_time="+timestamp+"&request_token="+token;
|
||||
String responseText = sendPost(url,json);
|
||||
System.out.println("responseText = " + responseText);
|
||||
System.out.println(responseText);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSystemTotal(){
|
||||
String url = server.concat("/system?action=GetSystemTotal");
|
||||
String json = "request_time="+timestamp+"&request_token="+token;
|
||||
String responseText = sendPost(url,json);
|
||||
System.out.println("responseText = " + responseText);
|
||||
return responseText;
|
||||
}
|
||||
|
||||
public String getDiskInfo(){
|
||||
String url = server.concat("/system?action=GetDiskInfo");
|
||||
String json = "request_time="+timestamp+"&request_token="+token;
|
||||
return sendPost(url,json);
|
||||
}
|
||||
|
||||
// public void config()
|
||||
// {
|
||||
// try {
|
||||
// System.out.println("tenantId = " + tenantId);
|
||||
// String btSign = "XXXXXXXXXXXXXXXXXXXXXXXX";
|
||||
// String url = "http://XXX.XXX.XXX.XXX:8888/system?action=GetSystemTotal";
|
||||
// String timestamp = (new Date().getTime()+"");
|
||||
// String md5Sign = getMd5(btSign);
|
||||
// String temp = timestamp+md5Sign;
|
||||
// String token = getMd5(temp);
|
||||
//
|
||||
// String json = "request_time="+timestamp+"&request_token="+token;
|
||||
// String responseText = sendPost(url,json);
|
||||
// System.out.println(responseText);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
public static String getMd5(String str) throws Exception
|
||||
{
|
||||
try {
|
||||
// 生成一个MD5加密计算摘要
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
// 计算md5函数
|
||||
md.update(str.getBytes());
|
||||
// digest()最后确定返回md5 hash值,返回值为8为字符串。因为md5 hash值是16位的hex值,实际上就是8位的字符
|
||||
// BigInteger函数则将8位的字符串转换成16位hex值,用字符串来表示;得到字符串形式的hash值
|
||||
return new BigInteger(1, md.digest()).toString(16);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("MD5加密出现错误,"+e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static String sendPost(String url, String param) {
|
||||
PrintWriter out = null;
|
||||
BufferedReader in = null;
|
||||
StringBuffer result = new StringBuffer();
|
||||
try {
|
||||
URL realUrl = new URL(url);
|
||||
// 打开和URL之间的连接
|
||||
URLConnection conn = realUrl.openConnection();
|
||||
// 设置通用的请求属性
|
||||
conn.setRequestProperty("accept", "text/xml,text/javascript,text/html,application/json");
|
||||
conn.setRequestProperty("connection", "Keep-Alive");
|
||||
// 发送POST请求必须设置如下两行
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
// 获取URLConnection对象对应的输出流
|
||||
out = new PrintWriter(conn.getOutputStream());
|
||||
// 发送请求参数
|
||||
out.print(param);
|
||||
// flush输出流的缓冲
|
||||
out.flush();
|
||||
// 定义BufferedReader输入流来读取URL的响应
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("发送 POST 请求出现异常!"+e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//使用finally块来关闭输出流、输入流
|
||||
finally{
|
||||
try{
|
||||
if(out!=null){
|
||||
out.close();
|
||||
}
|
||||
if(in!=null){
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch(IOException ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.gxwebsoft.common.core.utils;
|
||||
import java.util.*;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.gxwebsoft.common.system.param.UpdatePasswordParam;
|
||||
import com.gxwebsoft.common.system.result.CaptchaResult;
|
||||
import com.gxwebsoft.common.system.result.LoginResult;
|
||||
import com.gxwebsoft.common.system.service.*;
|
||||
import com.gxwebsoft.oa.service.CustomerService;
|
||||
import com.wf.captcha.SpecCaptcha;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -9,8 +9,6 @@ import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.Setting;
|
||||
import com.gxwebsoft.common.system.param.SettingParam;
|
||||
import com.gxwebsoft.common.system.service.SettingService;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import com.gxwebsoft.oa.service.TenantService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -34,8 +32,6 @@ public class SettingController extends BaseController {
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:setting:save')")
|
||||
@@ -99,11 +95,6 @@ public class SettingController extends BaseController {
|
||||
final String siteName = jsonObject.getString("siteName");
|
||||
final String logo = jsonObject.getString("logo");
|
||||
System.out.println("siteName = " + siteName);
|
||||
final Tenant tenant = new Tenant();
|
||||
tenant.setTenantName(siteName);
|
||||
tenant.setTenantId(getTenantId());
|
||||
tenant.setLogo(logo);
|
||||
tenantService.updateById(tenant);
|
||||
}
|
||||
return success("修改成功");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gxwebsoft.common.system.entity;
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -200,10 +199,6 @@ public class User implements UserDetails {
|
||||
@TableField(exist = false)
|
||||
private String mobile;
|
||||
|
||||
@ApiModelProperty("应用信息")
|
||||
@TableField(exist = false)
|
||||
private App appInfo;
|
||||
|
||||
@ApiModelProperty("企业信息")
|
||||
@TableField(exist = false)
|
||||
private Company companyInfo;
|
||||
|
||||
@@ -18,8 +18,6 @@ import com.gxwebsoft.common.system.service.CompanyService;
|
||||
import com.gxwebsoft.common.system.service.RoleMenuService;
|
||||
import com.gxwebsoft.common.system.service.UserRoleService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.oa.entity.App;
|
||||
import com.gxwebsoft.oa.service.AppService;
|
||||
import com.gxwebsoft.shop.entity.Merchant;
|
||||
import com.gxwebsoft.shop.entity.MerchantClerk;
|
||||
import com.gxwebsoft.shop.service.MerchantClerkService;
|
||||
@@ -62,8 +60,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
@Resource
|
||||
private AppService appService;
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@@ -93,12 +89,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
public void listRanking(UserParam param) {
|
||||
List<User> list = baseMapper.selectListRel(param);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
list.forEach(d -> {
|
||||
int count = appService.count(new LambdaQueryWrapper<App>()
|
||||
.eq(App::getUserId, d.getUserId()));
|
||||
// 更新全部用户的插件数量
|
||||
cacheClient.zAdd(USER_RANKING_BY_APPS,d.getUserId(), (double) count);
|
||||
});
|
||||
// list.forEach(d -> {
|
||||
// int count = appService.count(new LambdaQueryWrapper<App>()
|
||||
// .eq(App::getUserId, d.getUserId()));
|
||||
// // 更新全部用户的插件数量
|
||||
// cacheClient.zAdd(USER_RANKING_BY_APPS,d.getUserId(), (double) count);
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user