wangbing 7 years ago
parent e916a547e2
commit 0e0c3d3352

@ -13,7 +13,7 @@
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<!--<packaging>war</packaging>--><!--需要打包成war时放开-->
<name>FILEMGR-WEB</name>
<name>fmgr</name>
<description>project for Spring Boot</description>
<properties>
@ -28,12 +28,15 @@
<spring-cloud.version>Greenwich.RC2</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@ -50,6 +53,7 @@
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
@ -72,6 +76,13 @@
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<dependencyManagement>
@ -149,14 +160,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/src/main/resources/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
@ -176,12 +179,4 @@
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
</project>

@ -1,14 +1,11 @@
package xyz.wbsite;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
public class Application extends SpringBootServletInitializer {
@Override

@ -0,0 +1,68 @@
package xyz.wbsite.action;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import xyz.wbsite.frame.utils.LocalData;
import xyz.wbsite.frame.utils.MapperUtil;
import xyz.wbsite.frame.utils.Message;
import xyz.wbsite.frame.base.BaseResponse;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.utils.LogUtil;
import xyz.wbsite.frame.base.Error;
@Controller
public class AjaxController {
@RequestMapping("/ajax")
@ResponseBody
public BaseResponse ajax(@RequestParam("method") String method,HttpServletRequest request,HttpServletResponse response) {
BaseResponse baseResponse = new BaseResponse();
String jsonString = null;
try {
if (method == null){
baseResponse.addError(new Error(ErrorType.BUSINESS_ERROR, "请求方法不能为空!"));
return baseResponse;
}
Token token = LocalData.getToken();
if (token == null) {
token = LocalData.getTempToken();
}
if (!token.hasResource(method)) {
baseResponse.addError(new Error(ErrorType.BUSINESS_ERROR, "无权调用该接口!"));
return baseResponse;
}
InputStreamReader isr = new InputStreamReader(request.getInputStream(),"UTF-8");
BufferedReader in = new BufferedReader(isr);
jsonString = in.readLine();
switch (method) {
// 示例
case "ajax.example.example":
break;
default:
baseResponse.addError(ErrorType.INVALID_PARAMETER, Message.NOT_EXIST_METHOD);
break;
}
} catch (Exception ex) {
baseResponse.addError(ErrorType.SYSTEM_ERROR, Message.ERROR_500);
LogUtil.dumpException(ex);
} finally {
if(baseResponse.hasError()) {
LogUtil.e("请求方法" + method + ", 请求参数:" + jsonString);
LogUtil.e("返回结果包含异常" + MapperUtil.toJson(baseResponse));
}
}
return baseResponse;
}
}

@ -1,14 +1,13 @@
package xyz.wbsite.action;
import xyz.wbsite.framework.utils.LogUtil;
import xyz.wbsite.framework.base.FileUploadResponse;
import xyz.wbsite.framework.base.BaseResponse;
import xyz.wbsite.framework.base.ErrorType;
import xyz.wbsite.framework.base.Screen;
import xyz.wbsite.framework.utils.LocalData;
import xyz.wbsite.framework.config.BeanDefinitionRegistryConfig;
import org.springframework.beans.BeansException;
import org.apache.commons.io.FileUtils;
import xyz.wbsite.frame.base.FileUploadResponse;
import xyz.wbsite.frame.base.BaseResponse;
import xyz.wbsite.frame.base.ErrorType;
import xyz.wbsite.frame.base.Screen;
import xyz.wbsite.frame.utils.LocalData;
import xyz.wbsite.config.ActionConfig;
import org.springframework.beans.BeansException;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -26,9 +25,27 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Value;
import java.nio.file.Files;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 全局请求Controller,如果无特殊请求,则不需再增加其他Controller
* 全局htm后缀入口{@link GlobalController#hold}
* 全局异常捕捉{@link GlobalController#excepitonHandler}
* 全局上传接口{@link GlobalController#upload}
* 全局下载接口{@link GlobalController#download}
* <p>
* 说明Request命名规则,驼峰式命名
* Api#Example#Request ==> 目标#动作#Request
*
* @author author
* @version 0.0.1
* @since 2019-06-16
*/
@Controller
@ControllerAdvice
public class GlobalController implements ErrorController {
@ -88,28 +105,28 @@ public class GlobalController implements ErrorController {
}
}
@RequestMapping("/")
public String home() {
return "forward:" + homePage;
}
/**
* 当未明确指定控制器时,走该请求,默认返回对应的layout布局和screen视图
* 当需要使用layout时,不需要返回值,ViewNameTranslator会处理对应关系
*
* @param model
* @param request
*/
@RequestMapping("/**")
@RequestMapping({"/**/*.htm"})
public void hold(HttpServletRequest request, Model model) {
HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
// 处理根Url
String servletPath = request.getServletPath();
if ("/".equals(servletPath)) {
servletPath = "/" + homePage;
}
LocalData.setTarget(servletPath);
// 尝试执行Target Screen执行器(服务器渲染),不存在则直接返回视图模板(Ajax渲染)
Screen screenExec = null;
try {
servletPath = servletPath.replaceAll("/", ".").toLowerCase();
screenExec = LocalData.getApplicationContext().getBean(BeanDefinitionRegistryConfig.SCREEN_PREFIX + servletPath, Screen.class);
String target = LocalData.getTarget();
target = target.replaceAll("/", ".").toLowerCase();
screenExec = LocalData.getApplicationContext().getBean(ActionConfig.SCREEN_PREFIX + target, Screen.class);
screenExec.exec(model, request, response);
} catch (BeansException e) {
@ -121,49 +138,54 @@ public class GlobalController implements ErrorController {
@RequestMapping("/upload")
@ResponseBody
public BaseResponse upload(HttpServletRequest request) {
FileUploadResponse fileUploadResponse = new FileUploadResponse();
public String upload(HttpServletRequest request) {
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
MultipartFile target = multipartHttpServletRequest.getFile("file");
String path = multipartHttpServletRequest.getParameter("path");
String fileName = target.getOriginalFilename();
File file = new File(root, path + fileName);
if (file.exists()) {
int i = 1;
do {
int l = fileName.lastIndexOf(".");
file = new File(root, path + fileName.substring(0, l) + "(" + i + ")" + fileName.substring(l));
i++;
} while (file.exists());
}
//========
//处理文件
//========
fileUploadResponse.setId(1L);
fileUploadResponse.setUrl("example.com\\img\\1.jpg");
fileUploadResponse.setDownloadUrl("example.com\\img\\1.jpg");
if (target != null) {
fileUploadResponse.addError(ErrorType.BUSINESS_ERROR, "文件上传成功,但未处理文件[" + fileName + "]!");
} else {
fileUploadResponse.addError(ErrorType.BUSINESS_ERROR, "文件上传失败!");
try {
target.transferTo(file);
} catch (IOException e) {
e.printStackTrace();
}
return fileUploadResponse;
return "";
}
@Value("${file.root.path}")
private String root;
@RequestMapping("/download")
@ResponseBody
public ResponseEntity<byte[]> download(@RequestParam(value = "file", required = false) String file) throws IOException {
File downFile = new File(root, file);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
headers.setContentDispositionFormData("attachment", file);
headers.setContentDispositionFormData("attachment", new String(downFile.getName().getBytes("UTF-8"), "iso-8859-1"));
//========
//下载DEMO
//========
if (file == null) {
file = "test.txt";
headers.setContentDispositionFormData("attachment", file);
return new ResponseEntity<byte[]>("test".getBytes(),
headers, HttpStatus.CREATED);
}
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(new File(file)),
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(downFile),
headers, HttpStatus.CREATED);
}
}

@ -1,6 +1,6 @@
package xyz.wbsite.action.control;
import xyz.wbsite.framework.base.Control;
import xyz.wbsite.frame.base.Control;
import org.springframework.ui.Model;
import javax.servlet.http.HttpServletRequest;

@ -1,6 +1,6 @@
package xyz.wbsite.action.control;
import xyz.wbsite.framework.base.Control;
import xyz.wbsite.frame.base.Control;
import org.springframework.ui.Model;
import javax.servlet.http.HttpServletRequest;

@ -1,23 +1,73 @@
package xyz.wbsite.action.screen;
import xyz.wbsite.framework.base.Screen;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.ui.Model;
import java.util.ArrayList;
import xyz.wbsite.frame.base.Screen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
public class Index extends Screen {
@Value("${file.root.path}")
private String root;
@Override
public void exec(Model model, HttpServletRequest request, HttpServletResponse response) {
String path = request.getParameter("path");
if (path == null) {
path = root;
} else {
path = root + "/" + path;
}
System.out.println(path);
File rootFile = new File(path);
if (!rootFile.exists()) {
rootFile.mkdirs();
}
File[] files = rootFile.listFiles();
model.addAttribute("files", files);
model.addAttribute("path", new HtmlHepler().getPath(rootFile));
model.addAttribute("html", new HtmlHepler());
}
model.addAttribute("hello", "Hello world!!!");
model.addAttribute("status", 0);
public class HtmlHepler {
ArrayList<String> citys = new ArrayList<>();
citys.add("北京");
citys.add("上海");
citys.add("深圳");
model.addAttribute("citys", citys);
public String getPath(File file) {
if (file.getAbsolutePath().length() <= root.length()) {
return "";
}
String s = file.getAbsolutePath().substring(root.length() - 1);
s = s.replaceAll("\\\\", "/");
return s;
}
public String getHtml(File file) {
if (!file.isDirectory() || file.listFiles().length == 0) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append("<ul>");
for (File f : file.listFiles()) {
sb.append("<li>");
if (f.isDirectory()) {
sb.append("<a class='dir' href='?path=" + getPath(f) + "'>");
sb.append(f.getName());
sb.append("</a>");
sb.append(getHtml(f));
} else {
sb.append("<a href='download?file=" + getPath(f) + "'>");
sb.append(f.getName());
sb.append("</a>");
}
sb.append("</li>");
}
sb.append("</ul>");
return sb.toString();
}
}
}

@ -0,0 +1,25 @@
package xyz.wbsite.api.mgr;
import xyz.wbsite.api.req.*;
import xyz.wbsite.api.rsp.*;
import xyz.wbsite.frame.base.Token;
/**
* Api接口
*
* @author wangbing
* @version 0.0.1
* @since 2018-10-23
*/
public interface ApiManager {
/**
* Api#example
*
* @param request 请求对象
* @param token 令牌
* @return 响应
*/
ApiExampleResponse example(ApiExampleRequest request, Token token);
}

@ -0,0 +1,29 @@
package xyz.wbsite.api.mgr;
import xyz.wbsite.api.req.*;
import xyz.wbsite.api.rsp.*;
import xyz.wbsite.frame.base.Token;
import org.springframework.stereotype.Service;
/**
* Api接口
*
* @author wangbing
* @version 0.0.1
* @since 2018-10-23
*/
@Service
public class ApiManagerImpl implements ApiManager {
/**
* Api#example
*
* @param request 请求对象
* @param token 令牌
* @return 响应
*/
@Override
public ApiExampleResponse example(ApiExampleRequest request, Token token) {
return new ApiExampleResponse();
}
}

@ -0,0 +1,17 @@
package xyz.wbsite.api.req;
import xyz.wbsite.frame.base.BaseRequest;
/**
* ApiExampleRequest - Api示例请求
* <p>
* 说明Request命名规则,驼峰式命名
* Api#Example#Request ==> 目标#动作#Request
*
* @author wangbing
* @version 0.0.1
* @since 2019-06-29
*/
public class ApiExampleRequest extends BaseRequest {
}

@ -0,0 +1,17 @@
package xyz.wbsite.api.rsp;
import xyz.wbsite.frame.base.BaseResponse;
/**
* ApiExampleResponse - Api示例响应
* <p>
* 说明Response命名规则,驼峰式命名
* Api#Example#Response ==> 目标#动作#Response
*
* @author wangbing
* @version 0.0.1
* @since 2019-06-29
*/
public class ApiExampleResponse extends BaseResponse {
}

@ -1,7 +1,7 @@
package xyz.wbsite.framework.config;
package xyz.wbsite.config;
import xyz.wbsite.framework.base.Control;
import xyz.wbsite.framework.base.Screen;
import xyz.wbsite.frame.base.Control;
import xyz.wbsite.frame.base.Screen;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@ -16,16 +16,26 @@ import org.springframework.core.type.filter.TypeFilter;
import java.io.IOException;
/**
* 请求处理器配置类,Screen及Control
* <p>
* 注册扫描Screen处理器 {@link ActionConfig#registryScreen}
* 注册扫描Control处理器 {@link ActionConfig#registryControl}
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
@Configuration
public class BeanDefinitionRegistryConfig implements BeanDefinitionRegistryPostProcessor {
public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
public static final String SCREEN_PREFIX = "screen";
public static final String CONTROL_PREFIX = "control";
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
String aPackage = this.getClass().getPackage().getName();
int i = registryScreen(aPackage.replaceAll("framework.config", "action.screen"), beanDefinitionRegistry);
int i1 = registryControl(aPackage.replaceAll("framework.config", "action.control"), beanDefinitionRegistry);
int i = registryScreen("xyz.wbsite.action.screen", beanDefinitionRegistry);
int i1 = registryControl("xyz.wbsite.action.control", beanDefinitionRegistry);
System.out.println();
}

@ -1,4 +1,4 @@
package xyz.wbsite.framework.config;
package xyz.wbsite.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
@ -9,9 +9,9 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.Authentication;
import xyz.wbsite.framework.base.Token;
import xyz.wbsite.framework.utils.CookieUtil;
import xyz.wbsite.framework.utils.LocalData;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.utils.CookieUtil;
import xyz.wbsite.frame.utils.LocalData;
import javax.servlet.http.HttpServletRequest;
@Configuration
@ -22,8 +22,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
private String[] excluded;
@Value("${web.url.auth.included}")
private String[] included;
@Value("${web.url.login}")
private String login;
@Override
protected void configure(HttpSecurity http) throws Exception {
@ -71,8 +69,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
token1.setUserName("admin");
//继承临时Token
token1.addResourceSet(LocalData.getTempToken());
//管理员特有资源
token1.putResource("/admin/.*");
//管理员特有资源(这边请用正则表达式)
token1.putResource("/admin/.*\\.htm");
LocalData.setToken(token1);
}

@ -1,7 +1,7 @@
package xyz.wbsite.framework.config;
package xyz.wbsite.config;
import xyz.wbsite.framework.utils.LogUtil;
import xyz.wbsite.framework.utils.ProcessUtil;
import xyz.wbsite.frame.utils.LogUtil;
import xyz.wbsite.frame.utils.ProcessUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.scheduling.annotation.EnableScheduling;

@ -1,4 +1,4 @@
package xyz.wbsite.framework.config;
package xyz.wbsite.config;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Configuration;

@ -1,46 +1,33 @@
package xyz.wbsite.framework.config;
package xyz.wbsite.config;
import xyz.wbsite.framework.springmvc.GlobalHandlerInterceptor;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import xyz.wbsite.frame.base.Token;
import xyz.wbsite.frame.utils.LocalData;
import xyz.wbsite.frame.utils.LogUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import xyz.wbsite.framework.springmvc.GlobalHandlerInterceptor;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//将资源Order设为 -1 权重大于 Mapping,保证资源优先级高于Mapping("**")
registry.setOrder(-1);
}
@Autowired
private GlobalHandlerInterceptor globalHandlerInterceptor;
@Value("${web.welcome.page}")
private String homePage;
/**
* 增加全局拦截器,可用于
@ -49,7 +36,53 @@ public class WebMvcConfig implements WebMvcConfigurer {
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(globalHandlerInterceptor).addPathPatterns("/**").excludePathPatterns("/static/**");
registry.addInterceptor(new HandlerInterceptorAdapter() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 处理根Url
String servletPath = request.getServletPath();
if (servletPath.matches("(.+)\\.htm")) {
Pattern compile = Pattern.compile("(.+)\\.htm");
Matcher matcher = compile.matcher(servletPath);
if (matcher.find()) {
servletPath = matcher.group(1);
}
}
LocalData.setTarget(servletPath);
return super.preHandle(request, response, handler);
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
super.postHandle(request, response, handler, modelAndView);
//当请求为@ResponseBody,modelAndView为null,不处理
if (modelAndView == null) {
return;
}
//获取当前用户信息
Token token = LocalData.getToken();
modelAndView.addObject("token", token);
//主页
modelAndView.addObject("homePath", homePage);
//获取项目路径,在项目非根路径下用于拼接URL
String contextPath = request.getContextPath();
modelAndView.addObject("contextPath", contextPath);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
super.afterCompletion(request, response, handler, ex);
if (ex != null) {
LogUtil.dumpException(ex);
}
}
}).addPathPatterns("/**/*.htm").order(-1);
}
/**
@ -61,19 +94,15 @@ public class WebMvcConfig implements WebMvcConfigurer {
*/
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper objectMapper = jackson2HttpMessageConverter.getObjectMapper();
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
for (HttpMessageConverter<?> converter : converters) {
if (converter instanceof MappingJackson2HttpMessageConverter){
ObjectMapper objectMapper = ((MappingJackson2HttpMessageConverter)converter).getObjectMapper();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
objectMapper.registerModule(simpleModule);
jackson2HttpMessageConverter.setObjectMapper(objectMapper);
// 将转化器注册到首个
converters.add(0, jackson2HttpMessageConverter);
}
}
}
// @Bean

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Date;

@ -0,0 +1,29 @@
package xyz.wbsite.frame.base;
/**
* BaseFindRequest - 基类
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class BaseFindRequest extends BaseGetAllRequest {
private int pageNumber = 1;
private int pageSize = 10;
public int getPageNumber() {
return pageNumber;
}
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
}

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
import java.util.List;

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
/**
* BaseFindRequest - 基类

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
/**
* BaseRequest - 基类

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
import java.util.ArrayList;
import java.util.List;

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
/**
* BaseSearchRequest - 基类

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
/**
* BaseUpdateRequest - 基类

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
import org.springframework.ui.Model;

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
/**
* Error - 错误基类

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
/**
* ErrorType - 错误类型

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
public class FileUploadResponse extends BaseResponse {

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
import org.springframework.ui.Model;

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
/**
* SortTypeEnum - 排序方式

@ -1,4 +1,4 @@
package xyz.wbsite.framework.base;
package xyz.wbsite.frame.base;
import java.io.Serializable;
import java.util.HashSet;

@ -1,11 +1,10 @@
package xyz.wbsite.framework.freemarker;
package xyz.wbsite.frame.freemarker;
import java.io.File;
import xyz.wbsite.framework.config.BeanDefinitionRegistryConfig;
import xyz.wbsite.config.ActionConfig;
import freemarker.template.TemplateModelException;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.validation.support.BindingAwareModelMap;
import org.springframework.web.context.request.RequestContextHolder;
@ -17,8 +16,8 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;
import xyz.wbsite.framework.base.Control;
import xyz.wbsite.framework.utils.LocalData;
import xyz.wbsite.frame.base.Control;
import xyz.wbsite.frame.utils.LocalData;
/**
* 布局帮助类
@ -30,9 +29,6 @@ import xyz.wbsite.framework.utils.LocalData;
@Component
public class Layout {
@Value("${web.welcome.page}")
private String homePage;
@Autowired
private FreeMarkerViewResolver viewResolver;
@ -44,15 +40,9 @@ public class Layout {
try {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
LocaleResolver localeResolver = (LocaleResolver) request.getAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE);
String servletPath = request.getServletPath();
if ("/".equals(servletPath)) {
servletPath = this.homePage;
}
if (servletPath.startsWith("/")) {
servletPath = servletPath.substring(1);
}
String servletPath = LocalData.getTarget();
servletPath = servletPath.replaceAll("^/", "");
// 去除头部/
String[] split = servletPath.split("/");
StringBuilder sb = new StringBuilder("");
@ -84,7 +74,7 @@ public class Layout {
// 查找是否存在对应控制面板执行器
Control controlExec = null;
try {
controlExec = LocalData.getApplicationContext().getBean(BeanDefinitionRegistryConfig.CONTROL_PREFIX + "." + control, Control.class);
controlExec = LocalData.getApplicationContext().getBean(ActionConfig.CONTROL_PREFIX + "." + control, Control.class);
HttpServletRequest request = LocalData.getRequest();
HttpServletResponse response = LocalData.getResponse();

@ -1,4 +1,4 @@
package xyz.wbsite.framework.freemarker;
package xyz.wbsite.frame.freemarker;
import freemarker.template.TemplateModelException;
import org.springframework.stereotype.Component;

@ -1,25 +1,19 @@
package xyz.wbsite.framework.freemarker;
package xyz.wbsite.frame.freemarker;
import xyz.wbsite.frame.utils.LocalData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import xyz.wbsite.framework.utils.LocalData;
import xyz.wbsite.framework.utils.LogUtil;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.Locale;
import java.util.Map;
/**
* FreemarkerViewName解析器
*
@ -30,9 +24,6 @@ import java.util.Map;
@Component("viewNameTranslator")
public class ViewNameTranslator extends DefaultRequestToViewNameTranslator {
@Value("${web.welcome.page}")
private String homePage;
@Autowired
private FreeMarkerViewResolver viewResolver;
@Autowired
@ -53,12 +44,8 @@ public class ViewNameTranslator extends DefaultRequestToViewNameTranslator {
String viewName = "";
try {
LocaleResolver localeResolver = (LocaleResolver) request.getAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE);
String servletPath = request.getServletPath();
if (servletPath != null && "/".equals(servletPath)) {
servletPath = homePage;
} else {
String servletPath = LocalData.getTarget();
servletPath = servletPath.replaceAll("^/", "");
}
Locale locale = localeResolver.resolveLocale(request);
{//查询screen
@ -72,10 +59,9 @@ public class ViewNameTranslator extends DefaultRequestToViewNameTranslator {
viewName = sb.toString();
View view = viewResolver.resolveViewName(viewName, locale);
if (view == null) {
LogUtil.e("can not find screen.");
HttpServletResponse response = LocalData.getResponse();
response.setStatus(HttpStatus.NOT_FOUND.value());
return "";
// LogUtil.e("can not find screen.");
// HttpServletResponse response = LocalData.getResponse();
// response.setStatus(HttpStatus.NOT_FOUND.value());
}
}

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
@ -107,16 +107,4 @@ public class AESUtil {
}
return null;
}
public static void main(String[] args) {
// 加密
String data = "我有一个苹果";
String secret = "1234567890123456";
System.out.println("加密后的Base64密文是:" + AESUtil.encrypt2Base64(data.getBytes(), secret));
// 解密
String encrypt2Base64 = AESUtil.encrypt2Base64(data.getBytes(), secret);
byte[] decrypt = AESUtil.decrypt(Base64Util.decode(encrypt2Base64), secret);
System.out.println("解密后的明文是:" + new String(decrypt));
}
}

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import java.util.Arrays;
@ -494,13 +494,4 @@ public class Base64Util {
return dArr;
}
public static void main(String[] args) {
String s = Base64Util.encodeToString(("我搜搜").getBytes());
System.out.println(s);
byte[] decode = Base64Util.decode(s);
System.out.println(new String(decode));
}
}

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import javax.servlet.http.Cookie;

@ -0,0 +1,899 @@
package xyz.wbsite.frame.utils;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class FileUtil {
/**
* 私有构造方法,防止类的实例化,因为工具类不需要实例化。
*/
private FileUtil() {
}
/**
* 修改文件的最后访问时间。
* 如果文件不存在则创建该文件。
* <b>目前这个方法的行为方式还不稳定,主要是方法有些信息输出,这些信息输出是否保留还在考虑中。</b>
*
* @param file 需要修改最后访问时间的文件。
* @since 1.0
*/
public static void touch(File file) {
long currentTime = System.currentTimeMillis();
if (!file.exists()) {
System.err.println("file not found:" + file.getName());
System.err.println("Create a new file:" + file.getName());
try {
if (file.createNewFile()) {
System.out.println("Succeeded!");
} else {
System.err.println("Create file failed!");
}
} catch (IOException e) {
System.err.println("Create file failed!");
e.printStackTrace();
}
}
boolean result = file.setLastModified(currentTime);
if (!result) {
System.err.println("touch failed: " + file.getName());
}
}
/**
* 修改文件的最后访问时间。
* 如果文件不存在则创建该文件。
* <b>目前这个方法的行为方式还不稳定,主要是方法有些信息输出,这些信息输出是否保留还在考虑中。</b>
*
* @param fileName 需要修改最后访问时间的文件的文件名。
* @since 1.0
*/
public static void touch(String fileName) {
File file = new File(fileName);
touch(file);
}
/**
* 修改文件的最后访问时间。
* 如果文件不存在则创建该文件。
* <b>目前这个方法的行为方式还不稳定,主要是方法有些信息输出,这些信息输出是否保留还在考虑中。</b>
*
* @param files 需要修改最后访问时间的文件数组。
* @since 1.0
*/
public static void touch(File[] files) {
for (int i = 0; i < files.length; i++) {
touch(files[i]);
}
}
/**
* 修改文件的最后访问时间。
* 如果文件不存在则创建该文件。
* <b>目前这个方法的行为方式还不稳定,主要是方法有些信息输出,这些信息输出是否保留还在考虑中。</b>
*
* @param fileNames 需要修改最后访问时间的文件名数组。
* @since 1.0
*/
public static void touch(String[] fileNames) {
File[] files = new File[fileNames.length];
for (int i = 0; i < fileNames.length; i++) {
files[i] = new File(fileNames[i]);
}
touch(files);
}
/**
* 判断指定的文件是否存在。
*
* @param fileName 要判断的文件的文件名
* @return 存在时返回true,否则返回false。
* @since 1.0
*/
public static boolean isFileExist(String fileName) {
return new File(fileName).isFile();
}
/**
* 创建指定的目录。
* 如果指定的目录的父目录不存在则创建其目录书上所有需要的父目录。
* <b>注意:可能会在返回false的时候创建部分父目录。</b>
*
* @param file 要创建的目录
* @return 完全创建成功时返回true,否则返回false。
* @since 1.0
*/
public static boolean makeDirectory(File file) {
File parent = file.getParentFile();
if (parent != null) {
return parent.mkdirs();
}
return false;
}
/**
* 创建指定的目录。
* 如果指定的目录的父目录不存在则创建其目录书上所有需要的父目录。
* <b>注意:可能会在返回false的时候创建部分父目录。</b>
*
* @param fileName 要创建的目录的目录名
* @return 完全创建成功时返回true,否则返回false。
* @since 1.0
*/
public static boolean makeDirectory(String fileName) {
File file = new File(fileName);
return makeDirectory(file);
}
/**
* 清空指定目录中的文件。
* 这个方法将尽可能删除所有的文件,但是只要有一个文件没有被删除都会返回false。
* 另外这个方法不会迭代删除,即不会删除子目录及其内容。
*
* @param directory 要清空的目录
* @return 目录下的所有文件都被成功删除时返回true,否则返回false.
* @since 1.0
*/
public static boolean emptyDirectory(File directory) {
boolean result = true;
File[] entries = directory.listFiles();
for (int i = 0; i < entries.length; i++) {
if (!entries[i].delete()) {
result = false;
}
}
return result;
}
/**
* 清空指定目录中的文件。
* 这个方法将尽可能删除所有的文件,但是只要有一个文件没有被删除都会返回false。
* 另外这个方法不会迭代删除,即不会删除子目录及其内容。
*
* @param directoryName 要清空的目录的目录名
* @return 目录下的所有文件都被成功删除时返回true,否则返回false。
* @since 1.0
*/
public static boolean emptyDirectory(String directoryName) {
File dir = new File(directoryName);
return emptyDirectory(dir);
}
/**
* 删除指定目录及其中的所有内容。
*
* @param dirName 要删除的目录的目录名
* @return 删除成功时返回true,否则返回false。
* @since 1.0
*/
public static boolean deleteDirectory(String dirName) {
return deleteDirectory(new File(dirName));
}
/**
* 删除指定目录及其中的所有内容。
*
* @param dir 要删除的目录
* @return 删除成功时返回true,否则返回false。
* @since 1.0
*/
public static boolean deleteDirectory(File dir) {
if ((dir == null) || !dir.isDirectory()) {
throw new IllegalArgumentException("Argument " + dir +
" is not a directory. ");
}
File[] entries = dir.listFiles();
int sz = entries.length;
for (int i = 0; i < sz; i++) {
if (entries[i].isDirectory()) {
if (!deleteDirectory(entries[i])) {
return false;
}
} else {
if (!entries[i].delete()) {
return false;
}
}
}
if (!dir.delete()) {
return false;
}
return true;
}
/**
* 列出目录中的所有内容,包括其子目录中的内容。
*
* @param file 要列出的目录
* @param filter 过滤器
* @return 目录内容的文件数组。
* @since 1.0
*/
public static File[] listAll(File file,
javax.swing.filechooser.FileFilter filter) {
ArrayList list = new ArrayList();
File[] files;
if (!file.exists() || file.isFile()) {
return null;
}
list(list, file, filter);
files = new File[list.size()];
list.toArray(files);
return files;
}
/**
* 将目录中的内容添加到列表。
*
* @param list 文件列表
* @param filter 过滤器
* @param file 目录
*/
private static void list(ArrayList list, File file,
javax.swing.filechooser.FileFilter filter) {
if (filter.accept(file)) {
list.add(file);
if (file.isFile()) {
return;
}
}
if (file.isDirectory()) {
File files[] = file.listFiles();
for (int i = 0; i < files.length; i++) {
list(list, files[i], filter);
}
}
}
/**
* 返回文件的URL地址。
*
* @param file 文件
* @return 文件对应的的URL地址
* @throws MalformedURLException
* @since 1.0
* @deprecated 在实现的时候没有注意到File类本身带一个toURL方法将文件路径转换为URL。
* 请使用File.toURL方法。
*/
public static URL getURL(File file) throws MalformedURLException {
String fileURL = "file:/" + file.getAbsolutePath();
URL url = new URL(fileURL);
return url;
}
/**
* 从文件路径得到文件名。
*
* @param filePath 文件的路径,可以是相对路径也可以是绝对路径
* @return 对应的文件名
* @since 1.0
*/
public static String getFileName(String filePath) {
File file = new File(filePath);
return file.getName();
}
/**
* 从文件名得到文件绝对路径。
*
* @param fileName 文件名
* @return 对应的文件路径
* @since 1.0
*/
public static String getFilePath(String fileName) {
File file = new File(fileName);
return file.getAbsolutePath();
}
/**
* 将DOS/Windows格式的路径转换为UNIX/Linux格式的路径。
* 其实就是将路径中的"\"全部换为"/",因为在某些情况下我们转换为这种方式比较方便,
* 某中程度上说"/"比"\"更适合作为路径分隔符,而且DOS/Windows也将它当作路径分隔符。
*
* @param filePath 转换前的路径
* @return 转换后的路径
* @since 1.0
*/
public static String toUNIXpath(String filePath) {
return filePath.replace('\\', '/');
}
/**
* 从文件名得到UNIX风格的文件绝对路径。
*
* @param fileName 文件名
* @return 对应的UNIX风格的文件路径
* @see #toUNIXpath(String filePath) toUNIXpath
* @since 1.0
*/
public static String getUNIXfilePath(String fileName) {
File file = new File(fileName);
return toUNIXpath(file.getAbsolutePath());
}
/**
* 得到文件的类型。
* 实际上就是得到文件名中最后一个“.”后面的部分。
*
* @param fileName 文件名
* @return 文件名中的类型部分
* @since 1.0
*/
public static String getTypePart(String fileName) {
int point = fileName.lastIndexOf('.');
int length = fileName.length();
if (point == -1 || point == length - 1) {
return "";
} else {
return fileName.substring(point + 1, length);
}
}
/**
* 得到文件的类型。
* 实际上就是得到文件名中最后一个“.”后面的部分。
*
* @param file 文件
* @return 文件名中的类型部分
* @since 1.0
*/
public static String getFileType(File file) {
return getTypePart(file.getName());
}
/**
* 得到文件的名字部分。
* 实际上就是路径中的最后一个路径分隔符后的部分。
*
* @param fileName 文件名
* @return 文件名中的名字部分
* @since 1.0
*/
public static String getNamePart(String fileName) {
int point = getPathLsatIndex(fileName);
int length = fileName.length();
if (point == -1) {
return fileName;
} else if (point == length - 1) {
int secondPoint = getPathLsatIndex(fileName, point - 1);
if (secondPoint == -1) {
if (length == 1) {
return fileName;
} else {
return fileName.substring(0, point);
}
} else {
return fileName.substring(secondPoint + 1, point);
}
} else {
return fileName.substring(point + 1);
}
}
/**
* 得到文件名中的父路径部分。
* 对两种路径分隔符都有效。
* 不存在时返回""。
* 如果文件名是以路径分隔符结尾的则不考虑该分隔符,例如"/path/"返回""。
*
* @param fileName 文件名
* @return 父路径,不存在或者已经是父目录时返回""
* @since 1.0
*/
public static String getPathPart(String fileName) {
int point = getPathLsatIndex(fileName);
int length = fileName.length();
if (point == -1) {
return "";
} else if (point == length - 1) {
int secondPoint = getPathLsatIndex(fileName, point - 1);
if (secondPoint == -1) {
return "";
} else {
return fileName.substring(0, secondPoint);
}
} else {
return fileName.substring(0, point);
}
}
/**
* 得到路径分隔符在文件路径中首次出现的位置。
* 对于DOS或者UNIX风格的分隔符都可以。
*
* @param fileName 文件路径
* @return 路径分隔符在路径中首次出现的位置,没有出现时返回-1。
* @since 1.0
*/
public static int getPathIndex(String fileName) {
int point = fileName.indexOf('/');
if (point == -1) {
point = fileName.indexOf('\\');
}
return point;
}
/**
* 得到路径分隔符在文件路径中指定位置后首次出现的位置。
* 对于DOS或者UNIX风格的分隔符都可以。
*
* @param fileName 文件路径
* @param fromIndex 开始查找的位置
* @return 路径分隔符在路径中指定位置后首次出现的位置,没有出现时返回-1。
* @since 1.0
*/
public static int getPathIndex(String fileName, int fromIndex) {
int point = fileName.indexOf('/', fromIndex);
if (point == -1) {
point = fileName.indexOf('\\', fromIndex);
}
return point;
}
/**
* 得到路径分隔符在文件路径中最后出现的位置。
* 对于DOS或者UNIX风格的分隔符都可以。
*
* @param fileName 文件路径
* @return 路径分隔符在路径中最后出现的位置,没有出现时返回-1。
* @since 1.0
*/
public static int getPathLsatIndex(String fileName) {
int point = fileName.lastIndexOf('/');
if (point == -1) {
point = fileName.lastIndexOf('\\');
}
return point;
}
/**
* 得到路径分隔符在文件路径中指定位置前最后出现的位置。
* 对于DOS或者UNIX风格的分隔符都可以。
*
* @param fileName 文件路径
* @param fromIndex 开始查找的位置
* @return 路径分隔符在路径中指定位置前最后出现的位置,没有出现时返回-1。
* @since 1.0
*/
public static int getPathLsatIndex(String fileName, int fromIndex) {
int point = fileName.lastIndexOf('/', fromIndex);
if (point == -1) {
point = fileName.lastIndexOf('\\', fromIndex);
}
return point;
}
/**
* 将文件名中的类型部分去掉。
*
* @param filename 文件名
* @return 去掉类型部分的结果
* @since 1.0
*/
public static String trimType(String filename) {
int index = filename.lastIndexOf(".");
if (index != -1) {
return filename.substring(0, index);
} else {
return filename;
}
}
/**
* 得到相对路径。
* 文件名不是目录名的子节点时返回文件名。
*
* @param pathName 目录名
* @param fileName 文件名
* @return 得到文件名相对于目录名的相对路径,目录下不存在该文件时返回文件名
* @since 1.0
*/
public static String getSubpath(String pathName, String fileName) {
int index = fileName.indexOf(pathName);
if (index != -1) {
return fileName.substring(index + pathName.length() + 1);
} else {
return fileName;
}
}
/**
* 检查给定目录的存在性
* 保证指定的路径可用,如果指定的路径不存在,那么建立该路径,可以为多级路径
*
* @param path
* @return 真假值
* @since 1.0
*/
public static final boolean pathValidate(String path) {
//String path="d:/web/www/sub";
//System.out.println(path);
//path = getUNIXfilePath(path);
//path = ereg_replace("^\\/+", "", path);
//path = ereg_replace("\\/+$", "", path);
String[] arraypath = path.split("/");
String tmppath = "";
for (int i = 0; i < arraypath.length; i++) {
tmppath += "/" + arraypath[i];
File d = new File(tmppath.substring(1));
if (!d.exists()) { //检查Sub目录是否存在
System.out.println(tmppath.substring(1));
if (!d.mkdir()) {
return false;
}
}
}
return true;
}
/**
* 读取文件的内容
* 读取指定文件的内容
*
* @param path 为要读取文件的绝对路径
* @return 以行读取文件后的内容。
* @since 1.0
*/
public static final String getFileContent(String path) throws IOException {
String filecontent = "";
try {
File f = new File(path);
if (f.exists()) {
FileReader fr = new FileReader(path);
BufferedReader br = new BufferedReader(fr); //建立BufferedReader对象,并实例化为br
String line = br.readLine(); //从文件读取一行字符串
//判断读取到的字符串是否不为空
while (line != null) {
filecontent += line + "\n";
line = br.readLine(); //从文件中继续读取一行数据
}
br.close(); //关闭BufferedReader对象
fr.close(); //关闭文件
}
} catch (IOException e) {
throw e;
}
return filecontent;
}
/**
* 根据内容生成文件
*
* @param path 要生成文件的绝对路径,
* @param modulecontent 文件的内容。
* @return 真假值
* @since 1.0
*/
public static final boolean genModuleTpl(String path, String modulecontent) throws IOException {
path = getUNIXfilePath(path);
String[] patharray = path.split("\\/");
String modulepath = "";
for (int i = 0; i < patharray.length - 1; i++) {
modulepath += "/" + patharray[i];
}
File d = new File(modulepath.substring(1));
if (!d.exists()) {
if (!pathValidate(modulepath.substring(1))) {
return false;
}
}
try {
FileWriter fw = new FileWriter(path); //建立FileWriter对象,并实例化fw
//将字符串写入文件
fw.write(modulecontent);
fw.close();
} catch (IOException e) {
throw e;
}
return true;
}
/**
* 获取图片文件的扩展名(发布系统专用)
*
* @param pic_path 为图片名称加上前面的路径不包括扩展名
* @return 图片的扩展名
* @since 1.0
*/
public static final String getPicExtendName(String pic_path) {
pic_path = getUNIXfilePath(pic_path);
String pic_extend = "";
if (isFileExist(pic_path + ".gif")) {
pic_extend = ".gif";
}
if (isFileExist(pic_path + ".jpeg")) {
pic_extend = ".jpeg";
}
if (isFileExist(pic_path + ".jpg")) {
pic_extend = ".jpg";
}
if (isFileExist(pic_path + ".png")) {
pic_extend = ".png";
}
return pic_extend; //返回图片扩展名
}
/**
* 拷贝文件
*
* @param in 输入文件
* @param out 输出文件
* @return
* @throws Exception
*/
public static final boolean CopyFile(File in, File out) throws Exception {
try {
FileInputStream fis = new FileInputStream(in);
FileOutputStream fos = new FileOutputStream(out);
byte[] buf = new byte[1024];
int i = 0;
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
fis.close();
fos.close();
return true;
} catch (IOException ie) {
ie.printStackTrace();
return false;
}
}
/**
* 拷贝文件
*
* @param infile 输入字符串
* @param outfile 输出字符串
* @return
* @throws Exception
*/
public static final boolean CopyFile(String infile, String outfile) throws Exception {
try {
File in = new File(infile);
File out = new File(outfile);
return CopyFile(in, out);
} catch (IOException ie) {
ie.printStackTrace();
return false;
}
}
/**
* 把内容content写的path文件中
*
* @param content 输入内容
* @param path 文件路径
* @return
*/
public static boolean SaveFileAs(String content, String path) {
FileWriter fw = null;
try {
fw = new FileWriter(new File(path), false);
if (content != null) {
fw.write(content);
}
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
if (fw != null) {
try {
fw.flush();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return true;
}
/**
* 以字节为单位读取文件,常用于读二进制文件,如图片、声音、影像等文件。
*/
public static byte[] readFileByBytes(String fileName) throws IOException {
FileInputStream in = new FileInputStream(fileName);
byte[] bytes = null;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] temp = new byte[1024];
int size = 0;
while ((size = in.read(temp)) != -1) {
out.write(temp, 0, size);
}
in.close();
bytes = out.toByteArray();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (in != null) {
in.close();
}
}
return bytes;
}
/**
* 以字符为单位读取文件,常用于读文本,数字等类型的文件
*/
public static void readFileByChars(String fileName) {
File file = new File(fileName);
Reader reader = null;
try {
System.out.println("以字符为单位读取文件内容,一次读一个字节:");
// 一次读一个字符
reader = new InputStreamReader(new FileInputStream(file));
int tempchar;
while ((tempchar = reader.read()) != -1) {
// 对于windows下,\r\n这两个字符在一起时,表示一个换行。
// 但如果这两个字符分开显示时,会换两次行。
// 因此,屏蔽掉\r,或者屏蔽\n。否则,将会多出很多空行。
if (((char) tempchar) != '\r') {
System.out.print((char) tempchar);
}
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
System.out.println("以字符为单位读取文件内容,一次读多个字节:");
// 一次读多个字符
char[] tempchars = new char[30];
int charread = 0;
reader = new InputStreamReader(new FileInputStream(fileName));
// 读入多个字符到字符数组中,charread为一次读取字符数
while ((charread = reader.read(tempchars)) != -1) {
// 同样屏蔽掉\r不显示
if ((charread == tempchars.length)
&& (tempchars[tempchars.length - 1] != '\r')) {
System.out.print(tempchars);
} else {
for (int i = 0; i < charread; i++) {
if (tempchars[i] == '\r') {
continue;
} else {
System.out.print(tempchars[i]);
}
}
}
}
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
/**
* 以行为单位读取文件,常用于读面向行的格式化文件
*/
public static List<String> readFileByLines(String fileName) {
List<String> returnString = new ArrayList<String>();
File file = new File(fileName);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
int line = 1;
// 一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
// 显示行号
returnString.add(tempString);
line++;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return returnString;
}
/**
* 随机读取文件内容
*/
public static void readFileByRandomAccess(String fileName) {
RandomAccessFile randomFile = null;
try {
System.out.println("随机读取一段文件内容:");
// 打开一个随机访问文件流,按只读方式
randomFile = new RandomAccessFile(fileName, "r");
// 文件长度,字节数
long fileLength = randomFile.length();
// 读文件的起始位置
int beginIndex = (fileLength > 4) ? 4 : 0;
// 将读文件的开始位置移到beginIndex位置。
randomFile.seek(beginIndex);
byte[] bytes = new byte[10];
int byteread = 0;
// 一次读10个字节,如果文件内容不足10个字节,则读剩下的字节。
// 将一次读取的字节数赋给byteread
while ((byteread = randomFile.read(bytes)) != -1) {
System.out.write(bytes, 0, byteread);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (randomFile != null) {
try {
randomFile.close();
} catch (IOException e1) {
}
}
}
}
/**
* 读取文件内容
*
* @param fileName
* @return
*/
public static String readFileAll(String fileName) {
String encoding = "UTF-8";
File file = new File(fileName);
Long filelength = file.length();
byte[] filecontent = new byte[filelength.intValue()];
try {
FileInputStream in = new FileInputStream(file);
in.read(filecontent);
in.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
return new String(filecontent, encoding);
} catch (UnsupportedEncodingException e) {
System.err.println("The OS does not support " + encoding);
e.printStackTrace();
return "";
}
}
/**
* 显示输入流中还剩的字节数
*/
private static void showAvailableBytes(InputStream in) {
try {
System.out.println("当前字节输入流中的字节数为:" + in.available());
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import java.io.BufferedReader;
import java.io.IOException;
@ -70,11 +70,4 @@ public class IDgenerator {
protected static long timeGen() {
return System.currentTimeMillis();
}
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
long l = IDgenerator.nextId();
System.out.println(l);
}
}
}

@ -1,6 +1,6 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import xyz.wbsite.framework.base.Token;
import xyz.wbsite.frame.base.Token;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -17,19 +17,23 @@ import javax.servlet.http.HttpServletResponse;
* @since 2017-01-01
*/
public class LocalData {
private static final long serialVersionUID = 1L;
private static Token temp = null;
private static Token system = null;
static {
// 组装临时Token和系统Token
temp = new Token();
temp.setId(-1);
temp.setUserId(-1);
temp.setUserName("游客");
temp.putResource("/");
temp.putResource("/ajax");
temp.putResource("/upload");
temp.putResource("/index.htm");
temp.putResource("/home.htm");
temp.putResource("/app.htm");
temp.putResource("ajax.example.example");
system = new Token();
system.setId(0);

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import com.fasterxml.jackson.core.TreeNode;
import java.security.MessageDigest;
@ -55,33 +55,4 @@ public class MD5Util {
return hs.toString();
}
/**
* 测试实例
*
* @param args
*/
public static void main(String[] args) {
// String encode = MD5Util.encode("123456");
// System.out.println(encode);
//
// UserCreateRequest user = new UserCreateRequest();
// user.setUser("wangbing");
//
//
// ArrayList<User> users = new ArrayList<>();
// User user1 = new User();
// user1.setUser("ddd");
// users.add(user1);
// user.setList(users);
//
// TreeNode treeNode = MapperUtil.toTree(user);
// String s = MapperUtil.toJson(user,true);
// System.out.println(s);
//
// String s1 = MD5Util.toSign(treeNode, "asasasdadasda", "wwwwwwwwwwwwwwww");
//
// System.out.println(s1);
}
}

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -96,7 +96,7 @@ public class MapperUtil {
return null;
}
public static <T> T toJava(String json, TypeReference valueTypeRef) {
public static <T> T toJava(String json, TypeReference<T> valueTypeRef) {
try {
return om.readValue(json, valueTypeRef);
} catch (IOException e) {

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
/**

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import java.awt.*;
import java.io.BufferedReader;
@ -114,22 +114,4 @@ public class ProcessUtil {
}
}
}
public static void main(String[] args) {
// try {//调用bat文件,出现黑窗口
// executeCmd("cmd /k start E:\\windows_amd64\\sunny.bat");
// } catch (IOException e) {
// e.printStackTrace();
// }
// try {
// executeCmd("E:\\windows_amd64\\sunny.exe clientid 213609147996,201822147996");
// } catch (IOException e) {
// e.printStackTrace();
// }
// execExe("D:\\windows_amd64\\sunny.exe clientid 213609147996,201822147996");
// execBat("D:\\windows_amd64\\exec.bat");
// System.out.println("===================");
// System.out.println(s);
// System.out.println("===================");
}
}

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
@ -219,6 +219,9 @@ public class RSAUtil {
return null;
}
public static String sign2Base64(byte[] data) {
return sign2Base64(data, signPrivateKeyBase64);
}
public static String sign2Base64(byte[] data, String privateKey) {
byte[] sign = sign(data, privateKey);
@ -273,6 +276,10 @@ public class RSAUtil {
return false;
}
public static boolean doCheck(byte[] data, String sign) {
return doCheck(data, sign, signPublicKeyBase64);
}
public static PublicKey parsePublicKey(String cryptPublicKeyBase64) {
try {
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
@ -298,33 +305,4 @@ public class RSAUtil {
}
return null;
}
/**
* 测试实例
*
* @param args
*/
public static void main(String[] args) {
{//创建秘钥对
RSAUtil.createKey();
}
{//加解密
//加密
String encrypt = RSAUtil.encrypt2Base64("我有一个苹果".getBytes());
System.out.println(encrypt);
//解密
String decrypt = RSAUtil.decrypt2String(encrypt);
System.out.println(decrypt);
}
String sign = sign2Base64("我有一个苹果".getBytes(), signPrivateKeyBase64);
System.out.println(sign);
boolean b = doCheck("我有一个苹果".getBytes(), sign, signPublicKeyBase64);
System.out.println(b);
}
}

@ -1,8 +1,8 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import xyz.wbsite.framework.base.BaseRequest;
import xyz.wbsite.framework.base.BaseResponse;
import xyz.wbsite.framework.base.ErrorType;
import xyz.wbsite.frame.base.BaseRequest;
import xyz.wbsite.frame.base.BaseResponse;
import xyz.wbsite.frame.base.ErrorType;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;

@ -1,4 +1,4 @@
package xyz.wbsite.framework.utils;
package xyz.wbsite.frame.utils;
import javax.net.ssl.*;
import java.io.*;

@ -1,57 +0,0 @@
package xyz.wbsite.framework.base;
/**
* BaseFindRequest - 基类
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
public class BaseFindRequest extends BaseGetAllRequest {
private int pageNumber = 1;
private int pageSize = 10;
private int beginIndex = 0;
private int endIndex = 10;
public int getPageNumber() {
return pageNumber;
}
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getBeginIndex() {
beginIndex = pageSize * (pageNumber - 1);
return beginIndex;
}
public void setBeginIndex(int beginIndex) {
this.beginIndex = beginIndex;
}
public int getEndIndex() {
endIndex = pageSize * (pageNumber - 1) + pageSize;
return endIndex;
}
public void setEndIndex(int endIndex) {
this.endIndex = endIndex;
}
public void updatePageNumber(int totalCount){
int maxPage = totalCount / pageSize + (totalCount % pageSize > 0 ? 1 : 0);
if (pageNumber > maxPage){
pageNumber = maxPage;
}
}
}

@ -1,65 +0,0 @@
package xyz.wbsite.framework.springmvc;
import xyz.wbsite.framework.utils.LocalData;
import xyz.wbsite.framework.base.Token;
import xyz.wbsite.framework.utils.LogUtil;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* SpringMVC 全局拦截器,日志记录
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
@Component
public class GlobalHandlerInterceptor extends HandlerInterceptorAdapter {
@Value("${web.welcome.page}")
private String homePage;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
return super.preHandle(request, response, handler);
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
super.postHandle(request, response, handler, modelAndView);
//当请求为@ResponseBody,modelAndView为null,不处理
if (modelAndView == null){
return;
}
//获取当前用户信息
Token token = LocalData.getToken();
modelAndView.addObject("token", token);
//主页
modelAndView.addObject("homePath", homePage);
//获取项目路径,在项目非根路径下用于拼接URL
String contextPath = request.getContextPath();
modelAndView.addObject("contextPath", contextPath);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
super.afterCompletion(request, response, handler, ex);
if (ex != null) {
LogUtil.dumpException(ex);
}
}
@Override
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
super.afterConcurrentHandlingStarted(request, response, handler);
}
}

@ -4,25 +4,29 @@ server.servlet.context-path=/
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:static/
spring.application.name=FILEMGR-WEB
spring.main.banner-mode=CONSOLE
spring.devtools.restart.enabled=true
# 编码配置
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
# 根路径、欢迎页
web.welcome.page = index
# 需要验证授权
web.url.auth.included = /**
# 不需要验证授权
web.url.auth.excluded = /favicon.ico,/static/**,/open/**,/api,/index,/,/login,/up
# 默认的登录URL
web.url.login = /login
web.welcome.page=/index.htm
# 需要验证授权, 既访问时组装Token
web.url.auth.included=/aaaaaaaaaaaaa
# 不需要验证授权, 或该请求有自己的验证机制
web.url.auth.excluded=/favicon.ico,/static/**,/api,/login.htm
# 日志配置
logging.path=D://
logging.levels=DEBUG
logging.config=classpath:logback-config.xml
# 热部署生效
spring.devtools.restart.enabled = true
# jackson 相关配置
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.jackson.default-property-inclusion=use_defaults
spring.jackson.mapper.sort-properties-alphabetically=true
spring.jackson.deserialization.fail-on-unknown-properties=false
# freemarker
spring.freemarker.enabled=true
spring.freemarker.allow-request-override=false
@ -42,6 +46,7 @@ spring.freemarker.settings.classic_compatible=true
spring.freemarker.settings.whitespace_stripping=true
spring.freemarker.settings.url_escaping_charset=utf-8
# 文件上传配置
spring.servlet.multipart.resolveLazily = true
spring.servlet.multipart.resolveLazily=false
spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=100MB
file.root.path=E://file/

@ -5,23 +5,28 @@ spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:static/
spring.application.name=FILEMGR-WEB
spring.main.banner-mode=off
spring.devtools.restart.enabled=false
# 编码配置
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
# 根路径、欢迎页
web.welcome.page = index
# 需要验证授权
web.url.auth.included = /**
# 不需要验证授权
web.url.auth.excluded = /static/**,/open/**,/api,/index,/,/login
# 默认的登录URL
web.url.login = /login
web.welcome.page=/index.htm
# 需要验证授权, 既访问时组装Token
web.url.auth.included=/aaaaaaaaaaaaa
# 不需要验证授权, 或该请求有自己的验证机制
web.url.auth.excluded=/favicon.ico,/static/**,/api,/login.htm
# 日志配置
logging.path = /root/
logging.path=/root/
logging.levels=INFO
logging.config = classpath:logback-config.xml
logging.config=classpath:logback-config.xml
# jackson 相关配置
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.jackson.default-property-inclusion=use_defaults
spring.jackson.mapper.sort-properties-alphabetically=true
spring.jackson.deserialization.fail-on-unknown-properties=false
# freemarker
spring.freemarker.enabled=true
spring.freemarker.allow-request-override=false
@ -41,6 +46,7 @@ spring.freemarker.settings.classic_compatible=true
spring.freemarker.settings.whitespace_stripping=true
spring.freemarker.settings.url_escaping_charset=utf-8
# 文件上传配置
spring.servlet.multipart.resolveLazily = true
spring.servlet.multipart.resolveLazily=false
spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=100MB
file.root.path=E://file

@ -22,14 +22,5 @@ ${AnsiColor.BRIGHT_YELLOW}
/////////////////////////////////////////////////////////
佛祖保佑 永无BUG
_ _ _
| | | | (_)
| |__ _ _ __ __ __ _ _ __ __ _ | |__ _ _ __ __ _
| '_ \ | | | | \ \ /\ / / / _` || '_ \ / _` | | '_ \ | || '_ \ / _` |
| |_) || |_| | \ V V / | (_| || | | || (_| | | |_) || || | | || (_| |
|_.__/ \__, | \_/\_/ \__,_||_| |_| \__, | |_.__/ |_||_| |_| \__, |
__/ | __/ | __/ |
|___/ |___/ |___/
:: Spring Boot :: ${spring-boot.formatted-version} (${spring.profiles.active})

@ -3,25 +3,5 @@
<projectName>FILEMGR-WEB</projectName>
<projectBasePackage>xyz.wbsite</projectBasePackage>
<projectAuthor>wangbing</projectAuthor>
<modules>
<module>
<moduleComment>文件管理</moduleComment>
<modulePrefix>FM_</modulePrefix>
<moduleName>filemgr</moduleName>
<hasSysFields>true</hasSysFields>
<tables>
<table create="true" delete="true" find="true" get="true" getAll="false" search="false" tableComment="注释" tableName="NEW_TABLE" update="true">
<fields>
<field IsSystem="true" defaultValue="" fieldComment="主键" fieldLength="0" fieldName="ID" fieldType="Long" isMust="true" isPrimaryKey="true" isQuery="false" isSearch="false"/>
<field IsSystem="true" defaultValue="" fieldComment="行版本" fieldLength="0" fieldName="ROW_VERSION" fieldType="Long" isMust="true" isPrimaryKey="false" isQuery="false" isSearch="false"/>
<field IsSystem="true" defaultValue="0" fieldComment="是否已删除" fieldLength="0" fieldName="IS_DELETED" fieldType="Boolean" isMust="true" isPrimaryKey="false" isQuery="false" isSearch="false"/>
<field IsSystem="true" defaultValue="" fieldComment="创建用户" fieldLength="0" fieldName="CREATE_BY" fieldType="Long" isMust="true" isPrimaryKey="false" isQuery="false" isSearch="false"/>
<field IsSystem="true" defaultValue="NULL" fieldComment="创建时间" fieldLength="0" fieldName="CREATE_TIME" fieldType="Date" isMust="true" isPrimaryKey="false" isQuery="false" isSearch="false"/>
<field IsSystem="true" defaultValue="" fieldComment="最后更新用户" fieldLength="0" fieldName="LAST_UPDATE_BY" fieldType="Long" isMust="false" isPrimaryKey="false" isQuery="false" isSearch="false"/>
<field IsSystem="true" defaultValue="" fieldComment="最后更新时间" fieldLength="0" fieldName="LAST_UPDATE_TIME" fieldType="Date" isMust="false" isPrimaryKey="false" isQuery="false" isSearch="false"/>
</fields>
</table>
</tables>
</module>
</modules>
<modules/>
</project>

@ -2,8 +2,8 @@
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
margin: 0px;
padding: 0px;
margin: 0;
padding: 0;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}
@ -37,91 +37,11 @@ h1 {
margin: .67em 0
}
figcaption, figure, main {
display: block
}
figure {
margin: 1em 40px
}
hr {
-webkit-box-sizing: content-box;
box-sizing: content-box;
height: 0;
overflow: visible
}
pre {
font-family: monospace, monospace;
font-size: 1em
}
abbr[title] {
border-bottom: none;
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted
}
b, strong {
font-weight: inherit
}
b, strong {
font-weight: bolder
}
code, kbd, samp {
font-family: monospace, monospace;
font-size: 1em
}
dfn {
font-style: italic
}
mark {
background-color: #ff0;
color: #000
}
small {
font-size: 80%
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline
}
sub {
bottom: -.25em
}
sup {
top: -.5em
}
audio, video {
display: inline-block
}
audio:not([controls]) {
display: none;
height: 0
}
img {
border-style: none
}
svg:not(:root) {
overflow: hidden
}
button, input, optgroup, select, textarea {
font-family: sans-serif;
font-size: 100%;
@ -129,10 +49,6 @@ button, input, optgroup, select, textarea {
margin: 0
}
button, input {
overflow: visible
}
button, select {
text-transform: none
}
@ -225,21 +141,6 @@ template {
box-sizing: border-box
}
article, aside, blockquote, body, button, dd, details, div, dl, dt, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, input, legend, li, menu, nav, ol, p, section, td, textarea, th, ul {
margin: 0;
padding: 0
}
button, input, select, textarea {
font-family: inherit;
font-size: inherit;
line-height: inherit
}
input::-ms-clear, input::-ms-reveal {
display: none
}
a {
text-decoration: none;
outline: 0;
@ -779,8 +680,8 @@ code {
.wb-layout-foot-absolute > .wb-foot {
position: absolute;
bottom: 0px;
left: 0px;
bottom: 0;
left: 0;
height: 50px;
width: 100%;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -23,10 +23,18 @@ instance.interceptors.request.use(function (config) {
instance.interceptors.response.use(function (response) {
// 对响应数据做点什么
nav.tip.close();
try {//确保服务器正确返回Json
if(response.data.errors.length > 0){
console.error(response.data.errors)
}
nav.bar.finish();
}catch (e){
nav.bar.error();
response.data = {errors: [{message: '服务器错误'}]};
}
return response;
}, function (error) {
// 对响应错误做点什么
// 对响应错误做点什么,保准化返回结果
nav.tip.close();
nav.bar.error();
const rsp = {errors: []};
@ -64,7 +72,7 @@ jsonRequest = function (config) {
params: {
method: config.method
},
url: "/ajax",
url: '/ajax',
headers: {'Content-Type': 'text/plain'},
data: config.data
}).then(function (response) {
@ -75,7 +83,7 @@ jsonRequest = function (config) {
};
fileRequest = function (config) {
return instance.request({
url: "/upload",
url: '/upload',
data: config.data,
headers: {'Content-Type': 'multipart/form-data'},
onUploadProgress: function (progressEvent) {
@ -101,5 +109,5 @@ window.ajax = {
return fileRequest({
data: fd
})
}
},
}

@ -0,0 +1,105 @@
import axios from 'axios'
// 创建axios实例
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
withCredentials: true, // send cookies when cross-domain requests
method: 'post', // request method
timeout: 5000 // request timeout
})
// 添加请求拦截器
service.interceptors.request.use(config => {
// 在发送请求之前做些什么
if (config.url === '/upload') {
console.log()
} else {
console.log()
}
return config
}, error => {
// 对请求错误做些什么
return Promise.reject(error)
})
// 添加响应拦截器
service.interceptors.response.use(response => {
// 对响应数据做点什么
return response
}, error => {
// 对响应错误做点什么
const rsp = { errors: [] }
if (!error.response) {
rsp.errors.push({ message: error.message })
} else {
switch (error.response.status) {
case 401:
rsp.errors.push({ message: '未授权,请登录(401)' })
break
case 403:
rsp.errors.push({ message: '拒绝访问(403)' })
break
case 404:
rsp.errors.push({ message: '请求地址错误(404)' })
break
case 408:
rsp.errors.push({ message: '请求超时(408)' })
break
case 500:
rsp.errors.push({ message: '服务器内部错误(500)' })
break
case 501:
rsp.errors.push({ message: '服务未实现(501)' })
break
default:
rsp.errors.push({ message: '请求错误(' + error.response.status + ')' })
break
}
}
return Promise.reject(rsp)
})
export function jsonRequest(config) {
return service.request({
params: {
method: config.method
},
url: '/ajax',
headers: { 'Content-Type': 'text/plain' },
data: config.data
}).then(response => {
return Promise.resolve(response.data)
}, response => {
return Promise.resolve(response)
})
}
export function fileRequest(config) {
return service.request({
url: '/upload',
data: config.data,
headers: { 'Content-Type': 'multipart/form-data' },
onUploadProgress: progressEvent => {
console.log((progressEvent.loaded / progressEvent.total * 100 | 0) + '%')
}
}).then(response => {
return Promise.resolve(response.data)
}, response => {
return Promise.resolve(response)
})
}
const ajax = {
example: data => {
return jsonRequest({
method: 'ajax.example.example',
data: data
})
},
fileUpload: file => {
const fd = new FormData()
fd.append('file', file)
return fileRequest({
data: fd
})
},
}
export default ajax

@ -207,7 +207,7 @@
e.innerHTML = count + " 秒后自动跳转登录页"
count--;
} else {
location.href = '${Uri.getUrl("/login")}';
location.href = '${Uri.getUrl("/login.htm")}';
}
}

@ -0,0 +1,530 @@
<script>
window.nav = new Vue({
data: {
activeIndex: 'home',
contextPath: '${contextPath?default("")}',
homePath: '${homePath?default("")}',
tip: {
show: function (msg) {
if(msg) {
this.$indicator.open(msg);
}else {
this.$indicator.open();
}
},
close: function () {
this.$indicator.close();
}
},
},
methods: {
i: function (message, callback) {
this.$toast({
message: message,
position: 'middle',
duration: 3000
});
setTimeout(callback, 3000)
},
alert: function (message, callback) {
this.$messageBox.alert(message, "").then(callback);
},
confirm: function (message, callback) {
this.$messageBox.confirm(message, "").then(callback);
}
}
});
Vue.component('wb-field-select', {
data: function () {
return {
selectValue: '',
popupVisible: false,
clearVisible: false,
slots: [{
values: this.items
}],
}
},
computed: {
currentValue: {
get: function () {
return this.value;
},
set: function (value) {
this.$emit('input', value);
value ? this.clearVisible = true : this.clearVisible = false;
}
}
},
methods: {
onSelect: function () {
this.popupVisible = true;
if (!this.value) {
this.currentValue = this.items[0];
}
},
onClear: function () {
this.currentValue = '';
},
onValuesChange: function (picker, values) {
if (this.popupVisible) {
this.currentValue = picker.getValues(0)[0];
}
},
},
props: ['value', 'label', 'placeholder', 'items'],
template: '' +
'<a class="mint-cell mint-field"><!---->' +
' <div class="mint-cell-wrapper">' +
' <div class="mint-cell-title"><!----><span class="mint-cell-text">{{label}}</span><!----></div>' +
' <div class="mint-cell-value">' +
' <input :placeholder="placeholder" @click="onSelect" readonly v-model="currentValue" class="mint-field-core">' +
' <div class="mint-field-clear" v-if="clearVisible" @click="onClear"><i class="mintui mintui-field-error"></i></div>' +
' </div>' +
' </div>' +
' <mt-popup style="width: 100%" v-model="popupVisible" position="bottom"><mt-picker :slots="slots" @change="onValuesChange"></mt-picker></mt-popup>' +
'</a>'
});
Vue.component('wb-field-dict', {
data: function () {
return {
selectValue: '',
popupVisible: false,
clearVisible: false,
slots: [{
values: this.items
}],
}
},
computed: {
currentValue: {
get: function () {
return this.value;
},
set: function (value) {
this.$emit('input', value);
value ? this.clearVisible = true : this.clearVisible = false;
}
}
},
created: function () {
this.items.forEach(function (item) {
item.keyValue = "[" + item.key + "]" + item.value;
})
},
methods: {
onSelect: function () {
this.popupVisible = true;
if (!this.value) {
this.currentValue = "[" + this.items[0].key + "]" + this.items[0].value;
}
},
onClear: function () {
this.currentValue = '';
},
onValuesChange: function (picker, values) {
if (this.popupVisible) {
this.currentValue = "[" + picker.getValues(0)[0].key + "]" + picker.getValues(0)[0].value;
}
}
},
props: ['value', 'label', 'placeholder', 'items'],
template: '' +
'<a class="mint-cell mint-field"><!---->' +
' <div class="mint-cell-wrapper">' +
' <div class="mint-cell-title"><!----><span class="mint-cell-text">{{label}}</span><!----></div>' +
' <div class="mint-cell-value">' +
' <input :placeholder="placeholder" @click="onSelect" readonly v-model="currentValue" class="mint-field-core">' +
' <div class="mint-field-clear" v-if="clearVisible" @click="onClear"><i class="mintui mintui-field-error"></i></div>' +
' </div>' +
' </div>' +
' <mt-popup style="width: 100%" v-model="popupVisible" position="bottom"><mt-picker :slots="slots" valueKey="keyValue" @change="onValuesChange"></mt-picker></mt-popup>' +
'</a>'
});
Vue.component('wb-field-date', {
data: function () {
var startDate = new Date();
startDate.setFullYear(1990, 0, 1);
return {
selectValue: '',
clearVisible: false,
startDate:startDate
}
},
computed: {
currentValue: {
get: function () {
return this.value;
},
set: function (value) {
this.$emit('input', value);
value ? this.clearVisible = true : this.clearVisible = false;
}
}
},
methods: {
onSelect: function () {
this.$refs.picker.open();
},
onClear: function () {
this.currentValue = '';
},
onConfirm: function (value) {
this.currentValue = value.format("yyyy-MM-dd")
}
},
props: ['value', 'label', 'placeholder', 'items'],
template: '' +
'<a class="mint-cell mint-field"><!---->' +
' <div class="mint-cell-wrapper">' +
' <div class="mint-cell-title"><!----><span class="mint-cell-text">{{label}}</span><!----></div>' +
' <div class="mint-cell-value">' +
' <input :placeholder="placeholder" @click="onSelect" readonly v-model="currentValue" class="mint-field-core">' +
' <div class="mint-field-clear" v-if="clearVisible" @click="onClear"><i class="mintui mintui-field-error"></i></div>' +
' </div>' +
' </div>' +
' <mt-datetime-picker ref="picker" type="date" :startDate="startDate" v-model="selectValue" @confirm="onConfirm" year-format="{value}" month-format="{value}" date-format="{value}"></mt-datetime-picker>' +
'</a>'
});
Vue.component('wb-field-time', {
data: function () {
return {
selectValue: '',
clearVisible: false,
}
},
computed: {
currentValue: {
get: function () {
return this.value;
},
set: function (value) {
this.$emit('input', value);
value ? this.clearVisible = true : this.clearVisible = false;
}
}
},
methods: {
onSelect: function () {
this.$refs.picker.open();
},
onClear: function () {
this.currentValue = '';
},
onConfirm: function (value) {
this.currentValue = value;
}
},
props: ['value', 'label', 'placeholder', 'items'],
template: '' +
'<a class="mint-cell mint-field"><!---->' +
' <div class="mint-cell-wrapper">' +
' <div class="mint-cell-title"><!----><span class="mint-cell-text">{{label}}</span><!----></div>' +
' <div class="mint-cell-value">' +
' <input :placeholder="placeholder" @click="onSelect" readonly v-model="currentValue" class="mint-field-core">' +
' <div class="mint-field-clear" v-if="clearVisible" @click="onClear"><i class="mintui mintui-field-error"></i></div>' +
' </div>' +
' </div>' +
' <mt-datetime-picker ref="picker" type="time" v-model="selectValue" @confirm="onConfirm" year-format="{value}" month-format="{value}" date-format="{value}"></mt-datetime-picker>' +
'</a>'
});
Vue.component('wb-field-datetime', {
data: function () {
return {
selectValue: '',
clearVisible: false,
}
},
computed: {
currentValue: {
get: function () {
return this.value;
},
set: function (value) {
this.$emit('input', value);
value ? this.clearVisible = true : this.clearVisible = false;
}
}
},
methods: {
onSelect: function () {
this.$refs.picker.open();
},
onClear: function () {
this.currentValue = '';
},
onConfirm: function (value) {
this.currentValue = value.format("yyyy-MM-dd hh:mm")
}
},
props: ['value', 'label', 'placeholder', 'items'],
template: '' +
'<a class="mint-cell mint-field"><!---->' +
' <div class="mint-cell-wrapper">' +
' <div class="mint-cell-title"><!----><span class="mint-cell-text">{{label}}</span><!----></div>' +
' <div class="mint-cell-value">' +
' <input :placeholder="placeholder" @click="onSelect" readonly v-model="currentValue" class="mint-field-core">' +
' <div class="mint-field-clear" v-if="clearVisible" @click="onClear"><i class="mintui mintui-field-error"></i></div>' +
' </div>' +
' </div>' +
' <mt-datetime-picker ref="picker" type="datetime" v-model="selectValue" @confirm="onConfirm" year-format="{value}" month-format="{value}" date-format="{value}"></mt-datetime-picker>' +
'</a>'
});
Vue.component('wb-field-cphm', {
data: function () {
return {
prefixData: [
{
key: '',
value: '京',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'Y']
},
{
key: '',
value: '津',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R']
},
{key: '', value: '冀', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'O', 'R', 'T']},
{key: '', value: '晋', children: ['A', 'B', 'C', 'D', 'E', 'F', 'H', 'J', 'K', 'L', 'M']},
{key: '', value: '蒙', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M']},
{
key: '',
value: '辽',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P']
},
{key: '', value: '吉', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K']},
{
key: '',
value: '黑',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R']
},
{
key: '',
value: '沪',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'AX', 'BX', 'DX']
},
{
key: '',
value: '苏',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'U']
},
{key: '', value: '浙', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L']},
{
key: '',
value: '皖',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S']
},
{key: '', value: '闽', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K']},
{key: '', value: '赣', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'S']},
{
key: '',
value: '鲁',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'U', 'V', 'W', 'Y']
},
{
key: '',
value: '豫',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'U']
},
{
key: '',
value: '鄂',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'AW']
},
{
key: '',
value: '湘',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'S', 'U']
},
{
key: '',
value: '粤',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
},
{
key: '',
value: '桂',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R']
},
{key: '', value: '琼', children: ['A', 'B', 'C', 'D', 'E', 'F']},
{key: '', value: '渝', children: ['A', 'B', 'C', 'D', 'F', 'G', 'H', 'N']},
{
key: '',
value: '川',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
},
{key: '', value: '贵', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J']},
{
key: '',
value: '云',
children: ['A', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S']
},
{key: '', value: '藏', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J']},
{key: '', value: '陕', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'V']},
{
key: '',
value: '甘',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P']
},
{key: '', value: '青', children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']},
{key: '', value: '宁', children: ['A', 'B', 'C', 'D', 'E']},
{
key: '',
value: '新',
children: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'S']
}
],
popupVisible: false,
clearVisible: false,
slots: [{
values: [],
defaultIndex: 9,
className: 'slot1'
}, {
divider: true,
content: '',
className: 'slot2'
}, {
values: [],
defaultIndex: 11,
className: 'slot3'
}],
}
},
created: function () {
if (!this.value) {//当model为空时初始化前缀
this.$emit('input', this.prefixData[this.slots[0].defaultIndex].value + this.prefixData[this.slots[0].defaultIndex].children[this.slots[2].defaultIndex]);
}
this.slots[0].values = this.getSlot1();
this.slots[2].values = this.getSlot3(this.prefixData[0].value);
},
computed: {
prefix: {
get: function () {
return this.value.slice(0, 2);
},
set: function (value) {
this.$emit('input', value + this.value.slice(2, this.value.length));
}
},
subfix: {
get: function () {
return this.value.slice(2, this.value.length);
},
set: function (value) {
this.$emit('input', this.value.slice(0, 2) + value);
value ? this.clearVisible = true : this.clearVisible = false;
}
}
},
methods: {
onSelect: function () {
this.popupVisible = true;
},
getSlot1: function () {
var items = [];
this.prefixData.forEach(function (item) {
items.push(item.value);
});
return items;
},
getSlot3: function (value) {
for (var i in this.prefixData) {
if (value == this.prefixData[i].value) {
return this.prefixData[i].children;
}
}
return []
},
onClear: function () {
this.subfix = '';
},
onValuesChange: function (picker, values) {
if (this.popupVisible) {
picker.setSlotValues(1, this.getSlot3(values[0]));
this.prefix = picker.getSlotValue(0) + picker.getSlotValue(1)
}
}
},
props: ['value', 'label', 'placeholder', 'items'],
template: '' +
'<a class="mint-cell mint-field"><!---->' +
' <div class="mint-cell-wrapper">' +
' <div class="mint-cell-title"><!----><span class="mint-cell-text">{{label}}</span><!----></div>' +
' <div class="mint-cell-value">' +
' <span @click="onSelect" style="padding-right: 5px;color:#47d3ff;line-height: 1.6">{{prefix}}</span>' +
' <input :placeholder="placeholder" maxlength="6" v-model="subfix" class="mint-field-core">' +
' <div class="mint-field-clear" v-if="clearVisible" @click="onClear"><i class="mintui mintui-field-error"></i></div>' +
' </div>' +
' </div>' +
' <mt-popup style="width: 100%" v-model="popupVisible" position="bottom"><mt-picker ref="picker" :slots="slots" @change="onValuesChange"></mt-picker></mt-popup>' +
'</a>'
});
Vue.component('wb-field-pictures', {
data: function () {
return {
fileList: []
}
},
methods: {
onClear: function (item) {
this.fileList.remove(item);
},
onValuesChange: function (picker, values) {
if (this.popupVisible) {
picker.setSlotValues(1, this.getSlot3(values[0]));
this.prefix = picker.getSlotValue(0) + picker.getSlotValue(1)
}
},
onTakePicture: function () {
this.fileList.push({
name: '',
file: ''
})
setTimeout(function () {
this.$refs.input[this.fileList.length - 1].click();
}.bind(this), 1)
},
onChange: function (e, file) {
file.file = e.target.files[0]
file.name = e.target.files[0].name;
this.$emit("handle-file", file, {
finish: function () {
this.$emit("input", this.fileList)
}.bind(this),
cancel: function () {
this.fileList.remove(file);
this.$emit("input", this.fileList)
}.bind(this)
});
},
},
props: ['value', 'label'],
template: '' +
'<a class="mint-cell mint-field"><!---->' +
' <div class="mint-cell-wrapper">' +
' <div class="mint-cell-title"><!----><span class="mint-cell-text">{{label}}</span><!----></div>' +
' <div class="mint-cell-value">' +
' <div style="padding-top: 11px;padding-bottom: 11px;text-align: left;width: 100%">' +
' <mt-button type="primary" size="small" @click="onTakePicture">添加</mt-button>' +
' <div style="line-height: 35px;" v-for="item in fileList" v-show="item.name">' +
' <span class="mint-field-clear" style="padding-right: 10px;" @click="onClear(item)"><i class="mintui mintui-field-error"></i></span><!---->' +
' <a>{{item.name}}</a><!---->' +
' <input ref="input" @change="onChange($event,item)" type="file" style="display: none"/>' +
' </div>' +
' </div>' +
' </div>' +
' </div>' +
'</a>'
});
</script>

@ -157,77 +157,4 @@
}
}
});
/**
* 获取url参数
* @param key
*/
window.location.getParam = function (key) {
var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return decodeURIComponent(r[2]);
}
return null;
}
/**
* 打开新标签
* @param url
*/
window.location.open = function (url) {
$("body").append($("<a id='wb-open' href='" + url + "' target='_blank' style='dispaly:none;'></a>"))
document.getElementById("wb-open").click();
$("#wb-open").remove();
}
/**
* 日期格式化
*/
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length == 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
};
/**
* 数组移除
*/
Array.prototype.remove = function (val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
/**
* 数组替换
*/
Array.prototype.replace = function (val, obj) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1, obj);
}
};
/**
* 数组位置调整
*/
Array.prototype.exchange = function (val1, val2) {
if (val1 < 0 || val2 < 0 || val2 >= this.length || val1 >= this.length) {
return;
}
var o1 = this[val1];
var o2 = this[val2];
this.splice(val1, 1, o2);
this.splice(val2, 1, o1);
};
</script>

@ -0,0 +1,217 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<#--baseJs-->
<script src="${Uri.getUrl('/static/dist/lib.min.js')}" type="text/javascript"></script>
<#--移动端ui-->
<script src="${Uri.getUrl('/static/dist/mint-ui.min.js')}" type="text/javascript"></script>
<link href="${Uri.getUrl('/static/dist/mint-ui.min.css')}" rel="stylesheet"/>
<#--ajax接口-->
<script src="${Uri.getUrl('/static/js/ajax.js')}" type="text/javascript"></script>
<style>
* {
padding: 0px;
margin: 0px;
}
html,body,#app{
width: 100%;
height: 100%;
}
.left-in-right-out-enter-active, .left-in-right-out-leave-active {
transition: all 0.3s linear;
position: absolute;
}
.left-in-right-out-enter {
transform: translateX(-100%);
opacity: 0;
}
.left-in-right-out-leave-to {
transform: translateX(100%);
opacity: 0;
}
.right-in-left-out-enter-active, .right-in-left-out-leave-active {
transition: all .3s linear;
position: absolute;
}
.right-in-left-out-enter {
transform: translateX(100%);
}
.right-in-left-out-leave-to {
transform: translateX(-100%);
}
.left-in-right-out-enter-active, .left-in-right-out-leave-active {
transition: all 0.3s linear;
position: absolute;
}
.left-in-right-out-enter {
transform: translateX(-100%);
opacity: 0;
}
.left-in-right-out-leave-to {
transform: translateX(100%);
opacity: 0;
}
.right-in-left-out-enter-active, .right-in-left-out-leave-active {
transition: all .3s linear;
position: absolute;
}
.right-in-left-out-enter {
transform: translateX(100%);
}
.right-in-left-out-leave-to {
transform: translateX(-100%);
}
</style>
</head>
<body>
<#include Layout.setControl("mint-ui-extend")/>
<div id="app">
<transition :name="transitionName">
<router-view></router-view>
</transition>
</div>
<template id="home">
<div class="view">
<mt-header title="Hello world">
<router-link to="/" slot="left">
<mt-button icon="back">返回</mt-button>
</router-link>
<mt-button icon="more" slot="right"></mt-button>
</mt-header>
<div class="content" style="text-align: center;padding-top: 200px">
Hello world <router-link to="demo">demo</router-link>
</div>
</div>
</template>
<template id="demo">
<div class="view">
<mt-header title="表单输入">
<mt-button icon="back" slot="left" @click="back">关闭</mt-button>
</mt-header>
<div class="content" style="text-align: center;">
<mt-header title="Mint-ui自带控件"></mt-header>
<mt-field label="普通文字" placeholder="请输入用户名" v-model="field1"></mt-field>
<mt-field label="邮箱地址" placeholder="请输入邮箱" type="email" v-model="field2"></mt-field>
<mt-field label="用户密码" placeholder="请输入密码" type="password" v-model="field3"></mt-field>
<mt-field label="手机号码" placeholder="请输入手机号" type="tel" v-model="field4"></mt-field>
<mt-field label="网站链接" placeholder="请输入网址" type="url" v-model="field5"></mt-field>
<mt-field label="数字输入" placeholder="请输入数字" type="number" v-model="field6"></mt-field>
<mt-field label="生日日期" placeholder="请输入生日" type="date" v-model="field7"></mt-field>
<mt-field label="多行文字" placeholder="多行文字" type="textarea" rows="2" v-model="field8"></mt-field>
<mt-header title="扩展控件"></mt-header>
<wb-field-select label="文字选择" placeholder="请选择" :items="['男','女']" v-model="field10"></wb-field-select>
<wb-field-dict label="字典选择" placeholder="请选择" :items="[{key:'1',value:'男'},{key:'2',value:'女'}]"
v-model="field11"></wb-field-dict>
<wb-field-date label="日期选择" placeholder="请选择" v-model="field12"></wb-field-date>
<wb-field-time label="时间选择" placeholder="请选择" v-model="field13"></wb-field-time>
<wb-field-datetime label="日期时间" placeholder="请选择" v-model="field14"></wb-field-datetime>
<wb-field-cphm label="车牌号码" placeholder="车牌号" v-model="field15"></wb-field-cphm>
<wb-field-pictures label="选择照片" v-model="field16" @handle-file="handleFile"></wb-field-pictures>
<div style="padding: 10px">
<mt-button type="primary" size="large" @click="doSearch()">打印类容</mt-button>
</div>
</div>
</div>
</template>
<script>
var router = new VueRouter({
routes: [
{
path: '/',
name: 'home',
component: Vue.extend({template: '#home'})
},
{
path: '/demo',
name: 'demo',
component: Vue.extend({
template: '#demo',
mounted: function () {
},
data: function () {
return {
field1: '',
field2: '',
field3: '',
field4: '',
field5: '',
field6: '',
field7: '',
field8: '',
field9: '',
field10: '',
field11: '',
field12: '',
field13: '',
field14: '',
field15: '',
field16: '',
}
},
methods: {
doSearch: function () {
console.log(this.field10);
console.log(this.field11);
console.log(this.field12);
console.log(this.field13);
console.log(this.field14);
console.log(this.field15);
console.log(this.field16);
},
back: function () {
if (window.android) {
android.finish()
} else {
location.href = "${Uri.getUrl('/app/index.htm')}"
}
},
handleFile: function (file, call) {
//do upload
console.log("正在上传文件" + file.name);
if (true) {
call.finish();
} else {
call.cancel();
}
}
}
})
}
]
});
var app = new Vue({
el: '#app',
data: {
transitionName: ''
},
router: router,
watch: {
'$route': function (to, from) {
this.transitionName = to.meta.index < from.meta.index ? 'left-in-right-out' : 'right-in-left-out'
}
}
})
</script>
</html>

@ -15,13 +15,6 @@
<body>
<#include Layout.setControl("macro")/>
<#include Layout.setControl("nav")/>
<div class="wb-layout-title-fix">
<div class="wb-head">
<#include Layout.setControl("header")/>
</div>
<div class="wb-body">
<#include Layout.setScreen()/>
</div>
</div>
<#include Layout.setScreen()/>
</body>
</html>

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<#include Layout.setScreen()/>
</body>
</html>

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>文件管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
<#--baseJs-->
<script src="${Uri.getUrl('/static/dist/lib.min.js')}" type="text/javascript"></script>
<#--element-ui-->
<script src="${Uri.getUrl('/static/dist/index.min.js')}" type="text/javascript"></script>
<link href="${Uri.getUrl('/static/dist/index.min.css')}" rel="stylesheet"/>
<#--ajax接口-->
<script src="${Uri.getUrl('/static/js/ajax.js')}" type="text/javascript"></script>
<link href="${Uri.getUrl('/static/css/base.css')}" rel="stylesheet"/>
</head>
<body>
<#include Layout.setControl("macro")/>
<#include Layout.setControl("nav")/>
<#include Layout.setScreen()/>
</html>

@ -9,6 +9,7 @@
el: "#app",
data: {},
methods: {},
filters: {},
created: function () {
},
mounted: function () {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,134 @@
<div id="app" v-cloak>
<div class="frame">
<div class="login-box">
<div class="login-title">系统登录</div>
<el-form :model="form" :rules="rules" ref="form" class="form">
<el-form-item prop="name">
<el-input placeholder="用户名" v-model="form.name">
<template slot="prepend"><i class="icon iconfont el-icon-user"></i></template>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input placeholder="密码" v-model="form.password" type="password">
<template slot="prepend"><i class="icon iconfont el-icon-lock"></i></template>
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" style="width: 100%" :loading="isLogin" :disabled="isLogin"
@click="submitForm('form')">登录
</el-button>
</el-form-item>
</el-form>
<a class="tip">系统登录</a>
</div>
</div>
</div>
<style>
#app {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
display: flex;
background: #001d3a;
justify-content: center;
align-items: center;
}
.frame {
width: 600px;
height: 500px;
background: #42424263;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 0 10px 0 #afafaf52;
}
.login-box {
display: inline-block;
background: #fff;
border-radius: 5px;
text-align: left;
}
.login-title {
line-height: 50px;
border-bottom: 1px solid #e8e8e8;
font-weight: bold;
text-align: left;
padding-left: 20px;
font-size: 15px;
height: 50px;
color: #757575;
}
.form {
width: 300px;
margin-top: 20px;
margin-left: 20px;
margin-right: 20px;
}
.form .el-input-group__prepend {
padding: 10px;
}
.tip {
padding: 5px;
display: inline-block;
text-align: center;
color: #b7b7b7;
width: 100%;
margin-bottom: 10px;
}
</style>
<script type="text/javascript">
var app = new Vue({
el: "#app",
data: {
form: {
name: '',
password: ''
},
rules: {
name: [
{required: true, message: '请输入用户名', trigger: 'blur'}
],
password: [
{required: true, message: '请输入密码', trigger: 'change'}
],
},
isLogin: false
},
mounted: function () {
},
methods: {
submitForm: function (formName) {
this.$refs[formName].validate(function (valid) {
if (valid) {
this.isLogin = true;
setTimeout(function(){
nav.i("登录成功!", function () {
location.href = "/index.htm"
});
},1000)
} else {
return false;
}
}.bind(this));
},
resetForm: function (formName) {
this.$refs[formName].resetFields();
}
},
})
</script>

@ -1,96 +0,0 @@
<div id="app" v-cloak>
<div class="main">
<div class="content">
<div class="head">
<a>文件上传服务</a>
</div>
<el-upload
style="width: 300px;"
name="file"
class="upload-demo"
action="upload"
:http-request="handleUpload"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
multiple
:limit="3"
:on-exceed="handleExceed"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
<#--<div class="body">-->
<#--<form action="upload" method="post" enctype="multipart/form-data">-->
<#--<a class="icon" onclick="file.click()">-->
<#--<img src="${Uri.getUrl('/static/img/add.png')}">-->
<#--</a>-->
<#--<input id="file" name="file" type="file">-->
<#--<input class="submit" type="submit" value="提交">-->
<#--</form>-->
<#--</div>-->
</div>
</div>
</div>
<style>
* {
margin: 0px;
padding: 0px;
}
#app {
}
.main {
padding: 5px;
}
</style>
<script type="text/javascript">
$(function () {
var app = new Vue({
el: '#app',
data: {
transitionName: '',
fileList: [{
name: 'food.jpeg',
url: 'static/img/logo.png'
}],
},
methods: {
handleUpload: function (req) {
ajax.fileUpload(req.file).then(function (response) {
if (response.errors.length > 0) {
req.onError();
nav.e(response.errors[0].message);
} else {
req.onSuccess();
nav.i("文件上传成功!");
}
})
},
handlePreview: function (file) {
console.log(file);
},
handleRemove: function (file, fileList) {
console.log(file, fileList);
},
beforeRemove: function (file, fileList) {
console.log(fileList);
return this.$confirm('确定移除 ${ file.name }?');
},
handleExceed: function (files, fileList) {
this.$message.warning('当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件用户头像上传');
}
},
created: function () {
},
mounted: function () {
},
});
});
</script>

@ -0,0 +1,86 @@
package xyz.wbsite;
import xyz.wbsite.frame.utils.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* UtilTest - - 测试用例
*
* @author wangbing
* @version 0.0.1
* @since 2017-01-01
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class UtilTest {
@Test
public void testIDgenerator() {
for (int i = 0; i < 10; i++) {
long l = IDgenerator.nextId();
System.out.println(l);
}
}
@Test
public void testAESUtil() {
// 加密
String data = "我有一个苹果";
String secret = "1234567890123456";
System.out.println("加密后的Base64密文是:" + AESUtil.encrypt2Base64(data.getBytes(), secret));
// 解密
String encrypt2Base64 = AESUtil.encrypt2Base64(data.getBytes(), secret);
byte[] decrypt = AESUtil.decrypt(Base64Util.decode(encrypt2Base64), secret);
System.out.println("解密后的明文是:" + new String(decrypt));
}
@Test
public void testBase64Util() {
String s = Base64Util.encodeToString(("我搜搜").getBytes());
System.out.println(s);
byte[] decode = Base64Util.decode(s);
System.out.println(new String(decode));
}
@Test
public void testMD5Util() {
String encode = MD5Util.encode("123456");
System.out.println(encode);
}
@Test
public void testProcessUtil() {
ProcessUtil.execExe("D:\\example.exe");
ProcessUtil.execBat("D:\\example.bat");
}
@Test
public void testRSAUtil() {
{//创建秘钥对
RSAUtil.createKey();
}
{//加解密
//加密
String encrypt = RSAUtil.encrypt2Base64("我有一个苹果".getBytes());
System.out.println(encrypt);
//解密
String decrypt = RSAUtil.decrypt2String(encrypt);
System.out.println(decrypt);
}
String sign = RSAUtil.sign2Base64("我有一个苹果".getBytes());
System.out.println(sign);
boolean b = RSAUtil.doCheck("我有一个苹果".getBytes(), sign);
System.out.println(b);
}
}

@ -1,24 +1,16 @@
package xyz.wbsite.config;
import xyz.wbsite.framework.base.Token;
import xyz.wbsite.framework.springmvc.GlobalHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import xyz.wbsite.frame.base.Token;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class TestConfig {
@Bean
public Token getTestToken() {
Token token = new Token();
token.setId(-1);
token.setUserId(-1);
token.setId(0);
token.setUserId(0);
token.setUserName("system");
return token;
}

@ -1,25 +1,26 @@
# 开发环境
# 测试环境
server.port=8080
server.servlet.context-path=/
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:static/
spring.application.name=SpringBoot
spring.main.banner-mode=CONSOLE
spring.devtools.restart.enabled=true
# 编码配置
spring.http.encoding.force=true
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
server.tomcat.uri-encoding=UTF-8
# 根路径、欢迎页
web.welcome.page = index
# 排除的不需要验证的URL
web.url.excluded = /static/**,/open/**,/api,/index,/,/login
web.url.authorization = /**
# 默认的登录URL
web.url.login = /login
web.welcome.page=/index.htm
# 需要验证授权, 既访问时组装Token
web.url.auth.included=/**
# 不需要验证授权, 或该请求有自己的验证机制
web.url.auth.excluded=/favicon.ico,/static/**,/api,/login.htm
# 日志配置
logging.path=D://
logging.levels=DEBUG
logging.config=classpath:logback-config.xml
# 热部署生效
spring.devtools.restart.enabled=true
# mysql
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8
@ -32,6 +33,12 @@ pagehelper.autoRuntimeDialect=true
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
# jackson 相关配置
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.jackson.default-property-inclusion=use_defaults
spring.jackson.mapper.sort-properties-alphabetically=true
spring.jackson.deserialization.fail-on-unknown-properties=false
# freemarker
spring.freemarker.enabled=true
spring.freemarker.allow-request-override=false
@ -51,6 +58,6 @@ spring.freemarker.settings.classic_compatible=true
spring.freemarker.settings.whitespace_stripping=true
spring.freemarker.settings.url_escaping_charset=utf-8
# 文件上传配置
spring.servlet.multipart.resolveLazily = true
spring.servlet.multipart.max-file-size=100Mb
spring.servlet.multipart.max-request-size=100Mb
spring.servlet.multipart.resolveLazily=false
spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=100MB
Loading…
Cancel
Save

Powered by TurnKey Linux.