parent
a439f5303f
commit
9c51a18310
|
|
@ -24,7 +24,7 @@ public class BaseCustomerInfoController extends BaseController {
|
||||||
private final BaseCustomerInfoService baseCustomerInfoService;
|
private final BaseCustomerInfoService baseCustomerInfoService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查询客户管理表")
|
@ApiOperation("查询客户管理")
|
||||||
public TableDataInfo<BaseCustomerInfo> list(BaseCustomerInfo baseCustomerInfo) {
|
public TableDataInfo<BaseCustomerInfo> list(BaseCustomerInfo baseCustomerInfo) {
|
||||||
startPage();
|
startPage();
|
||||||
QueryWrapper<BaseCustomerInfo> queryWrapper = new QueryWrapper<>(baseCustomerInfo);
|
QueryWrapper<BaseCustomerInfo> queryWrapper = new QueryWrapper<>(baseCustomerInfo);
|
||||||
|
|
@ -34,21 +34,21 @@ public class BaseCustomerInfoController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增客户管理表")
|
@ApiOperation("新增客户管理")
|
||||||
@Log(title = "客户管理表", businessType = BusinessType.INSERT)
|
@Log(title = "客户管理表", businessType = BusinessType.INSERT)
|
||||||
public AjaxResult insert(@RequestBody BaseCustomerInfo baseCustomerInfo) {
|
public AjaxResult insert(@RequestBody BaseCustomerInfo baseCustomerInfo) {
|
||||||
return toAjax(baseCustomerInfoService.save(baseCustomerInfo));
|
return toAjax(baseCustomerInfoService.save(baseCustomerInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ApiOperation("修改客户管理表")
|
@ApiOperation("修改客户管理")
|
||||||
@Log(title = "客户管理表", businessType = BusinessType.UPDATE)
|
@Log(title = "客户管理表", businessType = BusinessType.UPDATE)
|
||||||
public AjaxResult update(@RequestBody BaseCustomerInfo baseCustomerInfo) {
|
public AjaxResult update(@RequestBody BaseCustomerInfo baseCustomerInfo) {
|
||||||
return toAjax(baseCustomerInfoService.updateById(baseCustomerInfo));
|
return toAjax(baseCustomerInfoService.updateById(baseCustomerInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@ApiOperation("删除客户管理表")
|
@ApiOperation("删除客户管理")
|
||||||
@Log(title = "客户管理表", businessType = BusinessType.DELETE)
|
@Log(title = "客户管理表", businessType = BusinessType.DELETE)
|
||||||
public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
|
public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
|
||||||
return toAjax(baseCustomerInfoService.removeByIds(idList));
|
return toAjax(baseCustomerInfoService.removeByIds(idList));
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ public class BaseParkingLotInfoController extends BaseController {
|
||||||
private final BaseParkingLotInfoService baseParkingLotInfoService;
|
private final BaseParkingLotInfoService baseParkingLotInfoService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查询停车场管理表")
|
@ApiOperation("查询停车场管理")
|
||||||
public TableDataInfo<BaseParkingLotInfo> list(BaseParkingLotInfo baseParkingLotInfo) {
|
public TableDataInfo<BaseParkingLotInfo> list(BaseParkingLotInfo baseParkingLotInfo) {
|
||||||
startPage();
|
startPage();
|
||||||
QueryWrapper<BaseParkingLotInfo> queryWrapper = new QueryWrapper<>(baseParkingLotInfo);
|
QueryWrapper<BaseParkingLotInfo> queryWrapper = new QueryWrapper<>(baseParkingLotInfo);
|
||||||
|
|
@ -34,21 +34,21 @@ public class BaseParkingLotInfoController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增停车场管理表")
|
@ApiOperation("新增停车场管理")
|
||||||
@Log(title = "停车场管理表", businessType = BusinessType.INSERT)
|
@Log(title = "停车场管理表", businessType = BusinessType.INSERT)
|
||||||
public AjaxResult insert(@RequestBody BaseParkingLotInfo baseParkingLotInfo) {
|
public AjaxResult insert(@RequestBody BaseParkingLotInfo baseParkingLotInfo) {
|
||||||
return toAjax(baseParkingLotInfoService.save(baseParkingLotInfo));
|
return toAjax(baseParkingLotInfoService.save(baseParkingLotInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ApiOperation("修改停车场管理表")
|
@ApiOperation("修改停车场管理")
|
||||||
@Log(title = "停车场管理表", businessType = BusinessType.UPDATE)
|
@Log(title = "停车场管理表", businessType = BusinessType.UPDATE)
|
||||||
public AjaxResult update(@RequestBody BaseParkingLotInfo baseParkingLotInfo) {
|
public AjaxResult update(@RequestBody BaseParkingLotInfo baseParkingLotInfo) {
|
||||||
return toAjax(baseParkingLotInfoService.updateById(baseParkingLotInfo));
|
return toAjax(baseParkingLotInfoService.updateById(baseParkingLotInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@ApiOperation("删除停车场管理表")
|
@ApiOperation("删除停车场管理")
|
||||||
@Log(title = "停车场管理表", businessType = BusinessType.DELETE)
|
@Log(title = "停车场管理表", businessType = BusinessType.DELETE)
|
||||||
public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
|
public AjaxResult delete(@RequestParam("idList") List<Long> idList) {
|
||||||
return toAjax(baseParkingLotInfoService.removeByIds(idList));
|
return toAjax(baseParkingLotInfoService.removeByIds(idList));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.ruoyi.database.util;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class AmapGeocoding {
|
||||||
|
|
||||||
|
|
||||||
|
public static String apiKey = "4cc27f0dbf3ebb77a3cf219866b405ad";
|
||||||
|
|
||||||
|
|
||||||
|
public static String getLocation(String address){
|
||||||
|
// 对地址进行URL编码,处理特殊字符
|
||||||
|
String encodedAddress = java.net.URLEncoder.encode(address);
|
||||||
|
// 构建请求URL
|
||||||
|
String urlStr = "https://restapi.amap.com/v3/geocode/geo?key=" + apiKey +
|
||||||
|
"&address=" + encodedAddress + "&output=json";
|
||||||
|
try {
|
||||||
|
// 创建URL对象并建立连接
|
||||||
|
URL url = new URL(urlStr);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
|
||||||
|
// 读取API返回的响应
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
String inputLine;
|
||||||
|
StringBuffer response = new StringBuffer();
|
||||||
|
while ((inputLine = in.readLine()) != null) {
|
||||||
|
response.append(inputLine);
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
// 将响应转换为JSON对象便于解析
|
||||||
|
JSONObject jsonResponse = new JSONObject(response.toString());
|
||||||
|
|
||||||
|
// 检查API请求状态
|
||||||
|
if ("1".equals(jsonResponse.getStr("status"))) {
|
||||||
|
// 获取地理编码数组
|
||||||
|
JSONArray geocodes = jsonResponse.getJSONArray("geocodes");
|
||||||
|
if (geocodes.size() > 0) {
|
||||||
|
// 从第一个结果中获取经纬度
|
||||||
|
String location = geocodes.getJSONObject(0).getStr("location");
|
||||||
|
System.out.println("该地址的经纬度为: " + location); // 输出示例: "116.480881,39.989410"
|
||||||
|
// 如果需要单独使用经度和纬度
|
||||||
|
String[] lngLat = location.split(",");
|
||||||
|
String longitude = lngLat[0]; // 经度
|
||||||
|
String latitude = lngLat[1]; // 纬度
|
||||||
|
System.out.println("经度: " + longitude + ", 纬度: " + latitude);
|
||||||
|
|
||||||
|
return location;
|
||||||
|
} else {
|
||||||
|
System.out.println("未找到该地址对应的经纬度。");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 处理请求失败的情况
|
||||||
|
String errorInfo = jsonResponse.getStr("info");
|
||||||
|
System.err.println("地理编码请求失败: " + errorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String location = getLocation("常熟市海虞北路27号");
|
||||||
|
System.out.println(location);
|
||||||
|
//120.754471,31.666573
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||||
import com.ruoyi.common.core.domain.model.LoginBodyByPhone;
|
import com.ruoyi.common.core.domain.model.LoginBodyByPhone;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUserByPhone;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.database.domain.BaseCustomerInfo;
|
import com.ruoyi.database.domain.BaseCustomerInfo;
|
||||||
import com.ruoyi.database.service.BaseCustomerInfoService;
|
import com.ruoyi.database.service.BaseCustomerInfoService;
|
||||||
|
|
@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -100,6 +102,7 @@ public class SysLoginController {
|
||||||
*
|
*
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation("获取管理员信息")
|
||||||
@GetMapping("getInfo")
|
@GetMapping("getInfo")
|
||||||
public AjaxResult getInfo() {
|
public AjaxResult getInfo() {
|
||||||
SysUser user = SecurityUtils.getLoginUser().getUser();
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
||||||
|
|
@ -122,6 +125,23 @@ public class SysLoginController {
|
||||||
return ajax;
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation("获取客户信息")
|
||||||
|
@GetMapping("getCustomerInfo")
|
||||||
|
public AjaxResult getCustomerInfo(HttpServletRequest request) {
|
||||||
|
LoginUserByPhone loginUser = loginService.getLoginUserByPhone(request);
|
||||||
|
if (loginUser != null) {
|
||||||
|
BaseCustomerInfo one = baseCustomerInfoService.lambdaQuery()
|
||||||
|
.eq(BaseCustomerInfo::getPhone, loginUser.getPhone())
|
||||||
|
.last("limit 1")
|
||||||
|
.one();
|
||||||
|
return AjaxResult.success(one);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(loginUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static String truncateAndPad(String str) {
|
public static String truncateAndPad(String str) {
|
||||||
if ("0".equals(StringKit.toString(str))) {
|
if ("0".equals(StringKit.toString(str))) {
|
||||||
return str;
|
return str;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||||
|
import com.ruoyi.common.core.domain.model.LoginUserByPhone;
|
||||||
import com.ruoyi.common.core.redis.RedisCache;
|
import com.ruoyi.common.core.redis.RedisCache;
|
||||||
import com.ruoyi.common.exception.ServiceException;
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.exception.user.*;
|
import com.ruoyi.common.exception.user.*;
|
||||||
|
|
@ -27,6 +28,7 @@ import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
|
|
@ -148,6 +150,10 @@ public class SysLoginService {
|
||||||
return tokenService.createTokenByPhone(phone);
|
return tokenService.createTokenByPhone(phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LoginUserByPhone getLoginUserByPhone(HttpServletRequest request) {
|
||||||
|
return tokenService.getLoginUserByPhone(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验验证码
|
* 校验验证码
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue