From 36b5a2397a94f210d3f3a0723139aa5f2c638003 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期一, 03 六月 2024 11:54:02 +0800 Subject: [PATCH] 注册完善 --- src/main/java/com/ycl/jxkg/service/impl/UserServiceImpl.java | 41 +++++++++++++++++++++++++++++------------ 1 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/ycl/jxkg/service/impl/UserServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/UserServiceImpl.java index 11b15e9..23f0be5 100644 --- a/src/main/java/com/ycl/jxkg/service/impl/UserServiceImpl.java +++ b/src/main/java/com/ycl/jxkg/service/impl/UserServiceImpl.java @@ -1,13 +1,17 @@ package com.ycl.jxkg.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ycl.jxkg.domain.entity.UserEventLog; import com.ycl.jxkg.domain.enums.RoleEnum; +import com.ycl.jxkg.domain.enums.UserStatusEnum; import com.ycl.jxkg.domain.form.RegisterForm; import com.ycl.jxkg.domain.other.KeyValue; +import com.ycl.jxkg.event.UserEvent; import com.ycl.jxkg.exception.BusinessException; import com.ycl.jxkg.domain.entity.User; import com.ycl.jxkg.event.OnRegistrationCompleteEvent; import com.ycl.jxkg.mapper.UserMapper; +import com.ycl.jxkg.service.AuthenticationService; import com.ycl.jxkg.service.UserService; import com.ycl.jxkg.domain.vo.admin.user.UserPageRequestVO; import com.github.pagehelper.PageHelper; @@ -18,9 +22,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service @@ -29,6 +31,7 @@ private final UserMapper userMapper; private final ApplicationEventPublisher eventPublisher; + private final AuthenticationService authenticationService; public List<User> getUsers() { @@ -41,14 +44,6 @@ public User getUserByUserName(String username) { return userMapper.getUserByUserName(username); - } - - public int insertByFilter(User record) { - return baseMapper.insert(record); - } - - public int updateByIdFilter(User record) { - return baseMapper.updateById(record); } @Override @@ -151,10 +146,32 @@ User teacher = new User(); BeanUtils.copyProperties(form, teacher); teacher.setRole(RoleEnum.ADMIN.getCode()); + teacher.setPassword(authenticationService.pwdEncode(form.getPassword())); + teacher.setUserUuid(UUID.randomUUID().toString()); + teacher.setLastActiveTime(new Date()); + teacher.setStatus(UserStatusEnum.Enable.getCode()); + teacher.setDeleted(0); + this.insertUser(teacher); + // 鍙戝竷娉ㄥ唽浜嬩欢锛屼繚瀛樻敞鍐屾棩蹇� + UserEventLog userEventLog = new UserEventLog(teacher.getId(), teacher.getUserName(), teacher.getRealName(), new Date()); + userEventLog.setContent("娆㈣繋 " + teacher.getUserName() + " 娉ㄥ唽鏉ュ埌姹熻タ绌虹闊宠棰戝煿璁郴缁�"); + eventPublisher.publishEvent(new UserEvent(userEventLog)); } @Override public void studentRegister(RegisterForm form) { - + User student = new User(); + BeanUtils.copyProperties(form, student); + student.setRole(RoleEnum.ADMIN.getCode()); + student.setPassword(authenticationService.pwdEncode(form.getPassword())); + student.setUserUuid(UUID.randomUUID().toString()); + student.setLastActiveTime(new Date()); + student.setStatus(UserStatusEnum.Enable.getCode()); + student.setDeleted(0); + this.insertUser(student); + // 鍙戝竷娉ㄥ唽浜嬩欢锛屼繚瀛樻敞鍐屾棩蹇� + UserEventLog userEventLog = new UserEventLog(student.getId(), student.getUserName(), student.getRealName(), new Date()); + userEventLog.setContent("娆㈣繋 " + student.getUserName() + " 娉ㄥ唽鏉ュ埌姹熻タ绌虹闊宠棰戝煿璁郴缁�"); + eventPublisher.publishEvent(new UserEvent(userEventLog)); } } -- Gitblit v1.8.0