日志添加医院管理员可以查询本医院的,日志添加医院id
This commit is contained in:
parent
c2ba966fa4
commit
98e0dfa77a
|
@ -455,6 +455,7 @@ CREATE TABLE `sys_log`
|
|||
`time` bigint DEFAULT NULL COMMENT '执行时间',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志',
|
||||
`exception` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '异常信息',
|
||||
`hospital_id` bigint DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `sys_log_request_uri` (`request_uri`) USING BTREE,
|
||||
KEY `sys_log_type` (`log_type`) USING BTREE,
|
||||
|
|
|
@ -136,4 +136,6 @@ public class SysLog implements Serializable {
|
|||
@Schema(description = "删除标记,1:已删除,0:正常")
|
||||
private String delFlag;
|
||||
|
||||
private Long hospitalId;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,9 +9,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.rax.admin.api.dto.SysLogDTO;
|
||||
import com.rax.admin.api.entity.SysLog;
|
||||
import com.rax.admin.api.entity.SysRole;
|
||||
import com.rax.admin.api.entity.SysUser;
|
||||
import com.rax.admin.mapper.SysLogMapper;
|
||||
import com.rax.admin.service.SysLogService;
|
||||
import com.rax.admin.service.SysRoleService;
|
||||
import com.rax.admin.service.SysUserService;
|
||||
import com.rax.common.security.service.RaxUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
@ -32,14 +34,21 @@ import java.util.Map;
|
|||
@Service
|
||||
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {
|
||||
private final static String ADMIN_ROLE_CODE = "ROLE_ADMIN";
|
||||
|
||||
private final static String SITE_ROLE_CODE = "ROLE_CHIEF";
|
||||
|
||||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
|
||||
@Override
|
||||
public Page getLogByPage(Page page, SysLogDTO sysLog) {
|
||||
RaxUser raxUser = (RaxUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
List<SysRole> roleList = roleService.findRolesByUserId(raxUser.getId());
|
||||
List<SysRole> adminRoleList = roleList.stream().filter(predicate -> ADMIN_ROLE_CODE.contains(predicate.getRoleCode())).toList();
|
||||
List<SysRole> siteRoleList = roleList.stream().filter(predicate -> SITE_ROLE_CODE.contains(predicate.getRoleCode())).toList();
|
||||
|
||||
LambdaQueryWrapper<SysLog> wrapper = Wrappers.lambdaQuery();
|
||||
if (StrUtil.isNotBlank(sysLog.getLogType())) {
|
||||
|
@ -47,7 +56,12 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
|||
}
|
||||
|
||||
if (adminRoleList.isEmpty()) {
|
||||
wrapper.eq(SysLog::getCreateBy, raxUser.getName());
|
||||
if (siteRoleList.isEmpty()) {
|
||||
wrapper.eq(SysLog::getCreateBy, raxUser.getName());
|
||||
} else {
|
||||
SysUser sysUser = userService.getById(raxUser.getId());
|
||||
wrapper.eq(SysLog::getHospitalId, sysUser.getHospitalId());
|
||||
}
|
||||
}
|
||||
|
||||
if (ArrayUtil.isNotEmpty(sysLog.getTimeInterval())) {
|
||||
|
@ -68,6 +82,8 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean saveLog(SysLog sysLog) {
|
||||
SysUser sysUser = userService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, sysLog.getCreateBy()));
|
||||
sysLog.setHospitalId(sysUser.getHospitalId());
|
||||
baseMapper.insert(sysLog);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user