@@ -48,6 +48,26 @@ public class CommonConfig { | |||
*/ | |||
public static String airportURL; | |||
/** | |||
* 小程序url | |||
*/ | |||
public static String wechatURL; | |||
/** | |||
* 小程序 appId | |||
*/ | |||
public static String appId; | |||
/** | |||
* 小程序 appSecret | |||
*/ | |||
public static String appSecret; | |||
/** | |||
* 主题id | |||
*/ | |||
public static String templateId; | |||
/** | |||
* 图片域名赋值 | |||
* | |||
@@ -125,4 +145,44 @@ public class CommonConfig { | |||
airportURL = url; | |||
} | |||
/** | |||
* 小程序url | |||
* | |||
* @param url | |||
*/ | |||
@Value("${tuoheng.wechat-url}") | |||
public void wechatURL(String url) { | |||
wechatURL = url; | |||
} | |||
/** | |||
* 小程序 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; | |||
} | |||
/** | |||
* 小程序 templateId赋值 | |||
* | |||
* @param tempId | |||
*/ | |||
@Value("${wx.templateId}") | |||
public void setTemplateId(String tempId) { | |||
templateId = tempId; | |||
} | |||
} |
@@ -0,0 +1,23 @@ | |||
-- 2024-12-03 14:30 | |||
-- v1.3.6 | |||
use tuoheng_freeway; | |||
-- 用户授权表 | |||
create table th_user_authorize | |||
( | |||
id varchar(36) not null comment 'ID' primary key, | |||
user_id varchar(36) null comment '用户id', | |||
open_id varchar(150) default '' not null comment '授权openid', | |||
access_token varchar(500) default '' null comment 'accesstoken值', | |||
create_user varchar(36) default '0' null comment '添加人', | |||
union_id varchar(150) null comment '唯一标识', | |||
create_time datetime null comment '创建时间', | |||
update_user varchar(36) default '0' null comment '更新人', | |||
update_time datetime null comment '更新时间', | |||
mark tinyint unsigned default '1' not null comment '有效标识' | |||
) comment '用户授权表'; | |||
-- 用户表 | |||
alter table tuoheng_freeway.th_user add authorize tinyint(1) default 1 not null comment '授权标识:1未授权 2授权' after status; | |||
alter table tuoheng_freeway.th_user add subscribe_times tinyint(1) default 1 not null comment '订阅次数 1:订阅一次 2非一次订阅' after authorize; |
@@ -15,14 +15,20 @@ public interface SystemConstant { | |||
String PLATFORM_CODE = "gs"; | |||
/** | |||
* 机场平台:获取航点文件坐标 | |||
* 高德url地址 | |||
*/ | |||
String API_AIRPORT_LOCATION = "/airportInterface/getLocationById"; | |||
String GAO_DE_URL = "https://restapi.amap.com/v3/geocode/regeo"; | |||
/** | |||
* 高德url地址 | |||
* 推送微信消息 | |||
*/ | |||
String GAO_DE_URL = "https://restapi.amap.com/v3/geocode/regeo"; | |||
String API_WEIXIN_SEND_MESSAGE = "/telecomumale/miniprogram/weiXin/send/message"; | |||
/** | |||
* 机场平台:获取航点文件坐标 | |||
*/ | |||
String API_AIRPORT_LOCATION = "/airportInterface/getLocationById"; | |||
/** | |||
* 机场平台:获取机场列表接口 |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.admin.entity; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
@@ -128,4 +129,7 @@ public class Tenant extends BaseEntity implements Serializable { | |||
*/ | |||
private String portraitUrl; | |||
@TableField(exist = false) | |||
private Integer flag; | |||
} |
@@ -231,4 +231,7 @@ public class User implements Serializable { | |||
* 数据权限:1:查看所有部门数据;2:查看本部门及子部门;3:查看本部门数据; | |||
*/ | |||
private Integer dataPermission; | |||
@TableField(exist = false) | |||
private Integer flag; | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.tuoheng.admin.service.third.dsp; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import cn.hutool.core.util.RandomUtil; | |||
import com.alibaba.fastjson.JSON; | |||
@@ -62,6 +63,9 @@ public class DspCallbackServiceImpl implements IDspCallbackService { | |||
@Autowired | |||
private IAccidentService accidentService; | |||
@Autowired | |||
private NoticeWeChatMiniProgramService noticeWeChatMiniProgramService; | |||
/** | |||
* 保存DSP回调数据 | |||
* | |||
@@ -282,10 +286,27 @@ public class DspCallbackServiceImpl implements IDspCallbackService { | |||
return inspectionFile; | |||
}).collect(Collectors.toList()); | |||
// 先判断是否第一次生成问题,通过问题表中是否有数据来判断 | |||
Integer count = inspectionFileMapper.selectCount(new LambdaQueryWrapper<InspectionFile>() | |||
.eq(InspectionFile::getInspectionId, inspection.getId()) | |||
.eq(InspectionFile::getMark, MarkEnum.VALID.getCode())); | |||
Map<String, QuestionType> questionTypeMap = getStringQuestionTypeMap(); | |||
// 通知小程序 | |||
if (count <= 0) { | |||
log.info("该任务第一次产生问题,通知小程序, inspectionId={}", inspection.getId()); | |||
// 该任务第一次产生问题,通知小程序 | |||
if (CollectionUtil.isNotEmpty(thirstyQuestionFiles) && thirstyQuestionFiles.size() > 0) { | |||
InspectionFile inspectionFile = thirstyQuestionFiles.get(0); | |||
QuestionType questionType = questionTypeMap.get(inspectionFile.getQuestionCode()); | |||
noticeWeChatMiniProgramService.notice(inspection, questionType); | |||
} | |||
} | |||
log.info("批量插入问题图片数据"); | |||
CommonUtils.batchOperate((x) -> inspectionFileMapper.addBatch(x), thirstyQuestionFiles, 1000); | |||
log.info("调用saveAccidentData方法保存应急记录数据..."); | |||
Boolean flag = this.saveAccidentData(thirstyQuestionFiles); |
@@ -0,0 +1,53 @@ | |||
package com.tuoheng.admin.service.third.dsp; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.admin.constant.SystemConstant; | |||
import com.tuoheng.admin.entity.Inspection; | |||
import com.tuoheng.admin.entity.QuestionType; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.exception.ServiceException; | |||
import com.tuoheng.common.core.utils.*; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
@Slf4j | |||
@Service | |||
public class NoticeWeChatMiniProgramService { | |||
/** | |||
* 通知微信小程序 | |||
* | |||
* @param inspection | |||
* @param questionType | |||
* @return | |||
*/ | |||
@Transactional | |||
public void notice(Inspection inspection, QuestionType questionType) { | |||
log.info("任务发现第一个问题,推送给微信小程序:inspection:{}, questionType:{}", inspection.getId(), questionType); | |||
String url = CommonConfig.wechatURL + SystemConstant.API_WEIXIN_SEND_MESSAGE; | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("tenantId", inspection.getTenantId()); | |||
jsonObject.put("deptId", inspection.getDeptId()); | |||
jsonObject.put("inspectionId", inspection.getId()); | |||
jsonObject.put("questionName", inspection.getName()); | |||
jsonObject.put("questionDesc", questionType.getContent()); | |||
jsonObject.put("createTime", DateUtils.dateTimeNow("yyyy-MM-dd HH:mm:ss")); | |||
log.info("任务发现第一个问题,推送给微信小程序:url:{}", url); | |||
log.info("任务发现第一个问题,推送给微信小程序:jsonObject:{}", jsonObject); | |||
String airPortStr = HttpUtils.doSend(url, jsonObject, null, "POST"); | |||
if (StringUtils.isEmpty(airPortStr)) { | |||
log.info("任务发现第一个问题,推送给微信小程序:返回数据为空"); | |||
throw new com.aliyun.oss.ServiceException("微信小程序返回数据为空"); | |||
} | |||
JsonResult jsonResult = JacksonUtil.json2pojo(airPortStr, JsonResult.class); | |||
if (0 != jsonResult.getCode()) { | |||
log.info("任务发现第一个问题,推送给微信小程序:返回失败,jsonResult:{}", jsonResult.getMsg()); | |||
throw new ServiceException("推送给微信小程序,返回失败"); | |||
} | |||
log.info("任务发现第一个问题,推送给微信小程序:成功,inspection:{}, questionType:{}", inspection.getId(), questionType); | |||
} | |||
} |
@@ -8,8 +8,8 @@ import com.tuoheng.admin.entity.Role; | |||
import com.tuoheng.admin.entity.Tenant; | |||
import com.tuoheng.admin.entity.User; | |||
import com.tuoheng.admin.enums.ClientEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.enums.DataPermissionEnum; | |||
import com.tuoheng.admin.enums.MarkEnum; | |||
import com.tuoheng.admin.mapper.RoleMapper; | |||
import com.tuoheng.admin.mapper.TenantMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
@@ -58,14 +58,14 @@ public class AddOidcTenantService { | |||
// return result; | |||
//} | |||
result = this.addTenant(tenant); | |||
result = this.editTenant(tenant); | |||
if (0 != result.getCode()) { | |||
log.info("创建租户业务:添加租户失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
user.setTenantId(tenant.getId()); | |||
result = this.addUser(user); | |||
result = this.editUser(user); | |||
if (0 != result.getCode()) { | |||
log.info("创建租户业务:添加用户失败:{}", result.getMsg()); | |||
return result; | |||
@@ -115,28 +115,50 @@ public class AddOidcTenantService { | |||
} | |||
private Tenant buildTenant(CreateOidcTenantRequest request) { | |||
// 创建租户数据 | |||
Tenant tenant = new Tenant(); | |||
tenant.setCode(request.getTenantCode()); | |||
tenant.setUsername(request.getUsername()); | |||
tenant.setName(request.getTenantName()); | |||
Tenant tenant = tenantMapper.selectOne(Wrappers.<Tenant>lambdaQuery().eq(Tenant::getUsername, request.getUsername())); | |||
if (ObjectUtil.isEmpty(tenant)) { | |||
// 创建租户数据 | |||
tenant = new Tenant(); | |||
tenant.setCode(request.getTenantCode()); | |||
tenant.setUsername(request.getUsername()); | |||
tenant.setName(request.getTenantName()); | |||
tenant.setProvinceCode(request.getProvinceCode()); | |||
tenant.setProvinceName(request.getProvinceName()); | |||
tenant.setDistrictCode(request.getDistrictCode()); | |||
tenant.setDistrictName(request.getDistrictName()); | |||
tenant.setCityCode(request.getCityCode()); | |||
tenant.setCityName(request.getCityName()); | |||
tenant.setFlag(1); | |||
return tenant; | |||
} | |||
tenant.setProvinceCode(request.getProvinceCode()); | |||
tenant.setProvinceName(request.getProvinceName()); | |||
tenant.setDistrictCode(request.getDistrictCode()); | |||
tenant.setDistrictName(request.getDistrictName()); | |||
tenant.setCityCode(request.getCityCode()); | |||
tenant.setCityName(request.getCityName()); | |||
tenant.setFlag(0); | |||
return tenant; | |||
} | |||
/** | |||
* 添加租户 | |||
*/ | |||
private JsonResult addTenant(Tenant tenant) { | |||
Integer count = tenantMapper.insert(tenant); | |||
if (count <= 0) { | |||
log.info("创建租户失败"); | |||
JsonResult.error("创建租户失败"); | |||
private JsonResult editTenant(Tenant tenant) { | |||
if (1 == tenant.getFlag()) { | |||
Integer count = tenantMapper.insert(tenant); | |||
if (count <= 0) { | |||
log.info("创建租户失败"); | |||
JsonResult.error("创建租户失败"); | |||
} | |||
} else if (0 == tenant.getFlag()) { | |||
tenant.setMark(1); | |||
Integer count = tenantMapper.updateById(tenant); | |||
if (count <= 0) { | |||
log.info("更新租户失败"); | |||
JsonResult.error("更新租户失败"); | |||
} | |||
} | |||
return JsonResult.success(tenant); | |||
} | |||
@@ -145,28 +167,41 @@ public class AddOidcTenantService { | |||
* 构建实体字段数据 | |||
*/ | |||
private User buildUser(CreateOidcTenantRequest request) { | |||
// 创建用户数据 | |||
User user = new User(); | |||
user.setCode(request.getTenantCode()); | |||
user.setUsername(request.getUsername()); | |||
user.setRealname(request.getTenantName()); | |||
user.setNickname(request.getTenantName()); | |||
user.setPassword(CommonUtils.password(request.getPassword())); | |||
user.setProvinceCode(request.getProvinceCode()); | |||
user.setCityCode(request.getCityCode()); | |||
user.setCityName(request.getCityName()); | |||
user.setDistrictCode(request.getDistrictCode()); | |||
user.setAvatar("imagedir/n1o1j9ndau_1670488066287.png"); | |||
User user = userMapper.selectOne(Wrappers.<User>lambdaQuery().eq(User::getUsername, request.getUsername())); | |||
if (ObjectUtil.isEmpty(user)) { | |||
// 创建用户数据 | |||
user = new User(); | |||
user.setCode(request.getTenantCode()); | |||
user.setUsername(request.getUsername()); | |||
user.setRealname(request.getTenantName()); | |||
user.setNickname(request.getTenantName()); | |||
user.setPassword(CommonUtils.password(request.getPassword())); | |||
user.setProvinceCode(request.getProvinceCode()); | |||
user.setCityCode(request.getCityCode()); | |||
user.setCityName(request.getCityName()); | |||
user.setDistrictCode(request.getDistrictCode()); | |||
user.setAvatar("imagedir/n1o1j9ndau_1670488066287.png"); | |||
for (ClientRoleDto clientRoleDto : request.getClientRoleDtoList()) { | |||
log.info("请求参数:{}", clientRoleDto); | |||
if (clientRoleDto.getClientId().contains("waterway")) { | |||
user.setRoleId(clientRoleDto.getRoleId()); | |||
user.setClientId("1,2"); | |||
} | |||
} | |||
user.setDeptId(""); | |||
user.setStatus(1); | |||
user.setCreateTime(DateUtils.now()); | |||
user.setFlag(1); | |||
return user; | |||
} | |||
for (ClientRoleDto clientRoleDto : request.getClientRoleDtoList()) { | |||
log.info("请求参数:{}", clientRoleDto); | |||
if (clientRoleDto.getClientId().contains("freeway")) { | |||
if (clientRoleDto.getClientId().contains("waterway")) { | |||
user.setRoleId(clientRoleDto.getRoleId()); | |||
user.setClientId("1,2"); | |||
user.setClientId(clientRoleDto.getClientId()); | |||
} | |||
} | |||
user.setDeptId(""); | |||
user.setStatus(1); | |||
user.setCreateTime(DateUtils.now()); | |||
user.setFlag(0); | |||
return user; | |||
} | |||
@@ -192,28 +227,21 @@ public class AddOidcTenantService { | |||
/** | |||
* 添加用户 | |||
*/ | |||
private JsonResult addUser(User user) { | |||
User userTmp = userMapper.selectOne(Wrappers.<User>lambdaQuery() | |||
.eq(User::getMark, 1) | |||
.eq(User::getStatus, 1) | |||
.eq(User::getUsername, user.getUsername())); | |||
if (ObjectUtil.isNotNull(userTmp)) { | |||
log.info("创建租户用户,用户已存在,username:{}", user.getUsername()); | |||
return JsonResult.error("创建租户用户,用户已存在"); | |||
} | |||
// 如果顶级部门存在,将该超级管理员与顶级部门关联 | |||
// Dept dept = deptMapper.selectOne(Wrappers.<Dept>lambdaQuery() | |||
// .eq(Dept::getMark, 1) | |||
// .eq(Dept::getTenantId, user.getTenantId()) | |||
// .eq(Dept::getPid, SystemConstant.ROOT_DEPT_PID)); | |||
// if (ObjectUtil.isNotNull(dept)) { | |||
// user.setDeptId(dept.getId()); | |||
// } | |||
Integer rowCount = userMapper.insert(user); | |||
if (rowCount <= 0) { | |||
log.info("创建租户用户失败,username:{}", user.getUsername()); | |||
return JsonResult.error("创建租户用户失败"); | |||
private JsonResult editUser(User user) { | |||
if (1 == user.getFlag()) { | |||
Integer rowCount = userMapper.insert(user); | |||
if (rowCount <= 0) { | |||
log.info("创建租户用户失败,username:{}", user.getUsername()); | |||
return JsonResult.error("创建租户用户失败"); | |||
} | |||
} else if (0 == user.getFlag()) { | |||
user.setMark(1); | |||
Integer rowCount = userMapper.updateById(user); | |||
if (rowCount <= 0) { | |||
log.info("更新用户失败,username:{}", user.getUsername()); | |||
return JsonResult.error("更新用户失败"); | |||
} | |||
} | |||
return JsonResult.success(); | |||
} |
@@ -146,6 +146,8 @@ tuoheng: | |||
#airport配置地址 | |||
#airport-url: http://192.168.11.22:9060 | |||
airport-url: http://192.168.11.11:7011/airport/admin | |||
#小程序配置地址 | |||
wechat-url: http://192.168.11.11:9119 | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 | |||
@@ -155,6 +157,11 @@ tuoheng: | |||
#静态资源实际存储路径 | |||
uploadFolder: /data/java/tuoheng_freeway/uploads/ | |||
wx: | |||
appId: wx8e25cc4a7eec55c6 | |||
appSecret: ff104538eb568d0d99405638e35af8ad | |||
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 |
@@ -152,9 +152,9 @@ tuoheng: | |||
#飞手平台地址 | |||
pilot-url: http://192.168.11.241:7011/pilot/web/ | |||
#airport配置地址 | |||
# airport-url: http://192.168.11.11:7011/airport/admin | |||
# airport测试环境地址 | |||
airport-url: https://airport-test.t-aaron.com/airport/admin | |||
airport-url: http://192.168.11.11:7011/airport/admin | |||
#小程序配置地址 | |||
wechat-url: http://192.168.11.11:9119 | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 | |||
@@ -164,6 +164,12 @@ tuoheng: | |||
#静态资源实际存储路径 | |||
uploadFolder: /data/java/tuoheng_freeway/uploads/ | |||
wx: | |||
appId: wx8e25cc4a7eec55c6 | |||
appSecret: ff104538eb568d0d99405638e35af8ad | |||
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 |
@@ -146,6 +146,8 @@ tuoheng: | |||
pilot-url: https://pilot.t-aaron.com/pilot/web/ | |||
#airport配置地址 | |||
airport-url: https://airport.t-aaron.com/airport/admin | |||
#小程序配置地址 | |||
wechat-url: https://freeway-miniprogram.t-aaron.com | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 | |||
@@ -155,6 +157,11 @@ tuoheng: | |||
#静态资源实际存储路径 | |||
uploadFolder: /data/java/tuoheng_freeway/uploads/ | |||
wx: | |||
appId: wx8e25cc4a7eec55c6 | |||
appSecret: ff104538eb568d0d99405638e35af8ad | |||
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 |
@@ -146,6 +146,8 @@ tuoheng: | |||
pilot-url: http://172.15.1.11:7011/pilot/web/ | |||
#airport配置地址 | |||
airport-url: https://airport-test.t-aaron.com/airport/admin | |||
#小程序配置地址 | |||
wechat-url: https://freeway-miniprogram-test.t-aaron.com | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 | |||
@@ -155,6 +157,11 @@ tuoheng: | |||
#静态资源实际存储路径 | |||
uploadFolder: /data/java/tuoheng_freeway/uploads/ | |||
wx: | |||
appId: wx8e25cc4a7eec55c6 | |||
appSecret: ff104538eb568d0d99405638e35af8ad | |||
templateId: _7WZK-DEsBk4goXP2jThDk0u606Nz0YQBXWkej6BJfg | |||
#阿里云 | |||
aliyuncsVod: | |||
accessKeyId: LTAI5tE7KWN9fsuGU7DyfYF4 |
@@ -0,0 +1,35 @@ | |||
package com.tuoheng.miniprogram.controller; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.miniprogram.entity.wx.WxMessageRequest; | |||
import com.tuoheng.miniprogram.service.IWxService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/23 | |||
*/ | |||
@RestController | |||
@Slf4j | |||
@RequestMapping("/weiXin") | |||
public class WxController { | |||
@Autowired | |||
private IWxService iWxService; | |||
//根据code获取openId | |||
@GetMapping("/getOpenId/{code}") | |||
public JsonResult getOpenId(@PathVariable("code") String code) { | |||
log.info("进入获取openId接口"); | |||
return iWxService.openid(code); | |||
} | |||
@PostMapping("/send/message") | |||
public JsonResult sendMessage(@RequestBody WxMessageRequest wxMessageRequest) { | |||
log.info("进入发送消息接口,WxMessageRequest={}", wxMessageRequest); | |||
return iWxService.sendMessage(wxMessageRequest); | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.tuoheng.miniprogram.dao; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.miniprogram.entity.UserAuthorize; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/26 | |||
*/ | |||
public interface UserAuthorizeMapper extends BaseMapper<UserAuthorize> { | |||
} |
@@ -233,4 +233,14 @@ public class User implements Serializable { | |||
* 数据权限:1:查看所有部门数据;2:查看本部门及子部门;3:查看本部门数据; | |||
*/ | |||
private Integer dataPermission; | |||
/** | |||
* 微信授权标识 1:未授权 2授权 | |||
*/ | |||
private Integer authorize; | |||
/** | |||
* 订阅次数 1:订阅一次 2非一次订阅 | |||
*/ | |||
private Integer subscribeTimes; | |||
} |
@@ -0,0 +1,40 @@ | |||
package com.tuoheng.miniprogram.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.tuoheng.common.core.common.BaseEntity; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2022/11/16 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@Accessors(chain = true) | |||
@TableName("th_user_authorize") | |||
public class UserAuthorize extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 用户id | |||
*/ | |||
private String userId; | |||
/** | |||
* 用户的openId | |||
*/ | |||
private String openId; | |||
/** | |||
* 唯一标识 | |||
*/ | |||
private String unionId; | |||
/** | |||
* accessToken值(先不存) | |||
*/ | |||
private String accessToken; | |||
} |
@@ -0,0 +1,20 @@ | |||
package com.tuoheng.miniprogram.entity.dto; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/23 | |||
*/ | |||
@Data | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
public class TemplateMinDto { | |||
/** | |||
* 填充信息 | |||
*/ | |||
private String value; | |||
} |
@@ -0,0 +1,46 @@ | |||
package com.tuoheng.miniprogram.entity.wx; | |||
import lombok.Data; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/26 | |||
*/ | |||
@Data | |||
public class WxMessageRequest { | |||
/** | |||
* 任务id | |||
*/ | |||
private String inspectionId; | |||
/** | |||
* 部门id | |||
*/ | |||
private String deptId; | |||
/** | |||
* 问题id | |||
*/ | |||
private String questionId; | |||
/** | |||
* 租户id | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 上报时间 | |||
*/ | |||
private String createTime; | |||
/** | |||
*问题标题 | |||
*/ | |||
private String questionName; | |||
/** | |||
* 问题描述 | |||
*/ | |||
private String questionDesc; | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.tuoheng.miniprogram.enums; | |||
import lombok.Getter; | |||
/** | |||
* 任务状态枚举 | |||
*/ | |||
public enum AuthorizeStatusEnum { | |||
//1未授权 2授权 | |||
AUTHORIZE_DOWN(1,"未授权"), | |||
AUTHORIZE_ON(2,"授权"); | |||
AuthorizeStatusEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.tuoheng.miniprogram.enums; | |||
import lombok.Getter; | |||
/** | |||
* 任务状态枚举 | |||
*/ | |||
public enum SubscribeTimesEnum { | |||
//1未授权 2授权 | |||
SUBSCRIBE_TIMES_ONE(1,"订阅一次"), | |||
SUBSCRIBE_TIMES_NO_ONE(2,"非一次订阅"); | |||
SubscribeTimesEnum(int code, String description){ | |||
this.code = code; | |||
this.description = description; | |||
} | |||
@Getter | |||
private int code; | |||
@Getter | |||
private String description; | |||
} |
@@ -0,0 +1,39 @@ | |||
package com.tuoheng.miniprogram.enums; | |||
public enum UserAuthorizeEnum { | |||
UNAUTHORIZED(10001, "用户未授权"), | |||
OPEN_ID_IS_NULL(10002, "openId为空"); | |||
/** | |||
* 标识码 | |||
*/ | |||
private Integer code; | |||
/** | |||
* 描述 | |||
*/ | |||
private String msg; | |||
UserAuthorizeEnum(Integer code, String msg) { | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public void setCode(Integer code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
package com.tuoheng.miniprogram.enums; | |||
/** | |||
* 获取子部门列表返回码 | |||
* 模块代码:20(部门管理) | |||
* 接口代码:06 (获取子部门列表) | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-11-22 | |||
*/ | |||
public enum WeiXinRequestEnum { | |||
INSPECTION_ID_IS_NULL(120010, "任务id为空"), | |||
DEPT_ID_IS_NULL(120011, "问题id为空"), | |||
TENANT_ID_NOT_EXIST(120012, "租户id为空"), | |||
CREATE_TIME_IS_NULL(120013, "上报时间为空"), | |||
INSPECTION_NAME_NOT_EXIST(120014, "问题标题不存在"), | |||
QUESTION_DESC_NOT_EXIST(120015, "问题标题不存在"); | |||
/** | |||
* 错误码 | |||
*/ | |||
private int code; | |||
/** | |||
* 错误信息 | |||
*/ | |||
private String msg; | |||
WeiXinRequestEnum(int code, String msg){ | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public void setCode(int code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
package com.tuoheng.miniprogram.param; | |||
import com.tuoheng.miniprogram.entity.dto.TemplateMinDto; | |||
import lombok.Data; | |||
import java.util.Map; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/23 | |||
*/ | |||
@Data | |||
public class WxSendMessageParam { | |||
/** | |||
* 接收者openId | |||
*/ | |||
private String touser; | |||
/** | |||
* 订阅模板id | |||
*/ | |||
private String template_id; | |||
/** | |||
* 点击模板卡片跳转页面 | |||
*/ | |||
private String page; | |||
/** | |||
* 跳转小程序类型 developer为开发版;trial为体验版;formal为正式版;默认为正式版 | |||
*/ | |||
//private String miniprogram_state; | |||
/** | |||
* 填充信息 | |||
*/ | |||
private Map<String, TemplateMinDto> data; | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.miniprogram.service; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.miniprogram.entity.wx.WxMessageRequest; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/23 | |||
*/ | |||
public interface IWxService { | |||
/** | |||
* 根据code获取openId | |||
* @param code | |||
* @return | |||
*/ | |||
JsonResult openid(String code); | |||
/** | |||
* 发送消息 | |||
* @param wxMessageRequest | |||
* @return | |||
*/ | |||
JsonResult sendMessage(WxMessageRequest wxMessageRequest); | |||
} |
@@ -0,0 +1,274 @@ | |||
package com.tuoheng.miniprogram.service.impl; | |||
import cn.hutool.core.collection.CollectionUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.tuoheng.common.core.config.common.CommonConfig; | |||
import com.tuoheng.common.core.utils.DateUtils; | |||
import com.tuoheng.common.core.utils.JsonResult; | |||
import com.tuoheng.common.core.utils.StringUtils; | |||
import com.tuoheng.miniprogram.dao.UserAuthorizeMapper; | |||
import com.tuoheng.miniprogram.dao.UserMapper; | |||
import com.tuoheng.miniprogram.entity.User; | |||
import com.tuoheng.miniprogram.entity.UserAuthorize; | |||
import com.tuoheng.miniprogram.entity.dto.TemplateMinDto; | |||
import com.tuoheng.miniprogram.entity.wx.WxMessageRequest; | |||
import com.tuoheng.miniprogram.enums.*; | |||
import com.tuoheng.miniprogram.param.WxSendMessageParam; | |||
import com.tuoheng.miniprogram.service.IWxService; | |||
import com.tuoheng.miniprogram.utils.CurrentUserUtil; | |||
import com.tuoheng.miniprogram.utils.GetOpenIdUtil; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.http.ResponseEntity; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.client.RestClientException; | |||
import org.springframework.web.client.RestTemplate; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Objects; | |||
/** | |||
* @Author ChengWang | |||
* @Date 2023/6/23 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class WxServiceImpl implements IWxService { | |||
@Autowired | |||
private UserAuthorizeMapper userAuthorizeMapper; | |||
@Autowired | |||
private UserMapper userMapper; | |||
private static String accessToken; | |||
private static long expiresTime; | |||
/** | |||
* 根据code获取openId | |||
* | |||
* @param code | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult openid(String code) { | |||
String userId = CurrentUserUtil.getUserId(); | |||
String openidResult = GetOpenIdUtil.getopenid(code, CommonConfig.appId, CommonConfig.appSecret); | |||
if (null != JSONObject.parseObject(openidResult).getInteger("errcode") || | |||
StringUtils.isNotEmpty(JSONObject.parseObject(openidResult).getString("errmsg"))) { | |||
return JsonResult.error(JSONObject.parseObject(openidResult).getInteger("errcode").intValue(), | |||
JSONObject.parseObject(openidResult).getString("errmsg")); | |||
} | |||
String openid = JSONObject.parseObject(openidResult).getString("openid"); | |||
if (StringUtils.isEmpty(openid)) { | |||
log.error("获取openid失败:", openidResult); | |||
return JsonResult.error("获取openid失败"); | |||
} | |||
//根据当前登录用户id查询授权表是否存在一条授权数据 | |||
UserAuthorize beforeUserAuthorize = userAuthorizeMapper.selectOne(Wrappers.<UserAuthorize>lambdaQuery() | |||
.eq(UserAuthorize::getUserId, userId) | |||
.eq(UserAuthorize::getMark, MarkEnum.VALID.getCode())); | |||
if (ObjectUtil.isNull(beforeUserAuthorize)) { | |||
UserAuthorize userAuthorize = new UserAuthorize(); | |||
if (StringUtils.isNotEmpty(openid)) { | |||
//查询出来openId数据入库 | |||
userAuthorize.setOpenId(openid); | |||
} | |||
userAuthorize.setUserId(userId); | |||
userAuthorize.setCreateTime(DateUtils.now()); | |||
if (StringUtils.isNotEmpty(userId)) { | |||
userAuthorize.setCreateUser(userId); | |||
} | |||
int result = userAuthorizeMapper.insert(userAuthorize); | |||
if (result <= 0) { | |||
return JsonResult.error("授权数据入库失败"); | |||
} | |||
} | |||
//关联登录用户,已经做过授权 修改授权标识 | |||
User user = CurrentUserUtil.getUserInfo(); | |||
if (ObjectUtil.isEmpty(user)) { | |||
return JsonResult.error(UserCodeEnum.USER_IS_NULL.getCode(), UserCodeEnum.USER_IS_NULL.getMsg()); | |||
} | |||
user.setAuthorize(AuthorizeStatusEnum.AUTHORIZE_ON.getCode()); | |||
user.setUpdateTime(DateUtils.now()); | |||
user.setUpdateUser(userId); | |||
int count = userMapper.updateById(user); | |||
if (count <= 0) { | |||
return JsonResult.error("用户授权标识更新失败"); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 获取access_code值 | |||
* | |||
* @return | |||
*/ | |||
public String getAccessToken() { | |||
//判断accessToken是否已经过期,如果国企需要重新获取 | |||
if (accessToken == null || expiresTime < System.currentTimeMillis()) { | |||
RestTemplate restTemplate = new RestTemplate(); | |||
Map<String, String> params = new HashMap<>(2); | |||
params.put("APPID", CommonConfig.appId); | |||
params.put("APPSECRET", CommonConfig.appSecret); | |||
ResponseEntity<String> responseEntity = restTemplate.getForEntity("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={APPID}&secret={APPSECRET}", String.class, params); | |||
String body = responseEntity.getBody(); | |||
JSONObject object = JSON.parseObject(body); | |||
Integer errcode = object.getInteger("errcode"); | |||
if (errcode != null && errcode != 0) { | |||
String errmsg = object.getString("errmsg"); | |||
log.info("请求accessToken失败,返回码:" + errcode + "错误信息:" + errmsg); | |||
throw new RuntimeException("请求获取accessToken失败"); | |||
} | |||
//缓存accessToken | |||
accessToken = object.getString("access_token"); | |||
log.info("获取的accessToken的值:" + accessToken); | |||
//设置accessToken的失效时间 | |||
Long expires_in = object.getLong("expires_in"); | |||
//失效时间 = 当前时间+有效期(提前一分钟,也可以不提前) | |||
expiresTime = System.currentTimeMillis() + (expires_in - 60) * 1000; | |||
} | |||
return accessToken; | |||
} | |||
/** | |||
* 发送消息 | |||
* | |||
* @param wxMessageRequest | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult sendMessage(WxMessageRequest wxMessageRequest) { | |||
wxMessageRequest.setQuestionDesc("发现疑似问题待处理,请及时查看。"); | |||
JsonResult result = this.check(wxMessageRequest); | |||
if (result.getCode() != 0) { | |||
//正常返回,信息提示 | |||
return JsonResult.success(result.getCode(), result.getMsg()); | |||
} | |||
List<User> userList = (List<User>) result.getData(); | |||
boolean isSend = false; | |||
//对用户进行遍历推送消息 | |||
for (User user : userList) { | |||
String userId = user.getId(); | |||
if (user.getAuthorize() == AuthorizeStatusEnum.AUTHORIZE_DOWN.getCode()) { | |||
//本次结束,进入下次循环 | |||
continue; | |||
} | |||
if (user.getAuthorize() == AuthorizeStatusEnum.AUTHORIZE_ON.getCode() | |||
&& user.getSubscribeTimes() == SubscribeTimesEnum.SUBSCRIBE_TIMES_NO_ONE.getCode()) { | |||
continue; | |||
} | |||
//获取当前登录openId | |||
UserAuthorize userAuthorize = userAuthorizeMapper.selectOne(Wrappers.<UserAuthorize>lambdaQuery() | |||
.eq(UserAuthorize::getUserId, userId) | |||
.eq(UserAuthorize::getMark, MarkEnum.VALID.getCode())); | |||
//授权数据校验 | |||
JsonResult jsonResult = this.getUserAuthorize(userAuthorize); | |||
if (jsonResult.getCode() != 0) { | |||
continue; | |||
} | |||
String openId = userAuthorize.getOpenId(); | |||
RestTemplate restTemplate = new RestTemplate(); | |||
//发送消息订阅 | |||
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + getAccessToken(); | |||
WxSendMessageParam param = new WxSendMessageParam(); | |||
param.setPage("/package_question/pages/taskList/taskList"); | |||
//param.setMiniprogram_state("formal"); | |||
param.setTouser(openId); | |||
param.setTemplate_id(CommonConfig.templateId); | |||
Map<String, TemplateMinDto> data = new HashMap<>(3); | |||
//消息模板{{time12.DATA}} {{thing4.DATA}} {{thing13.DATA}} 时间格式一定是这样的2022-01-13 02:31:36 | |||
ResponseEntity<String> responseEntity = null; | |||
try { | |||
data.put("time12", new TemplateMinDto(wxMessageRequest.getCreateTime())); | |||
data.put("thing4", new TemplateMinDto(wxMessageRequest.getQuestionName())); | |||
data.put("thing13", new TemplateMinDto(wxMessageRequest.getQuestionDesc())); | |||
param.setData(data); | |||
responseEntity = restTemplate.postForEntity(url, param, String.class); | |||
String messageBody = responseEntity.getBody(); | |||
Integer errcode = JSONObject.parseObject(messageBody).getInteger("errcode").intValue(); | |||
if (errcode != null && errcode == 0) { | |||
//修改用户订阅次数 | |||
user.setSubscribeTimes(SubscribeTimesEnum.SUBSCRIBE_TIMES_NO_ONE.getCode()); | |||
int count = userMapper.updateById(user); | |||
if (count <= 0) { | |||
throw new RuntimeException("更新用户订阅次数失败"); | |||
} | |||
} else if (errcode != null && errcode != 0) { | |||
String errmsg = JSONObject.parseObject(messageBody).getString("errmsg"); | |||
log.info("请求accessToken失败,返回码:" + errcode.intValue() + "错误信息:" + errmsg); | |||
//return JsonResult.error(errcode.intValue(),errmsg); | |||
} | |||
JSONObject jsonObject = JSON.parseObject(messageBody); | |||
if (Objects.nonNull(jsonObject)) { | |||
log.info("openId:" + openId + "发送消息返回内容:" + jsonObject.toJSONString()); | |||
} | |||
isSend = true; | |||
} catch (RestClientException e) { | |||
log.info("openId:" + openId + "发送消息异常报错:" + e); | |||
e.printStackTrace(); | |||
} | |||
} | |||
return JsonResult.success(isSend); | |||
} | |||
/** | |||
* 校验权限数据 | |||
* | |||
* @param userAuthorize | |||
* @return | |||
*/ | |||
private JsonResult getUserAuthorize(UserAuthorize userAuthorize) { | |||
if (ObjectUtil.isNull(userAuthorize)) { | |||
return JsonResult.error(UserAuthorizeEnum.UNAUTHORIZED.getCode(), UserAuthorizeEnum.UNAUTHORIZED.getMsg()); | |||
} | |||
if (StringUtils.isEmpty(userAuthorize.getOpenId())) { | |||
return JsonResult.error(UserAuthorizeEnum.OPEN_ID_IS_NULL.getCode(), UserAuthorizeEnum.OPEN_ID_IS_NULL.getMsg()); | |||
} | |||
return JsonResult.success(); | |||
} | |||
private JsonResult check(WxMessageRequest wxMessageRequest) { | |||
//传参校验 | |||
if (StringUtils.isEmpty(wxMessageRequest.getTenantId())) { | |||
return JsonResult.error(WeiXinRequestEnum.TENANT_ID_NOT_EXIST.getCode(), WeiXinRequestEnum.TENANT_ID_NOT_EXIST.getMsg()); | |||
} | |||
if (StringUtils.isEmpty(wxMessageRequest.getInspectionId())) { | |||
return JsonResult.error(WeiXinRequestEnum.INSPECTION_ID_IS_NULL.getCode(), WeiXinRequestEnum.INSPECTION_ID_IS_NULL.getMsg()); | |||
} | |||
if (StringUtils.isEmpty(wxMessageRequest.getDeptId())) { | |||
return JsonResult.error(WeiXinRequestEnum.DEPT_ID_IS_NULL.getCode(), WeiXinRequestEnum.DEPT_ID_IS_NULL.getMsg()); | |||
} | |||
if (StringUtils.isEmpty(wxMessageRequest.getCreateTime())) { | |||
return JsonResult.error(WeiXinRequestEnum.CREATE_TIME_IS_NULL.getCode(), WeiXinRequestEnum.CREATE_TIME_IS_NULL.getMsg()); | |||
} | |||
if (StringUtils.isEmpty(wxMessageRequest.getQuestionName())) { | |||
return JsonResult.error(WeiXinRequestEnum.INSPECTION_NAME_NOT_EXIST.getCode(), WeiXinRequestEnum.INSPECTION_NAME_NOT_EXIST.getMsg()); | |||
} | |||
if (StringUtils.isEmpty(wxMessageRequest.getQuestionDesc())) { | |||
return JsonResult.error(WeiXinRequestEnum.QUESTION_DESC_NOT_EXIST.getCode(), WeiXinRequestEnum.QUESTION_DESC_NOT_EXIST.getMsg()); | |||
} | |||
//根据租户id查询用户列表 | |||
List<User> users = userMapper.selectList(Wrappers.<User>lambdaQuery() | |||
.eq(User::getMark, MarkEnum.VALID.getCode()) | |||
.eq(User::getDeptId, wxMessageRequest.getDeptId()) | |||
.eq(User::getStatus, 1)); | |||
if (CollectionUtil.isEmpty(users) || users.size() == 0) { | |||
return JsonResult.error("此部门下没有用户"); | |||
} | |||
return JsonResult.success(users); | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
package com.tuoheng.miniprogram.utils; | |||
import java.io.BufferedReader; | |||
import java.io.InputStreamReader; | |||
import java.net.URL; | |||
import java.net.URLConnection; | |||
/** | |||
* 微信登陆工具类 | |||
*/ | |||
public class GetOpenIdUtil { | |||
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(); | |||
} | |||
} | |||
} | |||
} |
@@ -81,6 +81,8 @@ tuoheng: | |||
pilot-url: http://192.168.11.11:7011/pilot/web/ | |||
#airport配置地址 | |||
airport-url: http://192.168.11.22:9060 | |||
#小程序配置地址 | |||
wechat-url: http://192.168.11.11:9119 | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 | |||
@@ -89,6 +91,13 @@ tuoheng: | |||
staticAccessPath: /** | |||
#静态资源实际存储路径 | |||
uploadFolder: /data/java/tuoheng_freeway/uploads/ | |||
#小程序 | |||
wx: | |||
appId: wxfa4ec86caec22034 | |||
appSecret: dd8411aaa8fcfb251518d5021adb059d | |||
templateId: tOewJK9MXIbfXovwCb72KLpCdBp1spL6pQ2F3LTQkSI | |||
xxl: | |||
enable: true | |||
job: |
@@ -81,6 +81,8 @@ tuoheng: | |||
pilot-url: http://192.168.11.11:7011/pilot/web/ | |||
#airport配置地址 | |||
airport-url: http://192.168.11.22:9060 | |||
#小程序配置地址 | |||
wechat-url: http://192.168.11.11:9119 | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 | |||
@@ -89,6 +91,13 @@ tuoheng: | |||
staticAccessPath: /** | |||
#静态资源实际存储路径 | |||
uploadFolder: /data/java/tuoheng_freeway/uploads/ | |||
#小程序 | |||
wx: | |||
appId: wxfa4ec86caec22034 | |||
appSecret: dd8411aaa8fcfb251518d5021adb059d | |||
templateId: tOewJK9MXIbfXovwCb72KLpCdBp1spL6pQ2F3LTQkSI | |||
xxl: | |||
enable: true | |||
job: |
@@ -81,6 +81,8 @@ tuoheng: | |||
pilot-url: http://192.168.11.11:7011/pilot/web/ | |||
#airport配置地址 | |||
airport-url: https://airport.t-aaron.com/airport/admin | |||
#小程序配置地址 | |||
wechat-url: https://freeway-miniprogram.t-aaron.com | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 | |||
@@ -89,6 +91,13 @@ tuoheng: | |||
staticAccessPath: /** | |||
#静态资源实际存储路径 | |||
uploadFolder: /data/java/tuoheng_freeway/uploads/ | |||
#小程序 | |||
wx: | |||
appId: wxfa4ec86caec22034 | |||
appSecret: dd8411aaa8fcfb251518d5021adb059d | |||
templateId: tOewJK9MXIbfXovwCb72KLpCdBp1spL6pQ2F3LTQkSI | |||
## 配置feign熔断 | |||
#feign: | |||
# circuitbreaker: |
@@ -81,6 +81,8 @@ tuoheng: | |||
pilot-url: http://192.168.11.11:7011/pilot/web/ | |||
#airport配置地址 | |||
airport-url: https://airport-test.t-aaron.com/airport/admin | |||
#小程序配置地址 | |||
wechat-url: https://freeway-miniprogram-test.t-aaron.com | |||
# 文件配置 | |||
uploads: | |||
#上传的服务器上的映射文件夹 | |||
@@ -89,20 +91,13 @@ tuoheng: | |||
staticAccessPath: /** | |||
#静态资源实际存储路径 | |||
uploadFolder: /data/java/tuoheng_freeway/uploads/ | |||
xxl: | |||
enable: true | |||
job: | |||
admin: | |||
addresses: http://172.15.1.11:8110/xxl-job-admin | |||
accessToken: tuoheng | |||
executor: | |||
appname: xxl-job-executor-freeway-miniprogram | |||
address: | |||
ip: | |||
# 多个后台,端口号不能相同 | |||
port: 9991 | |||
logpath: /data/java/logs/xxl-job/jobhandler | |||
logretentiondays: 15 | |||
#小程序 | |||
wx: | |||
appId: wxfa4ec86caec22034 | |||
appSecret: dd8411aaa8fcfb251518d5021adb059d | |||
templateId: tOewJK9MXIbfXovwCb72KLpCdBp1spL6pQ2F3LTQkSI | |||
## 配置feign熔断 | |||
#feign: | |||
# circuitbreaker: |
@@ -0,0 +1,10 @@ | |||
<?xml version="1.0" encoding="UTF-8" ?> | |||
<!DOCTYPE mapper | |||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
<mapper namespace="com.tuoheng.miniprogram.dao.UserAuthorizeMapper"> | |||
</mapper> |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.miniprogram.utils; | |||
import com.alibaba.fastjson.JSONObject; | |||
public class GetOpenIdUtilTest { | |||
public static void main(String[] args) { | |||
System.out.println("start"); | |||
String openidJson = GetOpenIdUtil.getopenid("061pTj0w3j6DaZ23141w3X12aP0pTj04", "wxd0f247d7272ca1b7", "541002e33cd4b011d4c13954ed34efdb"); | |||
System.out.println("openid:" + openidJson); | |||
JSONObject jsonObject = JSONObject.parseObject(openidJson); | |||
String openid = jsonObject.getString("openid"); | |||
System.out.println("openid:" + openid); | |||
System.out.println("end"); | |||
} | |||
} |