Browse Source

显示模板信息

master
453530270@qq.com 2 years ago
parent
commit
cacd30952a
  1. 6
      conf/conf.properties
  2. 6
      pom.xml
  3. 10
      src/main/java/io/xtfs/jwebfs/bean/WbFile.java
  4. 17
      src/main/java/io/xtfs/jwebfs/configure/EnvConfig.java
  5. 46
      src/main/java/io/xtfs/jwebfs/web/ChErrorController.java
  6. 43
      src/main/java/io/xtfs/jwebfs/web/WbFileController.java
  7. 19
      src/main/resources/application.properties
  8. 2
      src/main/resources/mapper/webfs/WbFileMapper.xml
  9. 4
      src/main/resources/static/css/aa.css
  10. 13
      src/main/resources/templates/wbfs/list.html
  11. 2
      src/test/java/io/xtfs/jwebfs/mapper/WbFileMapperTest.java

6
conf/conf.properties

@ -0,0 +1,6 @@
# 数据库服务器配置
type=com.alibaba.druid.pool.DruidDataSource
druid.driver-class=com.mysql.cj.jdbc.Driver
druid.url=jdbc:mysql://127.0.0.1:3306/wbfs?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
druid.username=root
druid.password=root

6
pom.xml

@ -45,6 +45,12 @@
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<!--mybaits spring集成包-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>

10
src/main/java/io/xtfs/jwebfs/bean/WbFile.java

@ -6,7 +6,7 @@ package io.xtfs.jwebfs.bean;
public class WbFile {
private Integer id; //
private String filenmae; // 文件名
private String filename; // 文件名
private String filehash; // 文件hash
public Integer getId() {
@ -17,12 +17,12 @@ public class WbFile {
this.id = id;
}
public String getFilenmae() {
return filenmae;
public String getFilename() {
return filename;
}
public void setFilenmae(String filenmae) {
this.filenmae = filenmae;
public void setFilename(String filename) {
this.filename = filename;
}
public String getFilehash() {

17
src/main/java/io/xtfs/jwebfs/configure/EnvConfig.java

@ -29,21 +29,4 @@ public class EnvConfig {
String curPath=System.getProperty("user.dir");
return curPath;
}
/**
* 文件上传临时路径
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement(){
MultipartConfigFactory factory = new MultipartConfigFactory();
String tempUrl = System.getProperty("user.dir") + File.separator + "upload" + File.separator + "tmp";
System.out.println("临时目录:" + tempUrl);
File file = new File(tempUrl);
if (!file.exists()) {
file.mkdirs();
}
factory.setLocation(tempUrl);
return factory.createMultipartConfig();
}
}

46
src/main/java/io/xtfs/jwebfs/web/ChErrorController.java

@ -0,0 +1,46 @@
package io.xtfs.jwebfs.web;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.ServletWebRequest;
import javax.servlet.http.HttpServletRequest;
/**
* 系统默认错误页面
*/
@RestController
public class ChErrorController implements ErrorController {
@Autowired
private ErrorAttributes errorAttributes;
/**
* 默认错误
*/
private static final String path_default = "/error";
public String getErrorPath() {
return path_default;
}
/**
* JSON格式错误信息
*/
@RequestMapping(value = path_default, produces = {MediaType.APPLICATION_JSON_VALUE})
public JSONObject error(HttpServletRequest request) {
JSONObject jsonObject =new JSONObject();
ServletWebRequest servletWebRequest = new ServletWebRequest(request);
jsonObject.put("errmsg",errorAttributes.getErrorAttributes(servletWebRequest, ErrorAttributeOptions.defaults()));
return jsonObject;
}
}

43
src/main/java/io/xtfs/jwebfs/web/WbFileController.java

@ -0,0 +1,43 @@
package io.xtfs.jwebfs.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
/**
* webfile 文件管理
*/
@Controller
@RequestMapping("/wbfs")
public class WbFileController {
private static final Log log = LogFactory.getLog(WbFileController.class);
/**
* webfs home
* @param page
* @return
*/
@RequestMapping("")
public ModelAndView wblist(@RequestParam(value = "page",defaultValue = "1") int page){
long curts = System.currentTimeMillis();
ModelAndView mv = new ModelAndView();
mv.addObject("tstr",curts);
mv.setViewName("/wbfs/list");
return mv;
}
/**
* 监视文件夹信息如果有变动 发送变动的信息给
* @param reqstr
* @return
*/
@PostMapping("/notify")
public int add(@RequestBody String reqstr){
log.info("notify:"+reqstr);
return 1;
}
}

19
src/main/resources/application.properties

@ -26,8 +26,25 @@ spring.servlet.multipart.location=./upload/tmp
server.tomcat.max-http-form-post-size=2MB
# 静态资源
spring.mvc.static-path-pattern=/upload/**
spring.mvc.static-path-pattern=/static/**
# 设置日志级别为DEBUG模式
#log4j.rootLogger=DEBUG, stdout
# 静态资源文件的配置
#spring.web.resources.static-locations=classpath:/static
#spring.mvc.static-path-pattern=/static/**
# freemarker 配置
spring.freemarker.template-loader-path=classpath:/templates
spring.freemarker.suffix=.html
spring.freemarker.enabled=true
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=false
spring.freemarker.expose-session-attributes=false
spring.freemarker.request-context-attribute=request
spring.freemarker.settings.template_update_delay=0
spring.freemarker.settings.default_encoding=UTF-8
spring.freemarker.settings.classic_compatible=true

2
src/main/resources/mapper/webfs/WbFileMapper.xml

@ -2,7 +2,7 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="yc.mall.api.mapper.WbFileMapper">
<mapper namespace="io.xtfs.jwebfs.mapper.WbFileMapper">
<sql id="column">id.filename,filehash</sql>
<sql id="tbName">wbfile</sql>

4
src/main/resources/static/css/aa.css

@ -0,0 +1,4 @@
*{
margin: 0;
padding: 0;
}

13
src/main/resources/templates/wbfs/list.html

@ -0,0 +1,13 @@
<#assign rootPath=springMacroRequestContext.contextPath />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="${rootPath}/static/css/aa.css">
</head>
<body>
${tstr}
</body>
</html>

2
src/test/java/io/xtfs/jwebfs/mapper/WbFileMapperTest.java

@ -19,7 +19,7 @@ public class WbFileMapperTest {
public void addRs() {
WbFile wbFile = new WbFile();
wbFile.setFilehash("ss");
wbFile.setFilenmae("test");
wbFile.setFilename("test");
int rt= wbFileMapper.addRs(wbFile);
System.out.println(rt);
}

Loading…
Cancel
Save