专栏电商日志财经减肥爱情
投稿投诉
爱情常识
搭配分娩
减肥两性
孕期塑形
财经教案
论文美文
日志体育
养生学堂
电商科学
头戴业界
专栏星座
用品音乐

SpringBoot利用AOP写一个日志管理

  1。需求
  目前有这么个问题,有两个系统CSP和OMS,这俩系统共用的是同一套日志操作:Log;目前想区分下这俩系统的日志操作,那没办法了,只能重写一份Log的日志操作;
  你也可以参照若依框架的日志系统实现。2。新建一张日志表
  sysopercsplogNavicatPremiumDataTransferSourceServer:jpcscadminSourceServerType:MySQLSourceServerVersion:50728SourceHost:rmuf6miy84gu8u433x9。mysql。rds。aliyuncs。com:3306SourceSchema:jpomsTargetServerType:MySQLTargetServerVersion:50728FileEncoding:65001Date:0809202209:21:45SETNAMESutf8mb4;SETFOREIGNKEYCHECKS0;TablestructureforsysopercsplogDROPTABLEIFEXISTSsysopercsplog;CREATETABLEsysopercsplog(operidbigint(20)NOTNULLAUTOINCREMENTCOMMENTahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a主键,titlevarchar(50)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT模块标题,businesstypeint(2)NULLDEFAULT0COMMENT业务类型(0其它,1新增,2修改,3删除,4授权,5导出,6导入,7强退,8生成代码,9清空数据),methodvarchar(100)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT方法名称,requestmethodvarchar(10)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT请求方式,operatortypeint(1)NULLDEFAULT0COMMENT操作类别(0其它1后台用户2手机端用户),opernamevarchar(50)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT操作人员,deptnamevarchar(50)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT部门名称,operurlvarchar(255)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT请求URL,operipvarchar(128)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT主机地址,operlocationvarchar(255)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT操作地点,operparamvarchar(2000)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT请求参数,jsonresulttextCHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLCOMMENT返回参数,statusint(1)NULLDEFAULT0COMMENT操作状态(0正常1异常),errormsgvarchar(2000)CHARACTERSETutf8mb4COLLATEutf8mb4generalciNULLDEFAULTCOMMENT错误消息,opertimedatetimeNULLDEFAULTNULLCOMMENT操作时间,PRIMARYKEY(operid)USINGBTREE,INDEXidxtime(opertime,title,opername)USINGBTREE)ENGINEInnoDCHARACTERSETutf8mb4COLLATEutf8mb4generalciCOMMENTCSP系统操作ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a记录;3。写相应的Controller层packagecom。juepeiscm。csp。controller。csplog;importcom。juepeiscm。admin。api。domain。SysOperLog;importcom。juepeiscm。common。core。controller。BaseController;importcom。juepeiscm。common。core。domain。AjaxResult;importcom。juepeiscm。common。core。page。TableDataInfo;importcom。juepeiscm。common。enums。BusinessType;importcom。juepeiscm。common。utils。poi。ExcelUtil;importcom。juepeiscm。csp。annotation。CspLog;importcom。juepeiscm。csp。domain。csplog。SysOperCspLog;importcom。juepeiscm。csp。service。csplog。ISysOperCspLogService;importorg。springframework。beans。factory。annotation。Autowired;importorg。springframework。security。access。prepost。PreAuthorize;importorg。springframework。web。bind。annotation。;importjava。util。List;操作CSP系统ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志aAuthor:py。sunDate:20229714:51RestControllerRequestMapping({csplogopercsplog})publicclassSysOperCsplogControllerextendsBaseController{AutowiredprivateISysOperCspLogServiceoperCspLogService;publicSysOperCsplogController(){}查询操作ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a列表paramsysOperCspLogreturnPreAuthorize(ss。hasPermi(monitor:operlog:list))GetMapping({list})publicTableDataInfolist(SysOperCspLogsysOperCspLog){this。startPage();ListSysOperCspLoglistthis。operCspLogService。selectOperLogList(sysOperCspLog);returnthis。getDataTable(list);}查询系统模块的分类paramreturnGetMapping({listTitle})publicTableDataInfolistTitle(){this。startPage();ListStringlistthis。operCspLogService。selectOperLogListTitle();returnthis。getDataTable(list);}CspLog(title导出CSP系统ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a,businessTypeBusinessType。EXPORT)PreAuthorize(ss。hasPermi(monitor:operlog:export))GetMapping({export})publicAjaxResultexport(SysOperCspLogoperLog){ListSysOperCspLoglistthis。operCspLogService。selectOperLogList(operLog);ExcelUtilSysOperCspLogutilnewExcelUtil(SysOperLog。class);returnutil。exportExcel(list,操作CSP系统ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a);}CspLog(title操作CSP系统ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a,businessTypeBusinessType。DELETE)PreAuthorize(ss。hasPermi(monitor:operlog:remove))DeleteMapping({{operIds}})publicAjaxResultremove(PathVariableLong〔〕operIds){returnthis。toAjax(this。operCspLogService。deleteOperLogByIds(operIds));}CspLog(title清除CSP系统ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a,businessTypeBusinessType。CLEAN)PreAuthorize(ss。hasPermi(monitor:operlog:remove))DeleteMapping({clean})publicAjaxResultclean(){this。operCspLogService。cleanOperLog();returnAjaxResult。success();}}Service接口层packagecom。juepeiscm。csp。service。csplog;importcom。juepeiscm。admin。api。domain。SysOperLog;importcom。juepeiscm。csp。domain。csplog。SysOperCspLog;importjava。util。List;Author:py。sunDate:20229715:02publicinterfaceISysOperCspLogService{voidinsertOperlog(SysOperCspLogvar1);ListSysOperCspLogselectOperLogList(SysOperCspLogvar1);ListStringselectOperLogListTitle();intdeleteOperLogByIds(Long〔〕var1);SysOperLogselectOperLogById(Longvar1);voidcleanOperLog();}Service实现packagecom。juepeiscm。csp。service。impl。csplog;importcom。juepeiscm。admin。api。domain。SysOperLog;importcom。juepeiscm。common。core。domain。AjaxResult;importcom。juepeiscm。common。core。domain。entity。SysDept;importcom。juepeiscm。common。core。domain。entity。SysUser;importcom。juepeiscm。common。core。domain。model。LoginUser;importcom。juepeiscm。common。exception。CustomException;importcom。juepeiscm。common。utils。SecurityUtils;importcom。juepeiscm。common。utils。ServletUtils;importcom。juepeiscm。common。utils。StringUtils;importcom。juepeiscm。csp。domain。csplog。SysOperCspLog;importcom。juepeiscm。csp。mapper。csplog。SysOperCspLogMapper;importcom。juepeiscm。csp。service。csplog。ISysOperCspLogService;importcom。juepeiscm。framework。web。service。TokenService;importcom。juepeiscm。uam。service。ISysDeptService;importcom。juepeiscm。uam。version。UamVersion;importorg。apache。dubbo。config。annotation。Reference;importorg。springframework。beans。factory。annotation。Autowired;importorg。springframework。stereotype。Service;importjava。util。List;Author:py。sunDate:20229715:03ServicepublicclassSysOperCspLogServiceImplimplementsISysOperCspLogService{AutowiredprivateSysOperCspLogMapperoperLogMapper;AutowiredprivateTokenServicetokenService;Reference(versionUamVersion。idV)publicISysDeptServicedeptService;OverridepublicvoidinsertOperlog(SysOperCspLogsysOperCspLog){try{this。operLogMapper。insertOperlog(sysOperCspLog);}catch(Exceptione){e。printStackTrace();thrownewCustomException(CSP系统ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a插入失败,请联系管理员!!!);}}OverridepublicListSysOperCspLogselectOperLogList(SysOperCspLogsysOperCspLog){returnthis。operLogMapper。selectOperLogList(sysOperCspLog);}OverridepublicListStringselectOperLogListTitle(){returnthis。operLogMapper。selectOperLogListTitle();}OverridepublicintdeleteOperLogByIds(Long〔〕operIds){returnthis。operLogMapper。deleteOperLogByIds(operIds);}OverridepublicSysOperLogselectOperLogById(LongoperId){returnthis。operLogMapper。selectOperLogById(operId);}OverridepublicvoidcleanOperLog(){this。operLogMapper。cleanOperLog();}}Mapper接口packagecom。juepeiscm。csp。mapper。csplog;importcom。juepeiscm。admin。api。domain。SysOperLog;importcom。juepeiscm。csp。domain。csplog。SysOperCspLog;importjava。util。List;Author:py。sunDate:20229715:06publicinterfaceSysOperCspLogMapper{voidinsertOperlog(SysOperCspLogvar1);ListSysOperCspLogselectOperLogList(SysOperCspLogsysOperCspLog);ListStringselectOperLogListTitle();intdeleteOperLogByIds(Long〔〕var1);SysOperLogselectOperLogById(Longvar1);voidcleanOperLog();}Mapper。xml(我用的是Mybatis)lt;?xmlversion1。0encodingUTF8?!DOCTYPEmapperPUBLICmybatis。orgDTDMapper3。0ENhttp:mybatis。orgdtdmybatis3mapper。dtdmappernamespacecom。juepeiscm。csp。mapper。csplog。SysOperCspLogMapperresultMaptypeSysOperCspLogidSysOperLogResultidpropertyoperIdcolumnoperidresultpropertytitlecolumntitleresultpropertybusinessTypecolumnbusinesstyperesultpropertymethodcolumnmethodresultpropertyrequestMethodcolumnrequestmethodresultpropertyoperatorTypecolumnoperatortyperesultpropertyoperNamecolumnopernameresultpropertydeptNamecolumndeptnameresultpropertyoperUrlcolumnoperurlresultpropertyoperIpcolumnoperipresultpropertyoperLocationcolumnoperlocationresultpropertyoperParamcolumnoperparamresultpropertyjsonResultcolumnjsonresultresultpropertystatuscolumnstatusresultpropertyerrorMsgcolumnerrormsgresultpropertyoperTimecolumnopertimeresultMapsqlidselectOperLogVoselectoperid,title,businesstype,method,requestmethod,operatortype,opername,deptname,operurl,operip,operlocation,operparam,jsonresult,status,errormsg,opertimefromsysopercsplogsqlinsertidinsertOperlogparameterTypeSysOperCspLoginsertintosysopercsplog(title,businesstype,method,requestmethod,operatortype,opername,deptname,operurl,operip,operlocation,operparam,jsonresult,status,errormsg,opertime)values({title},{businessType},{method},{requestMethod},{operatorType},{operName},{deptName},{operUrl},{operIp},{operLocation},{operParam},{jsonResult},{status},{errorMsg},sysdate())insertselectidselectOperLogListparameterTypeSysOperCspLogresultMapSysOperLogResultincluderefidselectOperLogVowhereiftesttitle!nullandtitle!ANDtitlelikeconcat(,{title},)ififtestbusinessType!nullandbusinessType!ANDbusinesstype{businessType}ififtestbusinessTypes!nullandbusinessTypes。length0ANDbusinesstypeinforeachcollectionbusinessTypesitembusinessTypeopen(separator,close){businessType}foreachififteststatus!nullANDstatus{status}ififtestoperName!nullandoperName!ANDopernamelikeconcat(,{operName},)ififtestparams。beginTime!nullandparams。beginTime!!开始时间检索anddateformat(opertime,ymd)dateformat({params。beginTime},ymd)ififtestparams。endTime!nullandparams。endTime!!结束时间检索anddateformat(opertime,ymd)dateformat({params。endTime},ymd)ifwhereorderbyoperiddescselectdeleteiddeleteOperLogByIdsparameterTypeLongdeletefromsysopercsplogwhereoperidinforeachcollectionarrayitemoperIdopen(separator,close){operId}foreachdeleteselectidselectOperLogByIdparameterTypeLongresultMapSysOperLogResultincluderefidselectOperLogVowhereoperid{operId}selectselectidselectOperLogListTitleresultTypejava。lang。Stringselectdistinct(title)fromsysopercsplogselectupdateidcleanOperLogtruncatetablesysopercsplogupdatemapper
  定义一个日志管理的名称:CspLogpackagecom。juepeiscm。csp。annotation;importcom。juepeiscm。common。enums。BusinessType;importcom。juepeiscm。common。enums。OperatorType;importjava。lang。annotation。;CSP系统的ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a管理Author:py。sunDate:20229714:42Target表示注解可以使用到哪些地方,可以是类,方法,或者是属性上,定义在ElementType枚举中:Retention作用是定义被它所注解的注解保留多久,一共有三种策略,定义在RetentionPolicy枚举中:我们的CspLog注解,可以作用在方法和参数上,将由编译器记录在类文件中,并在运行时由VM保留,因此可以反射性地读取。该注解是通过AOP进行解析的Target({ElementType。PARAMETER,ElementType。METHOD})Retention(RetentionPolicy。RUNTIME)DocumentedpublicinterfaceCspLog{模块returnStringtitle()default;功能returnBusinessTypebusinessType()defaultBusinessType。OTHER;操作人类别returnOperatorTypeoperatorType()defaultOperatorType。MANAGE;是否保存请求的参数returnbooleanisSaveRequestData()defaulttrue;}实体类SysOperCspLogpackagecom。juepeiscm。csp。domain。csplog;importcom。fasterxml。jackson。annotation。JsonFormat;importcom。juepeiscm。common。annotation。Excel;importcom。juepeiscm。common。core。domain。BaseEntity;importjava。util。Date;Author:py。sunDate:20229715:04publicclassSysOperCspLogextendsBaseEntity{privatestaticfinallongserialVersionUID1L;Excel(name操作序号,cellTypeExcel。ColumnType。NUMERIC)privateLongoperId;Excel(name操作模块)privateStringtitle;Excel(name业务类型,readConverterExp0其它,1新增,2修改,3删除,4授权,5导出,6导入,7强退,8生成代码,9清空数据)privateIntegerbusinessType;privateInteger〔〕businessTypes;Excel(name请求方法)privateStringmethod;Excel(name请求方式)privateStringrequestMethod;Excel(name操作类别,readConverterExp0其它,1后台用户,2手机端用户)privateIntegeroperatorType;Excel(name操作人员)privateStringoperName;Excel(name部门名称)privateStringdeptName;Excel(name请求地址)privateStringoperUrl;Excel(name操作地址)privateStringoperIp;Excel(name操作地点)privateStringoperLocation;Excel(name请求参数)privateStringoperParam;Excel(name返回参数)privateStringjsonResult;Excel(name状态,readConverterExp0正常,1异常)privateIntegerstatus;Excel(name错误消息)privateStringerrorMsg;JsonFormat(patternyyyyMMddHH:mm:ss)Excel(name操作时间,width30。0D,dateFormatyyyyMMddHH:mm:ss)privateDateoperTime;publicSysOperCspLog(){}publicLonggetOperId(){returnthis。operId;}publicvoidsetOperId(LongoperId){this。operIdoperId;}publicStringgetTitle(){returnthis。title;}publicvoidsetTitle(Stringtitle){this。titletitle;}publicIntegergetBusinessType(){returnthis。businessType;}publicvoidsetBusinessType(IntegerbusinessType){this。businessTypebusinessType;}publicInteger〔〕getBusinessTypes(){returnthis。businessTypes;}publicvoidsetBusinessTypes(Integer〔〕businessTypes){this。businessTypesbusinessTypes;}publicStringgetMethod(){returnthis。method;}publicvoidsetMethod(Stringmethod){this。methodmethod;}publicStringgetRequestMethod(){returnthis。requestMethod;}publicvoidsetRequestMethod(StringrequestMethod){this。requestMethodrequestMethod;}publicIntegergetOperatorType(){returnthis。operatorType;}publicvoidsetOperatorType(IntegeroperatorType){this。operatorTypeoperatorType;}publicStringgetOperName(){returnthis。operName;}publicvoidsetOperName(StringoperName){this。operNameoperName;}publicStringgetDeptName(){returnthis。deptName;}publicvoidsetDeptName(StringdeptName){this。deptNamedeptName;}publicStringgetOperUrl(){returnthis。operUrl;}publicvoidsetOperUrl(StringoperUrl){this。operUrloperUrl;}publicStringgetOperIp(){returnthis。operIp;}publicvoidsetOperIp(StringoperIp){this。operIpoperIp;}publicStringgetOperLocation(){returnthis。operLocation;}publicvoidsetOperLocation(StringoperLocation){this。operLocationoperLocation;}publicStringgetOperParam(){returnthis。operParam;}publicvoidsetOperParam(StringoperParam){this。operParamoperParam;}publicStringgetJsonResult(){returnthis。jsonResult;}publicvoidsetJsonResult(StringjsonResult){this。jsonResultjsonResult;}publicIntegergetStatus(){returnthis。status;}publicvoidsetStatus(Integerstatus){this。statusstatus;}publicStringgetErrorMsg(){returnthis。errorMsg;}publicvoidsetErrorMsg(StringerrorMsg){this。errorMsgerrorMsg;}publicDategetOperTime(){returnthis。operTime;}publicvoidsetOperTime(DateoperTime){this。operTimeoperTime;}}10。定义日志管理的切面
  大家一定要记住哈,所有针对实体的SysOperCspLog赋值操作必须在这里main执行。packagecom。juepeiscm。csp。controller。utils;importcom。alibaba。fastjson。JSON;importcom。juepeiscm。common。core。domain。entity。SysDept;importcom。juepeiscm。common。core。domain。model。LoginUser;importcom。juepeiscm。common。enums。BusinessStatus;importcom。juepeiscm。common。enums。HttpMethod;importcom。juepeiscm。common。utils。ServletUtils;importcom。juepeiscm。common。utils。StringUtils;importcom。juepeiscm。common。utils。ip。IpUtils;importcom。juepeiscm。common。utils。spring。SpringUtils;importcom。juepeiscm。csp。annotation。CspLog;importcom。juepeiscm。csp。domain。csplog。SysOperCspLog;importcom。juepeiscm。framework。aspectj。LogAspect;importcom。juepeiscm。framework。manager。AsyncManager;importcom。juepeiscm。framework。web。service。TokenService;importcom。juepeiscm。uam。service。ISysDeptService;importcom。juepeiscm。uam。version。UamVersion;importorg。apache。dubbo。config。annotation。Reference;importorg。aspectj。lang。JoinPoint;importorg。aspectj。lang。Signature;importorg。aspectj。lang。annotation。AfterReturning;importorg。aspectj。lang。annotation。AfterThrowing;importorg。aspectj。lang。annotation。Aspect;importorg。aspectj。lang。annotation。Pointcut;importorg。aspectj。lang。reflect。MethodSignature;importorg。slf4j。Logger;importorg。slf4j。LoggerFactory;importorg。springframework。stereotype。Component;importorg。springframework。validation。BindingResult;importorg。springframework。web。multipart。MultipartFile;importorg。springframework。web。servlet。HandlerMapping;importjavax。servlet。http。HttpServletRequest;importjavax。servlet。http。HttpServletResponse;importjava。lang。reflect。Method;importjava。util。Collection;importjava。util。Iterator;importjava。util。Map;Author:py。sunDate:20229716:31操作ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a记录处理AspectComponentpublicclassCspLogAspect{privatestaticfinalLoggerlogLoggerFactory。getLogger(CspLog。class);Reference(versionUamVersion。idV)publicISysDeptServicedeptService;publicCspLogAspect(){}把CspLog配置为切入点。配置织入点Pointcut(annotation(com。juepeiscm。csp。annotation。CspLog))publicvoidlogPointCut(){}拦截异常操作处理完请求后执行该方法。也就是用CspLog注解的方法,执行完后,调用handleLog方法,处理返回结果。AfterReturning(pointcutlogPointCut(),returningjsonResult)publicvoiddoAfterReturning(JoinPointjoinPoint,ObjectjsonResult){this。handleLog(joinPoint,(Exception)null,jsonResult);}AfterThrowing(valuelogPointCut(),throwinge)publicvoiddoAfterThrowing(JoinPointjoinPoint,Exceptione){this。handleLog(joinPoint,e,(Object)null);}如果函数抛出了异常,也是执行handleLog方法,不过和正常返回的参数不一样,此处是为了处理异常。protectedvoidhandleLog(JoinPointjoinPoint,Exceptione,ObjectjsonResult){try{获得注解CspLogcontrollerLogthis。getAnnotationLog(joinPoint);if(controllerLognull){return;}获取当前的用户LoginUserloginUser((TokenService)SpringUtils。getBean(TokenService。class))。getLoginUser(ServletUtils。getRequest());数据库ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志aSysOperCspLogoperLognewSysOperCspLog();operLog。setStatus(BusinessStatus。SUCCESS。ordinal());请求的地址StringipIpUtils。getIpAddr(ServletUtils。getRequest());operLog。setOperIp(ip);返回参数operLog。setJsonResult(JSON。toJSONString(jsonResult));operLog。setOperUrl(ServletUtils。getRequest()。getRequestURI());if(loginUser!null){operLog。setOperName(loginUser。getUsername());}获取当前登录用户的部门名称SysDeptsysDeptdeptService。selectDeptIdByUserIdAndAppId(loginUser。getUser()。getUserId(),oms);if(sysDept!nullStringUtils。isNotEmpty(sysDept。getDeptName())){operLog。setDeptName(sysDept。getDeptName());}if(e!null){operLog。setStatus(BusinessStatus。FAIL。ordinal());operLog。setErrorMsg(StringUtils。substring(e。getMessage(),0,2000));}设置方法名称StringclassNamejoinPoint。getTarget()。getClass()。getName();StringmethodNamejoinPoint。getSignature()。getName();operLog。setMethod(className。methodName());设置请求方式operLog。setRequestMethod(ServletUtils。getRequest()。getMethod());处理设置注解上的参数this。getControllerMethodDescription(joinPoint,controllerLog,operLog);保存数据库AsyncManager。me()。execute(AsyncFactoryCsp。recordOper(operLog));}catch(Exceptionvar10){记录本地异常ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志alog。error(前置通知异常);log。error(异常信息:{},var10。getMessage());var10。printStackTrace();}}publicvoidgetControllerMethodDescription(JoinPointjoinPoint,CspLoglog,SysOperCspLogoperLog)throwsException{operLog。setBusinessType(log。businessType()。ordinal());operLog。setTitle(log。title());operLog。setOperatorType(log。operatorType()。ordinal());if(log。isSaveRequestData()){this。setRequestValue(joinPoint,operLog);}}privatevoidsetRequestValue(JoinPointjoinPoint,SysOperCspLogoperLog)throwsException{StringrequestMethodoperLog。getRequestMethod();if(!HttpMethod。PUT。name()。equals(requestMethod)!HttpMethod。POST。name()。equals(requestMethod)){Maplt;?,?paramsMap(Map)ServletUtils。getRequest()。getAttribute(HandlerMapping。URITEMPLATEVARIABLESATTRIBUTE);operLog。setOperParam(StringUtils。substring(paramsMap。toString(),0,2000));}else{Stringparamsthis。argsArrayToString(joinPoint。getArgs());operLog。setOperParam(StringUtils。substring(params,0,2000));}}privateCspLoggetAnnotationLog(JoinPointjoinPoint)throwsException{SignaturesignaturejoinPoint。getSignature();MethodSignaturemethodSignature(MethodSignature)signature;MethodmethodmethodSignature。getMethod();returnmethod!null?(CspLog)method。getAnnotation(CspLog。class):null;}privateStringargsArrayToString(Object〔〕paramsArray){Stringparams;if(paramsArray!nullparamsArray。length0){for(inti0;iparamsArray。length;i){if(StringUtils。isNotNull(paramsArray〔i〕)!this。isFilterObject(paramsArray〔i〕)){ObjectjsonObjJSON。toJSON(paramsArray〔i〕);paramsparamsjsonObj。toString();}}}returnparams。trim();}publicbooleanisFilterObject(Objecto){Classlt;?clazzo。getClass();if(clazz。isArray()){returnclazz。getComponentType()。isAssignableFrom(MultipartFile。class);}else{Iteratoriter;if(Collection。class。isAssignableFrom(clazz)){Collectioncollection(Collection)o;itercollection。iterator();if(iter。hasNext()){returniter。next()instanceofMultipartFile;}}elseif(Map。class。isAssignableFrom(clazz)){Mapmap(Map)o;itermap。entrySet()。iterator();if(iter。hasNext()){Map。Entryentry(Map。Entry)iter。next();returnentry。getValue()instanceofMultipartFile;}}returnoinstanceofMultipartFileoinstanceofHttpServletRequestoinstanceofHttpServletResponseoinstanceofBindingResult;}}}AsyncFactoryCsppackagecom。juepeiscm。csp。controller。utils;importcom。juepeiscm。common。utils。ip。AddressUtils;importcom。juepeiscm。common。utils。spring。SpringUtils;importcom。juepeiscm。csp。domain。csplog。SysOperCspLog;importcom。juepeiscm。csp。service。csplog。ISysOperCspLogService;importorg。slf4j。Logger;importorg。slf4j。LoggerFactory;importjava。util。TimerTask;Author:py。sunDate:20229716:47publicclassAsyncFactoryCsp{privatestaticfinalLoggersysuserloggerLoggerFactory。getLogger(sysuser);publicAsyncFactoryCsp(){}publicstaticTimerTaskrecordOper(finalSysOperCspLogoperLog){returnnewTimerTask(){publicvoidrun(){operLog。setOperLocation(AddressUtils。getRealAddressByIP(operLog。getOperIp()));((ISysOperCspLogService)SpringUtils。getBean(ISysOperCspLogService。class))。insertOperlog(operLog);}};}}12。写一个Controller的Demo来执行一条日志试试在这里插入代码片packagecom。juepeiscm。csp。controller。order;importcom。alibaba。fastjson。JSON;importcom。juepeiscm。admin。api。service。ISysDictDataService;importcom。juepeiscm。common。annotation。RepeatSubmit;importcom。juepeiscm。common。core。controller。BaseController;importcom。juepeiscm。common。core。domain。AjaxResult;importcom。juepeiscm。common。core。domain。entity。SysDictData;importcom。juepeiscm。common。core。page。TableDataInfo;importcom。juepeiscm。common。enums。BusinessType;importcom。juepeiscm。common。exception。BaseException;importcom。juepeiscm。common。utils。StringUtils;importcom。juepeiscm。common。utils。poi。ExcelUtil;importcom。juepeiscm。csp。annotation。CspLog;importcom。juepeiscm。csp。domain。order。CspGodownEntry;importcom。juepeiscm。csp。domain。order。CspGodownEntryDetails;importcom。juepeiscm。csp。service。common。MenuLogService;importcom。juepeiscm。csp。service。data。ICspGoodsdataService;importcom。juepeiscm。csp。service。order。ICspGodownEntryService;importcom。juepeiscm。csp。vo。GodownEntryExcel;importcom。juepeiscm。csp。vo。GoodsDataForGodownEntryDetails;importio。swagger。annotations。Api;importio。swagger。annotations。ApiOperation;importorg。slf4j。Logger;importorg。slf4j。LoggerFactory;importorg。springframework。beans。factory。annotation。Autowired;importorg。springframework。security。access。prepost。PreAuthorize;importorg。springframework。util。CollectionUtils;importorg。springframework。web。bind。annotation。;importorg。springframework。web。multipart。MultipartFile;importjavax。validation。Valid;importjava。math。BigDecimal;importjava。math。RoundingMode;importjava。util。;importjava。util。stream。Collectors;入库订单Controllerauthorjuepeiscmdate20210723Api(tags入库订单接口)RestControllerRequestMapping(ordergodownEntry)publicclassCspGodownEntryControllerextendsBaseController{privatestaticfinalLoggerloggerLoggerFactory。getLogger(CspGodownEntryController。class);AutowiredprivateICspGodownEntryServicecspGodownEntryService;AutowiredprivateICspGoodsdataServicegoodsDataService;AutowiredprivateMenuLogServicemenuLogService;AutowiredprivateISysDictDataServicesysDictDataService;新增入库订单DemoPreAuthorize(ss。hasPermi(order:godownEntry:add))ApiOperation(value新增入库订单)CspLog(title入库订单demo4,businessTypeBusinessType。INSERT)PostMapping(addOrder)RepeatSubmitpublicAjaxResultaddDemo(RequestBodyValidCspGodownEntrygodownEntry){try{returntoAjax(cspGodownEntryService。insertOmsGodownEntry(godownEntry));}catch(Exceptione){e。printStackTrace();returnAjaxResult。error(新增失败,请联系管理员);}}}测试下,看看数据库内容

NBA最新东西部排名太阳7连胜领跑全联盟,热火位居东部第一NBA今天继续激战,在焦点战勇士对阵独行侠的比赛中,勇士全队开花,最终大比分轻松战胜了独行侠,稳定住了自己西部第二的排名,截止到目前,NBA最新东西部排名如下西部排名(附加赛区以内0分1板0助!广东27岁悍将越打越差,杜锋忍无可忍,离队或成定局北京时间1月26日,CBA常规赛继续开打,广东宏远11076击败四川男篮,此役首节比赛就结束比赛悬念,整个后三节,基本上围绕主力球员热身,年轻球员锻炼为主,杜锋更是把徐杰放到轮休的科比除了打球其他的真不敢恭维,逼宫湖人管理层赶走暮年奥尼尔我真的不知道为什么科比在全世界拥有那么多的忠实粉丝,难道他们真的不去了解科比吗?如果你足够了解科比,你就知道,科比可能除了打球之外,在没有什么品质值得那么多的人去崇拜他,成为他的粉舞会意外为霍华德生下女儿,模特霍普最终能得到多少补偿?魔兽霍华德,这家伙曾经是单换詹姆斯的存在,他也有机会冲击NBA最好的内线,可惜的是因为天生的态度以及私生活的混乱,霍华德没有达到预期的高度,甚至当詹姆斯还在拿着顶薪的时候,霍华德已一座塔,见证了明代最具争议的太监的最后七年紫竹院公园是一座以竹取胜的园林,是在明清时期紫竹院古刹和行宫的基础上扩建而成的,因此园内古迹众多。紫竹院公园紫竹院公园内郁郁葱葱的竹林从公园的南门进入,向右行不远,就有一座被保护起河北正定银装素裹靓古城我是大美河北推荐官河北文旅看图识景头条带你乐享河北临近年关,瑞雪翩然而至。图为银装素裹的正定古城。长城网冀云客户端记者孙文宾摄雪中的阳河楼更显气势恢宏。长城网冀云客户端记者孙文宾摄美了美了!龙泉驿的新年氛围感拉满临近虎年的春节夜幕降临华灯初上龙泉驿的夜景出片率极高还不快来打卡吗?为营造喜庆祥和的新春氛围,区公园城市局早早地就开始谋划春节氛围营造工作,在重要道路及节点悬挂特色灯笼,进行光彩维独家古道沉默打金复古单职业传奇服务端特别注意经验箱子,各种材料,散人玩家可以摆摊出售!好东西13转材料很好爆,4转以上爆率稍低,沙城捐献地图,神火荣耀地图,会员地图,潜龙地图,首富地图,清风谷,傲视九重天48转材料非春节最值得去的绝美古镇,原来就在你身边邂逅冬天的美好旅程龚滩古镇乌江边的璀璨明珠春节倒计时难道不想来一次说走就走的旅行吗?龚滩古镇绝对是你的理想目的地当你慢悠悠穿行在这座古镇中轻舟画舫的乌江梦里所瞥见的皆是温婉灵动的山黄河边上的古镇,名气小却敢和周庄比美!以前很辉煌,现在很神秘在国人心中,古镇总是江南的好。周庄乌镇西塘南浔一个个犹如大家闺秀般温润可人,撩得人心痒痒,总想着去一探究竟。而在甘肃,有这么一座古镇,虽不像江南那般极尽水乡之柔美,却也有着欲说还休没有麒麟芯片太可惜!爆料鼎桥Mate40将搭载天玑1000芯片1月25日消息,一款搭载华为麒麟9855G芯片的鼎桥N8Pro手机引起了业内非常大的关注,该机最特别之处就是搭载了如今华为自家都罕见的麒麟5G芯片,拥有完整的5G规格,可使用5G网
42分16板4断,美媒晒老詹德鲁联赛数据,詹欧联手会怎样?今天凌晨结束的一场德鲁联赛,詹姆斯和德罗赞带领球队104102惊险击败对手。这是詹姆斯自2011年来首次参加德鲁联赛,全场他得到42分16个篮板4次抢断,当选全场最佳球员,德罗赞得03!朱婷恩师惨败,无缘决赛!意大利女排开心庆祝,真核26分7月17日凌晨,女排总决赛第2场半决赛进行,土耳其女排跟意大利女排交手。值得一提的是,意大利队在上一场强势淘汰了中国女排,球队全靠埃格努频频下球。此番过招土耳其,她的表现直接关乎比做酸菜鱼,鱼肉不能直接下锅,多做1步,鱼片滑嫩入味,不碎不腥做酸菜鱼,鱼肉不可直接下锅,多做1步,鱼片滑嫩入味,不碎不腥可能和别的家庭不一样,我们家一家三口轮流做饭,说起来这样更有意思,不会感觉特别累,反而乐在其中。每次到我做饭的时候,我都入伏多吃姜,不用神医开处方多囤一些腌起来,酸甜脆爽很好吃入伏多吃姜,不用神医开处方。多囤一些腌起来,酸甜脆爽很好吃民间有不少俗语,比如冬吃萝卜夏吃姜,不用劳烦医生开药方。而夏天里最值得关注的就是三伏天,所以入伏以后,一定要多吃姜。姜是热全国哪的腐乳最好吃?经过评比,这5个地方不错,有你家乡吗腐乳,从古至今,都是人们极为珍爱的特色美味。虽然腐乳说不上有多珍贵,但其似乎是万能的,无论是拿来炒菜,调制蘸料等,亦或者只是简单的用来搭配白粥,都能尽显其自身独特的魅力。要想充分感女雷神娜塔莉波特曼杂志封面大片,新片苦练10月增肌塑形雷神4爱与雷霆北美热映,女主角娜塔莉波特曼登上TheSundayTimesStyle杂志7月新刊封面。为扮演片中女雷神,素食主义的娜塔莉制定严格计划,卖力训练增肌塑形10个月,练出Herewego!迪马ampampamp罗马诺莱万加盟巴萨达成协议,总价5000万欧直播吧7月16日讯名记迪马济奥报道,莱万加盟巴萨达成协议!迪马表示,莱万不会出席当地时间周六拜仁在安联的亮相仪式。名记罗马诺也用标志性的herewego跟进确认,拜仁与巴萨就莱万转热身赛0奎维利直播吧7月15日讯北京时间7月15日晚11点,巴黎在训练基地与法乙球队奎维利鲁昂进行一场友谊赛。上半场梅西造点拉莫斯点射,下半场加萨马替补建功,最终,巴黎20奎维利。本场是巴黎新主一夜10大交易签约动态!篮网首选留杜兰特,湖人无意塔克换贝弗利北京时间7月16日,拉斯维加斯夏季联赛接近尾声,NBA高管们将进入休假模式。过去这一夜,又有哪些交易签约动态传来?篮网没有收到任何满意的报价,首选留下杜兰特。湖人无意用霍顿塔克去交44落后成功翻盘北京时间2022年7月16日,斯诺克欧洲大师赛结束资格赛首日争夺,世界冠军马克威廉姆斯在2比4落后的情况下连赢3局,以5比4淘汰海菲尔德。另一场比赛爆出大冷门,冠军名将斯蒂芬马奎尔奥运会银牌得主希望担任约书亚陪练,只有我能帮他备战乌西克东京奥运会超重量级银牌得主理查德托雷斯表示,他希望担任前拳王安东尼约书亚的陪练。托雷斯坚持认为,只有自己才能够帮助约书亚备战与奥雷科桑德乌西克的第二次交锋。约书亚团队坦言,要想寻找
友情链接:快好找快生活快百科快传网中准网文好找聚热点快软网