微信登录优化;小程序首页四个类型数据优化
This commit is contained in:
parent
a664b062b6
commit
34eabfe518
|
@ -12,8 +12,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.dromara.common.core.domain.model.LoginUser;
|
||||
import org.dromara.common.core.domain.model.XcxLoginBody;
|
||||
import org.dromara.common.core.domain.model.XcxLoginUser;
|
||||
import org.dromara.common.core.exception.user.UserException;
|
||||
import org.dromara.common.core.utils.ValidatorUtils;
|
||||
import org.dromara.common.json.utils.JsonUtils;
|
||||
|
@ -46,8 +46,6 @@ public class XcxAuthStrategy implements IAuthStrategy {
|
|||
public LoginVo login(String body, SysClientVo client) {
|
||||
XcxLoginBody loginBody = JsonUtils.parseObject(body, XcxLoginBody.class);
|
||||
ValidatorUtils.validate(loginBody);
|
||||
// 多个小程序识别使用
|
||||
String appid = loginBody.getAppid();
|
||||
String tenantId = loginBody.getTenantId();
|
||||
// code 为 小程序调用 wx.login 授权后获取
|
||||
String code = loginBody.getCode();
|
||||
|
@ -71,7 +69,7 @@ public class XcxAuthStrategy implements IAuthStrategy {
|
|||
SysUser user = loadUserByOpenidAndPhoneNumber(openid, phoneNumber, tenantId);
|
||||
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
XcxLoginUser loginUser = new XcxLoginUser();
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setTenantId(user.getTenantId());
|
||||
loginUser.setUserId(user.getUserId());
|
||||
loginUser.setUsername(user.getUserName());
|
||||
|
|
|
@ -260,7 +260,7 @@ justauth:
|
|||
wx:
|
||||
pay:
|
||||
appId: wx2e09db4124332242
|
||||
mchId: #微信支付商户号
|
||||
mchId: 1646701170
|
||||
mchKey: #微信支付商户密钥
|
||||
subAppId: #服务商模式下的子商户公众账号ID
|
||||
subMchId: #服务商模式下的子商户号
|
||||
|
|
|
@ -31,6 +31,11 @@ public class LoginUser implements Serializable {
|
|||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* openid
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
|
|
|
@ -38,6 +38,7 @@ public class LoginHelper {
|
|||
public static final String DEPT_NAME_KEY = "deptName";
|
||||
public static final String DEPT_CATEGORY_KEY = "deptCategory";
|
||||
public static final String CLIENT_KEY = "clientid";
|
||||
public static final String OPEN_ID_KEY = "openid";
|
||||
|
||||
/**
|
||||
* 登录系统 基于 设备类型
|
||||
|
@ -55,6 +56,7 @@ public class LoginHelper {
|
|||
.setExtra(DEPT_KEY, loginUser.getDeptId())
|
||||
.setExtra(DEPT_NAME_KEY, loginUser.getDeptName())
|
||||
.setExtra(DEPT_CATEGORY_KEY, loginUser.getDeptCategory())
|
||||
.setExtra(OPEN_ID_KEY, loginUser.getOpenid())
|
||||
);
|
||||
StpUtil.getTokenSession().set(LOGIN_USER_KEY, loginUser);
|
||||
}
|
||||
|
@ -123,6 +125,13 @@ public class LoginHelper {
|
|||
return Convert.toStr(getExtra(DEPT_CATEGORY_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序openid
|
||||
*/
|
||||
public static String getOpenId() {
|
||||
return Convert.toStr(getExtra(OPEN_ID_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前 Token 的扩展信息
|
||||
*
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.dromara.scale.controller.wx;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
|
@ -48,8 +48,8 @@ public class WxScaleController extends BaseController {
|
|||
* 查询心理测评量列表,默认展示两条数据
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R<Map<String, List<SysScaleVo>>> list(String[] scaleType) {
|
||||
if (ObjectUtil.isEmpty(scaleType)) {
|
||||
public R<Map<String, List<SysScaleVo>>> list(String scaleType) {
|
||||
if (StringUtils.isEmpty(scaleType)) {
|
||||
throw new ServiceException("类型不能为空");
|
||||
}
|
||||
return R.ok(sysScaleService.queryWxMapList(scaleType));
|
||||
|
|
|
@ -47,5 +47,5 @@ public interface ISysScaleService {
|
|||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
Map<String,List<SysScaleVo>> queryWxMapList(String[] scaleType);
|
||||
Map<String,List<SysScaleVo>> queryWxMapList(String scaleType);
|
||||
}
|
||||
|
|
|
@ -156,9 +156,10 @@ public class SysScaleServiceImpl implements ISysScaleService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<SysScaleVo>> queryWxMapList(String[] scaleType) {
|
||||
Map<String, List<SysScaleVo>> map = new HashMap<>(scaleType.length);
|
||||
for (String s : scaleType) {
|
||||
public Map<String, List<SysScaleVo>> queryWxMapList(String scaleType) {
|
||||
List<String> split = StrUtil.split(scaleType, ",");
|
||||
Map<String, List<SysScaleVo>> map = new HashMap<>(split.size());
|
||||
for (String s : split) {
|
||||
LambdaQueryWrapper<SysScale> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.like(SysScale::getScaleType, s);
|
||||
lqw.orderByDesc(SysScale::getPublishNums);
|
||||
|
|
Loading…
Reference in New Issue