员工角色 名称

This commit is contained in:
2026-04-27 11:32:35 +08:00
parent 61e1aeb16a
commit b1a39167ac
2 changed files with 14 additions and 4 deletions

View File

@@ -89,6 +89,8 @@ public class ShopStaff implements Serializable {
@Column(ignore = true) @Column(ignore = true)
private Long roleId; private Long roleId;
@Column(ignore = true) @Column(ignore = true)
private String roleName;
@Column(ignore = true)
private String accountName; private String accountName;
@Column(ignore = true) @Column(ignore = true)
private String accountPwd; private String accountPwd;

View File

@@ -17,7 +17,6 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
@@ -48,7 +47,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean add(ShopStaffAddDTO shopStaffAddDTO) { public Boolean add(ShopStaffAddDTO shopStaffAddDTO) {
SysUser sysUser = sysUserService.addUser(shopStaffAddDTO.getName(), StpKit.USER.getLoginIdAsString() + "@" +shopStaffAddDTO.getAccountName(), SysUser sysUser = sysUserService.addUser(shopStaffAddDTO.getName(), StpKit.USER.getLoginIdAsString() + "@" + shopStaffAddDTO.getAccountName(),
shopStaffAddDTO.getAccountPwd(), shopStaffAddDTO.getPhone(), shopStaffAddDTO.getRoleId()); shopStaffAddDTO.getAccountPwd(), shopStaffAddDTO.getPhone(), shopStaffAddDTO.getRoleId());
ShopStaff shopStaff = BeanUtil.copyProperties(shopStaffAddDTO, ShopStaff.class); ShopStaff shopStaff = BeanUtil.copyProperties(shopStaffAddDTO, ShopStaff.class);
shopStaff.setShopId(StpKit.USER.getLoginIdAsLong()); shopStaff.setShopId(StpKit.USER.getLoginIdAsLong());
@@ -104,7 +103,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
BeanUtil.copyProperties(shopStaffEditDTO, shopStaff); BeanUtil.copyProperties(shopStaffEditDTO, shopStaff);
updateById(shopStaff); updateById(shopStaff);
if (shopStaffEditDTO.getShopPermissionIds() != null ) { if (shopStaffEditDTO.getShopPermissionIds() != null) {
shopStaffPermissionService.updateChain().eq(ShopStaffPermission::getStaffId, shopStaff.getId()) shopStaffPermissionService.updateChain().eq(ShopStaffPermission::getStaffId, shopStaff.getId())
.eq(ShopStaffPermission::getShopId, StpKit.USER.getShopId()).eq(ShopStaffPermission::getUserId, shopStaff.getId()).remove(); .eq(ShopStaffPermission::getShopId, StpKit.USER.getShopId()).eq(ShopStaffPermission::getUserId, shopStaff.getId()).remove();
// 权限添加 // 权限添加
@@ -152,7 +151,16 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
} }
queryWrapper.eq(ShopStaff::getShopId, StpKit.USER.getLoginIdAsLong()); queryWrapper.eq(ShopStaff::getShopId, StpKit.USER.getLoginIdAsLong());
return page(PageUtil.buildPage(), queryWrapper); Page<ShopStaff> page = page(PageUtil.buildPage(), queryWrapper);
for (ShopStaff record : page.getRecords()) {
SysUsersRoles sysUsersRoles = sysUsersRolesService.getOne(new QueryWrapper().eq(SysUsersRoles::getUserId, record.getId()));
if (sysUsersRoles != null) {
record.setRoleId(sysUsersRoles.getRoleId());
SysRole role = sysRoleService.getById(sysUsersRoles.getRoleId());
record.setRoleName(role == null ? "" : role.getName());
}
}
return page;
} }
@Override @Override