调整鉴权信息
This commit is contained in:
parent
f066abcff1
commit
5d60bc7772
|
@ -112,7 +112,7 @@ public class H5ApiAdvisoryInfoController extends JeecgController<NuBizAdvisoryIn
|
|||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryWeixinInfo")
|
||||
public Result<NuBizAdvisoryInfo> queryByOpenId(@RequestParam(name="openId",required=true) String openId,@RequestParam(name="wechatName",required=true) String wechatName) {
|
||||
public Result<NuBizAdvisoryInfo> queryByOpenId(@RequestParam(name="openId",required=true) String openId,@RequestParam(name="wechatName",required=false) String wechatName) {
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfo = nuBizAdvisoryInfoService.queryWeixinInfo(openId,wechatName);
|
||||
return Result.OK(nuBizAdvisoryInfo);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,9 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
|
@ -35,97 +37,99 @@ public class NuBizAdvisoryInfo implements Serializable {
|
|||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
private String id;
|
||||
/**微信id*/
|
||||
@Excel(name = "微信id", width = 15)
|
||||
@ApiModelProperty(value = "微信id")
|
||||
private java.lang.String openId;
|
||||
private String openId;
|
||||
/**微信名称*/
|
||||
@Excel(name = "微信名称", width = 15)
|
||||
@ApiModelProperty(value = "微信名称")
|
||||
private java.lang.String wechatName;
|
||||
private String wechatName;
|
||||
/**咨询人姓名*/
|
||||
@Excel(name = "咨询人姓名", width = 15)
|
||||
@ApiModelProperty(value = "咨询人姓名")
|
||||
private java.lang.String name;
|
||||
private String name;
|
||||
/**性别*/
|
||||
@Excel(name = "性别", width = 15, dicCode = "sex")
|
||||
@Dict(dicCode = "sex")
|
||||
@ApiModelProperty(value = "性别")
|
||||
private java.lang.String sex;
|
||||
private String sex;
|
||||
/**联系电话*/
|
||||
@Excel(name = "联系电话", width = 15)
|
||||
@ApiModelProperty(value = "联系电话")
|
||||
private java.lang.String tel;
|
||||
private String tel;
|
||||
/**咨询类型 1入住nu 2入驻机构 3我要加盟*/
|
||||
@Excel(name = "咨询类型", width = 15, dicCode = "advisory_type")
|
||||
@Dict(dicCode = "advisory_type")
|
||||
@ApiModelProperty(value = "咨询类型")
|
||||
private java.lang.String advisoryType;
|
||||
private String advisoryType;
|
||||
/**状态 1审核中 2审核完成 3驳回*/
|
||||
@Excel(name = "状态", width = 15, dicCode = "advisory_approval")
|
||||
@Dict(dicCode = "advisory_approval")
|
||||
@ApiModelProperty(value = "状态")
|
||||
private java.lang.String status;
|
||||
private String status;
|
||||
/**审核备注*/
|
||||
@Excel(name = "审核备注", width = 15)
|
||||
@ApiModelProperty(value = "审核备注")
|
||||
private java.lang.String content;
|
||||
private String content;
|
||||
/**机构访问地址*/
|
||||
@Excel(name = "机构访问地址", width = 15)
|
||||
@ApiModelProperty(value = "机构访问地址")
|
||||
private java.lang.String serverUrl;
|
||||
private String serverUrl;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
private Date updateTime;
|
||||
/**所属部门*/
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
private String sysOrgCode;
|
||||
|
||||
/**老人姓名*/
|
||||
private java.lang.String oldManName;
|
||||
private String oldManName;
|
||||
/**老人年龄*/
|
||||
private java.lang.String oldManAge;
|
||||
private String oldManAge;
|
||||
/**医保类型*/
|
||||
@Dict(dicCode = "medical_insurance_type")
|
||||
private java.lang.String medicalInsuranceType;
|
||||
private String medicalInsuranceType;
|
||||
/**老人性别*/
|
||||
@Dict(dicCode = "sex")
|
||||
private java.lang.String oldManSex;
|
||||
private String oldManSex;
|
||||
/**报销类型*/
|
||||
@Dict(dicCode = "reimb_type")
|
||||
private java.lang.String reimbType;
|
||||
private String reimbType;
|
||||
/**护理单元*/
|
||||
private java.lang.String nuId;
|
||||
private String nuId;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private java.lang.String advisoryTypeName;
|
||||
private String advisoryTypeName;
|
||||
@TableField(exist = false)
|
||||
private java.lang.String sexName;
|
||||
private String sexName;
|
||||
@TableField(exist = false)
|
||||
private java.lang.String sysOrgCodeName;
|
||||
private String sysOrgCodeName;
|
||||
@TableField(exist = false)
|
||||
private java.lang.String statusName;
|
||||
private String statusName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private java.lang.String oldManSexName;
|
||||
private String oldManSexName;
|
||||
@TableField(exist = false)
|
||||
private java.lang.String medicalInsuranceTypeName;
|
||||
private String medicalInsuranceTypeName;
|
||||
@TableField(exist = false)
|
||||
private java.lang.String reimbTypeName;
|
||||
private String reimbTypeName;
|
||||
@TableField(exist = false)
|
||||
private String token;
|
||||
|
||||
}
|
||||
|
|
|
@ -15,4 +15,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
public interface NuBizAdvisoryInfoMapper extends BaseMapper<NuBizAdvisoryInfo> {
|
||||
|
||||
NuBizAdvisoryInfo getUserByTel(@Param("mobile") String mobile);
|
||||
|
||||
NuBizAdvisoryInfo findByOpenId(@Param("openId")String openId);
|
||||
}
|
||||
|
|
|
@ -5,4 +5,7 @@
|
|||
<select id="getUserByTel" resultType="com.nu.modules.NuBizAdvisoryInfo.entity.NuBizAdvisoryInfo">
|
||||
select * from nu_biz_advisory_info where tel=#{mobile}
|
||||
</select>
|
||||
<select id="findByOpenId" resultType="com.nu.modules.NuBizAdvisoryInfo.entity.NuBizAdvisoryInfo">
|
||||
select * from nu_biz_advisory_info where open_id=#{openId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -14,4 +14,6 @@ public interface INuBizAdvisoryInfoService extends IService<NuBizAdvisoryInfo> {
|
|||
NuBizAdvisoryInfo queryWeixinInfo(String openId, String wechatName);
|
||||
|
||||
NuBizAdvisoryInfo getUserByTel(String mobile);
|
||||
|
||||
NuBizAdvisoryInfo findByOpenId(String openId);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
package com.nu.modules.NuBizAdvisoryInfo.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.entity.NuBizAdvisoryInfo;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.mapper.NuBizAdvisoryInfoMapper;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.service.INuBizAdvisoryInfoService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 咨询信息
|
||||
* @Author: 张明远
|
||||
|
@ -17,11 +29,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
@Service
|
||||
public class NuBizAdvisoryInfoServiceImpl extends ServiceImpl<NuBizAdvisoryInfoMapper, NuBizAdvisoryInfo> implements INuBizAdvisoryInfoService {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public NuBizAdvisoryInfo queryWeixinInfo(String openId, String wechatName) {
|
||||
QueryWrapper<NuBizAdvisoryInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("open_id",openId);
|
||||
queryWrapper.eq("wechat_name",wechatName);
|
||||
queryWrapper.eq(StringUtils.isNotBlank(wechatName),"wechat_name",wechatName);
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfo = baseMapper.selectOne(queryWrapper);
|
||||
//查询是否有微信注册信息,没有则创建
|
||||
if(nuBizAdvisoryInfo==null) {
|
||||
|
@ -30,11 +45,37 @@ public class NuBizAdvisoryInfoServiceImpl extends ServiceImpl<NuBizAdvisoryInfoM
|
|||
nuBizAdvisoryInfo.setWechatName(wechatName);
|
||||
baseMapper.insert(nuBizAdvisoryInfo);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(nuBizAdvisoryInfo.getTel())){
|
||||
String token =userInfo(nuBizAdvisoryInfo);
|
||||
nuBizAdvisoryInfo.setToken(token);
|
||||
}
|
||||
return nuBizAdvisoryInfo;
|
||||
}
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
private String userInfo(NuBizAdvisoryInfo sysUser) {
|
||||
String username = sysUser.getOpenId();
|
||||
String syspassword = sysUser.getTel();
|
||||
//1.生成token
|
||||
String token = JwtUtil.sign(username, syspassword);
|
||||
// 设置token缓存有效时间
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NuBizAdvisoryInfo getUserByTel(String mobile) {
|
||||
return baseMapper.getUserByTel(mobile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NuBizAdvisoryInfo findByOpenId(String openId) {
|
||||
return baseMapper.findByOpenId(openId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@ import org.jeecg.common.exception.JeecgBootException;
|
|||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.system.vo.SysUserCacheInfo;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -27,6 +29,7 @@ import javax.servlet.http.HttpSession;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -325,6 +328,12 @@ public class JwtUtil {
|
|||
return returnValue;
|
||||
}
|
||||
|
||||
public static String getNuBizAdvisoryInfoUser(String key) {
|
||||
String username = JwtUtil.getUsername(key);
|
||||
//1.优先获取 SysUserCacheInfo
|
||||
return username;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NjUzMzY1MTMsInVzZXJuYW1lIjoiYWRtaW4ifQ.xjhud_tWCNYBOg_aRlMgOdlZoWFFKB_givNElHNw3X0";
|
||||
// System.out.println(JwtUtil.getUsername(token));
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
|
|||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.shiro.JwtToken;
|
||||
import org.jeecg.config.shiro.ignore.InMemoryIgnoreAuth;
|
||||
|
@ -77,7 +78,13 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
|
|||
|
||||
JwtToken jwtToken = new JwtToken(token);
|
||||
// 提交给realm进行登入,如果错误他会抛出异常并被捕获
|
||||
getSubject(request, response).login(jwtToken);
|
||||
try {
|
||||
getSubject(request, response).login(jwtToken);
|
||||
} catch (Exception e) {
|
||||
log.error("-------JwtFilter executeLogin error-------", e);
|
||||
JwtUtil.getNuBizAdvisoryInfoUser(token);
|
||||
}
|
||||
|
||||
// 如果没有抛出异常则代表登入成功,返回true
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.util.RandomUtil;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.entity.NuBizAdvisoryInfo;
|
||||
import com.nu.modules.NuBizAdvisoryInfo.service.INuBizAdvisoryInfoService;
|
||||
|
@ -836,7 +837,11 @@ public class LoginController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/smsCode")
|
||||
public Result<String> smsCode(@RequestParam(name="mobile",required=true) String mobile,@RequestParam(name="smsmode",required=true) String smsmode,@RequestParam(name="hkcode",required=true) String hkcode,HttpServletRequest request) {
|
||||
public Result<String> smsCode(@RequestBody Map<String,String> map,HttpServletRequest request) {
|
||||
String mobile = map.get("mobile");
|
||||
String smsmode = map.get("smsmode");
|
||||
String hkcode = map.get("hkcode");
|
||||
// @RequestParam(name="mobile",required=true) String mobile,@RequestParam(name="smsmode",required=true) String smsmode,@RequestParam(name="hkcode",required=true) String hkcode
|
||||
Result<String> result = new Result<String>();
|
||||
String clientIp = IpUtils.getIpAddr(request);
|
||||
// //手机号模式 登录模式: "2" 注册模式: "1"
|
||||
|
@ -882,7 +887,7 @@ public class LoginController {
|
|||
//-------------------------------------------------------------------------------------
|
||||
|
||||
//随机数
|
||||
String captcha = RandomUtil.randomNumbers(6);
|
||||
String captcha = RandomUtil.randomNumbers(4);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("code", captcha);
|
||||
try {
|
||||
|
@ -942,8 +947,17 @@ public class LoginController {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 手机号验证码验证接口
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/checkPhoneCode")
|
||||
public Result<JSONObject> checkPhoneCode(@RequestParam(name="mobile",required=true) String mobile,@RequestParam(name="smscode",required=true) String smscode, HttpServletRequest request) {
|
||||
public Result<JSONObject> checkPhoneCode(@RequestBody Map<String,String> map, HttpServletRequest request) {
|
||||
String mobile = map.get("mobile");
|
||||
String smscode = map.get("smscode");
|
||||
String openId = map.get("openId");
|
||||
// @RequestParam(name="mobile",required=true) String mobile,@RequestParam(name="smscode",required=true) String smscode,@RequestParam(name="openId",required=false) String openId,
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String phone = mobile;
|
||||
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
|
@ -968,18 +982,25 @@ public class LoginController {
|
|||
addLoginFailOvertimes(phone);
|
||||
return Result.error("手机验证码错误");
|
||||
}
|
||||
QueryWrapper<NuBizAdvisoryInfo> queryWrapper = new QueryWrapper<>();
|
||||
System.out.println("openId = " + openId);
|
||||
queryWrapper.eq("open_id", openId);
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfo = nuBizAdvisoryInfoService.getOne(queryWrapper);
|
||||
nuBizAdvisoryInfo.setTel(phone);
|
||||
nuBizAdvisoryInfoService.updateById(nuBizAdvisoryInfo);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取滑块code
|
||||
* @param mobile
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getHkCode")
|
||||
public Result<JSONObject> getHkCode(@RequestParam(name="mobile",required=true) String mobile, HttpServletRequest request) {
|
||||
public Result<JSONObject> getHkCode(@RequestBody Map<String,String> map, HttpServletRequest request) {
|
||||
// @RequestParam(name="mobile",required=true) String mobile
|
||||
String mobile = map.get("mobile");
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String phone = mobile;
|
||||
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
|
|
Loading…
Reference in New Issue