log日志记录
This commit is contained in:
@ -16,6 +16,7 @@ import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
@ -248,32 +249,32 @@ public class OperateLogAspect {
|
||||
|
||||
|
||||
public String getIpLocation(String ip) {
|
||||
try {
|
||||
// 发送请求到ip-api服务
|
||||
String url = "http://ip-api.com/json/" + ip + "?lang=zh-CN"; // 获取中文结果
|
||||
URL obj = new URL(url);
|
||||
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer response = new StringBuffer();
|
||||
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
|
||||
// 解析JSON返回结果
|
||||
JSONObject jsonResponse = JSONObject.parseObject(response.toString());
|
||||
String region = jsonResponse.getString("regionName"); // 省
|
||||
String city = jsonResponse.getString("city"); // 城市
|
||||
String country = jsonResponse.getString("country"); // 国家
|
||||
|
||||
return city + ", " + region + ", " + country; // 返回位置
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// try {
|
||||
// // 发送请求到ip-api服务
|
||||
// String url = "http://ip-api.com/json/" + ip + "?lang=zh-CN"; // 获取中文结果
|
||||
// URL obj = new URL(url);
|
||||
// HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||
// con.setRequestMethod("GET");
|
||||
//
|
||||
// BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
// String inputLine;
|
||||
// StringBuffer response = new StringBuffer();
|
||||
//
|
||||
// while ((inputLine = in.readLine()) != null) {
|
||||
// response.append(inputLine);
|
||||
// }
|
||||
// in.close();
|
||||
//
|
||||
// // 解析JSON返回结果
|
||||
// JSONObject jsonResponse = JSONObject.parseObject(response.toString());
|
||||
// String country = jsonResponse.getString("country"); // 国家
|
||||
// String region = jsonResponse.getString("regionName"); // 省
|
||||
// String city = jsonResponse.getString("city"); // 城市
|
||||
//
|
||||
// return country + "-" + region + "-" + city; // 返回位置
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
return "未知";
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.greenorange.promotion.annotation.RequiresPermission;
|
||||
import com.greenorange.promotion.annotation.SysLog;
|
||||
import com.greenorange.promotion.common.BaseResponse;
|
||||
import com.greenorange.promotion.common.ErrorCode;
|
||||
import com.greenorange.promotion.common.ResultUtils;
|
||||
@ -123,6 +124,7 @@ public class UserInfoController {
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* web端管理员删除用户表
|
||||
* @param commonRequest 用户表删除请求体
|
||||
@ -136,6 +138,7 @@ public class UserInfoController {
|
||||
return ResultUtils.success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Web端管理员分页查看用户表
|
||||
* @param userInfoQueryRequest 用户表查询请求体
|
||||
@ -157,6 +160,7 @@ public class UserInfoController {
|
||||
return ResultUtils.success(voPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* web端管理员根据id查询用户表
|
||||
* @param commonRequest 用户表查询请求体
|
||||
@ -164,7 +168,8 @@ public class UserInfoController {
|
||||
*/
|
||||
@PostMapping("queryById")
|
||||
@Operation(summary = "web端管理员根据id查询用户", description = "参数:用户表查询请求体,权限:管理员(boss, admin),方法名:queryUserInfoById")
|
||||
// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
@SysLog(title = "用户管理", content = "web端管理员根据id查询用户")
|
||||
public BaseResponse<UserInfoVO> queryUserInfoById(@Valid @RequestBody CommonRequest commonRequest) {
|
||||
Long id = commonRequest.getId();
|
||||
UserInfo userInfo = userInfoService.getById(id);
|
||||
@ -174,38 +179,6 @@ public class UserInfoController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* web端管理员根据id查询用户表
|
||||
* @param id 用户表查询请求体
|
||||
* @return 用户表信息
|
||||
*/
|
||||
@GetMapping("queryById")
|
||||
@Operation(summary = "web端管理员根据id查询用户", description = "参数:用户表查询请求体,权限:管理员(boss, admin),方法名:queryUserInfoById")
|
||||
// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<UserInfoVO> queryUserInfoByGetId(@RequestParam Long id) {
|
||||
UserInfo userInfo = userInfoService.getById(id);
|
||||
ThrowUtils.throwIf(userInfo == null, ErrorCode.OPERATION_ERROR, "当前用户不存在");
|
||||
UserInfoVO userInfoVO = commonService.copyProperties(userInfo, UserInfoVO.class);
|
||||
return ResultUtils.success(userInfoVO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* web端管理员根据id查询用户表
|
||||
* @param id 用户表查询请求体
|
||||
* @return 用户表信息
|
||||
*/
|
||||
@GetMapping("queryById/{id}")
|
||||
@Operation(summary = "web端管理员根据id查询用户", description = "参数:用户表查询请求体,权限:管理员(boss, admin),方法名:queryUserInfoById")
|
||||
// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
|
||||
public BaseResponse<UserInfoVO> queryUserInfoByPathId(@PathVariable Long id) {
|
||||
UserInfo userInfo = userInfoService.getById(id);
|
||||
ThrowUtils.throwIf(userInfo == null, ErrorCode.OPERATION_ERROR, "当前用户不存在");
|
||||
UserInfoVO userInfoVO = commonService.copyProperties(userInfo, UserInfoVO.class);
|
||||
return ResultUtils.success(userInfoVO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.greenorange.promotion.utils.paybank;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
|
||||
/**
|
||||
* v1.0.2
|
||||
|
Reference in New Issue
Block a user