package com.yongjie.system.service.impl;
import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.date.*;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yongjie.dic.domain.Area;
import com.yongjie.dic.domain.Dept;
import com.yongjie.dic.service.AreaService;
import com.yongjie.dic.service.DeptService;
import com.yongjie.framework.common.base.domain.BaseUser;
import com.yongjie.framework.common.base.service.Impl.BaseServiceImpl;
import com.yongjie.framework.common.constant.CommonConstant;
import com.yongjie.framework.common.constant.ExceptionMsgConstant;
import com.yongjie.framework.common.constant.RSAConstant;
import com.yongjie.framework.common.constant.StringConstant;
import com.yongjie.framework.common.enums.RegexpEnum;
import com.yongjie.framework.common.exception.ServerException;
import com.yongjie.framework.common.util.DateUtils;
import com.yongjie.framework.common.util.RSAUtil;
import com.yongjie.framework.common.util.SaTokenUtil;
import com.yongjie.framework.common.util.StringUtils;
import com.yongjie.sms.domain.SysUserSmsLog;
import com.yongjie.sms.service.SysUserSmsLogService;
import com.yongjie.system.domain.User;
import com.yongjie.system.domain.UserLockLog;
import com.yongjie.system.domain.UserRole;
import com.yongjie.system.domain.vo.UserVo;
import com.yongjie.system.dto.LoginDto;
import com.yongjie.system.dto.UpdatePwdDto;
import com.yongjie.system.dto.UpdatePwdSmsDto;
import com.yongjie.system.mapper.UserMapper;
import com.yongjie.system.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import javax.naming.AuthenticationException;
import java.time.LocalDateTime;
import java.util.*;
/**
* @author Bob
* @description 针对表【sys_user(系统用户表)】的数据库操作Service实现
* @createDate 2023-02-28 16:06:25
*/
@Slf4j
@Service
public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements UserService {
//权限
@Resource
private RoleService roleService;
@Resource
private DeptService deptService;
@Resource
private AreaService areaService;
//用户-锁定用户历史
@Resource
private UserLockLogService userLockLogService;
// 用户角色
@Resource
private UserRoleService userRoleService;
@Resource
private SysUserSmsLogService sysUserSmsLogService;
@Resource
private AccountsbptService accountsbptService;
@Resource
private AccountxzspService accountxzspService;
/**
* 这个密码在登录后会要求强制修改
*/
private static final String SIMPLE_PWD = "abc1234";
@Override
public Map<String, Object> doLogin(LoginDto loginDto) {
// RSA私钥解密username和password
String username = RSAUtil.decryptByPrivateKey(RSAConstant.LOGIN_PRIVATE_KEY, loginDto.getUsername());
String password = RSAUtil.decryptByPrivateKey(RSAConstant.LOGIN_PRIVATE_KEY, loginDto.getPassword());
String loginType = RSAUtil.decryptByPrivateKey(RSAConstant.LOGIN_PRIVATE_KEY, loginDto.getLoginType());
// String s = SecureUtil.md5(username + password);
User user = new User();
if("机构报名".equals(loginType)){
user = accountsbptService.getUserByName(username, "1854075011552514049");
}else if("承检单位".equals(loginType)){
user = accountsbptService.getUserByName(username, "1854076857616699393");
}else if("审批人员".equals(loginType)){
user = accountxzspService.getUserByName(username);
}else {
user = this.getUserByName(username);
password = username + password;
}
log.info("user==={}", user);
//判断用户密码是否正确
if (user == null || !StringUtils.equalsIgnoreCase(user.getPassword(), SecureUtil.md5(password))) {
throw new ServerException(ExceptionMsgConstant.USERNAME_OR_PASSWORD_IS_NOT_CORRECT);
}
//判断当前用户的状态
log.info("user.getStatus()==={}", user.getStatus());
if (StrUtil.equals(user.getStatus(), CommonConstant.STATUS_INVALID)) {
throw new ServerException(ExceptionMsgConstant.ACCOUNT_IS_LOCKED);
}
user.setSimplePwd(StrUtil.equals(password, SIMPLE_PWD));
user.setLoginType(loginType);
//登录用户,将用户信息保存的SaSession中后,生成token并返回
return getLoginToken(user);
}
@Override
public Map<String, Object> oneClickLogin(String username) {
User user = this.getUserByName(username);
log.info("user==={}", user);
log.info("user.getStatus()==={}", user.getStatus());
if (StrUtil.equals(user.getStatus(), CommonConstant.STATUS_INVALID)) {
throw new ServerException(ExceptionMsgConstant.ACCOUNT_IS_LOCKED);
}
return getLoginToken(user);
}
@Override
public Map<String, Object> getLoginToken(User user) {
StpUtil.login(user.getUsername());
user.setPassword(StringConstant.EMPTY);
user.setSalt(StringConstant.EMPTY);
String deptId = user.getDeptId();
if (StringUtils.isNotEmpty(deptId)) {
Dept dept = deptService.getById(deptId);
user.setDeptName(dept == null ? "" : dept.getName());
}
String areaCode = user.getAreaCode();
log.info("areaCode==={}", areaCode);
if (StringUtils.isNotEmpty(areaCode)) {
Area area = areaService.getByCode(areaCode);
log.info("area==={}", area);
if (area != null) {
user.setAreaId(area.getId().toString());
}
}
List<String> roleList = roleService.getUserRoleCode(user.getId());
SaSession userSession = StpUtil.getSession();
userSession.set(CommonConstant.USER_IN_SESSION_KEY, user);
userSession.set(CommonConstant.USER_ROLE_CODE_IN_SESSION_KEY, roleList);
log.info("获取token前===");
Map<String, Object> resultToken = new HashMap<String, Object>(2);
resultToken.put(StpUtil.getTokenName(), StpUtil.getTokenValue());
resultToken.put("user", user);
log.info("获取token前===");
resultToken.put("role", roleList.toString());
return resultToken;
}
@Override
public User getUserByName(String username) {
return this.lambdaQuery().eq(User::getUsername, username).one();
}
@Override
public User getUserByIdCard(String idCard) {
return this.lambdaQuery().eq(User::getIdCard, idCard).one();
}
@Override
public String resetPwd(String userids) {
List<String> pwdList = new ArrayList<>();
String format = DatePattern.PURE_DATE_FORMAT.format(new DateTime());
String[] userid = userids.split(StringConstant.COMMA);
for (String id : userid) {
User user = this.checkIdAndReturnDomain(Long.valueOf(id));
//重置密码为 用户名@当前日期
user.resetPwd();
this.updateById(user);
pwdList.add(StrUtil.format("密码重置为:{}@{}", user.getUsername(), format));
}
return pwdList.toString();
}
@Override
public IPage<?> listPage(IPage<User> page, User t) throws AuthenticationException {
return this.lambdaQuery().like(StringUtils.isNotEmpty(t.getUsername()), User::getUsername, t.getUsername()) // 账号
.like(StringUtils.isNotEmpty(t.getTruename()), User::getTruename, t.getTruename()) // 姓名
.like(StringUtils.isNotEmpty(t.getEmail
没有合适的资源?快使用搜索试试~ 我知道了~
基于JavaScript与多语言集成的天津能力验证系统设计源码
共1147个文件
gif:311个
java:223个
class:192个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 124 浏览量
2024-12-14
00:22:31
上传
评论
收藏 38.7MB ZIP 举报
温馨提示
该系统是一款基于JavaScript与多语言集成的天津能力验证系统设计源码,包含1144个文件,涵盖311个GIF图像、223个Java类文件、192个CSS样式表、113个HTML文件、101个PNG图片、56个CSS文件、42个JavaScript脚本以及32个XML配置文件等。项目采用了Java、HTML、CSS和JavaScript等多种语言编写,适用于天津能力验证项目的需求。
资源推荐
资源详情
资源评论
收起资源包目录
基于JavaScript与多语言集成的天津能力验证系统设计源码 (1147个子文件)
$PRODUCT_WORKSPACE_FILE$ 489B
UserServiceImpl.class 23KB
BaseServiceImpl.class 18KB
PdfUtil.class 17KB
MinioUtil.class 16KB
UserController.class 15KB
DeptServiceImpl.class 12KB
FileUploadUtil.class 11KB
ZipUtil.class 10KB
DeptController.class 10KB
AreaController.class 10KB
GlobalExceptionHandler.class 9KB
RedisUtil.class 8KB
MvcConfiguration.class 8KB
ImgUtils.class 8KB
SmsUtil.class 7KB
RoleController.class 7KB
SmsLog.class 7KB
StringUtils.class 7KB
EasyExcelUtil.class 7KB
SysUserSignServiceImpl.class 7KB
UserRoleServiceImpl.class 7KB
AreaServiceImpl.class 6KB
FileDownUtil.class 6KB
BaseUser.class 6KB
SmsUtil.class 6KB
Dept.class 6KB
MenuController.class 6KB
ImageToPdfUtil.class 6KB
JsonResult.class 6KB
Convert.class 6KB
BaseService.class 6KB
MybatisPlusConfiguration.class 5KB
SysUserSignController.class 5KB
FileUploadConfig.class 5KB
SmsLogController.class 5KB
RedisConfiguration.class 5KB
RoleGroupController.class 5KB
AsyncService.class 5KB
TreeUtil.class 5KB
DateUtils.class 4KB
RegexpEnum.class 4KB
RSAUtil.class 4KB
TreeNodeUtil.class 4KB
RepeatLimitAspect.class 4KB
CommonUtil.class 4KB
TreeEntityConfig.class 3KB
SysUserSmsLogController.class 3KB
VoZipFujian.class 3KB
MinioConfig.class 3KB
BaseController.class 3KB
ServletUtils.class 3KB
SmsLogServiceImpl.class 3KB
Area.class 3KB
MvcConfiguration$1.class 3KB
NlyzYzjhController.class 3KB
UserService.class 3KB
MybatisPlusConfiguration$1.class 3KB
MultiDateFormat.class 3KB
JacksonConfiguration.class 3KB
RegexpValidator.class 3KB
FileUtil.class 3KB
NlyzNlyzController.class 3KB
BaseTreeEntity.class 3KB
User.class 3KB
RoleMenuServiceImpl.class 3KB
UpdatePwdSmsDto.class 2KB
ServerException.class 2KB
SaTokenUtil.class 2KB
RoleServiceImpl.class 2KB
UserLockLog.class 2KB
NlyzNlyz.class 2KB
AreaVo.class 2KB
ZipFujian.class 2KB
MergePdfVo.class 2KB
ThreadPoolTaskExecutorConfiguration.class 2KB
ErrorCode.class 2KB
DeptService.class 2KB
MenuServiceImpl.class 2KB
RoleMenuController.class 2KB
RoleGroupServiceImpl.class 2KB
SmsEntity.class 2KB
CustomJavaTimeModule.class 2KB
Menu.class 2KB
UserRole.class 2KB
RoleGroup.class 2KB
RoleMenu.class 2KB
UploadEnum.class 2KB
BaseFileEntity.class 2KB
FastJson2RedisSerializer.class 2KB
NlyzYzjh.class 2KB
UpdatePwdDto.class 2KB
UserRoleController.class 2KB
StrFormatter.class 2KB
CharsetKit.class 2KB
TimeTypeOffEnum.class 2KB
TimeTypeEnum.class 2KB
SysUserSign.class 2KB
TjNlyzServerApplication.class 2KB
BizFlagEnum.class 2KB
共 1147 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
资源评论
csbysj2020
- 粉丝: 2752
- 资源: 5535
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 数据库建模工具PDManer
- 鱼检测30-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- Python代码实现了一个基于PointNet架构的深度学习模型,用于处理点云数据分类任务 代码涵盖了模型的各个组件定义(如卷积层、全连接层、归一化层等)
- 前端分析-2023071100789
- Objective-C文件操作代码
- 鱼检测29-YOLO(v5至v9)、COCO、Darknet、TFRecord、VOC数据集合集.rar
- Python+Pygame制作飞机大战素材
- 鱼检测12-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、VOC数据集合集.rar
- 西门子V90 EPOS电子齿轮比和LU怎样设置.mp4
- python面对对象编程2
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功