检测系统,员工管理

This commit is contained in:
许允枞 2024-10-29 15:13:47 +08:00
parent b458fc1b7b
commit baf972df52
10 changed files with 102 additions and 0 deletions

View File

@ -97,4 +97,24 @@ public class RoleController {
BeanUtils.toBean(list, RoleRespVO.class));
}
/**
* app端通过服务套餐id查询角色列表
* @param roleDO
* @return
*/
@GetMapping("/pageByQuery")
public CommonResult pageByQuery(RoleDO roleDO){
return success(roleService.pageByQuery(roleDO));
}
/**
* 通过角色id查询角色
* @param roleIds
* @return
*/
@GetMapping("/selectListByRoleId")
public CommonResult selectListByRoleId(RolePageReqVO role){
return success(roleService.selectListByRoleId(role));
}
}

View File

@ -24,6 +24,10 @@ public class RolePageReqVO extends PageParam {
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
private Integer status;
private Long roleId;
private String nickname;
@Schema(description = "创建时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -42,6 +43,9 @@ public class RoleRespVO {
@Schema(description = "角色类型,参见 RoleTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer type;
@Schema(description = "服务套餐id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private String servicePackageId;
@Schema(description = "备注", example = "我是一个角色")
private String remark;

View File

@ -27,6 +27,11 @@ public class RoleSaveReqVO {
@DiffLogField(name = "角色标志")
private String code;
@NotBlank(message = "服务套餐id不能为空")
@Schema(description = "服务套餐id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@DiffLogField(name = "服务套餐id")
private String servicePackageId;
@Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "显示顺序不能为空")
@DiffLogField(name = "显示顺序")

View File

@ -70,6 +70,15 @@ public class UserController {
userService.deleteUser(id);
return success(true);
}
@DeleteMapping("/deleteUserByIds")
@Operation(summary = "删除用户")
@PreAuthorize("@ss.hasPermission('system:user:delete')")
public CommonResult<Boolean> deleteUserByIds(@RequestBody List<Long> ids) {
for (Long id : ids) {
userService.deleteUser(id);
}
return success(true);
}
@PutMapping("/update-password")
@Operation(summary = "重置用户密码")

View File

@ -44,6 +44,10 @@ public class RoleDO extends TenantBaseDO {
* 角色排序
*/
private Integer sort;
/**
* 服务套餐编号
*/
private String servicePackageId;
/**
* 角色状态
*

View File

@ -1,9 +1,13 @@
package cn.iocoder.yudao.module.system.dal.mysql.permission;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -36,4 +40,6 @@ public interface UserRoleMapper extends BaseMapperX<UserRoleDO> {
}
List<UserDTO> selectByRoleCode(@Param("tenantId") Long tenantId, @Param("roleCode") String roleCode);
IPage<UserDTO> selectListByRoleId(@Param("page") Page<UserDTO> page,@Param("role") RolePageReqVO role);
}

View File

@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import javax.validation.Valid;
import java.util.Collection;
@ -157,4 +159,13 @@ public interface RoleService {
* @return java.util.List<cn.iocoder.yudao.module.system.api.user.dto.UserDTO>
**/
List<UserDTO> selectByRoleCode(Long tenantId,String roleCode);
/**
* 根据服务套餐查询角色
* @param roleDO
* @return
*/
List<RoleDO> pageByQuery(RoleDO roleDO);
IPage<UserDTO> selectListByRoleId(RolePageReqVO role);
}

View File

@ -16,12 +16,16 @@ import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
import cn.iocoder.yudao.module.system.dal.mysql.permission.RoleMapper;
import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper;
import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum;
import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum;
import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.annotations.VisibleForTesting;
import com.mzt.logapi.context.LogRecordContext;
import com.mzt.logapi.service.impl.DiffParseFunction;
@ -29,6 +33,7 @@ import com.mzt.logapi.starter.annotation.LogRecord;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@ -336,6 +341,24 @@ public class RoleServiceImpl implements RoleService {
return userRoleMapper.selectByRoleCode(tenantId,roleCode);
}
/**
* 根据服务套餐查询角色
*
* @param roleDO
* @return
*/
@Override
public List<RoleDO> pageByQuery(RoleDO roleDO) {
return roleMapper.selectList(new LambdaQueryWrapper<RoleDO>()
.eq(RoleDO::getServicePackageId, roleDO.getServicePackageId()));
}
@Override
public IPage<UserDTO> selectListByRoleId(RolePageReqVO role) {
Page<UserDTO> page = new Page<>(role.getPageNo(), role.getPageSize());
return userRoleMapper.selectListByRoleId(page,role);
}
/**
* 获得自身的代理对象解决 AOP 生效问题
*

View File

@ -19,4 +19,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sur.tenant_id = #{tenantId}
AND sur.role_id = ( SELECT id FROM system_role WHERE `code` = #{roleCode} ))
</select>
<select id="selectListByRoleId" resultType="cn.iocoder.yudao.module.system.api.user.dto.UserDTO"
parameterType="cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO">
select su.*
from system_user_role sr
left join system_users su on sr.user_id = su.id
left join system_role sr2 on sr.role_id = sr2.id
<where>
su.deleted = 0 and sr2.service_package_id = 'jiance'
<if test="role.roleId != null">
and sr.role_id = #{role.roleId}
</if>
<if test="role.nickname != null">
and su.nickname like CONCAT('%',#{role.nickname},'%')
</if>
</where>
</select>
</mapper>