mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-11 02:37:06 +00:00
feat(wechat): 修复微信公众号无法登录
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
package org.ruoyi.system.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.domain.R;
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.common.excel.utils.ExcelUtil;
|
||||
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.ruoyi.common.log.annotation.Log;
|
||||
import org.ruoyi.common.log.enums.BusinessType;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.common.web.core.BaseController;
|
||||
import org.ruoyi.system.domain.bo.ChatConfigBo;
|
||||
import org.ruoyi.system.domain.vo.ChatConfigVo;
|
||||
import org.ruoyi.system.service.IChatConfigService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-12-14
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/chat/config")
|
||||
public class ChatConfigController extends BaseController {
|
||||
|
||||
private final IChatConfigService chatConfigService;
|
||||
|
||||
/**
|
||||
* 查询配置信息列表
|
||||
*/
|
||||
@SaCheckPermission("system:config:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<ChatConfigVo> list(ChatConfigBo bo, PageQuery pageQuery) {
|
||||
return chatConfigService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出配置信息列表
|
||||
*/
|
||||
@SaCheckPermission("system:config:export")
|
||||
@Log(title = "配置信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(ChatConfigBo bo, HttpServletResponse response) {
|
||||
List<ChatConfigVo> list = chatConfigService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "配置信息", ChatConfigVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配置信息详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:config:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<ChatConfigVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(chatConfigService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配置信息
|
||||
*/
|
||||
@SaCheckPermission("system:config:add")
|
||||
@Log(title = "配置信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody ChatConfigBo bo) {
|
||||
return toAjax(chatConfigService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或者修改配置信息
|
||||
*/
|
||||
@SaCheckPermission("system:config:add")
|
||||
@Log(title = "新增或者修改配置信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/saveOrUpdate")
|
||||
public R<Void> saveOrUpdate(@RequestBody List<ChatConfigBo> boList) {
|
||||
for (ChatConfigBo chatConfigBo : boList) {
|
||||
if (chatConfigBo.getId() == null) {
|
||||
chatConfigService.insertByBo(chatConfigBo);
|
||||
} else {
|
||||
chatConfigService.updateByBo(chatConfigBo);
|
||||
}
|
||||
}
|
||||
return toAjax(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改配置信息
|
||||
*/
|
||||
@SaCheckPermission("system:config:edit")
|
||||
@Log(title = "配置信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody ChatConfigBo bo) {
|
||||
return toAjax(chatConfigService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配置信息
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:config:remove")
|
||||
@Log(title = "配置信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(chatConfigService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.ruoyi.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.tenant.core.TenantEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 配置信息对象 chat_config
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-12-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("chat_config")
|
||||
public class ChatConfig extends TenantEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 配置类型
|
||||
*/
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 配置名称
|
||||
*/
|
||||
private String configName;
|
||||
|
||||
/**
|
||||
* 配置值
|
||||
*/
|
||||
private String configValue;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
private String configDict;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
@Version
|
||||
private Long version;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 1代表删除)
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 更新IP
|
||||
*/
|
||||
private String updateIp;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.ruoyi.system.domain.bo;
|
||||
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.ruoyi.common.core.validate.AddGroup;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.common.mybatis.core.domain.BaseEntity;
|
||||
import org.ruoyi.system.domain.ChatConfig;
|
||||
|
||||
/**
|
||||
* 配置信息业务对象 chat_config
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-12-14
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = ChatConfig.class, reverseConvertGenerate = false)
|
||||
public class ChatConfigBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "主键不能为空", groups = { EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 配置类型
|
||||
*/
|
||||
@NotBlank(message = "配置类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 配置名称
|
||||
*/
|
||||
@NotBlank(message = "配置名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String configName;
|
||||
|
||||
/**
|
||||
* 配置值
|
||||
*/
|
||||
@NotBlank(message = "配置值不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String configValue;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
private String configDict;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 更新IP
|
||||
*/
|
||||
private String updateIp;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.ruoyi.system.domain.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import org.ruoyi.system.domain.ChatConfig;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 配置信息视图对象 chat_config
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-12-14
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = ChatConfig.class)
|
||||
public class ChatConfigVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ExcelProperty(value = "主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 配置类型
|
||||
*/
|
||||
@ExcelProperty(value = "配置类型")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 配置名称
|
||||
*/
|
||||
@ExcelProperty(value = "配置名称")
|
||||
private String configName;
|
||||
|
||||
/**
|
||||
* 配置值
|
||||
*/
|
||||
@ExcelProperty(value = "配置值")
|
||||
private String configValue;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
@ExcelProperty(value = "说明")
|
||||
private String configDict;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 更新IP
|
||||
*/
|
||||
@ExcelProperty(value = "更新IP")
|
||||
private String updateIp;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.ruoyi.system.mapper;
|
||||
|
||||
import org.ruoyi.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.ruoyi.system.domain.ChatConfig;
|
||||
import org.ruoyi.system.domain.vo.ChatConfigVo;
|
||||
|
||||
/**
|
||||
* 配置信息Mapper接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-12-14
|
||||
*/
|
||||
public interface ChatConfigMapper extends BaseMapperPlus<ChatConfig, ChatConfigVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.ruoyi.system.service;
|
||||
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.system.domain.bo.ChatConfigBo;
|
||||
import org.ruoyi.system.domain.vo.ChatConfigVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 配置信息Service接口
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-12-14
|
||||
*/
|
||||
public interface IChatConfigService {
|
||||
|
||||
/**
|
||||
* 查询配置信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 配置信息
|
||||
*/
|
||||
ChatConfigVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询配置信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 配置信息分页列表
|
||||
*/
|
||||
TableDataInfo<ChatConfigVo> queryPageList(ChatConfigBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的配置信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 配置信息列表
|
||||
*/
|
||||
List<ChatConfigVo> queryList(ChatConfigBo bo);
|
||||
|
||||
/**
|
||||
* 新增配置信息
|
||||
*
|
||||
* @param bo 配置信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(ChatConfigBo bo);
|
||||
|
||||
/**
|
||||
* 修改配置信息
|
||||
*
|
||||
* @param bo 配置信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(ChatConfigBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除配置信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package org.ruoyi.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.ruoyi.common.core.utils.MapstructUtils;
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.system.domain.ChatConfig;
|
||||
import org.ruoyi.system.domain.bo.ChatConfigBo;
|
||||
import org.ruoyi.system.domain.vo.ChatConfigVo;
|
||||
import org.ruoyi.system.mapper.ChatConfigMapper;
|
||||
import org.ruoyi.system.service.IChatConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 配置信息Service业务层处理
|
||||
*
|
||||
* @author ageerle
|
||||
* @date 2025-12-14
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ChatConfigServiceImpl implements IChatConfigService {
|
||||
|
||||
private final ChatConfigMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询配置信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 配置信息
|
||||
*/
|
||||
@Override
|
||||
public ChatConfigVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询配置信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 配置信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<ChatConfigVo> queryPageList(ChatConfigBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<ChatConfig> lqw = buildQueryWrapper(bo);
|
||||
Page<ChatConfigVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的配置信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 配置信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<ChatConfigVo> queryList(ChatConfigBo bo) {
|
||||
LambdaQueryWrapper<ChatConfig> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<ChatConfig> buildQueryWrapper(ChatConfigBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<ChatConfig> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(ChatConfig::getId);
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCategory()), ChatConfig::getCategory, bo.getCategory());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getConfigName()), ChatConfig::getConfigName, bo.getConfigName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigValue()), ChatConfig::getConfigValue, bo.getConfigValue());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getConfigDict()), ChatConfig::getConfigDict, bo.getConfigDict());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUpdateIp()), ChatConfig::getUpdateIp, bo.getUpdateIp());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增配置信息
|
||||
*
|
||||
* @param bo 配置信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ChatConfigBo bo) {
|
||||
ChatConfig add = MapstructUtils.convert(bo, ChatConfig.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配置信息
|
||||
*
|
||||
* @param bo 配置信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ChatConfigBo bo) {
|
||||
ChatConfig update = MapstructUtils.convert(bo, ChatConfig.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ChatConfig entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除配置信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,11 @@ import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.common.redis.utils.CacheUtils;
|
||||
import org.ruoyi.common.tenant.helper.TenantHelper;
|
||||
import org.ruoyi.system.domain.ChatConfig;
|
||||
import org.ruoyi.system.domain.SysConfig;
|
||||
import org.ruoyi.system.domain.bo.SysConfigBo;
|
||||
import org.ruoyi.system.domain.vo.SysConfigVo;
|
||||
import org.ruoyi.system.mapper.ChatConfigMapper;
|
||||
import org.ruoyi.system.mapper.SysConfigMapper;
|
||||
import org.ruoyi.system.service.ISysConfigService;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
@@ -41,6 +43,9 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
|
||||
private final SysConfigMapper baseMapper;
|
||||
|
||||
|
||||
private final ChatConfigMapper configMapper;
|
||||
|
||||
/**
|
||||
* 分页查询参数配置列表
|
||||
*
|
||||
@@ -212,4 +217,12 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
return SpringUtils.getAopProxy(this).selectConfigByKey(configKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigValue(String category, String configKey) {
|
||||
ChatConfig config = configMapper.selectOne(new LambdaQueryWrapper<ChatConfig>()
|
||||
.eq(ChatConfig::getCategory, category)
|
||||
.eq(ChatConfig::getConfigName, configKey));
|
||||
return ObjectUtils.notNullGetter(config, ChatConfig::getConfigValue, StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@ import cn.hutool.crypto.digest.BCrypt;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.ruoyi.common.core.constant.Constants;
|
||||
import org.ruoyi.common.core.constant.SystemConstants;
|
||||
import org.ruoyi.common.core.domain.dto.VisitorLoginUserDto;
|
||||
import org.ruoyi.common.core.enums.UserType;
|
||||
import org.ruoyi.common.core.exception.ServiceException;
|
||||
import org.ruoyi.common.core.service.UserLoginService;
|
||||
import org.ruoyi.common.core.utils.MessageUtils;
|
||||
import org.ruoyi.common.satoken.utils.LoginHelper;
|
||||
@@ -33,12 +35,19 @@ public class UserLoginServiceImpl implements UserLoginService {
|
||||
|
||||
|
||||
public VisitorLoginUserDto mpLogin(String openid, String clientId) {
|
||||
// 校验客户端
|
||||
SysClientVo client = clientService.queryByClientId(clientId);
|
||||
if (ObjectUtil.isNull(client)) {
|
||||
throw new ServiceException(MessageUtils.message("auth.grant.type.error"));
|
||||
} else if (!SystemConstants.NORMAL.equals(client.getStatus())) {
|
||||
throw new ServiceException(MessageUtils.message("auth.grant.type.blocked"));
|
||||
}
|
||||
// 使用 openid 查询绑定用户 如未绑定用户 则根据业务自行处理 例如 创建默认用户
|
||||
SysUserVo user = userService.selectUserByOpenId(openid);
|
||||
VisitorLoginUserDto loginUser = new VisitorLoginUserDto();
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
SysUserBo sysUser = new SysUserBo();
|
||||
String name = "用户" + UUID.randomUUID().toString().replace("-", "");
|
||||
String name = "用户" + UUID.randomUUID().toString().replace("-", "").substring(0, 7);
|
||||
// 设置默认用户名
|
||||
sysUser.setUserName(name);
|
||||
// 设置默认昵称
|
||||
@@ -47,6 +56,8 @@ public class UserLoginServiceImpl implements UserLoginService {
|
||||
sysUser.setPassword(BCrypt.hashpw("123456"));
|
||||
// 设置微信openId
|
||||
sysUser.setOpenId(openid);
|
||||
// 设置用户类型
|
||||
sysUser.setUserType(UserType.SYS_USER.getUserType());
|
||||
// 设置默认余额
|
||||
sysUser.setUserBalance(NumberUtils.toDouble("1"));
|
||||
// 注册用户,设置默认租户为0
|
||||
@@ -54,16 +65,15 @@ public class UserLoginServiceImpl implements UserLoginService {
|
||||
// 构建登录用户信息
|
||||
loginUser.setUserId(sysUser.getUserId());
|
||||
loginUser.setUsername(sysUser.getUserName());
|
||||
loginUser.setUserType(UserType.APP_USER.getUserType());
|
||||
loginUser.setUserType(UserType.SYS_USER.getUserType());
|
||||
loginUser.setOpenid(openid);
|
||||
} else {
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
||||
loginUser.setUserId(user.getUserId());
|
||||
loginUser.setUsername(user.getUserName());
|
||||
loginUser.setUserType(user.getUserType());
|
||||
loginUser.setUserType(UserType.SYS_USER.getUserType());
|
||||
loginUser.setOpenid(openid);
|
||||
}
|
||||
SysClientVo client = clientService.queryByClientId(clientId);
|
||||
SaLoginParameter model = new SaLoginParameter();
|
||||
model.setDeviceType(client.getDeviceType());
|
||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||
|
||||
Reference in New Issue
Block a user