| | |
| | | select * from lf.sys_login; |
| | | select * from lf.sys_login_2022; |
| | | select * from lf.sys_login_2024; |
| | | select a.*,b.uname from lf.sys_login a inner join lf.sys_user b on a.userid = b.id; |
| | | ----------------------------------------------------------------------------------------------------- 6.操作日志表 |
| | | -- DROP TABLE IF EXISTS lf.sys_operate; |
| | | create table lf.sys_operate( |
| | | id serial8, |
| | | modular varchar(60), |
| | | module1 varchar(50), |
| | | module2 varchar(50), |
| | | url varchar(1024), |
| | | ip varchar(30), |
| | | exec bigint, |
| | |
| | | comment on table lf.sys_operate is '操作日志表'; |
| | | comment on column lf.sys_operate.id is '主键ID'; |
| | | comment on column lf.sys_operate.modular is '操作模块:如 数据管理\目录管理'; |
| | | comment on column lf.sys_operate.modular1 is '一级模块:如 数据管理'; |
| | | comment on column lf.sys_operate.modular2 is '二级模块:如 目录管理'; |
| | | comment on column lf.sys_operate.url is '操作网址'; |
| | | comment on column lf.sys_operate.ip is 'IP地址'; |
| | | comment on column lf.sys_operate.exec is '操作时间:单位为毫秒'; |
| | |
| | | comment on column lf.sys_operate.optime is '操作时间'; |
| | | comment on column lf.sys_operate.bak is '备注'; |
| | | |
| | | alter table lf.sys_operate add column modular1 varchar(50); |
| | | alter table lf.sys_operate add column modular2 varchar(50); |
| | | select split_part(modular,'\',1),split_part(modular,'\',2) from lf.sys_operate; |
| | | update lf.sys_operate set modular1=split_part(modular,'\',1),modular2=split_part(modular,'\',2); |
| | | |
| | | /*insert into lf.sys_operate (modular,url,ip,type) values ('数据管理\目录管理','data/manage/update','192.168.20.106',5); |
| | | insert into lf.sys_operate (modular,url,ip,type,optime) values ('数据管理\目录管理','data/manage/delete','192.168.20.107',4,'2024-01-02');*/ |
| | | |
| | |
| | | |
| | | private final static String DOWNLOAD = "download"; |
| | | |
| | | private final static String SPLIT = "\\"; |
| | | |
| | | private static final Log log = LogFactory.getLog(LogAspect.class); |
| | | |
| | | @Pointcut("@annotation(com.lf.server.aspect.SysLog)") |
| | |
| | | // 设置模块 |
| | | Api api = clazz.getAnnotation(Api.class); |
| | | if (api != null) { |
| | | oe.setModular(api.tags()[0]); |
| | | String[] strs = api.tags()[0].split(SPLIT); |
| | | oe.setModular1(strs[0]); |
| | | oe.setModular1(strs[1]); |
| | | } |
| | | |
| | | // 设置类名\方法名、类别 |
| | |
| | | |
| | | operateService.insertOperate(oe); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getStackTrace()); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | pathHelper.init(); |
| | | |
| | | log.info("*****************系统启动完毕*****************"); |
| | | log.info("*****************系统启动完毕*****************" + "\n"); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getStackTrace()); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | WebSocketService.broadCastInfo(json); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getStackTrace()); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | WebSocketService.broadCastInfo(json); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getStackTrace()); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | } |
| | | } |
| | |
| | | outputStream.close(); |
| | | fileInputStream.close(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getStackTrace()); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private String modular; |
| | | |
| | | private String modular1; |
| | | |
| | | private String modular2; |
| | | |
| | | private String url; |
| | | |
| | | private String ip; |
| | |
| | | this.modular = modular; |
| | | } |
| | | |
| | | public String getModular1() { |
| | | return modular1; |
| | | } |
| | | |
| | | public void setModular1(String modular1) { |
| | | this.modular1 = modular1; |
| | | } |
| | | |
| | | public String getModular2() { |
| | | return modular2; |
| | | } |
| | | |
| | | public void setModular2(String modular2) { |
| | | this.modular2 = modular2; |
| | | } |
| | | |
| | | public String getUrl() { |
| | | return url; |
| | | } |
| | |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | return result; |
| | | } |
| | |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage()); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | return result; |
| | | } |
| | |
| | | |
| | | return EntityUtils.toString(entity, StaticData.TEXT_ENCODER); |
| | | } catch (Exception ex) { |
| | | log.error(ex); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | |
| | | return getErrorInfo(uri, ex); |
| | | } |
| | |
| | | |
| | | return EntityUtils.toString(entity, StaticData.TEXT_ENCODER); |
| | | } catch (Exception ex) { |
| | | log.error(ex); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | |
| | | return getErrorInfo(uri, ex); |
| | | } |
| | |
| | | |
| | | return rest.getForObject(uri, String.class); |
| | | } catch (Exception ex) { |
| | | log.error(ex); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | |
| | | return getErrorInfo(uri, ex); |
| | | } |
| | |
| | | |
| | | return rest.postForObject(uri, entity, String.class); |
| | | } catch (Exception ex) { |
| | | log.error(ex); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | |
| | | return getErrorInfo(uri, ex); |
| | | } |
| | |
| | | import com.lf.server.entity.all.HttpStatus; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.helper.WebHelper; |
| | | import com.lf.server.service.sys.TokenService; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | |
| | | */ |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { |
| | | //noinspection AlibabaRemoveCommentedCode |
| | | try { |
| | | System.out.println(request.getRequestURI().toLowerCase() + "," + (handler instanceof HandlerMethod)); |
| | | |
| | | // // 非方法,无需拦截 |
| | | // if (!(handler instanceof HandlerMethod)) { |
| | | // return true; |
| | | // } |
| | | // |
| | | // // 无需授权 |
| | | // if (noNeedAuth(request)) { |
| | | // return true; |
| | | // } |
| | | // |
| | | // String token = WebHelper.getToken(request); |
| | | // if (StringHelper.isNull(token)) { |
| | | // WebHelper.write2Page(response, NO_TOKEN); |
| | | // return false; |
| | | // } |
| | | // |
| | | // UsersEntity ue = tokenService.getCurrentUser(request); |
| | | // if (ue == null) { |
| | | // WebHelper.write2Page(response, NO_LOGIN); |
| | | // return false; |
| | | // } |
| | | // 非方法,无需拦截 |
| | | if (!(handler instanceof HandlerMethod)) { |
| | | return true; |
| | | } |
| | | |
| | | // 无需授权 |
| | | if (noNeedAuth(request)) { |
| | | return true; |
| | | } |
| | | |
| | | String token = WebHelper.getToken(request); |
| | | if (StringHelper.isNull(token)) { |
| | | WebHelper.write2Page(response, NO_TOKEN); |
| | | return false; |
| | | } |
| | | |
| | | UserEntity ue = tokenService.getCurrentUser(request); |
| | | if (ue == null) { |
| | | WebHelper.write2Page(response, NO_LOGIN); |
| | | return false; |
| | | } |
| | | |
| | | //noinspection AlibabaRemoveCommentedCode |
| | | // 权限校验 |
| | | |
| | | return true; |
| | | } catch (Exception ex) { |
| | | log.error(ex.getStackTrace()); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getStackTrace()); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | } |
| | | |
| | |
| | | // 以 utf-8的编码格式来解析 value值 |
| | | value = item.getString("utf-8"); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getStackTrace()); |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | |
| | | // 输出到控制台 |
| | |
| | | // Ping通地址 |
| | | socket.connect(add, 2000); |
| | | } catch (Exception e) { |
| | | log.error(e.getStackTrace()); |
| | | log.error(e.getMessage() + e.getStackTrace() + "\n"); |
| | | list.add(re); |
| | | } finally { |
| | | try { |
| | | socket.close(); |
| | | } catch (Exception e) { |
| | | log.error(e.getStackTrace()); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage() + ex.getStackTrace() + "\n"); |
| | | } |
| | | } |
| | | } |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!-- scan 配置文件如果发生改变,将会被重新加载 scanPeriod 检测间隔时间--> |
| | | <configuration scan="true" scanPeriod="60 seconds" debug="false"> |
| | | <contextName>jcpimserver</contextName> |
| | | <contextName>LFServer</contextName> |
| | | |
| | | <!-- 文件名称 --> |
| | | <property name="log.name.info" value="info" /> |
| | |
| | | <logger name="com.apache.ibatis" level="DEBUG"></logger> |
| | | |
| | | <!-- additivity:是否在父(这里为root节点)输出, 默认 true; --> |
| | | <logger name="com.jcpim" level="INFO" additivity="true"> |
| | | <logger name="com.lf.server" level="INFO" additivity="true"> |
| | | <appender-ref ref="INFO_FILE"/> |
| | | <appender-ref ref="ERROR_FILE"/> |
| | | </logger> |
| | |
| | | <root level="INFO"> |
| | | <appender-ref ref="STDOUT" /> |
| | | </root> |
| | | |
| | | </configuration> |
| | |
| | | |
| | | <insert id="insertOperates" > |
| | | insert into lf.sys_operate |
| | | (modular,url,ip,exec,clazz,type,userid,optime,bak) |
| | | (modular1,modular2,url,ip,exec,clazz,type,userid,optime,bak) |
| | | values |
| | | <foreach collection="list" item="item" index="index" separator="," > |
| | | (#{modular},#{url},#{ip},#{exec},#{clazz},#{type},#{userid},now(),#{bak}) |
| | | <foreach collection="list" item="item" index="index" separator="," > |
| | | (#{modular1},#{modular2},#{url},#{ip},#{exec},#{clazz},#{type},#{userid},now(),#{bak}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | |
| | | </delete> |
| | | |
| | | <update id="updateOperate"> |
| | | update lf.sys_operate set modular=#{modular},url=#{url},ip=#{ip},exec=#{exec},clazz=#{clazz},type=#{type},userid=#{userid},optime=now(),bak=#{bak} where id=#{id} |
| | | update lf.sys_operate set modular1=#{modular1},modular2=#{modular2},url=#{url},ip=#{ip},exec=#{exec},clazz=#{clazz},type=#{type},userid=#{userid},optime=now(),bak=#{bak} where id=#{id} |
| | | </update> |
| | | </mapper> |