员工管理
This commit is contained in:
@@ -76,6 +76,14 @@ public class TbPlussShopStaffController {
|
|||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("updateStatus")
|
||||||
|
@Log("修改员工状态:#resources.name")
|
||||||
|
@ApiOperation("修改/shop/shopStaff")
|
||||||
|
public ResponseEntity<Object> updateStatus(@Validated @RequestBody TbPlussShopStaff resources){
|
||||||
|
tbPlussShopStaffService.updateStatus(resources);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@Log("删除员工:#ids")
|
@Log("删除员工:#ids")
|
||||||
@ApiOperation("删除/shop/shopStaff")
|
@ApiOperation("删除/shop/shopStaff")
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package cn.ysk.cashier.dto.shop;
|
package cn.ysk.cashier.dto.shop;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.system.service.dto.RoleSmallDto;
|
||||||
import cn.ysk.cashier.system.service.dto.UserDto;
|
import cn.ysk.cashier.system.service.dto.UserDto;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -22,6 +23,7 @@ import lombok.Data;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
@@ -70,7 +72,10 @@ public class TbPlussShopStaffDto implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer isPc;
|
private Integer isPc;
|
||||||
|
|
||||||
private UserDto user;
|
// private UserDto user;
|
||||||
|
// private RoleSmallDto roles;
|
||||||
|
private Long roleId;
|
||||||
|
private String phone;
|
||||||
|
|
||||||
private Long createdAt;
|
private Long createdAt;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package cn.ysk.cashier.pojo.shop;
|
package cn.ysk.cashier.pojo.shop;
|
||||||
|
|
||||||
|
import cn.ysk.cashier.system.service.dto.RoleSmallDto;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import cn.ysk.cashier.system.domain.Role;
|
|||||||
import cn.ysk.cashier.system.domain.User;
|
import cn.ysk.cashier.system.domain.User;
|
||||||
import cn.ysk.cashier.system.repository.UserRepository;
|
import cn.ysk.cashier.system.repository.UserRepository;
|
||||||
import cn.ysk.cashier.system.service.UserService;
|
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.system.service.dto.UserDto;
|
||||||
import cn.ysk.cashier.utils.*;
|
import cn.ysk.cashier.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -36,6 +37,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -77,7 +79,11 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
ValidationUtil.isNull(tbPlussShopStaff.getId(),"TbPlussShopStaff","id",id);
|
ValidationUtil.isNull(tbPlussShopStaff.getId(),"TbPlussShopStaff","id",id);
|
||||||
TbPlussShopStaffDto dto = tbPlussShopStaffMapper.toDto(tbPlussShopStaff);
|
TbPlussShopStaffDto dto = tbPlussShopStaffMapper.toDto(tbPlussShopStaff);
|
||||||
UserDto userDto = userService.findByName(tbPlussShopStaff.getAccount());
|
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;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +110,11 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
|
|
||||||
Set<Role> roles = new HashSet<>();
|
Set<Role> roles = new HashSet<>();
|
||||||
Role role = new Role();
|
Role role = new Role();
|
||||||
role.setId(2L);
|
if(resources.getRoleId()!=null){
|
||||||
|
role.setId(resources.getRoleId());
|
||||||
|
}else {
|
||||||
|
role.setId(2l);
|
||||||
|
}
|
||||||
roles.add(role);
|
roles.add(role);
|
||||||
user.setRoles(roles);
|
user.setRoles(roles);
|
||||||
|
|
||||||
@@ -137,6 +147,15 @@ public class TbPlussShopStaffServiceImpl implements TbPlussShopStaffService {
|
|||||||
userRepository.save(sysUser);
|
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
|
@Override
|
||||||
public void deleteAll(Integer[] ids) {
|
public void deleteAll(Integer[] ids) {
|
||||||
Set<Long> sysUserIds=new HashSet<>();
|
Set<Long> sysUserIds=new HashSet<>();
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ public interface TbPlussShopStaffService {
|
|||||||
*/
|
*/
|
||||||
void update(TbPlussShopStaff resources);
|
void update(TbPlussShopStaff resources);
|
||||||
|
|
||||||
|
void updateStatus(TbPlussShopStaff resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
* @param ids /
|
* @param ids /
|
||||||
|
|||||||
Reference in New Issue
Block a user