优化工作流监控,修复头像上传问题

This commit is contained in:
zxm 2018-04-23 22:22:24 +08:00
parent f85fbe1dda
commit 0e603de6f0
14 changed files with 3220 additions and 898 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View File

@ -47,9 +47,8 @@ public class ListenUserRole {
* @param joinPoint
*/
@Around("execution(com.len.util.JsonUtil com.len.controller.UserController.updateUser(*,String[]))")
public Object listenerUserUpdate(ProceedingJoinPoint joinPoint){
public Object listenerUserUpdate(ProceedingJoinPoint joinPoint) throws Throwable{
Object o=new Object();
try{
//更新前拿到用户-角色数据
SysRoleUser sysRoleUser =new SysRoleUser();
Object[] args = joinPoint.getArgs();
@ -62,9 +61,6 @@ public class ListenUserRole {
if(jsonUtil.isFlag()){
changeUser(args,strings);
}
}catch (Throwable e){
e.printStackTrace();
}
return o;
}
@ -73,9 +69,8 @@ public class ListenUserRole {
* @param joinPoint
*/
@Around("execution(com.len.util.JsonUtil com.len.controller.UserController.addUser(*,String[]))")
public Object listenerUserInsert(ProceedingJoinPoint joinPoint){
public Object listenerUserInsert(ProceedingJoinPoint joinPoint) throws Throwable{
Object o=new Object();
try{
o = joinPoint.proceed(joinPoint.getArgs());
Object[] args = joinPoint.getArgs();
if(args.length==2){
@ -84,26 +79,18 @@ public class ListenUserRole {
changeUser(args, Arrays.asList((String[]) args[1]));
}
}
}catch (Throwable e){
e.printStackTrace();
}
return o;
}
@Around("execution(com.len.util.JsonUtil com.len.controller.UserController.del(..))")
public Object listenDelUser(ProceedingJoinPoint point){
public Object listenDelUser(ProceedingJoinPoint point) throws Throwable{
Object o=new Object();
try{
o = point.proceed(point.getArgs());
JsonUtil util= (JsonUtil) o;
if(util.isFlag()){
Object[] args = point.getArgs();
identityService.deleteUser((String) args[0]);
}
}catch (Throwable e){
e.printStackTrace();
}
return o;
}
@ -139,9 +126,8 @@ public class ListenUserRole {
/**********************角色处理begin***************************/
@Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.addRole(*,String[]))")
public Object listenRoleInsert(ProceedingJoinPoint joinPoint){
public Object listenRoleInsert(ProceedingJoinPoint joinPoint)throws Throwable{
Object o=null;
try{
o=joinPoint.proceed(joinPoint.getArgs());
JsonUtil j=(JsonUtil)o;
if(j.isFlag()){
@ -150,16 +136,12 @@ public class ListenUserRole {
changeRole(args);
}
}
}catch (Throwable throwable){
}
return o;
}
@Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.updateUser(*,String[]))")
public Object listenRoleUpdate(ProceedingJoinPoint joinPoint){
public Object listenRoleUpdate(ProceedingJoinPoint joinPoint) throws Throwable{
Object o=null;
try{
o=joinPoint.proceed(joinPoint.getArgs());
Object[] args = joinPoint.getArgs();
if(args.length==2){
@ -167,26 +149,19 @@ public class ListenUserRole {
changeRole(args);
}
}
}catch (Throwable throwable){
}
return o;
}
@Around("execution(com.len.util.JsonUtil com.len.controller.RoleController.del(..))")
public Object listenDelRole(ProceedingJoinPoint point){
public Object listenDelRole(ProceedingJoinPoint point) throws Throwable{
Object o=new Object();
try{
o = point.proceed(point.getArgs());
JsonUtil util= (JsonUtil) o;
if(util.isFlag()){
Object[] args = point.getArgs();
identityService.deleteGroup((String) args[0]);
}
}catch (Throwable e){
e.printStackTrace();
}
return o;
}

File diff suppressed because it is too large Load Diff

View File

@ -15,15 +15,16 @@ import com.len.util.JsonUtil;
import com.len.util.Md5Util;
import io.swagger.annotations.ApiOperation;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.io.*;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
@ -232,6 +233,8 @@ public class UserController extends BaseController {
return j;
}
@Value("${imagePath}")
private String imagePath;
/**
* 头像上传 目前首先相对路径
*/
@ -240,30 +243,17 @@ public class UserController extends BaseController {
public JsonUtil imgUpload(HttpServletRequest req, @RequestParam("file") MultipartFile file,
ModelMap model) {
JsonUtil j = new JsonUtil();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf1 = new SimpleDateFormat("hhmmss");
String fileName = sdf1.format(new Date()) + file.getOriginalFilename();
String objPath =
req.getSession().getServletContext().getRealPath("image/") + sdf.format(new Date())
.toString();
File targetFile1 = new File(objPath, fileName);
File file2 = new File(objPath);
if (!file2.exists()) {
file2.mkdirs();
}
if (!targetFile1.exists()) {
targetFile1.mkdirs();
}
String imageName=file.getOriginalFilename();
imageName= UUID.randomUUID()+imageName.substring(imageName.indexOf("."),imageName.length());
File file2 = new File(imagePath+"\\"+imageName);
try {
file.transferTo(targetFile1);
} catch (Exception e) {
FileUtils.copyInputStreamToFile(file.getInputStream(), file2);
} catch (IOException e) {
j.setFlag(false);
j.setMsg("上传失败");
e.printStackTrace();
}
j.setMsg("image/" + sdf.format(new Date()).toString() + "/" + req.getContextPath() + fileName);
j.setMsg(imageName);
return j;
}

View File

@ -76,7 +76,7 @@
layer = layui.layer;
var msg='${message}';
if(msg.trim()!=""){
layer.msg(msg, {icon: 5,anim:6});
layer.msg(msg, {icon: 5,anim:6,offset: 't'});
}
$("#code").click(function(){
var url = "/getCode?"+new Date().getTime();

View File

@ -53,7 +53,7 @@
<li class="layui-nav-item">
<a href="javascript:;">
<#assign currentUser = Session["curentUser"]>
<img src="${currentUser.photo}" class="layui-nav-img">${currentUser.username}
<img src="/images/${currentUser.photo}" class="layui-nav-img">${currentUser.username}
</a>
<dl class="layui-nav-child">
<dd><a href="javascript:;" kit-target data-options="{url:'basic.html',icon:'&#xe658;',title:'基本资料',id:'966'}"><span>基本资料</span></a></dd>

View File

@ -54,7 +54,7 @@ To change this template use File | Settings | File Templates.-->
<div class="layui-input-inline">
<div id="demo2" style="margin-top: 20px;margin-left: 50px">
<img src="${re.contextPath}/${user.photo!"plugin/x-admin/images/bg.png"}" width="100px" height="100px" class="layui-upload-img layui-circle">
<img src="/images/${re.contextPath}/${user.photo}" width="100px" height="100px" class="layui-upload-img layui-circle">
</div>
</div>
@ -189,6 +189,7 @@ To change this template use File | Settings | File Templates.-->
if(!res.flag){
layer.msg(res.msg,{icon: 5,anim: 6});
}else{
console.log(res);
$("#photo").val(res.msg);
console.info($('#photo').val());
}

View File

@ -71,8 +71,8 @@ function layerAjax(url,data,tableId){
}else{
layer.msg(d.msg,{icon:5});
}
},error:function(){
layer.alert("请求失败", {icon: 6},function () {
},error:function(e){
layer.alert("发生错误", {icon: 6},function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
});

View File

@ -125,7 +125,7 @@
<orderEntry type="module-library">
<library name="Maven: com.alibaba:tools:1.6.0">
<CLASSES>
<root url="jar://D:/Program Files/Java/jdk1.8.0_101/lib/tools.jar!/" />
<root url="jar://E:/Program Files/Java/jdk1.8.0_101/lib/tools.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />

View File

@ -7,11 +7,14 @@ import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.len.core.annotation.LogAspect;
import com.len.freemarker.MyFreemarkerConfig;
import freemarker.template.TemplateException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
@ -31,11 +34,15 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
* @author zhuxiaomeng
* @date 2018/1/1.
* @email 154040976@qq.com
*spring shiro
* spring shiro
*/
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Value("${imagePath}")
private String imagePath;
@Value("${filePath}")
private String filePath;
@Bean
public HttpMessageConverter<String> responseBodyConverter() {
@ -44,7 +51,6 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
}
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
@ -53,8 +59,10 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/plugin/**","/static/**")
.addResourceLocations("classpath:/plugin/","classpath:/static/");
registry.addResourceHandler("/plugin/**", "/static/**")
.addResourceLocations("classpath:/plugin/", "classpath:/static/");
registry.addResourceHandler("/ftl/**").addResourceLocations("classpath:/ftl/");
registry.addResourceHandler("/images/**").addResourceLocations("file:"+imagePath);
registry.addResourceHandler("/file/**").addResourceLocations("file:"+imagePath);
}
}

View File

@ -5,9 +5,6 @@ security:
enabled: false
spring:
datasource:
# url: jdbc:mysql://www.cqwzxt.com:3306/lenos?useUnicode=true&characterEncoding=UTF-8
# username: lenos
# password: lenos
url: jdbc:mysql://localhost:3306/lenos?useUnicode=true&characterEncoding=UTF-8
username: root
password: 123456
@ -55,4 +52,8 @@ logging:
com.len.mapper: debug
#security:
# basic:
# enabled: false
# enabled: false
filePath: G\os\file\
imagePath: G:\os\image\

View File

@ -5,23 +5,23 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n
#logger input file
log4j.logger.DebugAppender.access=DEBUG
log4j.appender.DebugAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DebugAppender.File=../logs/debug.log
log4j.logger.DebugAppender.access=DEBUG
log4j.appender.DebugAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DebugAppender.File=G:/os/lenosp/logs/debug.log
log4j.appender.DebugAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.DebugAppender.layout.ConversionPattern=%d-[TS] %p %t %c - %m%n
#logger input file
log4j.logger.InfoAppender.access=INFO
log4j.appender.InfoAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.InfoAppender.File=../logs/INFO.log
log4j.appender.InfoAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.InfoAppender.File=G:/os/lenosp/logs/INFO.log
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern=%d-[TS] %p %t %c - %m%n
log4j.appender.InfoAppender.layout.ConversionPattern=%d-[TS] %p %t %c - %m%n
#error log input file
log4j.logger.ErrorAppender.access=ERROR
log4j.appender.ErrorAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ErrorAppender.File=../logs/ERROR.log
log4j.appender.ErrorAppender.File=G:/os/lenosp/logs/ERROR.log
log4j.appender.ErrorAppender.Append = true
log4j.appender.ErrorAppender.threshold = ERROR
log4j.appender.ErrorAppender.layout=org.apache.log4j.PatternLayout