| | |
| | | package com.vci.ubcs.log.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.vci.ubcs.log.entity.LogOperate; |
| | | import com.vci.ubcs.log.mapper.LogOperateMapper; |
| | | import com.vci.ubcs.log.service.ILogOperateService; |
| | | import com.vci.ubcs.starter.util.UBCSCondition; |
| | | import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.log.model.LogOperate; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | * @date 2023/11/24 10:51 |
| | | */ |
| | | @Service |
| | | public class LogOperateServiceImpl extends ServiceImpl<LogOperateMapper,LogOperate> implements ILogOperateService { |
| | | public class LogOperateServiceImpl extends ServiceImpl<LogOperateMapper, LogOperate> implements ILogOperateService { |
| | | |
| | | @Autowired |
| | | private LogOperateMapper logOperateMapper; |
| | |
| | | if(Func.isEmpty(logOperate)){ |
| | | return false; |
| | | } |
| | | // 获取到角色名称判断是否为三员管理员 |
| | | String userRole = AuthUtil.getUserRole().toLowerCase(Locale.ROOT); |
| | | userRole = Func.isBlank(userRole) ? logOperate.getUserName():userRole; |
| | | if(userRole.contains("auditadmin") || userRole.contains("sysadmin") || userRole.contains("secadmin") || userRole.contains("admin")){ |
| | | logOperate.setIsAdmin(1); |
| | | } |
| | | return SqlHelper.retBool(logOperateMapper.insert(logOperate)); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<LogOperate> listByCondition(BladeQueryObject bladeQueryObject) throws ServiceException{ |
| | | public IPage<LogOperate> listByCondition(BladeQueryObject bladeQueryObject) throws ServiceException{ |
| | | Map<String, Object> conditionMap = bladeQueryObject.getConditionMap(); |
| | | if(conditionMap.isEmpty() || Func.isBlank(conditionMap.get("logType").toString())){ |
| | | // 主要为了区分是操作日志还是登录日志等 |
| | | if(conditionMap.isEmpty() || Func.isBlank(conditionMap.get("log_type").toString())){ |
| | | throw new ServiceException("日志查询必传参数【日志类型】不能为空!"); |
| | | } |
| | | // map对象转换为查询对象 |
| | | QueryWrapper<LogOperate> queryWrapper = Condition.getQueryWrapper(bladeQueryObject.getConditionMap(),LogOperate.class); |
| | | return this.list(queryWrapper); |
| | | LambdaQueryWrapper<LogOperate> wrapper = UBCSCondition.getQueryWrapper(bladeQueryObject.getConditionMap(), LogOperate.class).lambda(); |
| | | wrapper.select( |
| | | LogOperate::getOid, |
| | | LogOperate::getUserName, |
| | | LogOperate::getRealName, |
| | | LogOperate::getIp, |
| | | LogOperate::getModel, |
| | | LogOperate::getOperate, |
| | | LogOperate::getTime, |
| | | LogOperate::getOperateResult, |
| | | LogOperate::getLogType, |
| | | LogOperate::getIsAdmin |
| | | ); |
| | | IPage<LogOperate> logOperateIPage = this.logOperateMapper.selectPage(Condition.getPage(bladeQueryObject.getQuery().setDescs("TIME")), wrapper); |
| | | return logOperateIPage; |
| | | } |
| | | |
| | | /** |
| | | * 根据oid查询日志详情 |
| | | * @param oid |
| | | * @return |
| | | * @throws ServiceException |
| | | */ |
| | | @Override |
| | | public LogOperate detailByOid(String oid) throws ServiceException { |
| | | if(Func.isBlank(oid)){ |
| | | throw new ServiceException("必传参数日志的oid不能为空!"); |
| | | } |
| | | LogOperate logOperate = this.logOperateMapper.selectOne(Wrappers.<LogOperate>query().lambda().eq(LogOperate::getOid, oid)); |
| | | return logOperate; |
| | | } |
| | | |
| | | |
| | | } |