use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class ThirdLoginController method getThirdLoginUser.
@SuppressWarnings("unchecked")
@RequestMapping(value = "/getLoginUser/{token}/{thirdType}", method = RequestMethod.GET)
@ResponseBody
public Result<JSONObject> getThirdLoginUser(@PathVariable("token") String token, @PathVariable("thirdType") String thirdType) throws Exception {
Result<JSONObject> result = new Result<JSONObject>();
String username = JwtUtil.getUsername(token);
// 1. 校验用户是否有效
SysUser sysUser = sysUserService.getUserByName(username);
result = sysUserService.checkUserIsEffective(sysUser);
if (!result.isSuccess()) {
return result;
}
// update-begin-author:wangshuai date:20201118 for:如果真实姓名和头像不存在就取第三方登录的
LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<>();
query.eq(SysThirdAccount::getSysUserId, sysUser.getId());
query.eq(SysThirdAccount::getThirdType, thirdType);
SysThirdAccount account = sysThirdAccountService.getOne(query);
if (oConvertUtils.isEmpty(sysUser.getRealname())) {
sysUser.setRealname(account.getRealname());
}
if (oConvertUtils.isEmpty(sysUser.getAvatar())) {
sysUser.setAvatar(account.getAvatar());
}
// update-end-author:wangshuai date:20201118 for:如果真实姓名和头像不存在就取第三方登录的
JSONObject obj = new JSONObject();
// 用户登录信息
obj.put("userInfo", sysUser);
// token 信息
obj.put("token", token);
result.setResult(obj);
result.setSuccess(true);
result.setCode(200);
baseCommonService.addLog("用户名: " + username + ",登录成功[第三方用户]!", CommonConstant.LOG_TYPE_1, null);
return result;
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project kms by mahonelau.
the class ThirdLoginController method loginThird.
@RequestMapping("/{source}/callback")
public String loginThird(@PathVariable("source") String source, AuthCallback callback, ModelMap modelMap) {
log.info("第三方登录进入callback:" + source + " params:" + JSONObject.toJSONString(callback));
AuthRequest authRequest = factory.get(source);
AuthResponse response = authRequest.login(callback);
log.info(JSONObject.toJSONString(response));
Result<JSONObject> result = new Result<JSONObject>();
if (response.getCode() == 2000) {
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(response.getData()));
String username = data.getString("username");
String avatar = data.getString("avatar");
String uuid = data.getString("uuid");
// 构造第三方登录信息存储对象
ThirdLoginModel tlm = new ThirdLoginModel(source, uuid, username, avatar);
// 判断有没有这个人
// update-begin-author:wangshuai date:20201118 for:修改成查询第三方账户表
LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<SysThirdAccount>();
query.eq(SysThirdAccount::getThirdUserUuid, uuid);
query.eq(SysThirdAccount::getThirdType, source);
List<SysThirdAccount> thridList = sysThirdAccountService.list(query);
SysThirdAccount user = null;
if (thridList == null || thridList.size() == 0) {
// 否则直接创建新账号
user = saveThirdUser(tlm);
} else {
// 已存在 只设置用户名 不设置头像
user = thridList.get(0);
}
// update-begin-author:wangshuai date:20201118 for:从第三方登录查询是否存在用户id,不存在绑定手机号
if (oConvertUtils.isNotEmpty(user.getSysUserId())) {
String sysUserId = user.getSysUserId();
SysUser sysUser = sysUserService.getById(sysUserId);
String token = saveToken(sysUser);
modelMap.addAttribute("token", token);
} else {
modelMap.addAttribute("token", "绑定手机号," + "" + uuid);
}
// update-end-author:wangshuai date:20201118 for:从第三方登录查询是否存在用户id,不存在绑定手机号
// update-begin--Author:wangshuai Date:20200729 for:接口在签名校验失败时返回失败的标识码 issues#1441--------------------
} else {
modelMap.addAttribute("token", "登录失败");
}
// update-end--Author:wangshuai Date:20200729 for:接口在签名校验失败时返回失败的标识码 issues#1441--------------------
result.setSuccess(false);
result.setMessage("第三方登录异常,请联系管理员");
return "thirdLogin";
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project RuoYi-Vue-Plus by JavaLionLi.
the class SysDictTypeServiceImpl method deleteDictTypeByIds.
/**
* 批量删除字典类型信息
*
* @param dictIds 需要删除的字典ID
*/
@Override
public void deleteDictTypeByIds(Long[] dictIds) {
for (Long dictId : dictIds) {
SysDictType dictType = selectDictTypeById(dictId);
if (dictDataMapper.exists(new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getDictType, dictType.getDictType()))) {
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
}
RedisUtils.deleteObject(getCacheKey(dictType.getDictType()));
}
baseMapper.deleteBatchIds(Arrays.asList(dictIds));
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project yshopmall by guchengwuyue.
the class YxStoreCouponUserServiceImpl method queryAll.
@Override
public // @Cacheable
Map<String, Object> queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxStoreCouponUser> page = new PageInfo<>(queryAll(criteria));
List<YxStoreCouponUserDto> storeOrderDTOS = generator.convert(page.getList(), YxStoreCouponUserDto.class);
for (YxStoreCouponUserDto couponUserDTO : storeOrderDTOS) {
YxUser yxUser = userService.getOne(new LambdaQueryWrapper<YxUser>().eq(YxUser::getUid, couponUserDTO.getUid()));
if (yxUser == null) {
couponUserDTO.setNickname("--");
continue;
}
couponUserDTO.setNickname(yxUser.getNickname());
}
Map<String, Object> map = new LinkedHashMap<>(2);
map.put("content", storeOrderDTOS);
map.put("totalElements", page.getTotal());
return map;
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project yshopmall by guchengwuyue.
the class QiNiuServiceImpl method upload.
@Override
// @CacheEvict(allEntries = true)
@Transactional(rollbackFor = Exception.class)
public QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig) {
FileUtil.checkSize(maxSize, file.getSize());
if (qiniuConfig.getId() == null) {
throw new BadRequestException("请先添加相应配置,再操作");
}
// 构造一个带指定Zone对象的配置类
Configuration cfg = new Configuration(QiNiuUtil.getRegion(qiniuConfig.getZone()));
UploadManager uploadManager = new UploadManager(cfg);
Auth auth = Auth.create(qiniuConfig.getAccessKey(), qiniuConfig.getSecretKey());
String upToken = auth.uploadToken(qiniuConfig.getBucket());
try {
String key = file.getOriginalFilename();
if (qiniuContentService.getOne(new LambdaQueryWrapper<QiniuContent>().eq(QiniuContent::getName, key)) != null) {
key = QiNiuUtil.getKey(key);
}
Response response = uploadManager.put(file.getBytes(), key, upToken);
// 解析上传成功的结果
DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class);
QiniuContent content = qiniuContentService.getOne(new LambdaQueryWrapper<QiniuContent>().eq(QiniuContent::getName, FileUtil.getFileNameNoEx(putRet.key)));
if (content == null) {
// 存入数据库
QiniuContent qiniuContent = new QiniuContent();
qiniuContent.setSuffix(FileUtil.getExtensionName(putRet.key));
qiniuContent.setBucket(qiniuConfig.getBucket());
qiniuContent.setType(qiniuConfig.getType());
qiniuContent.setName(FileUtil.getFileNameNoEx(putRet.key));
qiniuContent.setUrl(qiniuConfig.getHost() + "/" + putRet.key);
qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(file.getSize() + "")));
qiniuContentService.save(qiniuContent);
return qiniuContent;
}
return content;
} catch (Exception e) {
throw new BadRequestException(e.getMessage());
}
}
Aggregations