Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
[fix] Fixed some naming and definition errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RAOE committed Dec 12, 2021
1 parent fbbbba1 commit fbedf55
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.show.admin.scetc.interceptor.DemoInterceptor;
import com.show.admin.scetc.interceptor.MethodInterceptor;

/**
* 全局配置类webmvcconfigurerAdapter
Expand Down Expand Up @@ -35,8 +35,8 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {

// 用于测试用户请求的时间
@Bean
public DemoInterceptor demoInterceptor() {
return new DemoInterceptor();
public MethodInterceptor demoInterceptor() {
return new MethodInterceptor();
}

//开发环境暂时关闭
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,119 +29,116 @@
import com.show.admin.scetc.utils.XyfJsonResult;

/**
*
* @author Ray
*
*/
@RestController
@RequestMapping("/bgm")
public class BgmController extends BasicController {

@Autowired
private BgmService bgmService;

/**
* 分页查询背景音乐的列表
*
* @param keyword
* @param page
* @param pageSize
* @return
*/
@SysLog
@RequestMapping("/selectBgmList")
public XyfJsonResult selectBgmList(String keyword, String title,
@RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
@RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize) {
PageResult list = bgmService.queryAll(page, pageSize, keyword, title);
return XyfJsonResult.ok(list);
}

/**
* 根据状态码来更新背景音乐
*
* @param id
* @param status
* @param author
* @param name
* @return
*/
@SysLog
@RequestMapping("/updateBgm")
public XyfJsonResult updateBgm(Long id, String status, String author, String name) {

if (status.equals(DELETE)) {
bgmService.deleteBgm(id);
return XyfJsonResult.ok();
} else if (status.equals(UPDATE)) {
bgmService.updateBgm(id, author, name);
return XyfJsonResult.ok();
}
return XyfJsonResult.errorMsg("参数错误");

}

/**
* 查询一条背景音乐的详细信息
*
* @param id
* @return
*/
@SysLog
@PostMapping("/selectResourceById")
public XyfJsonResult selectResourceById(Long id) {
// 根据id查询出一个背景音乐的全部信息
Bgm bgm = bgmService.selectOne(id);
return XyfJsonResult.ok(bgm);

}

/**
* 上传音乐代码
*
* @param request
* @return
* @throws Exception
*/
@SysLog
@PostMapping("/addSubmit.do")
public @ResponseBody XyfJsonResult uploadMulPic(HttpServletRequest request) throws Exception {

AdminUser adminUserVo = (AdminUser) request.getSession().getAttribute("adminUser");
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultiValueMap<String, MultipartFile> multiFileMap = multipartRequest.getMultiFileMap();
for (String key : multiFileMap.keySet()) {
List<MultipartFile> MultipartFiles = multiFileMap.get(key);
for (MultipartFile files : MultipartFiles) {
String fileName = files.getOriginalFilename();
String fosName = UUID.randomUUID().toString() + ".mp3";
String finalPath = bgm_filePath + fosName;
File saveFile = new File(finalPath);// 定义背景音乐的上传路径
File parentFile = saveFile.getParentFile();
if (saveFile.exists()) {
saveFile.delete();
} else if (!parentFile.exists()) {
parentFile.mkdirs();
} else if (files.getSize() != 0 && files.getSize() > 0) {
FileOutputStream fos = new FileOutputStream(saveFile);
Bgm bgm = new Bgm();
fileName = HtmlUtils.htmlEscape(fileName);
bgm.setAuthor(fileName);
bgm.setName(fileName);
bgm.setPath(File.separator+"bgm"+File.separator+ fosName);
bgmService.insert(bgm);
IOUtils.copy(files.getInputStream(), fos);// 复制流
SimpleDateFormat formate = new SimpleDateFormat();
String date = formate.format(new Date());
redis.lpush(Operate_REDIS_SESSION,
date + "&nbsp;&nbsp;&nbsp;" + adminUserVo.getRealName() + ":添加了背景音乐" + fileName);// 存放到redis

} else {
continue;
}
}
}
return XyfJsonResult.ok();
}
@Autowired
private BgmService bgmService;

/**
* 分页查询背景音乐的列表
*
* @param keyword
* @param page
* @param pageSize
* @return
*/
@SysLog
@RequestMapping("/selectBgmList")
public XyfJsonResult selectBgmList(String keyword, String title,
@RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
@RequestParam(value = "pageSize", required = true, defaultValue = "10") Integer pageSize) {
PageResult list = bgmService.queryAll(page, pageSize, keyword, title);
return XyfJsonResult.ok(list);
}

/**
* 根据状态码来更新背景音乐
*
* @param id
* @param status
* @param author
* @param name
* @return
*/
@SysLog
@RequestMapping("/updateBgm")
public XyfJsonResult updateBgm(Long id, String status, String author, String name) {

if (status.equals(DELETE)) {
bgmService.deleteBgm(id);
return XyfJsonResult.ok();
} else if (status.equals(UPDATE)) {
bgmService.updateBgm(id, author, name);
return XyfJsonResult.ok();
}
return XyfJsonResult.errorMsg("参数错误");

}

/**
* 查询一条背景音乐的详细信息
*
* @param id
* @return
*/
@SysLog
@PostMapping("/selectResourceById")
public XyfJsonResult selectResourceById(Long id) {
// 根据id查询出一个背景音乐的全部信息
Bgm bgm = bgmService.selectOne(id);
return XyfJsonResult.ok(bgm);

}

/**
* 上传音乐代码
*
* @param request
* @return
* @throws Exception
*/
@SysLog
@PostMapping("/addSubmit.do")
public @ResponseBody
XyfJsonResult uploadMulPic(HttpServletRequest request) throws Exception {

AdminUser adminUserVo = (AdminUser) request.getSession().getAttribute("adminUser");
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultiValueMap<String, MultipartFile> multiFileMap = multipartRequest.getMultiFileMap();
for (String key : multiFileMap.keySet()) {
List<MultipartFile> MultipartFiles = multiFileMap.get(key);
for (MultipartFile files : MultipartFiles) {
String fileName = files.getOriginalFilename();
String fosName = UUID.randomUUID().toString() + ".mp3";
String finalPath = bgm_filePath + fosName;
File saveFile = new File(finalPath);// 定义背景音乐的上传路径
File parentFile = saveFile.getParentFile();
if (saveFile.exists()) {
saveFile.delete();
} else if (!parentFile.exists()) {
parentFile.mkdirs();
} else if (files.getSize() != 0 && files.getSize() > 0) {
FileOutputStream fos = new FileOutputStream(saveFile);
Bgm bgm = new Bgm();
fileName = HtmlUtils.htmlEscape(fileName);
bgm.setAuthor(fileName);
bgm.setName(fileName);
bgm.setPath(File.separator + "bgm" + File.separator + fosName);
bgmService.insert(bgm);
IOUtils.copy(files.getInputStream(), fos);// 复制流
SimpleDateFormat formate = new SimpleDateFormat();
String date = formate.format(new Date());
redis.lpush(Operate_REDIS_SESSION,
date + "&nbsp;&nbsp;&nbsp;" + adminUserVo.getRealName() + ":添加了背景音乐" + fileName);// 存放到redis

}
}
}
return XyfJsonResult.ok();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

//对每一个请求进行拦截 并计算每一个请求的响应时间,输出到控制台
@Component
public class DemoInterceptor extends HandlerInterceptorAdapter {
public class MethodInterceptor extends HandlerInterceptorAdapter {

//拦截请求
// preHandle方法是进行处理器拦截用的,顾名思义,该方法将在Controller处理之前进行调用,SpringMVC中的Interceptor拦截器是链式的,可以同时存在
Expand All @@ -20,8 +20,6 @@ public class DemoInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
long startTime = System.currentTimeMillis();
request.setAttribute("startTime", startTime);
return super.preHandle(request, response, handler);
}

Expand All @@ -34,13 +32,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {

long startTime = (long) request.getAttribute("startTime");
request.removeAttribute("startTime");
long endTime = System.currentTimeMillis();
System.out.println("请求响应时间" + new Long(endTime - startTime) + "ms");
super.postHandle(request, response, handler, modelAndView);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ server.port=8082
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost/scetc-show-video-dev?characterEncoding=utf8&useSSL=false&serverTimezone=GMT
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.password=123456
mybatis.type-aliases-package=com.show.admin.scetc.pojo
mybatis.mapper-locations=classpath:mapper/*.xml
#mapper
Expand Down Expand Up @@ -31,17 +31,17 @@ spring.redis.pool.max-wait=-1
spring.redis.pool.max-idle=8
spring.redis.pool.min-idle=0
spring.redis.timeout=0
spring.redis.password=xuyuanfeng
spring.redis.password=
spring.devtools.restart.enabled: true
spring.http.multipart.max-file-size=50Mb
spring.http.multipart.max-request-size=50Mb
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
# 视频存放路径„
# 视频存放路径
web.upload.path=D://show_videos_dev
# 背景音乐存放路径„
# 背景音乐存放路径
bgm.upload.path=D://show_videos_dev//bgm//
# 定义需要映射为url的路径
classpath_mapping=classpath:/META-INF/resources/
Expand Down

0 comments on commit fbedf55

Please sign in to comment.