Browse Source

20220317

master
zy_Java 3 years ago
parent
commit
ca281657a4
  1. 2
      ptos_tall/src/main/java/com/ccsens/ptos_tall/api/BusinessController.java
  2. 41
      ptos_tall/src/main/java/com/ccsens/ptos_tall/api/TaskController.java
  3. 14
      ptos_tall/src/main/java/com/ccsens/ptos_tall/api/UserController.java
  4. 36
      ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/TaskDto.java
  5. 116
      ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/vo/TaskVo.java
  6. 19
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/ITaskService.java
  7. 4
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java
  8. 93
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/TaskService.java
  9. 63
      ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java
  10. 8
      tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/TaskController.java
  11. 27
      tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/dto/TallTaskDto.java
  12. 9
      tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/vo/TallTaskVo.java
  13. 7
      tall_sdk/src/main/java/com/ccsensptos/tallsdk/service/ITallService.java
  14. 2
      wechatutil/src/main/java/com/ccsens/wechatutil/util/WxConstant.java
  15. 36
      wechatutil/src/main/java/com/ccsens/wechatutil/wxofficial/OfficialAccountSigninUtil.java

2
ptos_tall/src/main/java/com/ccsens/ptos_tall/api/BusinessController.java

@ -108,6 +108,4 @@ public class BusinessController {
log.info("返回accessToken");
return JsonResponse.newInstance().ok(accessToken);
}
}

41
ptos_tall/src/main/java/com/ccsens/ptos_tall/api/TaskController.java

@ -0,0 +1,41 @@
package com.ccsens.ptos_tall.api;
import com.ccsens.ptos_tall.bean.dto.BusinessDto;
import com.ccsens.ptos_tall.bean.dto.TaskDto;
import com.ccsens.ptos_tall.bean.vo.TaskVo;
import com.ccsens.ptos_tall.service.ITaskService;
import com.ccsens.util.JsonResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author
*/
@Api(tags = "任务相关" , description = " ")
@RestController
@RequestMapping("/task")
@Slf4j
public class TaskController {
@Resource
private ITaskService taskService;
@ApiOperation(value = "查找用户在本域所有服务内的所有任务", notes = "")
@RequestMapping(value = "/allTask", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<TaskVo.QueryTask>> queryAllTaskByUserId(@ApiParam @Validated @RequestBody TaskDto.QueryAllTask params) throws Exception{
log.info("查找用户在本域所有服务内的所有任务:{}",params);
List<TaskVo.QueryTask> queryTasks = taskService.queryAllTaskByUserId(params);
log.info("返回用户在本域所有服务内的所有任务");
return JsonResponse.newInstance().ok(queryTasks);
}
}

14
ptos_tall/src/main/java/com/ccsens/ptos_tall/api/UserController.java

@ -93,7 +93,6 @@ public class UserController {
return JsonResponse.newInstance().ok(tokenToUserId);
}
@ApiOperation(value = "通过手机号获取userId",notes = "")
@ApiImplicitParams({
})
@ -103,4 +102,17 @@ public class UserController {
List<String> userIdList = userService.getUserIdByPhone(phoneList);
return JsonResponse.newInstance().ok(userIdList);
}
// @ApiOperation(value = "/修改用户信息", notes = "")
// @ApiImplicitParams({
// })
// @RequestMapping(value = "/userInfo", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
// public JsonResponse<UserVo.WxInfo> updateUserInfo(HttpServletRequest request,
// @ApiParam @RequestBody UserDto.WxInfo userInfo) throws Exception {
// log.info("修改用户信息,{}",userInfo);
// Long currentUserId = Long.valueOf(((Claims) request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS)).getSubject());
// UserVo.WxInfo wxInfo = userService.updateUserInfo(currentUserId, userInfo);
// return JsonResponse.newInstance().ok(wxInfo);
// }
}

36
ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/dto/TaskDto.java

@ -0,0 +1,36 @@
package com.ccsens.ptos_tall.bean.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author
*/
@Data
public class TaskDto {
@Data
@ApiModel("查找用户的所有任务")
public static class QueryAllTask {
@ApiModelProperty("userId")
private Long userId;
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("codes")
private List<String> codes;
@ApiModelProperty("时间基准点 默认当前")
private Long timeNode = System.currentTimeMillis();
@ApiModelProperty("时间颗粒度 默认天")
private int timeUnit = 4;
@ApiModelProperty("0向上查找 1向下查找(默认) 下查包含自己,上查不包含")
private int queryType = 1;
@ApiModelProperty("第几页")
private Integer pageNum = 1;
@ApiModelProperty("每页几条信息")
private Integer pageSize = 10;
}
}

116
ptos_tall/src/main/java/com/ccsens/ptos_tall/bean/vo/TaskVo.java

@ -0,0 +1,116 @@
package com.ccsens.ptos_tall.bean.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author
*/
@Data
public class TaskVo {
@Data
@ApiModel("查看定期任务返回值")
public static class QueryTask{
@ApiModelProperty("任务id(任务分解id)")
private Long id;
@ApiModelProperty("详情id")
private Long detailId;
@ApiModelProperty("任务名")
private String name;
@ApiModelProperty("任务详情")
private String description;
@ApiModelProperty("计划开始时间")
private Long planStart;
@ApiModelProperty("计划时长")
private Long planDuration;
@ApiModelProperty("计划结束时长")
private Long planEnd;
@ApiModelProperty("实际开始时间")
private Long realStart;
@ApiModelProperty("实际时长")
private Long realDuration;
@ApiModelProperty("实际结束时长")
private Long realEnd;
@ApiModelProperty("任务状态 0未开始 1进行中 2暂停中 3已完成")
private int process;
@ApiModelProperty("任务流转策略 -1不跳转 0直接跳转 如果是其他正整数 就是多少毫秒后跳转 ")
private Long skip;
@ApiModelProperty("跳转的任务id")
private Long skipTaskId;
@ApiModelProperty("任务面板")
private PanelInfo panel;
@ApiModelProperty("检查人列表")
private List<CheckerOfTask> checkerList;
@ApiModelProperty("插件")
private List<List<TaskPluginInfo>> plugins;
@ApiModelProperty("项目id")
private Long projectId;
@ApiModelProperty("负责人id")
private Long executorRoleId;
@ApiModelProperty("所属服务的code")
private String businessCode;
@ApiModelProperty("服务的url")
private String businessUrl;
}
@Data
@ApiModel("任务下的检查人")
public static class CheckerOfTask {
@ApiModelProperty("角色id")
private Long roleId;
@ApiModelProperty("名字")
private String name;
}
@Data
@ApiModel("任务面板信息")
public static class PanelInfo{
@ApiModelProperty("背景色")
private String backgroundColor;
@ApiModelProperty("圆角")
private String borderRadius;
@ApiModelProperty("边框")
private String border;
@ApiModelProperty("阴影")
private String shadow;
@ApiModelProperty("宽")
private String width;
@ApiModelProperty("高")
private String height;
@ApiModelProperty("行")
private int row;
@ApiModelProperty("列")
private int col;
}
@Data
@ApiModel("任务下的插件信息")
public static class TaskPluginInfo{
@ApiModelProperty("插件任务关联id")
private Long pluginTaskId;
@ApiModelProperty("插件id")
private Long pluginId;
@ApiModelProperty("插件和服务关联的id")
private Long businessPluginId;
@ApiModelProperty("插件code")
private String pluginCode;
@ApiModelProperty("是否是内置组件 0否 1是")
private Byte inner;
@ApiModelProperty("参数")
private String param;
@ApiModelProperty("行")
private int row;
@ApiModelProperty("列")
private int col;
@ApiModelProperty("跨行")
private int rowspan;
@ApiModelProperty("跨列")
private int colspan;
@ApiModelProperty("插件在时间轴的展示信息")
private String data;
}
}

19
ptos_tall/src/main/java/com/ccsens/ptos_tall/service/ITaskService.java

@ -0,0 +1,19 @@
package com.ccsens.ptos_tall.service;
import com.ccsens.ptos_tall.bean.dto.TaskDto;
import com.ccsens.ptos_tall.bean.vo.TaskVo;
import java.util.List;
/**
* @author
*/
public interface ITaskService {
/**
* 查找用户在服务下的所有任务
* @param params useId和时间等
* @return 返回任务列表
*/
List<TaskVo.QueryTask> queryAllTaskByUserId(TaskDto.QueryAllTask params);
}

4
ptos_tall/src/main/java/com/ccsens/ptos_tall/service/IWxUserService.java

@ -4,6 +4,8 @@ import com.ccsens.ptos_tall.bean.dto.UserDto;
import com.ccsens.ptos_tall.bean.vo.UserVo;
import com.ccsens.wechatutil.bean.dto.wxmini.NoticeDto;
import java.io.IOException;
/**
* @author
*/
@ -21,7 +23,7 @@ public interface IWxUserService {
* 关注公众号并登录
* @param notice 微信返回的信息
*/
String officialLogin(NoticeDto.Notice notice);
String officialLogin(NoticeDto.Notice notice) throws IOException;
/**
* 通过eventKey获取用户信息

93
ptos_tall/src/main/java/com/ccsens/ptos_tall/service/TaskService.java

@ -0,0 +1,93 @@
package com.ccsens.ptos_tall.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.ptos_tall.bean.dto.ProjectDto;
import com.ccsens.ptos_tall.bean.dto.TaskDto;
import com.ccsens.ptos_tall.bean.po.OpenBusiness;
import com.ccsens.ptos_tall.bean.po.OpenBusinessExample;
import com.ccsens.ptos_tall.bean.vo.ProjectVo;
import com.ccsens.ptos_tall.bean.vo.TaskVo;
import com.ccsens.ptos_tall.persist.mapper.OpenBusinessMapper;
import com.ccsens.ptos_tall.util.PtOsConstant;
import com.ccsens.util.RestTemplateUtil;
import com.ccsens.util.WebConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author
*/
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
public class TaskService implements ITaskService {
@Resource
private OpenBusinessMapper businessMapper;
@Override
public List<TaskVo.QueryTask> queryAllTaskByUserId(TaskDto.QueryAllTask params) {
List<TaskVo.QueryTask> allTask = new ArrayList<>();
//根据code查询服务
//查询本域所有在线的业务信息
Long lastAnswerTime = System.currentTimeMillis() - PtOsConstant.LAST_ANSWER_TIME;
OpenBusinessExample businessExample = new OpenBusinessExample();
if(CollectionUtil.isEmpty(params.getCodes())) {
businessExample.createCriteria().andLastAnswerTimeGreaterThanOrEqualTo(lastAnswerTime).andTypeEqualTo((byte) 0);
}else {
businessExample.createCriteria().andLastAnswerTimeGreaterThanOrEqualTo(lastAnswerTime).andTypeEqualTo((byte) 0).andCodeIn(params.getCodes());
}
List<OpenBusiness> openBusinessList = businessMapper.selectByExample(businessExample);
//循环调用服务内的接口查询任务信息
//遍历业务
if(CollectionUtil.isNotEmpty(openBusinessList)){
for (OpenBusiness business : openBusinessList) {
String url = business.getUrl() + "/tall/task/allTask";
log.info("调用接口:{}--", url);
String postBody = null;
try{
postBody = RestTemplateUtil.postBody(url, params);
}catch (Exception e){
log.error("查询任务列表--" + business.getName() + e);
}
if(StrUtil.isBlank(postBody)){
continue;
}
JSONObject jsonObject = JSONObject.parseObject(postBody);
log.info("接口返回:{}", jsonObject);
//请求正确返回则修改最后应答时间,否则无操作
Integer code = jsonObject.getInteger("code");
if (code == null || code != 200) {
continue;
}
JSONArray data = jsonObject.getJSONArray("data");
if(CollectionUtil.isNotEmpty(data)){
for (Object object : data) {
TaskVo.QueryTask queryTask;
try {
JSONObject object1 = (JSONObject) object;
queryTask = object1.toJavaObject(TaskVo.QueryTask.class);
allTask.add(queryTask);
}catch (Exception e){
log.error("项目转换失败"+e);
}
}
}
}
}
return allTask;
}
}

63
ptos_tall/src/main/java/com/ccsens/ptos_tall/service/WxUserService.java

@ -16,7 +16,9 @@ import com.ccsens.util.RedisKeyManager;
import com.ccsens.util.RedisUtil;
import com.ccsens.wechatutil.bean.dto.wxmini.NoticeDto;
import com.ccsens.wechatutil.bean.dto.wxofficial.WxQrCodeDto;
import com.ccsens.wechatutil.bean.po.WxOauth2UserInfo;
import com.ccsens.wechatutil.bean.vo.wxofficial.WxQrCodeVo;
import com.ccsens.wechatutil.wxofficial.OfficialAccountSigninUtil;
import com.ccsens.wechatutil.wxofficial.OfficialQrCodeUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -24,6 +26,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
@ -78,7 +81,7 @@ public class WxUserService implements IWxUserService {
}
@Override
public String officialLogin(NoticeDto.Notice notice) {
public String officialLogin(NoticeDto.Notice notice) throws IOException {
log.info("接收公众号消息息通知:{}", notice);
if (notice== null) {
@ -87,14 +90,31 @@ public class WxUserService implements IWxUserService {
switch (notice.getEvent()) {
case "subscribe":
case "SCAN":
//查找公众号
WxOfficial wxOfficial = null;
WxOfficialExample wxOfficialExample = new WxOfficialExample();
wxOfficialExample.createCriteria().andDeveloperIdEqualTo(notice.getToUserName());
List<WxOfficial> wxOfficials = wxOfficialDao.selectByExample(wxOfficialExample);
if(CollectionUtil.isNotEmpty(wxOfficials)){
wxOfficial = wxOfficials.get(0);
}
//用openId查找用户
UserVo.UserSign userSign = sysUserDao.getUserByIdentifier(8,notice.getFromUserName());
if(ObjectUtil.isNull(userSign)){
WxOauth2UserInfo wxUserInfo = new WxOauth2UserInfo();
if(ObjectUtil.isNotNull(wxOfficial)){
//获取用户的微信信息
try {
wxUserInfo = OfficialAccountSigninUtil.getUserInfo(notice.getFromUserName(), wxOfficial.getAppId(), wxOfficial.getSecret());
}catch (Exception e){
log.info("获取用户的微信信息异常");
}
}
userSign = new UserVo.UserSign();
saveUser(notice, userSign);
saveUser(notice, userSign, wxUserInfo);
}
//添加用户和公众号的关联关系
saveOfficialsUser(notice, userSign);
saveOfficialsUser(userSign,wxOfficial);
//生成token
UserVo.TokenBean tokenBean = userService.generateToken(userSign.getUserId(), userSign.getAuthId());
tokenBean.setId(userSign.getUserId());
@ -109,20 +129,14 @@ public class WxUserService implements IWxUserService {
//用openId查找用户
UserVo.UserSign userSignOut = sysUserDao.getUserByIdentifier(8,notice.getFromUserName());
if(ObjectUtil.isNotNull(userSignOut)){
// //删除认证记录
// SysAuth sysAuth = new SysAuth();
// sysAuth.setId(userSignOut.getAuthId());
// sysAuth.setRecStatus((byte) 2);
// sysAuthDao.updateByPrimaryKeySelective(sysAuth);
//查找公众号信息
WxOfficialExample wxOfficialExample = new WxOfficialExample();
wxOfficialExample.createCriteria().andDeveloperIdEqualTo(notice.getToUserName());
List<WxOfficial> wxOfficials = wxOfficialDao.selectByExample(wxOfficialExample);
if(CollectionUtil.isNotEmpty(wxOfficials)) {
WxOfficialExample officialExample = new WxOfficialExample();
officialExample.createCriteria().andDeveloperIdEqualTo(notice.getToUserName());
List<WxOfficial> officials = wxOfficialDao.selectByExample(officialExample);
if(CollectionUtil.isNotEmpty(officials)) {
//修改用户和公众号的关注状态
WxOfficialUserExample officialUserExample = new WxOfficialUserExample();
officialUserExample.createCriteria().andUserIdEqualTo(userSignOut.getUserId()).andOfficialIdEqualTo(wxOfficials.get(0).getId());
officialUserExample.createCriteria().andUserIdEqualTo(userSignOut.getUserId()).andOfficialIdEqualTo(officials.get(0).getId());
List<WxOfficialUser> wxOfficialUsers = wxOfficialUserMapper.selectByExample(officialUserExample);
if(CollectionUtil.isNotEmpty(wxOfficialUsers)){
//如果已有,修改关注状态
@ -174,15 +188,12 @@ public class WxUserService implements IWxUserService {
return userOfficial;
}
private void saveOfficialsUser(NoticeDto.Notice notice, UserVo.UserSign userSign) {
//查找公众号
WxOfficialExample wxOfficialExample = new WxOfficialExample();
wxOfficialExample.createCriteria().andDeveloperIdEqualTo(notice.getToUserName());
List<WxOfficial> wxOfficials = wxOfficialDao.selectByExample(wxOfficialExample);
if(CollectionUtil.isNotEmpty(wxOfficials)){
private void saveOfficialsUser(UserVo.UserSign userSign,WxOfficial wxOfficial) {
if(ObjectUtil.isNotNull(wxOfficial)){
//查找用户和公众号的关联关系
WxOfficialUserExample officialUserExample = new WxOfficialUserExample();
officialUserExample.createCriteria().andUserIdEqualTo(userSign.getUserId()).andOfficialIdEqualTo(wxOfficials.get(0).getId());
officialUserExample.createCriteria().andUserIdEqualTo(userSign.getUserId()).andOfficialIdEqualTo(wxOfficial.getId());
List<WxOfficialUser> wxOfficialUsers = wxOfficialUserMapper.selectByExample(officialUserExample);
if(CollectionUtil.isNotEmpty(wxOfficialUsers)){
//如果已有,修改关注状态
@ -194,17 +205,23 @@ public class WxUserService implements IWxUserService {
WxOfficialUser wxOfficialUser = new WxOfficialUser();
wxOfficialUser.setId(snowflake.nextId());
wxOfficialUser.setUserId(userSign.getUserId());
wxOfficialUser.setOfficialId(wxOfficials.get(0).getId());
wxOfficialUser.setOfficialId(wxOfficial.getId());
wxOfficialUser.setAttentionStatus((byte) 1);
wxOfficialUserMapper.insertSelective(wxOfficialUser);
}
}
}
private void saveUser(NoticeDto.Notice notice, UserVo.UserSign userSign) {
private void saveUser(NoticeDto.Notice notice, UserVo.UserSign userSign, WxOauth2UserInfo wxUserInfo) {
//添加新用户
SysUser newUser = new SysUser();
newUser.setId(snowflake.nextId());
newUser.setName(wxUserInfo.getNickname());
newUser.setAvatarUrl(wxUserInfo.getHeadImgUrl());
newUser.setGender((byte) wxUserInfo.getSex());
newUser.setCity(wxUserInfo.getCity());
newUser.setCountry(wxUserInfo.getCountry());
newUser.setProvince(wxUserInfo.getProvince());
sysUserDao.insertSelective(newUser);
//添加认证方式
SysAuth newAuth = new SysAuth();

8
tall_sdk/src/main/java/com/ccsensptos/tallsdk/api/TaskController.java

@ -82,4 +82,12 @@ public class TaskController {
return JsonResponse.newInstance().ok(queryTasks);
}
@ApiOperation(value = "查看用户所有的任务", notes = "")
@RequestMapping(value = "/allTask", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<TallTaskVo.QueryTask>> queryAllTask(HttpServletRequest request, @ApiParam @Validated @RequestBody QueryDto<TallTaskDto.QueryAllTask> params) {
log.info("查看用户所有的任务:{}",params);
List<TallTaskVo.QueryTask> queryTasks = tallService.queryAllTask(params.getParam());
log.info("返回用户所有的任务");
return JsonResponse.newInstance().ok(queryTasks);
}
}

27
tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/dto/TallTaskDto.java

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class TallTaskDto {
@ -64,5 +65,31 @@ public class TallTaskDto {
private Integer pageNum = 1;
@ApiModelProperty("每页几条信息")
private Integer pageSize = 10;
@ApiModelProperty("任务所属的服务code")
private String businessCode;
@ApiModelProperty("触发类型 0翻页查找 1双击小红点触发")
private int triggerType = 1;
}
@Data
@ApiModel("查找用户的所有任务")
public static class QueryAllTask {
@ApiModelProperty("userId")
private Long userId;
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("codes")
private List<String> codes;
@ApiModelProperty("时间基准点 默认当前")
private Long timeNode = System.currentTimeMillis();
@ApiModelProperty("时间颗粒度 默认天")
private int timeUnit = 4;
@ApiModelProperty("0向上查找 1向下查找(默认) 下查包含自己,上查不包含")
private int queryType = 1;
@ApiModelProperty("第几页")
private Integer pageNum = 1;
@ApiModelProperty("每页几条信息")
private Integer pageSize = 10;
}
}

9
tall_sdk/src/main/java/com/ccsensptos/tallsdk/bean/vo/TallTaskVo.java

@ -47,6 +47,15 @@ public class TallTaskVo {
private List<CheckerOfTask> checkerList;
@ApiModelProperty("插件")
private List<List<TaskPluginInfo>> plugins;
@ApiModelProperty("项目id")
private Long projectId;
@ApiModelProperty("负责人id")
private Long executorRoleId;
@ApiModelProperty("所属服务的code")
private String businessCode;
@ApiModelProperty("服务的url")
private String businessUrl;
}
@Data
@ApiModel("任务下的检查人")

7
tall_sdk/src/main/java/com/ccsensptos/tallsdk/service/ITallService.java

@ -86,4 +86,11 @@ public interface ITallService {
* @return 返回wbs的下载路径
*/
TallWbsVo.WbsPath exportWbs(String token, TallProjectDto.ProjectById param);
/**
* 查找用户所有的任务
* @param param 用户信息和查询条件
* @return 返回任务信息
*/
List<TallTaskVo.QueryTask> queryAllTask(TallTaskDto.QueryAllTask param);
}

2
wechatutil/src/main/java/com/ccsens/wechatutil/util/WxConstant.java

@ -24,6 +24,8 @@ public class WxConstant {
public static final String MESSAGE_TEMPLATE_SEND = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%1$s";
/** 创建二维码 */
public static final String QR_CODE_CREATE = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={}";
/**根据openId获取用户信息*/
public static final String USER_INFO = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=%1$s&openid=%2$s&lang=zh_CN";
/*** 小程序登录路径 */

36
wechatutil/src/main/java/com/ccsens/wechatutil/wxofficial/OfficialAccountSigninUtil.java

@ -1,14 +1,20 @@
package com.ccsens.wechatutil.wxofficial;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.util.DateUtil;
import com.ccsens.util.JacksonUtil;
import com.ccsens.util.exception.BaseException;
import com.ccsens.util.exception.BusinessException;
import com.ccsens.util.exception.WxException;
import com.ccsens.wechatutil.bean.po.WxOauth2AccessToken;
import com.ccsens.wechatutil.bean.po.WxOauth2UserInfo;
import com.ccsens.wechatutil.util.WxCodeError;
import com.ccsens.wechatutil.util.WxConstant;
import com.ccsens.wechatutil.wxcommon.WxCommonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -102,4 +108,34 @@ public class OfficialAccountSigninUtil {
}
return wxOauth2UserInfo;
}
/**
* 根据openid查询用户信息
* @param openid
* @return
* @throws BaseException
*/
public static WxOauth2UserInfo getUserInfo(String openid,String appId, String secret) throws BaseException, IOException {
WxOauth2UserInfo wxOauth2UserInfo;
String url = String.format(WxConstant.USER_INFO, WxCommonUtil.getAccessToken(appId,secret),openid);
String response = HttpRequest.get(url).execute().body();
Console.log("请求路径:{}, 返回结果:{}", url, response);
// pageResponse(response);
log.info("url: {}\nresponse: {}", url, response);
try {
if (StrUtil.isEmpty(response) || null == (wxOauth2UserInfo = JacksonUtil.jsonToBean(response, WxOauth2UserInfo.class))) {
throw new BaseException(WxCodeError.WX_HTTP_ERROR);
}
} catch (IOException e) {
throw new BaseException(e.getMessage());
}
if (null != wxOauth2UserInfo.getErrcode()) {
throw new BaseException(wxOauth2UserInfo.getErrcode(), wxOauth2UserInfo.getErrmsg());
}
if (StrUtil.isEmpty(wxOauth2UserInfo.getOpenId())) {
throw new BaseException(WxCodeError.OPENID_ERROR);
}
return wxOauth2UserInfo;
}
}

Loading…
Cancel
Save