员工管理

This commit is contained in:
2024-07-26 09:20:44 +08:00
parent ae8fdd72b3
commit b8a0a14b21
5 changed files with 38 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ import cn.ysk.cashier.system.domain.Role;
import cn.ysk.cashier.system.domain.User;
import cn.ysk.cashier.system.repository.UserRepository;
import cn.ysk.cashier.system.service.UserService;
import cn.ysk.cashier.system.service.dto.RoleSmallDto;
import cn.ysk.cashier.system.service.dto.UserDto;
import cn.ysk.cashier.utils.*;
import lombok.RequiredArgsConstructor;
@@ -36,6 +37,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.CollectionUtils;
import java.time.Instant;
import java.util.*;
@@ -77,7 +79,11 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
ValidationUtil.isNull(tbPlussShopStaff.getId(),"TbPlussShopStaff","id",id);
TbPlussShopStaffDto dto = tbPlussShopStaffMapper.toDto(tbPlussShopStaff);
UserDto userDto = userService.findByName(tbPlussShopStaff.getAccount());
dto.setUser(userDto);
// dto.setUser(userDto);
if(!CollectionUtils.isEmpty(userDto.getRoles())){
dto.setRoleId(userDto.getRoles().stream().findFirst().get().getId());
}
dto.setPhone(userDto.getPhone());
return dto;
}
@@ -104,7 +110,11 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
Set<Role> roles = new HashSet<>();
Role role = new Role();
role.setId(2L);
if(resources.getRoleId()!=null){
role.setId(resources.getRoleId());
}else {
role.setId(2l);
}
roles.add(role);
user.setRoles(roles);
@@ -137,6 +147,15 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
userRepository.save(sysUser);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateStatus(TbPlussShopStaff resources) {
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffRepository.findById(resources.getId()).orElseGet(TbPlussShopStaff::new);
tbPlussShopStaff.setUpdatedAt(Instant.now().toEpochMilli());
tbPlussShopStaff.setStatus(resources.getStatus());
tbPlussShopStaffRepository.save(tbPlussShopStaff);
}
@Override
public void deleteAll(Integer[] ids) {
Set<Long> sysUserIds=new HashSet<>();

View File

@@ -67,6 +67,8 @@ public interface TbPlussShopStaffService {
*/
void update(TbPlussShopStaff resources);
void updateStatus(TbPlussShopStaff resources);
/**
* 多选删除
* @param ids /