mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
登录之后返回sessionId
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package cn.lihongjie.coal.dto;
|
||||
|
||||
import cn.lihongjie.coal.dto.base.OrgCommonDto;
|
||||
import cn.lihongjie.coal.entity.PermissionEntity;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
@@ -23,6 +21,8 @@ public class UserDto extends OrgCommonDto {
|
||||
@Comment("手机号")
|
||||
private String phone;
|
||||
|
||||
@Comment("会话ID")
|
||||
private String sessionId;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lihongjie.coal.service;
|
||||
|
||||
import cn.lihongjie.coal.common.Ctx;
|
||||
import cn.lihongjie.coal.dao.UserRepository;
|
||||
import cn.lihongjie.coal.dto.*;
|
||||
import cn.lihongjie.coal.entity.OrganizationEntity;
|
||||
@@ -26,7 +27,7 @@ import java.util.Optional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class UserService extends BaseService<UserEntity, UserRepository>{
|
||||
public class UserService extends BaseService<UserEntity, UserRepository> {
|
||||
|
||||
@Autowired
|
||||
UserRepository repository;
|
||||
@@ -38,15 +39,14 @@ public class UserService extends BaseService<UserEntity, UserRepository>{
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
public void init() {
|
||||
|
||||
passwordEncoder = Pbkdf2PasswordEncoder.defaultsForSpringSecurity_v5_8();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UserDto create(CreateUserDto request){
|
||||
public UserDto create(CreateUserDto request) {
|
||||
|
||||
request.setPassword(passwordEncoder.encode(request.getPassword()));
|
||||
UserEntity entity = mapper.toEntity(request);
|
||||
@@ -58,9 +58,7 @@ public class UserService extends BaseService<UserEntity, UserRepository>{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public UserDto update(UpdateUserDto request){
|
||||
public UserDto update(UpdateUserDto request) {
|
||||
UserEntity user = this.repository.get(request.getId());
|
||||
this.mapper.updateEntity(user, request);
|
||||
|
||||
@@ -68,27 +66,28 @@ public class UserService extends BaseService<UserEntity, UserRepository>{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void delete(IdRequest request){
|
||||
public void delete(IdRequest request) {
|
||||
|
||||
this.repository.deleteAllById(request.getIds());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UserDto getById(String id){
|
||||
public UserDto getById(String id) {
|
||||
|
||||
UserEntity user = repository.get(id);
|
||||
|
||||
|
||||
return mapper.toDto(user);
|
||||
UserDto dto = mapper.toDto(user);
|
||||
if (Ctx.isLoggedIn()) {
|
||||
dto.setSessionId(Ctx.getSessionId());
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public UserDto changePwd(ChangeUserPwdDto request){
|
||||
public UserDto changePwd(ChangeUserPwdDto request) {
|
||||
|
||||
|
||||
UserEntity user = repository.findById(request.getId()).orElseThrow(() -> new BizException("用户不存在"));
|
||||
@@ -102,9 +101,7 @@ public class UserService extends BaseService<UserEntity, UserRepository>{
|
||||
repository.save(user);
|
||||
|
||||
return
|
||||
getById(request.getId());
|
||||
|
||||
|
||||
getById(request.getId());
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user