Browse Source

用户添加微信授权标识

tags/v1.0.0^2
chengwang 1 year ago
parent
commit
6148ba271d
5 changed files with 15 additions and 41 deletions
  1. +5
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/User.java
  2. +0
    -19
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java
  3. +2
    -1
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/UserMapper.xml
  4. +5
    -0
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/User.java
  5. +3
    -21
      tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java

+ 5
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/entity/User.java View File

@@ -232,4 +232,9 @@ public class User implements Serializable {
*/
private Integer dataPermission;

/**
* 微信授权标识 1:未授权 2授权
*/
private Integer authorize;

}

+ 0
- 19
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/dsp/DspCallbackServiceImpl.java View File

@@ -7,13 +7,11 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.constant.SystemConstant;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.*;
import com.tuoheng.admin.mapper.*;
import com.tuoheng.admin.request.third.DspCallbackRequest;
import com.tuoheng.admin.request.third.QuestionFile;
import com.tuoheng.admin.request.wx.WxRequest;
import com.tuoheng.admin.service.accident.IAccidentService;
import com.tuoheng.admin.service.inspection.update.flyer.DeliverStreamingService;
import com.tuoheng.admin.utils.GaodeUtil;
@@ -319,23 +317,6 @@ public class DspCallbackServiceImpl implements IDspCallbackService {
return JsonResult.success();
}

/**
* 异步向第三方发送请求
*
* @param url
* @param request
*/
public JsonResult doPost(String url, Object request) {

//发送新增请求
String result = restTemplate.postForObject(url, request, String.class);

JsonResult jsonResult = JSON.parseObject(result, JsonResult.class);
if (JsonResult.SUCCESS != jsonResult.getCode()) {
return JsonResult.error(jsonResult.getMsg());
}
return JsonResult.success();
}

/**
* 应急记录数据入库

+ 2
- 1
tuoheng-service/tuoheng-admin/src/main/resources/mapper/UserMapper.xml View File

@@ -29,6 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="salt" column="salt" />
<result property="intro" column="intro" />
<result property="status" column="status" />
<result property="authorize" column="authorize" />
<result property="note" column="note" />
<result property="sort" column="sort" />
<result property="loginNum" column="login_num" />
@@ -46,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

<sql id="selectUserVo">
id, tenant_id, code, realname, nickname, gender, avatar, mobile, email, birthday, dept_id, province_code, city_code, district_code, street_code, address, city_name,
username, password, driver_type, driver_code, salt, intro, status, note, sort, login_num, login_ip, login_time, create_user, create_time, update_user, update_time,
username, password, driver_type, driver_code, salt, intro, status, authorize, note, sort, login_num, login_ip, login_time, create_user, create_time, update_user, update_time,
role_id, data_permission, client_id, mark
</sql>


+ 5
- 0
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/entity/User.java View File

@@ -236,4 +236,9 @@ public class User implements Serializable {
*/
private Integer dataPermission;

/**
* 微信授权标识 1:未授权 2授权
*/
private Integer authorize;

}

+ 3
- 21
tuoheng-service/tuoheng-miniprogram/src/main/java/com/tuoheng/miniprogram/service/impl/WxServiceImpl.java View File

@@ -55,7 +55,6 @@ public class WxServiceImpl implements IWxService {
String userId = CurrentUserUtil.getUserId();
String openidResult = GetOpenIdUtil.getopenid(code, CommonConfig.appId, CommonConfig.appSecret);
String openid = JSONObject.parseObject(openidResult).getString("openid");
String unionid = JSONObject.parseObject(openidResult).getString("unionid");
if(StringUtils.isEmpty(openid)){
log.error("获取openid失败:",openidResult);
return JsonResult.error("获取openid失败");
@@ -70,35 +69,18 @@ public class WxServiceImpl implements IWxService {
//查询出来openId数据入库
userAuthorize.setOpenId(openid);
}
if(StringUtils.isNotEmpty(unionid)){
userAuthorize.setUnionId(unionid);
}
userAuthorize.setCreateTime(DateUtils.now());
if(StringUtils.isNotEmpty(CurrentUserUtil.getUserId())){
userAuthorize.setCreateUser(CurrentUserUtil.getUserId());
if(StringUtils.isNotEmpty(userId)){
userAuthorize.setCreateUser(userId);
}
int result = userAuthorizeMapper.insert(userAuthorize);

if(result<=0){
return JsonResult.error("授权数据入库失败");
}
}else if(ObjectUtil.isNotNull(beforeUserAuthorize)){
if(StringUtils.isNotEmpty(openid)){
//更新openId数据入库
beforeUserAuthorize.setOpenId(openid);
}
if(StringUtils.isNotEmpty(unionid)){
beforeUserAuthorize.setUnionId(unionid);
}
beforeUserAuthorize.setUpdateTime(DateUtils.now());
beforeUserAuthorize.setUpdateUser(userId);
int count = userAuthorizeMapper.updateById(beforeUserAuthorize);
if(count <= 0){
return JsonResult.error("更新授权数据入库失败");
}
}

return JsonResult.success(openid);
return JsonResult.success();
}

/**

Loading…
Cancel
Save