@@ -48,7 +48,7 @@ | |||
<dependency> | |||
<groupId>com.alibaba</groupId> | |||
<artifactId>druid-spring-boot-starter</artifactId> | |||
<version>1.1.10</version> | |||
<version>1.1.22</version> | |||
</dependency> | |||
<!-- https://mvnrepository.com/artifact/log4j/log4j --> | |||
<dependency> |
@@ -15,7 +15,7 @@ tuoheng: | |||
# 视频域名 | |||
video-url: https://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 8eb26a06684d34501e5a56dcc2f5af15 | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
spring: | |||
# 配置数据源 |
@@ -15,7 +15,7 @@ tuoheng: | |||
# 视频域名 | |||
video-url: http://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 8eb26a06684d34501e5a56dcc2f5af15 | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 |
@@ -15,7 +15,7 @@ tuoheng: | |||
# 视频域名 | |||
video-url: https://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 8eb26a06684d34501e5a56dcc2f5af15 | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 |
@@ -15,7 +15,7 @@ tuoheng: | |||
# 视频域名 | |||
video-url: https://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 8eb26a06684d34501e5a56dcc2f5af15 | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 |
@@ -74,7 +74,7 @@ | |||
<dependency> | |||
<groupId>com.alibaba</groupId> | |||
<artifactId>druid-spring-boot-starter</artifactId> | |||
<version>1.1.10</version> | |||
<version>1.1.22</version> | |||
</dependency> | |||
<!-- https://mvnrepository.com/artifact/log4j/log4j --> | |||
<dependency> |
@@ -0,0 +1,56 @@ | |||
package com.tuoheng.api.config; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* 阿里云点播服务配置类 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-03-11 | |||
*/ | |||
@Component | |||
public class AliyuncsVodConfig { | |||
/** | |||
* 账号 | |||
*/ | |||
public static String accessKeyId; | |||
/** | |||
* 密码 | |||
*/ | |||
public static String accessKeySecret; | |||
/** | |||
* 角色ARN | |||
*/ | |||
public static String roleArn; | |||
/** | |||
* Bucket名称 | |||
*/ | |||
public static String bucketName; | |||
@Value("${aliyuncsVod.accessKeyId}") | |||
public void setAccessKeyId(String accessKeyId) { | |||
AliyuncsVodConfig.accessKeyId = accessKeyId; | |||
} | |||
@Value("${aliyuncsVod.accessKeySecret}") | |||
public void setAccessKeySecret(String accessKeySecret) { | |||
AliyuncsVodConfig.accessKeySecret = accessKeySecret; | |||
} | |||
@Value("${aliyuncsVod.roleArn}") | |||
public void setRoleArn(String roleArn) { | |||
AliyuncsVodConfig.roleArn = roleArn; | |||
} | |||
@Value("${aliyuncsVod.bucketName}") | |||
public void setBucketName(String bucketName) { | |||
AliyuncsVodConfig.bucketName = bucketName; | |||
} | |||
} |
@@ -0,0 +1,105 @@ | |||
package com.tuoheng.api.controller; | |||
import com.aliyuncs.DefaultAcsClient; | |||
import com.aliyuncs.exceptions.ClientException; | |||
import com.aliyuncs.http.MethodType; | |||
import com.aliyuncs.profile.DefaultProfile; | |||
import com.aliyuncs.profile.IClientProfile; | |||
import com.aliyuncs.sts.model.v20150401.AssumeRoleRequest; | |||
import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse; | |||
import com.tuoheng.api.config.AliyuncsVodConfig; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* 阿里云对象存储OSS 前端控制器 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-03-15 | |||
*/ | |||
@Slf4j | |||
@RestController | |||
@RequestMapping("/aliyunOss") | |||
public class AliyunOssController { | |||
/** | |||
* 获取securityToken | |||
* | |||
* @return | |||
*/ | |||
@GetMapping("/getSecurityToken") | |||
public AssumeRoleResponse.Credentials getSecurityToken() { | |||
AssumeRoleResponse.Credentials credentials = getSecurityToken("SessionTest"); | |||
return credentials; | |||
} | |||
/** | |||
* 获取临时访问凭证 | |||
* | |||
* @param roleSessionName 自定义角色会话名称,用来区分不同的令牌,例如可填写为SessionTest。 | |||
* @return | |||
*/ | |||
public static AssumeRoleResponse.Credentials getSecurityToken(String roleSessionName) { | |||
// STS接入地址,例如sts.cn-shanghai.aliyuncs.com。 | |||
String endpoint = "sts.cn-shanghai.aliyuncs.com"; | |||
// 填写步骤1生成的访问密钥AccessKey ID和AccessKey Secret。 | |||
String AccessKeyId = AliyuncsVodConfig.accessKeyId; | |||
String accessKeySecret = AliyuncsVodConfig.accessKeySecret; | |||
// 填写步骤3获取的角色ARN。 | |||
String roleArn = AliyuncsVodConfig.roleArn; | |||
// 自定义角色会话名称,用来区分不同的令牌,例如可填写为SessionTest。 | |||
// String roleSessionName = "<yourRoleSessionName>"; | |||
// 以下Policy用于限制仅允许使用临时访问凭证向目标存储空间examplebucket上传文件。 | |||
// 临时访问凭证最后获得的权限是步骤4设置的角色权限和该Policy设置权限的交集,即仅允许将文件上传至目标存储空间examplebucket下的exampledir目录。 | |||
String policy = "{\n" + | |||
" \"Version\": \"1\", \n" + | |||
" \"Statement\": [\n" + | |||
" {\n" + | |||
" \"Action\": [\n" + | |||
" \"oss:PutObject\"\n" + | |||
" ], \n" + | |||
" \"Resource\": [\n" + | |||
" \"acs:oss:*:*:ta-tech-image/imagedir/*\" \n" + | |||
" ], \n" + | |||
" \"Effect\": \"Allow\"\n" + | |||
" }\n" + | |||
" ]\n" + | |||
"}"; | |||
try { | |||
// regionId表示RAM的地域ID。以华东1(杭州)地域为例,regionID填写为cn-hangzhou。也可以保留默认值,默认值为空字符串("")。 | |||
String regionId = ""; | |||
// 添加endpoint。适用于Java SDK 3.12.0及以上版本。 | |||
DefaultProfile.addEndpoint(regionId, "Sts", endpoint); | |||
// 添加endpoint。适用于Java SDK 3.12.0以下版本。 | |||
// DefaultProfile.addEndpoint("",regionId, "Sts", endpoint); | |||
// 构造default profile。 | |||
IClientProfile profile = DefaultProfile.getProfile(regionId, AccessKeyId, accessKeySecret); | |||
// 构造client。 | |||
DefaultAcsClient client = new DefaultAcsClient(profile); | |||
final AssumeRoleRequest request = new AssumeRoleRequest(); | |||
// 适用于Java SDK 3.12.0及以上版本。 | |||
request.setSysMethod(MethodType.POST); | |||
// 适用于Java SDK 3.12.0以下版本。 | |||
//request.setMethod(MethodType.POST); | |||
request.setRoleArn(roleArn); | |||
request.setRoleSessionName(roleSessionName); | |||
request.setPolicy(policy); // 如果policy为空,则用户将获得该角色下所有权限。 | |||
request.setDurationSeconds(3600L); // 设置临时访问凭证的有效时间为3600秒。 | |||
final AssumeRoleResponse response = client.getAcsResponse(request); | |||
log.info("Expiration: " + response.getCredentials().getExpiration()); | |||
log.info("Access Key Id: " + response.getCredentials().getAccessKeyId()); | |||
log.info("Access Key Secret: " + response.getCredentials().getAccessKeySecret()); | |||
log.info("Security Token: " + response.getCredentials().getSecurityToken()); | |||
log.info("RequestId: " + response.getRequestId()); | |||
return response.getCredentials(); | |||
} catch (ClientException e) { | |||
log.error("Error code: " + e.getErrCode()); | |||
log.error("Error message: " + e.getErrMsg()); | |||
log.error("RequestId: " + e.getRequestId()); | |||
} | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.domain.City; | |||
import com.tuoheng.api.entity.request.CityQuery; | |||
import com.tuoheng.api.entity.request.CityRequest; | |||
import com.tuoheng.api.entity.vo.CityInfoVo; | |||
import com.tuoheng.api.service.ICityService; | |||
import com.tuoheng.common.common.BaseController; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 高德城市表 前端控制器 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-11-03 | |||
*/ | |||
@RestController | |||
@RequestMapping("/city") | |||
public class CityController extends BaseController { | |||
@Autowired | |||
private ICityService cityService; | |||
/** | |||
* 获取城市列表 | |||
* | |||
* @param cityQuery 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/index") | |||
public JsonResult index(CityQuery cityQuery) { | |||
return cityService.getList(cityQuery); | |||
} | |||
/** | |||
* 查询行政区列表(树结构) | |||
* | |||
* @return 行政区列表(树结构) | |||
*/ | |||
@GetMapping("/queryCityList") | |||
public JsonResult queryCityList() { | |||
return cityService.getCityList(); | |||
} | |||
/** | |||
* 查询省市区名及编码 | |||
* @return | |||
*/ | |||
@GetMapping("/cityNameAndCode") | |||
public JsonResult getCityNameAndCode(CityRequest request){ | |||
CityInfoVo vo = cityService.getCityNameAndCode(request); | |||
return JsonResult.success(vo); | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.domain.Feedback; | |||
import com.tuoheng.api.entity.request.FeedbackQuery; | |||
import com.tuoheng.api.service.IFeedbackService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
/** | |||
* 全名护河反馈表 前端控制器 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-09-06 | |||
*/ | |||
@RestController | |||
@RequestMapping("/feedback") | |||
public class FeedbackController { | |||
@Autowired | |||
private IFeedbackService feedbackService; | |||
/** | |||
* 上报问题-提交 | |||
* @param feedback | |||
* @return | |||
*/ | |||
@PostMapping("/submit") | |||
public JsonResult submit(@RequestBody Feedback feedback){ | |||
return feedbackService.submit(feedback); | |||
} | |||
/** | |||
* 我的反馈 | |||
* | |||
* @param feedbackQuery 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/my") | |||
public JsonResult my(FeedbackQuery feedbackQuery) { | |||
return feedbackService.my(feedbackQuery); | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.entity.request.StreamQuery; | |||
import com.tuoheng.api.service.IStreamService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
/** | |||
* 河流表 前端控制器 | |||
* | |||
* @author WangHaoran | |||
* @since 2021-09-06 | |||
*/ | |||
@RestController | |||
@RequestMapping("/stream") | |||
public class StreamController { | |||
@Autowired | |||
IStreamService streamService; | |||
/** | |||
* 获取河流列表(分页) | |||
* | |||
* @param streamQuery 查询条件 | |||
* @return | |||
*/ | |||
@GetMapping("/index") | |||
public JsonResult index(StreamQuery streamQuery) { | |||
return streamService.queryPage(streamQuery); | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
package com.tuoheng.api.controller; | |||
import com.tuoheng.api.service.IWxService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.PathVariable; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* 后台用户管理表 前端控制器 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-09-06 | |||
*/ | |||
@RestController | |||
@RequestMapping("/wx") | |||
public class WxController { | |||
@Autowired | |||
private IWxService wxService; | |||
/** | |||
* 登录凭证校验 | |||
* | |||
* @return | |||
*/ | |||
@GetMapping("/openid/{code}") | |||
public JsonResult openid(@PathVariable("code") String code) { | |||
return wxService.openid(code); | |||
} | |||
} |
@@ -0,0 +1,86 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 高德城市表 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-11-03 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@Accessors(chain = true) | |||
@TableName("sys_city") | |||
public class City extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 父级编号 | |||
*/ | |||
private Integer pid; | |||
/** | |||
* 城市级别(1省;2市;3区;4街道;5村;) | |||
*/ | |||
private Integer level; | |||
/** | |||
* 城市名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 城市编号(区号) | |||
*/ | |||
private String citycode; | |||
/** | |||
* 父级地理编号 | |||
*/ | |||
private String pAdcode; | |||
/** | |||
* 地理编号 | |||
*/ | |||
private String adcode; | |||
/** | |||
* 城市坐标中心点经度(* 1e6):如果是中国,此值是 1e7 | |||
*/ | |||
private Integer lng; | |||
/** | |||
* 城市坐标中心点纬度(* 1e6) | |||
*/ | |||
private Integer lat; | |||
/** | |||
* 排序号 | |||
*/ | |||
private Integer sort; | |||
/** | |||
* 是否含有子级 | |||
*/ | |||
@TableField(exist = false) | |||
private boolean hasChildren; | |||
/** | |||
* 行政区 子集 | |||
*/ | |||
@TableField(exist = false) | |||
List<City> itemList; | |||
} |
@@ -0,0 +1,137 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* 反馈表 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-09-06 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@Accessors(chain = true) | |||
@TableName("th_feedback") | |||
public class Feedback extends BaseEntity { | |||
/** | |||
* 租户ID | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* 提交人openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 河道ID | |||
*/ | |||
private Integer streamId; | |||
/** | |||
* 河道名称 | |||
*/ | |||
private String streamName; | |||
/** | |||
* 责任河湖长ID | |||
*/ | |||
private Integer streamAdminId; | |||
/** | |||
* 责任河湖长名称 | |||
*/ | |||
private String streamAdminName; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 位置名称 | |||
*/ | |||
private String location; | |||
/** | |||
* 问题描述 | |||
*/ | |||
private String feedbackDesc; | |||
/** | |||
* 反馈人姓名 | |||
*/ | |||
private String feedbackName; | |||
/** | |||
* 反馈人手机号 | |||
*/ | |||
private String feedbackPhone; | |||
/** | |||
* 反馈图片地址 多张用,隔开 | |||
*/ | |||
private String feedbackUrl; | |||
/** | |||
* 处理图片地址 多张用,隔开 | |||
*/ | |||
private String handleUrl; | |||
/** | |||
* 处理意见 | |||
*/ | |||
private String handleRemark; | |||
/** | |||
* 处理时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date handleTime; | |||
/** | |||
* 审核意见 | |||
*/ | |||
private String examineRemark; | |||
/** | |||
* 状态:1待审核 2待处理 3已忽略 4已处理 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 河道图片 | |||
*/ | |||
@TableField(exist = false) | |||
private String streamImage; | |||
/** | |||
* 反馈图片封面地址 | |||
*/ | |||
@TableField(exist = false) | |||
private String feedbackCover; | |||
/** | |||
* 处理人 | |||
*/ | |||
@TableField(exist =false) | |||
private String realname; | |||
} |
@@ -0,0 +1,132 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.FieldStrategy; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* 河流表 | |||
* | |||
* @author WangHaoran | |||
* @since 2021-09-06 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@Accessors(chain = true) | |||
@TableName("th_stream") | |||
public class Stream extends BaseEntity { | |||
/** | |||
* 河流编码 | |||
*/ | |||
@NotBlank(message = "河流编码不能为空!") | |||
private String code; | |||
/** | |||
* 河流名称 | |||
*/ | |||
@NotBlank(message = "河流名称不能为空!") | |||
private String name; | |||
/** | |||
* 省份编码 | |||
*/ | |||
@NotBlank(message = "省份编码不能为空!") | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
@NotBlank(message = "城市编码不能为空!") | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
@NotBlank(message = "区县编码不能为空!") | |||
private String districtCode; | |||
/** | |||
* 街道编码 | |||
*/ | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) | |||
private String streetCode; | |||
/** | |||
* 村编码 | |||
*/ | |||
@TableField(updateStrategy = FieldStrategy.IGNORED) | |||
private String villageCode; | |||
/** | |||
* 责任河湖长ID | |||
*/ | |||
@NotNull(message = "责任河湖长ID不能为空!") | |||
private Integer streamAdminId; | |||
/** | |||
* 责任河湖长名称 | |||
*/ | |||
private String streamAdminName; | |||
/** | |||
* 经度 | |||
*/ | |||
@NotBlank(message = "经度不能为空!") | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
@NotBlank(message = "纬度不能为空!") | |||
private String latitude; | |||
/** | |||
* 起止位置 | |||
*/ | |||
@NotBlank(message = "起止位置不能为空!") | |||
private String location; | |||
/** | |||
* 河流长度 | |||
*/ | |||
@NotBlank(message = "河流长度不能为空!") | |||
private String length; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 状态:1正常 2停用 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 添加人名称 | |||
*/ | |||
private String createUserName; | |||
/** | |||
* 更新人名称 | |||
*/ | |||
private String updateUserName; | |||
/** | |||
* 头像url | |||
*/ | |||
private String image; | |||
/** | |||
* 租户id | |||
*/ | |||
private Integer tenantId; | |||
} |
@@ -0,0 +1,243 @@ | |||
package com.tuoheng.api.entity.domain; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* <p> | |||
* 后台用户管理表 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-10-30 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("sys_user") | |||
public class User implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 用户ID | |||
*/ | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Integer id; | |||
/** | |||
* 租户ID | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* 用户编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 真实姓名 | |||
*/ | |||
private String realname; | |||
/** | |||
* 昵称 | |||
*/ | |||
private String nickname; | |||
/** | |||
* 性别:1男 2女 3保密 | |||
*/ | |||
private Integer gender; | |||
/** | |||
* 头像 | |||
*/ | |||
private String avatar; | |||
/** | |||
* 手机号码 | |||
*/ | |||
private String mobile; | |||
/** | |||
* 邮箱地址 | |||
*/ | |||
private String email; | |||
/** | |||
* 出生日期 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd") | |||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") | |||
private Date birthday; | |||
/** | |||
* 部门ID | |||
*/ | |||
private Integer deptId; | |||
/** | |||
* 职级ID | |||
*/ | |||
private Integer levelId; | |||
/** | |||
* 岗位ID | |||
*/ | |||
private Integer positionId; | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 街道编码 | |||
*/ | |||
private String streetCode; | |||
/** | |||
* 详细地址 | |||
*/ | |||
private String address; | |||
/** | |||
* 所属城市 | |||
*/ | |||
private String cityName; | |||
/** | |||
* 登录用户名 | |||
*/ | |||
private String username; | |||
/** | |||
* 登录密码 | |||
*/ | |||
private String password; | |||
/** | |||
* 用户类型:1普通用户 2飞手 3问题处理员 4市河湖长 5区河湖长 6街道河湖长 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 驾照类型:1飞行执照 2飞行许可证 | |||
*/ | |||
private Integer driverType; | |||
/** | |||
* 驾照编号 | |||
*/ | |||
private String driverCode; | |||
/** | |||
* 盐加密 | |||
*/ | |||
private String salt; | |||
/** | |||
* 个人简介 | |||
*/ | |||
private String intro; | |||
/** | |||
* 状态:1正常 2禁用 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 显示顺序 | |||
*/ | |||
private Integer sort; | |||
/** | |||
* 登录次数 | |||
*/ | |||
private Integer loginNum; | |||
/** | |||
* 最近登录IP | |||
*/ | |||
private String loginIp; | |||
/** | |||
* 最近登录时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date loginTime; | |||
/** | |||
* 是否有问题分派人权限(1是 0否) | |||
*/ | |||
private Integer isAssignAuth; | |||
/** | |||
* 添加人 | |||
*/ | |||
private Integer createUser; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date createTime; | |||
/** | |||
* 更新人 | |||
*/ | |||
private Integer updateUser; | |||
/** | |||
* 更新时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date updateTime; | |||
/** | |||
* 有效标识 | |||
*/ | |||
private Integer mark; | |||
/** | |||
* 角色ID | |||
*/ | |||
@TableField(exist = false) | |||
private Integer[] roleIds; | |||
/** | |||
* 城市集合 | |||
*/ | |||
@TableField(exist = false) | |||
private String[] city; | |||
} |
@@ -0,0 +1,22 @@ | |||
package com.tuoheng.api.entity.request; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* 城市查询条件 | |||
*/ | |||
@Data | |||
public class CityQuery extends BaseQuery { | |||
/** | |||
* 城市名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 父级ID | |||
*/ | |||
private Integer pid; | |||
} |
@@ -0,0 +1,21 @@ | |||
package com.tuoheng.api.entity.request; | |||
import lombok.Data; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/10/19 | |||
*/ | |||
@Data | |||
public class CityRequest { | |||
/** | |||
* 经度 | |||
*/ | |||
private String lng; | |||
/** | |||
*维度 | |||
*/ | |||
private String lat; | |||
} |
@@ -0,0 +1,10 @@ | |||
package com.tuoheng.api.entity.request; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import lombok.Data; | |||
@Data | |||
public class FeedbackQuery extends BaseQuery { | |||
private String openid; | |||
} |
@@ -0,0 +1,50 @@ | |||
package com.tuoheng.api.entity.request; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import lombok.Data; | |||
/** | |||
* 河流查询 | |||
* | |||
* @author WangHaoran | |||
* @since 2021-09-06 | |||
*/ | |||
@Data | |||
public class StreamQuery extends BaseQuery { | |||
/** | |||
* 河流名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 河流编码 | |||
*/ | |||
private String code; | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 街道编码 | |||
*/ | |||
private String streetCode; | |||
/** | |||
* 村编码 | |||
*/ | |||
private String villageCode; | |||
} |
@@ -0,0 +1,160 @@ | |||
package com.tuoheng.api.entity.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* <p> | |||
* 高德城市表表单Vo | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-01-07 | |||
*/ | |||
@Data | |||
public class CityInfoVo { | |||
/** | |||
* 高德城市表ID | |||
*/ | |||
private Integer id; | |||
/** | |||
* ID | |||
*/ | |||
private Integer cityId; | |||
/** | |||
* 父级ID | |||
*/ | |||
private Integer pid; | |||
/** | |||
* 层级:1省 2市 3区 | |||
*/ | |||
private Integer level; | |||
/** | |||
* 省市区名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 简称 | |||
*/ | |||
private String simple; | |||
/** | |||
* 拼音 | |||
*/ | |||
private String pinyin; | |||
/** | |||
* 简拼 | |||
*/ | |||
private String code; | |||
/** | |||
* 首字母 | |||
*/ | |||
private String firstChar; | |||
/** | |||
* 原城市ID | |||
*/ | |||
private Integer oldCityId; | |||
/** | |||
* 有无子级:1有 2无 | |||
*/ | |||
private Integer hasChild; | |||
/** | |||
* 显示顺序 | |||
*/ | |||
private Integer sort; | |||
/** | |||
* 1-有效 2-无效 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 创建人 | |||
*/ | |||
private String createUser; | |||
/** | |||
* 更新人 | |||
*/ | |||
private String updateUser; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
private Date createTime; | |||
/** | |||
* 更新时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
private Date updateTime; | |||
/** | |||
* 是否删除 1未删除 0已删除 | |||
*/ | |||
private Integer mark; | |||
/** | |||
* 城市名称(省市区街道村拼接) | |||
*/ | |||
private String cityArea; | |||
/** | |||
* 省份名称 | |||
*/ | |||
private String provinceName; | |||
/** | |||
* 城市名称 | |||
*/ | |||
private String cityName; | |||
/** | |||
* 区县名称 | |||
*/ | |||
private String districtName; | |||
/** | |||
* 街道名称 | |||
*/ | |||
private String streetName; | |||
/** | |||
* 村名称 | |||
*/ | |||
private String villageName; | |||
/** | |||
* 省编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
} |
@@ -0,0 +1,138 @@ | |||
package com.tuoheng.api.entity.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
@Data | |||
public class FeedbackInfoVo { | |||
/** | |||
* 主键ID | |||
*/ | |||
private Integer id; | |||
/** | |||
* 租户ID | |||
*/ | |||
private Integer tenantId; | |||
/** | |||
* 提交人openid | |||
*/ | |||
private String openid; | |||
/** | |||
* 河道ID | |||
*/ | |||
private Integer streamId; | |||
/** | |||
* 河道名称 | |||
*/ | |||
private String streamName; | |||
/** | |||
* 责任河湖长ID | |||
*/ | |||
private Integer streamAdminId; | |||
/** | |||
* 责任河湖长名称 | |||
*/ | |||
private String streamAdminName; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 位置名称 | |||
*/ | |||
private String location; | |||
/** | |||
* 问题描述 | |||
*/ | |||
private String feedbackDesc; | |||
/** | |||
* 反馈人姓名 | |||
*/ | |||
private String feedbackName; | |||
/** | |||
* 反馈人手机号 | |||
*/ | |||
private String feedbackPhone; | |||
/** | |||
* 反馈图片地址 多张用,隔开 | |||
*/ | |||
private String feedbackUrl; | |||
/** | |||
* 处理图片地址 多张用,隔开 | |||
*/ | |||
private String handleUrl; | |||
/** | |||
* 处理意见 | |||
*/ | |||
private String handleRemark; | |||
/** | |||
* 处理时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date handleTime; | |||
/** | |||
* 审核意见 | |||
*/ | |||
private String examineRemark; | |||
/** | |||
* 状态:1待审核 2待处理 3已忽略 4已处理 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 添加人 | |||
*/ | |||
private Integer createUser; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date createTime; | |||
/** | |||
* 更新人 | |||
*/ | |||
private Integer updateUser; | |||
/** | |||
* 更新时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date updateTime; | |||
/** | |||
* 河道图片 | |||
*/ | |||
private String streamImage; | |||
} |
@@ -0,0 +1,173 @@ | |||
package com.tuoheng.api.entity.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
/** | |||
* 河流信息Vo | |||
*/ | |||
@Data | |||
public class StreamInfoVo { | |||
/** | |||
* 主键 | |||
*/ | |||
private Integer id; | |||
/** | |||
* 河流编码 | |||
*/ | |||
private String code; | |||
/** | |||
* 河流名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 省份编码 | |||
*/ | |||
private String provinceCode; | |||
/** | |||
* 城市编码 | |||
*/ | |||
private String cityCode; | |||
/** | |||
* 区县编码 | |||
*/ | |||
private String districtCode; | |||
/** | |||
* 街道编码 | |||
*/ | |||
private String streetCode; | |||
/** | |||
* 村编码 | |||
*/ | |||
private String villageCode; | |||
/** | |||
* 责任河湖长ID | |||
*/ | |||
private Integer streamAdminId; | |||
/** | |||
* 责任河湖长名称 | |||
*/ | |||
private String streamAdminName; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 起止位置 | |||
*/ | |||
private String location; | |||
/** | |||
* 河流长度 | |||
*/ | |||
private String length; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 状态:1正常 2停用 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 添加人名称 | |||
*/ | |||
private String createUserName; | |||
/** | |||
* 更新人名称 | |||
*/ | |||
private String updateUserName; | |||
/** | |||
* 城市名称(省市区街道村拼接) | |||
*/ | |||
private String cityArea; | |||
/** | |||
* 省份名称 | |||
*/ | |||
private String provinceName; | |||
/** | |||
* 城市名称 | |||
*/ | |||
private String cityName; | |||
/** | |||
* 区县名称 | |||
*/ | |||
private String districtName; | |||
/** | |||
* 街道名称 | |||
*/ | |||
private String streetName; | |||
/** | |||
* 村名称 | |||
*/ | |||
private String villageName; | |||
/** | |||
* 添加人 | |||
*/ | |||
private Integer createUser; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date createTime; | |||
/** | |||
* 更新人 | |||
*/ | |||
private Integer updateUser; | |||
/** | |||
* 更新时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date updateTime; | |||
/** | |||
* 有效标识 | |||
*/ | |||
private Integer mark; | |||
/** | |||
* 头像地址 | |||
*/ | |||
private String image; | |||
/** | |||
* 巡检河流数量 | |||
*/ | |||
private Integer streamGisNumber; | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.City; | |||
/** | |||
* <p> | |||
* 高德城市表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-11-03 | |||
*/ | |||
public interface CityMapper extends BaseMapper<City> { | |||
} |
@@ -0,0 +1,7 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.Feedback; | |||
public interface FeedbackMapper extends BaseMapper<Feedback> { | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.Stream; | |||
/** | |||
* 河流表 Mapper 接口 | |||
* | |||
* @author WangHaoran | |||
* @since 2021-09-06 | |||
*/ | |||
public interface StreamMapper extends BaseMapper<Stream> { | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.api.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.api.entity.domain.User; | |||
/** | |||
* <p> | |||
* 后台用户管理表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-10-30 | |||
*/ | |||
public interface UserMapper extends BaseMapper<User> { | |||
} |
@@ -0,0 +1,52 @@ | |||
package com.tuoheng.api.service; | |||
import com.tuoheng.api.entity.domain.City; | |||
import com.tuoheng.api.entity.request.CityRequest; | |||
import com.tuoheng.api.entity.vo.CityInfoVo; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 高德城市表 服务类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-11-03 | |||
*/ | |||
public interface ICityService extends IBaseService<City> { | |||
/** | |||
* 根据城市编码获取城市信息 | |||
* | |||
* @param cityCode 城市编码 | |||
* @param delimiter 分隔符号 | |||
* @return | |||
*/ | |||
String getCityNameByCode(String cityCode, String delimiter); | |||
/** | |||
* 根据城市编码获取城市信息 | |||
* | |||
* @param cityCode 城市编码 | |||
* @param delimiter 分隔符号 | |||
* @return | |||
*/ | |||
CityInfoVo getCityInfoByCode(String cityCode, String delimiter); | |||
/** | |||
* 获取行政区列表 | |||
* | |||
* @return 行政区列表 | |||
*/ | |||
JsonResult getCityList(); | |||
/** | |||
* 获取省市区及城市编码 | |||
* @param request | |||
* @return | |||
*/ | |||
CityInfoVo getCityNameAndCode(CityRequest request); | |||
} |
@@ -0,0 +1,18 @@ | |||
package com.tuoheng.api.service; | |||
import com.tuoheng.api.entity.domain.Feedback; | |||
import com.tuoheng.api.entity.request.FeedbackQuery; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 反馈表 服务类 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-09-06 | |||
*/ | |||
public interface IFeedbackService extends IBaseService<Feedback> { | |||
JsonResult submit(Feedback feedback); | |||
JsonResult my(FeedbackQuery feedbackQuery); | |||
} |
@@ -0,0 +1,10 @@ | |||
package com.tuoheng.api.service; | |||
import com.tuoheng.api.entity.domain.User; | |||
public interface IJwtService { | |||
User getUserInfo(); | |||
Integer getTenantId(); | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.api.service; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.tuoheng.api.entity.domain.Stream; | |||
import com.tuoheng.api.entity.request.StreamQuery; | |||
import com.tuoheng.api.entity.vo.StreamInfoVo; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
* 河流表 服务类 | |||
* | |||
* @author WangHaoran | |||
* @since 2021-09-06 | |||
*/ | |||
public interface IStreamService extends IBaseService<Stream> { | |||
/** | |||
* 分页查询 | |||
* | |||
* @param query | |||
* @return | |||
*/ | |||
JsonResult queryPage(StreamQuery query); | |||
} |
@@ -0,0 +1,7 @@ | |||
package com.tuoheng.api.service; | |||
import com.tuoheng.common.utils.JsonResult; | |||
public interface IWxService { | |||
JsonResult openid(String code); | |||
} |
@@ -0,0 +1,304 @@ | |||
package com.tuoheng.api.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.tuoheng.api.entity.domain.City; | |||
import com.tuoheng.api.entity.request.CityQuery; | |||
import com.tuoheng.api.entity.request.CityRequest; | |||
import com.tuoheng.api.entity.vo.CityInfoVo; | |||
import com.tuoheng.api.mapper.CityMapper; | |||
import com.tuoheng.api.service.ICityService; | |||
import com.tuoheng.api.utils.GaodeUtil; | |||
import com.tuoheng.common.common.BaseQuery; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.Comparator; | |||
import java.util.List; | |||
import java.util.stream.Collectors; | |||
/** | |||
* <p> | |||
* 高德城市表 服务实现类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2020-11-03 | |||
*/ | |||
@Service | |||
public class CityServiceImpl extends BaseServiceImpl<CityMapper, City> implements ICityService { | |||
@Autowired | |||
private CityMapper cityMapper; | |||
@Override | |||
public JsonResult getCityList() { | |||
List<City> list = cityMapper.selectList(new LambdaQueryWrapper<City>() | |||
.eq(City::getMark, 1)); | |||
// 获取所有一级节点 | |||
List<City> result = list.stream(). | |||
filter(city -> city.getPid() == 0) | |||
.peek(city -> city.setItemList(getChildren(city, list))).sorted(Comparator.comparingInt(city -> (city.getSort() == null ? 0 : city.getSort()))) | |||
.collect(Collectors.toList()); | |||
return JsonResult.success(result); | |||
} | |||
/** | |||
* 递归获取有行政区的子集 | |||
* | |||
* @author zhu_zishuang | |||
* @date 3/13/21 | |||
*/ | |||
private List<City> getChildren(City rootCity, List<City> list) { | |||
return list.stream().filter(city -> | |||
city.getPid().equals(rootCity.getId()) | |||
).peek(city -> { | |||
// 设置子集 | |||
city.setItemList(getChildren(city, list)); | |||
}).sorted(Comparator.comparingInt(city -> (city.getSort() == null ? 0 : city.getSort()))).collect(Collectors.toList()); | |||
} | |||
/** | |||
* 获取城市列表 | |||
* | |||
* @param query 查询条件 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getList(BaseQuery query) { | |||
CityQuery cityQuery = (CityQuery) query; | |||
// 查询条件 | |||
QueryWrapper<City> queryWrapper = new QueryWrapper<>(); | |||
// 父级ID | |||
if (StringUtils.isNull(cityQuery.getPid())) { | |||
queryWrapper.eq("pid", 0); | |||
} else { | |||
queryWrapper.eq("pid", cityQuery.getPid()); | |||
} | |||
// 城市名称 | |||
if (!StringUtils.isEmpty(cityQuery.getName())) { | |||
queryWrapper.like("name", cityQuery.getName()); | |||
} | |||
queryWrapper.eq("mark", 1); | |||
queryWrapper.orderByAsc("sort"); | |||
// 查询分页数据 | |||
List<City> cityList = cityMapper.selectList(queryWrapper); | |||
cityList.forEach(item -> { | |||
//省、市、区、街道、村 | |||
if (item.getLevel() <= 4) { | |||
item.setHasChildren(true); | |||
} | |||
}); | |||
return JsonResult.success(cityList); | |||
} | |||
/** | |||
* 添加或编辑 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult edit(City entity) { | |||
// 城市编码唯一性验证 | |||
if (StringUtils.isNotNull(entity.getId()) && entity.getId() > 0) { | |||
// 更新 | |||
QueryWrapper<City> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.ne("id", entity.getId()); | |||
queryWrapper.eq("citycode", entity.getCitycode()); | |||
queryWrapper.eq("mark", 1); | |||
Integer count = cityMapper.selectCount(queryWrapper); | |||
if (count >= 1) { | |||
return JsonResult.error("系统中已存在相同的城市编码"); | |||
} | |||
} else { | |||
// 添加 | |||
QueryWrapper<City> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("citycode", entity.getCitycode()); | |||
queryWrapper.eq("mark", 1); | |||
Integer count = cityMapper.selectCount(queryWrapper); | |||
if (count >= 1) { | |||
return JsonResult.error("系统中已存在相同的城市编码"); | |||
} | |||
} | |||
return super.edit(entity); | |||
} | |||
/** | |||
* 根据城市编码获取城市信息 | |||
* | |||
* @param cityCode 城市编码 | |||
* @param delimiter 分隔符号 | |||
* @return | |||
*/ | |||
@Override | |||
public String getCityNameByCode(String cityCode, String delimiter) { | |||
List<String> nameList = new ArrayList<>(); | |||
QueryWrapper<City> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("citycode", cityCode); | |||
queryWrapper.eq("mark", 1); | |||
queryWrapper.last("limit 1"); | |||
City cityInfo = cityMapper.selectOne(queryWrapper); | |||
if (cityInfo == null) { | |||
return null; | |||
} | |||
Integer cityId = cityInfo.getId(); | |||
while (cityId > 0) { | |||
City cateInfo = cityMapper.selectById(cityId); | |||
if (cateInfo != null) { | |||
nameList.add(cateInfo.getName()); | |||
cityId = cateInfo.getPid(); | |||
} else { | |||
cityId = null; | |||
} | |||
} | |||
// 使用集合工具实现数组翻转 | |||
Collections.reverse(nameList); | |||
return org.apache.commons.lang3.StringUtils.join(nameList.toArray(), delimiter); | |||
} | |||
/** | |||
* 根据城市编码获取城市信息 | |||
* | |||
* @param cityCode 城市编码 | |||
* @param delimiter 分隔符号 | |||
* @return | |||
*/ | |||
@Override | |||
public CityInfoVo getCityInfoByCode(String cityCode, String delimiter) { | |||
CityInfoVo cityInfoVo = new CityInfoVo(); | |||
List<String> nameList = new ArrayList<>(); | |||
QueryWrapper<City> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("citycode", cityCode); | |||
queryWrapper.eq("mark", 1); | |||
queryWrapper.last("limit 1"); | |||
City cityInfo = cityMapper.selectOne(queryWrapper); | |||
if (cityInfo == null) { | |||
return null; | |||
} | |||
Integer cityId = cityInfo.getId(); | |||
while (cityId > 0) { | |||
City cateInfo = cityMapper.selectById(cityId); | |||
if (cateInfo != null) { | |||
nameList.add(cateInfo.getName()); | |||
cityId = cateInfo.getPid(); | |||
} else { | |||
cityId = null; | |||
} | |||
} | |||
// 使用集合工具实现数组翻转 | |||
Collections.reverse(nameList); | |||
String cityArea = org.apache.commons.lang3.StringUtils.join(nameList.toArray(), delimiter); | |||
cityInfoVo.setCityArea(cityArea); | |||
if (StringUtils.isNotEmpty(nameList) && nameList.size() > 0) { | |||
cityInfoVo.setProvinceName(nameList.get(0)); | |||
} | |||
if (StringUtils.isNotEmpty(nameList) && nameList.size() > 1) { | |||
cityInfoVo.setCityName(nameList.get(1)); | |||
} | |||
if (StringUtils.isNotEmpty(nameList) && nameList.size() > 2) { | |||
cityInfoVo.setDistrictName(nameList.get(2)); | |||
} | |||
if (StringUtils.isNotEmpty(nameList) && nameList.size() > 3) { | |||
cityInfoVo.setStreetName(nameList.get(3)); | |||
} | |||
if (StringUtils.isNotEmpty(nameList) && nameList.size() > 4) { | |||
cityInfoVo.setVillageName(nameList.get(4)); | |||
} | |||
return cityInfoVo; | |||
} | |||
/** | |||
* 获取城市名称及编码 | |||
* | |||
* @param request | |||
* @return | |||
*/ | |||
@Override | |||
public CityInfoVo getCityNameAndCode(CityRequest request) { | |||
//校验 | |||
if (StringUtils.isNull(request.getLat()) && StringUtils.isNull(request.getLng())) { | |||
JsonResult.error("经纬度坐标不存在"); | |||
} | |||
CityInfoVo cityInfoVo = new CityInfoVo(); | |||
List<String> nameList = new ArrayList<>(); | |||
String cityCode = GaodeUtil.getGaodeCode(request.getLng(), request.getLat()); | |||
if (StringUtils.isNull(cityCode)) { | |||
JsonResult.error("城市编码不存在"); | |||
} | |||
//根据编码查询对应城市信息 | |||
LambdaQueryWrapper<City> qw = new LambdaQueryWrapper<>(); | |||
qw.eq(StringUtils.isNotNull(cityCode), City::getCitycode, cityCode); | |||
qw.eq(City::getMark, 1); | |||
qw.last("limit 1"); | |||
City cityInfo = cityMapper.selectOne(qw); | |||
if (cityInfo == null) { | |||
return null; | |||
} | |||
Integer cityId = cityInfo.getId(); | |||
while (cityId > 0) { | |||
City cateInfo = cityMapper.selectById(cityId); | |||
if (cateInfo != null) { | |||
nameList.add(cateInfo.getName()); | |||
cityId = cateInfo.getPid(); | |||
} else { | |||
cityId = null; | |||
} | |||
} | |||
// 使用集合工具实现数组翻转 | |||
Collections.reverse(nameList); | |||
if (StringUtils.isNotEmpty(nameList) && nameList.size() > 0) { | |||
cityInfoVo.setProvinceName(nameList.get(0)); | |||
String provinceName = nameList.get(0); | |||
LambdaQueryWrapper<City> qw1 = new LambdaQueryWrapper<>(); | |||
qw1.eq(StringUtils.isNotEmpty(provinceName), City::getName, provinceName).eq(City::getMark, 1); | |||
qw1.last("limit 1"); | |||
City city = cityMapper.selectOne(qw1); | |||
if (StringUtils.isNull(city)) { | |||
return null; | |||
} | |||
String provinceCode = city.getCitycode(); | |||
cityInfoVo.setProvinceCode(provinceCode); | |||
} | |||
if (StringUtils.isNotEmpty(nameList) && nameList.size() > 1) { | |||
cityInfoVo.setCityName(nameList.get(1)); | |||
String cityName = nameList.get(1); | |||
LambdaQueryWrapper<City> qw2 = new LambdaQueryWrapper<>(); | |||
qw2.eq(StringUtils.isNotEmpty(cityName), City::getName, cityName).eq(City::getMark, 1); | |||
qw2.last("limit 1"); | |||
City city = cityMapper.selectOne(qw2); | |||
if (StringUtils.isNull(city)) { | |||
return null; | |||
} | |||
String cyCode = city.getCitycode(); | |||
cityInfoVo.setCityCode(cyCode); | |||
} | |||
if (StringUtils.isNotEmpty(nameList) && nameList.size() > 2) { | |||
cityInfoVo.setDistrictName(nameList.get(2)); | |||
String districtName = nameList.get(2); | |||
LambdaQueryWrapper<City> qw3 = new LambdaQueryWrapper<>(); | |||
qw3.eq(StringUtils.isNotEmpty(districtName), City::getName, districtName).eq(City::getMark, 1); | |||
qw3.last("limit 1"); | |||
City city = cityMapper.selectOne(qw3); | |||
if (StringUtils.isNull(city)) { | |||
return null; | |||
} | |||
String districtCode = city.getCitycode(); | |||
cityInfoVo.setDistrictCode(districtCode); | |||
} | |||
return cityInfoVo; | |||
} | |||
} |
@@ -0,0 +1,132 @@ | |||
package com.tuoheng.api.service.impl; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.api.entity.domain.Feedback; | |||
import com.tuoheng.api.entity.domain.Stream; | |||
import com.tuoheng.api.entity.domain.User; | |||
import com.tuoheng.api.entity.request.FeedbackQuery; | |||
import com.tuoheng.api.mapper.FeedbackMapper; | |||
import com.tuoheng.api.mapper.StreamMapper; | |||
import com.tuoheng.api.mapper.UserMapper; | |||
import com.tuoheng.api.service.IFeedbackService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.config.CommonConfig; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.CommonUtils; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.http.HttpStatus; | |||
import org.springframework.stereotype.Service; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 反馈表 服务实现类 | |||
* | |||
* @author WangHaoran | |||
* @since 2022-09-06 | |||
*/ | |||
@Service | |||
public class FeedbackServiceImpl extends BaseServiceImpl<FeedbackMapper, Feedback> implements IFeedbackService { | |||
@Autowired | |||
private FeedbackMapper feedbackMapper; | |||
@Autowired | |||
private StreamMapper streamMapper; | |||
@Autowired | |||
private UserMapper userMapper; | |||
@Override | |||
public JsonResult submit(Feedback feedback) { | |||
if(StringUtils.isEmpty(feedback.getOpenid())){ | |||
return JsonResult.error("openid为空"); | |||
} | |||
Stream stream = streamMapper.selectById(feedback.getStreamId()); | |||
if(ObjectUtil.isNotNull(stream)){ | |||
feedback.setTenantId(stream.getTenantId()); | |||
feedback.setStreamName(stream.getName()); | |||
feedback.setStreamAdminId(stream.getStreamAdminId()); | |||
feedback.setStreamAdminName(stream.getStreamAdminName()); | |||
}else { | |||
return JsonResult.error("河流信息不存在"); | |||
} | |||
return super.add(feedback); | |||
} | |||
@Override | |||
public JsonResult my(FeedbackQuery query) { | |||
if(null == query.getPage() || null == query.getLimit()){ | |||
return JsonResult.error("分页数据为空"); | |||
} | |||
if(StringUtils.isEmpty(query.getOpenid())){ | |||
return JsonResult.error("openid为空"); | |||
} | |||
// 获取分页数据 | |||
IPage<Feedback> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<Feedback> pageData = feedbackMapper.selectPage(page, new LambdaQueryWrapper<Feedback>() | |||
.eq(Feedback::getMark, 1) | |||
.eq(Feedback::getOpenid, query.getOpenid()) | |||
.orderByDesc(Feedback::getCreateTime)); | |||
pageData.getRecords().stream().map(vo -> { | |||
Stream stream = streamMapper.selectById(vo.getStreamId()); | |||
if(StringUtils.isNotNull(stream)){ | |||
vo.setStreamImage(CommonUtils.getImageURL(stream.getImage())); | |||
} | |||
if (StringUtils.isNotNull(vo.getStatus())){ | |||
if(vo.getStatus()==4 || vo.getStatus()==3){ | |||
User user = userMapper.selectById(vo.getStreamAdminId()); | |||
//判空 | |||
if(StringUtils.isNull(user)){ | |||
throw new ServiceException(HttpStatus.BAD_REQUEST.value(),"当前反馈问题id"+vo.getId()+"查询不到对应责任河湖长"); | |||
} | |||
vo.setRealname(user.getRealname()); | |||
}else { | |||
vo.setHandleTime(null); | |||
} | |||
} | |||
//反馈图片地址 | |||
if(StringUtils.isNotEmpty(vo.getFeedbackUrl())){ | |||
String[] feedbackUrls = vo.getFeedbackUrl().split(","); | |||
if(StringUtils.isNotEmpty(feedbackUrls)){ | |||
for (int i = 0; i < feedbackUrls.length; i++) { | |||
if(StringUtils.isNotEmpty(feedbackUrls[i])){ | |||
feedbackUrls[i] = CommonConfig.imageURL + feedbackUrls[i]; | |||
} | |||
} | |||
} | |||
//反馈图片封面地址,取第一张图 | |||
vo.setFeedbackCover(feedbackUrls[0]); | |||
vo.setFeedbackUrl(StringUtils.join(feedbackUrls, ",")); | |||
} | |||
//处理图片地址 | |||
if(StringUtils.isNotEmpty(vo.getHandleUrl())){ | |||
String[] handleUrls = vo.getHandleUrl().split(","); | |||
if(StringUtils.isNotEmpty(handleUrls)){ | |||
for (int i = 0; i < handleUrls.length; i++) { | |||
if(StringUtils.isNotEmpty(handleUrls[i])){ | |||
handleUrls[i] = CommonConfig.imageURL + handleUrls[i]; | |||
} | |||
} | |||
} | |||
vo.setHandleUrl(StringUtils.join(handleUrls, ",")); | |||
} | |||
return vo; | |||
} | |||
).collect(Collectors.toList()); | |||
return JsonResult.success(pageData); | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
package com.tuoheng.api.service.impl; | |||
import com.tuoheng.api.entity.domain.User; | |||
import com.tuoheng.api.mapper.UserMapper; | |||
import com.tuoheng.api.service.IJwtService; | |||
import com.tuoheng.common.utils.JwtUtil; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@Service | |||
public class JwtServiceImpl implements IJwtService { | |||
@Autowired | |||
private UserMapper userMapper; | |||
/** | |||
* 获取当前用户信息 | |||
* | |||
* @return | |||
*/ | |||
@Override | |||
public User getUserInfo() { | |||
Integer userId = JwtUtil.userId(); | |||
User user = userMapper.selectById(userId); | |||
return user; | |||
} | |||
/** | |||
* 获取当前用户TenantId | |||
* | |||
* @return | |||
*/ | |||
@Override | |||
public Integer getTenantId() { | |||
Integer userId = JwtUtil.userId(); | |||
User user = userMapper.selectById(userId); | |||
return user.getTenantId(); | |||
} | |||
} |
@@ -0,0 +1,84 @@ | |||
package com.tuoheng.api.service.impl; | |||
import cn.hutool.core.convert.Convert; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.api.entity.domain.Stream; | |||
import com.tuoheng.api.entity.request.StreamQuery; | |||
import com.tuoheng.api.entity.vo.CityInfoVo; | |||
import com.tuoheng.api.entity.vo.StreamInfoVo; | |||
import com.tuoheng.api.mapper.StreamMapper; | |||
import com.tuoheng.api.service.ICityService; | |||
import com.tuoheng.api.service.IStreamService; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.config.CommonConfig; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* 河道表 服务实现类 | |||
* | |||
* @author WangHaoran | |||
* @since 2021-09-06 | |||
*/ | |||
@Service | |||
public class StreamServiceImpl extends BaseServiceImpl<StreamMapper, Stream> implements IStreamService { | |||
@Autowired | |||
private StreamMapper streamMapper; | |||
@Autowired | |||
private ICityService cityService; | |||
@Override | |||
public JsonResult queryPage(StreamQuery query) { | |||
if (null == query.getPage() || null == query.getLimit()) { | |||
return JsonResult.error("参数为空!"); | |||
} | |||
// 获取分页数据 | |||
IPage<Stream> page = new Page<>(query.getPage(), query.getLimit()); | |||
IPage<Stream> pageData = streamMapper.selectPage(page, new LambdaQueryWrapper<Stream>() | |||
.eq(Stream::getMark, 1) | |||
.like(StringUtils.isNotEmpty(query.getName()), Stream::getName, query.getName()) | |||
.eq(StringUtils.isNotEmpty(query.getProvinceCode()), Stream::getProvinceCode, query.getProvinceCode()) | |||
.eq(StringUtils.isNotEmpty(query.getCityCode()), Stream::getCityCode, query.getCityCode()) | |||
.eq(StringUtils.isNotEmpty(query.getDistrictCode()), Stream::getDistrictCode, query.getDistrictCode()) | |||
.orderByDesc(Stream::getCreateTime)); | |||
pageData.convert(x -> { | |||
StreamInfoVo streamInfoVo = Convert.convert(StreamInfoVo.class, x); | |||
CityInfoVo cityInfoVo = null; | |||
if (StringUtils.isNotEmpty(x.getVillageCode())) { | |||
// 最后一级到村 | |||
cityInfoVo = cityService.getCityInfoByCode(x.getVillageCode(), ""); | |||
} else if (StringUtils.isEmpty(x.getVillageCode()) && StringUtils.isNotEmpty(x.getStreetCode())) { | |||
// 最后一级到街道 | |||
cityInfoVo = cityService.getCityInfoByCode(x.getStreetCode(), ""); | |||
} else if (StringUtils.isEmpty(x.getVillageCode()) && StringUtils.isEmpty(x.getStreetCode())) { | |||
// 最后一级到区 | |||
cityInfoVo = cityService.getCityInfoByCode(x.getDistrictCode(), ""); | |||
} | |||
if (cityInfoVo != null) { | |||
streamInfoVo.setCityArea(cityInfoVo.getCityArea()); | |||
streamInfoVo.setProvinceName(cityInfoVo.getProvinceName()); | |||
streamInfoVo.setCityName(cityInfoVo.getCityName()); | |||
streamInfoVo.setDistrictName(cityInfoVo.getDistrictName()); | |||
streamInfoVo.setStreetName(cityInfoVo.getStreetName()); | |||
streamInfoVo.setVillageName(cityInfoVo.getVillageName()); | |||
} | |||
if (StringUtils.isEmpty(streamInfoVo.getImage())) { | |||
// 设置一张默认图 | |||
streamInfoVo.setImage(CommonConfig.imageURL + "stream.png"); | |||
} else if (!streamInfoVo.getImage().contains(CommonConfig.imageURL)) { | |||
streamInfoVo.setImage(CommonConfig.imageURL + streamInfoVo.getImage()); | |||
} | |||
return streamInfoVo; | |||
}); | |||
return JsonResult.success(pageData); | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
package com.tuoheng.api.service.impl; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.api.service.IWxService; | |||
import com.tuoheng.common.config.CommonConfig; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import com.tuoheng.api.utils.GetOpenIdUtil; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
@Slf4j | |||
@Service | |||
public class WxServiceImpl implements IWxService { | |||
@Override | |||
public JsonResult openid(String code) { | |||
String openidResult = GetOpenIdUtil.getopenid(code, CommonConfig.appId, CommonConfig.appSecret); | |||
String openid = JSONObject.parseObject(openidResult).getString("openid"); | |||
if(StringUtils.isNotEmpty(openid)){ | |||
return JsonResult.success(openid); | |||
}else { | |||
log.error("获取openid失败:",openidResult); | |||
return JsonResult.error("获取openid失败"); | |||
} | |||
} | |||
} |
@@ -0,0 +1,187 @@ | |||
package com.tuoheng.api.utils; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.common.config.CommonConfig; | |||
import lombok.extern.slf4j.Slf4j; | |||
import java.io.BufferedReader; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.io.InputStreamReader; | |||
import java.net.HttpURLConnection; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.text.DecimalFormat; | |||
import java.util.Map; | |||
@Slf4j | |||
public class GaodeUtil { | |||
/** | |||
* 逆地理编码 | |||
* | |||
* @param longitude 经度 | |||
* @param latitude 纬度 | |||
* @return | |||
*/ | |||
public static String getGaodeAddress(String longitude, String latitude) { | |||
String address = null; | |||
JSONObject json = new JSONObject(); | |||
try { | |||
json.put("key", CommonConfig.gaodeKey); | |||
json.put("location", longitude + "," + latitude); | |||
log.info("调用高德逆地理编码API请求参数:" + json); | |||
String result = doGet("https://restapi.amap.com/v3/geocode/regeo", json, null); | |||
log.info("调用高德逆地理编码API成功:" + result); | |||
JSONObject resultJson = JSONObject.parseObject(result.trim()); | |||
if("1".equals(resultJson.getString("status"))){ | |||
address = resultJson.getJSONObject("regeocode").getString("formatted_address"); | |||
} | |||
} catch (Exception e) { | |||
log.error("逆地理编码方法异常:", e); | |||
} | |||
return address; | |||
} | |||
/** | |||
* 逆地理编码 | |||
* | |||
* @param longitude 经度 | |||
* @param latitude 纬度 | |||
* @return | |||
*/ | |||
public static String getGaodeCode(String longitude, String latitude) { | |||
String cityCode = null; | |||
JSONObject json = new JSONObject(); | |||
try { | |||
json.put("key", CommonConfig.gaodeKey); | |||
json.put("location", longitude + "," + latitude); | |||
log.info("调用高德逆地理编码API请求参数:" + json); | |||
String result = doGet("https://restapi.amap.com/v3/geocode/regeo", json, null); | |||
log.info("调用高德逆地理编码API成功:" + result); | |||
JSONObject resultJson = JSONObject.parseObject(result.trim()); | |||
if("1".equals(resultJson.getString("status"))){ | |||
cityCode = resultJson.getJSONObject("regeocode").getJSONObject("addressComponent").getString("adcode"); | |||
} | |||
} catch (Exception e) { | |||
log.error("逆地理编码方法异常:", e); | |||
} | |||
return cityCode; | |||
} | |||
/** | |||
* 高德坐标转换 | |||
* | |||
* @param longitude 经度 | |||
* @param latitude 纬度 | |||
* @return | |||
*/ | |||
public static JSONObject getGaodeCoordinate(String longitude, String latitude) { | |||
JSONObject json = new JSONObject(); | |||
JSONObject param = new JSONObject(); | |||
try { | |||
//取六位小数 | |||
DecimalFormat df = new DecimalFormat("0.000000"); | |||
param.put("key", CommonConfig.gaodeKey); | |||
param.put("locations", df.format(Double.valueOf(longitude)) + "," + df.format(Double.valueOf(latitude))); | |||
param.put("coordsys", "gps"); | |||
log.info("调用高德坐标转换API请求参数:" + param); | |||
String result = doGet("https://restapi.amap.com/v3/assistant/coordinate/convert", param, null); | |||
log.info("调用高德坐标转换API成功:" + result); | |||
JSONObject resultJson = JSONObject.parseObject(result.trim()); | |||
if("1".equals(resultJson.getString("status"))){ | |||
String locations = JSONObject.parseObject(result).getString("locations"); | |||
String lonStr = locations.substring(0, locations.indexOf(",")); | |||
String latStr = locations.substring(lonStr.length()+1); | |||
json.put("longitude", lonStr); | |||
json.put("latitude", latStr); | |||
} | |||
} catch (Exception e) { | |||
log.error("高德坐标转换方法异常:", e); | |||
} | |||
return json; | |||
} | |||
public static String doGet(String url, JSONObject data, Map<String, String> properties) { | |||
HttpURLConnection connection = null; | |||
InputStream is = null; | |||
BufferedReader br = null; | |||
String result = null;// 返回结果字符串 | |||
StringBuffer urlNameString = new StringBuffer().append(url).append("?"); | |||
if (data != null) { | |||
for (String key : data.keySet()) { | |||
urlNameString.append(key).append("=").append(data.get(key)).append("&"); | |||
} | |||
url = urlNameString.substring(0, urlNameString.lastIndexOf("&")); | |||
} | |||
try { | |||
// 创建远程url连接对象 | |||
URL httpUrl = new URL(url); | |||
// 通过远程url连接对象打开一个连接,强转成httpURLConnection类 | |||
connection = (HttpURLConnection) httpUrl.openConnection(); | |||
// 设置连接方式:get | |||
connection.setRequestMethod("GET"); | |||
// 设置连接主机服务器的超时时间:15000毫秒 | |||
connection.setConnectTimeout(15000); | |||
// 设置读取远程返回的数据时间:60000毫秒 | |||
connection.setReadTimeout(60000); | |||
if(null != properties && !properties.isEmpty()){ | |||
for (String key:properties.keySet()){ | |||
connection.setRequestProperty(key, properties.get(key)); | |||
} | |||
} | |||
// 发送请求 | |||
connection.connect(); | |||
// 通过connection连接,获取输入流 | |||
if (connection.getResponseCode() == 200) { | |||
is = connection.getInputStream(); | |||
// 封装输入流is,并指定字符集 | |||
br = new BufferedReader(new InputStreamReader(is, "UTF-8")); | |||
// 存放数据 | |||
StringBuffer sbf = new StringBuffer(); | |||
String temp = null; | |||
while ((temp = br.readLine()) != null) { | |||
sbf.append(temp); | |||
sbf.append("\r\n"); | |||
} | |||
result = sbf.toString(); | |||
} | |||
} catch (MalformedURLException e) { | |||
e.printStackTrace(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} finally { | |||
// 关闭资源 | |||
if (null != br) { | |||
try { | |||
br.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
if (null != is) { | |||
try { | |||
is.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
connection.disconnect();// 关闭远程连接 | |||
} | |||
return result; | |||
} | |||
} |
@@ -0,0 +1,59 @@ | |||
package com.tuoheng.api.utils; | |||
import com.alibaba.fastjson.JSONObject; | |||
import java.io.BufferedReader; | |||
import java.io.InputStreamReader; | |||
import java.net.URL; | |||
import java.net.URLConnection; | |||
/** | |||
* 微信登陆工具类 | |||
*/ | |||
public class GetOpenIdUtil { | |||
public static void main(String[] args) { | |||
System.out.println("start"); | |||
String openidJson = getopenid("061pTj0w3j6DaZ23141w3X12aP0pTj04", "wxd0f247d7272ca1b7", "541002e33cd4b011d4c13954ed34efdb"); | |||
System.out.println("openid:" + openidJson); | |||
JSONObject jsonObject = JSONObject.parseObject(openidJson); | |||
String openid = jsonObject.getString("openid"); | |||
System.out.println("end"); | |||
} | |||
public static String getopenid(String code,String appid,String secret) { | |||
BufferedReader in = null; | |||
//appid和secret是开发者分别是小程序ID和小程序密钥,开发者通过微信公众平台-》设置-》开发设置就可以直接获取, | |||
String url="https://api.weixin.qq.com/sns/jscode2session?appid=" | |||
+appid+"&secret="+secret+"&js_code="+code+"&grant_type=authorization_code"; | |||
try{ | |||
URL weChatUrl = new URL(url); | |||
// 打开和URL之间的连接 | |||
URLConnection connection = weChatUrl.openConnection(); | |||
// 设置通用的请求属性 | |||
connection.setConnectTimeout(5000); | |||
connection.setReadTimeout(5000); | |||
// 建立实际的连接 | |||
connection.connect(); | |||
// 定义 BufferedReader输入流来读取URL的响应 | |||
in = new BufferedReader(new InputStreamReader(connection.getInputStream())); | |||
StringBuffer sb = new StringBuffer(); | |||
String line; | |||
while ((line = in.readLine()) != null) { | |||
sb.append(line); | |||
} | |||
return sb.toString(); | |||
}catch (Exception e) { | |||
throw new RuntimeException(e); | |||
} | |||
// 使用finally块来关闭输入流 | |||
finally { | |||
try { | |||
if (in != null) { | |||
in.close(); | |||
} | |||
} catch (Exception e2) { | |||
e2.printStackTrace(); | |||
} | |||
} | |||
} | |||
} |
@@ -14,13 +14,17 @@ tuoheng: | |||
# 视频域名 | |||
video-url: http://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 8eb26a06684d34501e5a56dcc2f5af15 | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 | |||
accessKeySecret: yPPCyfsqWgrTuoz5H4sisY0COclx8E | |||
roleArn: acs:ram::1399733914954856:role/ramosstest | |||
bucketName: ta-tech-image | |||
#全名护河小程序 | |||
wx: | |||
appId: wxd0f247d7272ca1b7 | |||
appSecret: 541002e33cd4b011d4c13954ed34efdb | |||
spring: | |||
# 配置数据源 |
@@ -8,13 +8,13 @@ server: | |||
# 自定义配置 | |||
tuoheng: | |||
# 图片域名 | |||
image-url: http://localhost:9056/api | |||
image-url: http://localhost:9056/api/ | |||
# OSS域名 | |||
oss-url: https://ta-tech-image.oss-cn-shanghai.aliyuncs.com | |||
# 视频域名 | |||
video-url: http://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 8eb26a06684d34501e5a56dcc2f5af15 | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
#阿里云 | |||
aliyuncsVod: | |||
@@ -22,6 +22,10 @@ aliyuncsVod: | |||
accessKeySecret: yPPCyfsqWgrTuoz5H4sisY0COclx8E | |||
roleArn: acs:ram::1399733914954856:role/ramosstest | |||
bucketName: ta-tech-image | |||
#全名护河小程序 | |||
wx: | |||
appId: wxd0f247d7272ca1b7 | |||
appSecret: 541002e33cd4b011d4c13954ed34efdb | |||
spring: | |||
# 配置数据源 | |||
@@ -30,7 +34,7 @@ spring: | |||
type: com.alibaba.druid.pool.DruidDataSource | |||
driver-class-name: com.mysql.cj.jdbc.Driver | |||
# 填写你数据库的url、登录名、密码和数据库名 | |||
url: jdbc:mysql://192.168.11.242:3306/tuoheng_hhz?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false | |||
url: jdbc:mysql://192.168.11.13:3306/tuoheng_hhz?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false | |||
username: root | |||
password: idontcare | |||
druid: |
@@ -14,13 +14,17 @@ tuoheng: | |||
# 视频域名 | |||
video-url: https://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 8eb26a06684d34501e5a56dcc2f5af15 | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 | |||
accessKeySecret: yPPCyfsqWgrTuoz5H4sisY0COclx8E | |||
roleArn: acs:ram::1399733914954856:role/ramosstest | |||
bucketName: ta-tech-image | |||
#全名护河小程序 | |||
wx: | |||
appId: wxd0f247d7272ca1b7 | |||
appSecret: 541002e33cd4b011d4c13954ed34efdb | |||
spring: | |||
# 配置数据源 |
@@ -14,13 +14,17 @@ tuoheng: | |||
# 视频域名 | |||
video-url: http://vod.play.t-aaron.com/ | |||
# 高德Key | |||
gaodeKey: 8eb26a06684d34501e5a56dcc2f5af15 | |||
gaodeKey: 5a1f63e7563cba471a9d0773e218144a | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 | |||
accessKeySecret: yPPCyfsqWgrTuoz5H4sisY0COclx8E | |||
roleArn: acs:ram::1399733914954856:role/ramosstest | |||
bucketName: ta-tech-image | |||
#全名护河小程序 | |||
wx: | |||
appId: wxd0f247d7272ca1b7 | |||
appSecret: 541002e33cd4b011d4c13954ed34efdb | |||
spring: | |||
# 配置数据源 |
@@ -28,6 +28,16 @@ public class CommonConfig { | |||
*/ | |||
public static String gaodeKey; | |||
/** | |||
* 小程序 appId | |||
*/ | |||
public static String appId; | |||
/** | |||
* 小程序 appSecret | |||
*/ | |||
public static String appSecret; | |||
/** | |||
* 图片域名赋值 | |||
* | |||
@@ -68,4 +78,24 @@ public class CommonConfig { | |||
gaodeKey = key; | |||
} | |||
/** | |||
* 小程序 appId赋值 | |||
* | |||
* @param id 小程序 appId | |||
*/ | |||
@Value("${wx.appId}") | |||
public void setAppId(String id) { | |||
appId = id; | |||
} | |||
/** | |||
* 小程序 appSecret赋值 | |||
* | |||
* @param secret 小程序 appSecret | |||
*/ | |||
@Value("${wx.appSecret}") | |||
public void setAppSecret(String secret) { | |||
appSecret = secret; | |||
} | |||
} |