Commit 1e6fd989 authored by zhangqingle's avatar zhangqingle

增加控制日志等级接口

parent 8b0ab389
......@@ -1368,6 +1368,25 @@ public class BLessonServiceImpl implements BLessonService {
if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
//获取讲师部门
List<String> ids = new ArrayList<>();
ids.add(bLesson.getLecturerId());
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0 && mtUserInfoRspDTO.getId().equals(bLesson.getLecturerId())) {
//设置部门名
bLesson.setLecturerDeptName(mtUserInfoRspDTO.getDepts().get(0).getName());
bLesson.setLecturerPic(mtUserInfoRspDTO.getAvatar());
}
});
}
int trainApplyCount = bLessonRepository.trainApplyCount(bLesson.getBusinessId());
if (StringUtils.isNotEmpty(bLesson.getMaxApplyPerson()) && !"0".equals(bLesson.getMaxApplyPerson()) && trainApplyCount >= Integer.parseInt(bLesson.getMaxApplyPerson())) {
bLesson.setApplyIsFull("1");
......
package org.rcisoft.common.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/logback")
public class LogbackController {
private Logger log = LoggerFactory.getLogger(LogbackController.class);
@RequestMapping(value = "/logback")
public String logj(){
log.error("我是error");
log.warn("我是warn");
log.info("我是info");
log.debug("我是debug");
return "success";
}
/**
* logback动态修改包名的日志级别
* @param level 日志级别
* @param packageName 包名
* @return
* @throws Exception
*/
@RequestMapping(value = "/level")
public String updateLogbackLevel( @RequestParam(value="level") String level,
@RequestParam(value="packageName",defaultValue = "-1") String packageName) throws Exception {
ch.qos.logback.classic.LoggerContext loggerContext =(ch.qos.logback.classic.LoggerContext) LoggerFactory.getILoggerFactory();
if(packageName.equals("-1")) {
// 默认值-1,更改全局日志级别;否则按传递的包名或类名修改日志级别。
loggerContext.getLogger("root").setLevel(ch.qos.logback.classic.Level.toLevel(level));
} else {
loggerContext.getLogger(packageName).setLevel(ch.qos.logback.classic.Level.valueOf(level));
}
return "success";
}
}
\ No newline at end of file
......@@ -58,7 +58,7 @@ public class CurUserAspect {
if(null == model)
throw new ServiceException(ResultExceptionEnum.USER_NO_AUTHEN);
//免登 不拦截
if(methodSignature.getName().equals("loginByCode") || methodSignature.getName().equals("refreshToken") || methodSignature.getName().equals("synchronizedUsers"))
if(methodSignature.getName().equals("loginByCode") || methodSignature.getName().equals("refreshToken") || methodSignature.getName().equals("synchronizedUsers") || methodSignature.getName().equals("updateLogbackLevel"))
return;
CurUser curUser = (CurUser) model;
//非法权限
......
......@@ -19,7 +19,7 @@ import java.io.*;
public class FileReadableUtil {
public static void main(String[] args) {
String filePath = "C:\\Users\\三\\Desktop\\素材\\加密-pdf.pdf";
String filePath = "C:\\Users\\三\\Desktop\\素材\\63.7M-82页.docx";
fileReadable(filePath,(long)100,100);
}
......@@ -138,7 +138,7 @@ public class FileReadableUtil {
File file = new File(path);
Long size = file.length();
if (size > (long)(1024 * 1024 * fileMaxSize)){
throw new ServiceException("该文件超过最大"+fileMaxSize+"M限制");
throw new ServiceException(400,"该文件超过最大"+fileMaxSize+"M限制");
}
Integer pages = -1;
......@@ -164,7 +164,7 @@ public class FileReadableUtil {
}
if (pages != -1 && pages > fileMaxPages) {
throw new ServiceException("该文件超过最多"+fileMaxPages+"M限制");
throw new ServiceException(400,"该文件超过最多"+fileMaxPages+"页限制");
}
// if (!CheckFileHeaderUtil.toCheck(path)){
......
......@@ -6,6 +6,6 @@ import lombok.extern.slf4j.Slf4j;
public class LogUtil {
//文件转换日志打印
public static void fileChangeLog(String message){
log.debug(message);
log.warn(message);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment