安庆大理运城常德铜陵江西
投稿投诉
江西南阳
嘉兴昆明
铜陵滨州
广东西昌
常德梅州
兰州阳江
运城金华
广西萍乡
大理重庆
诸暨泉州
安庆南充
武汉辽宁

SpringBoot利用AOP写一个日志管理

1月5日 吴梦筱投稿
  1。需求
  目前有这么个问题,有两个系统CSP和OMS,这俩系统共用的是同一套日志操作:L目前想区分下这俩系统的日志操作,那没办法了,只能重写一份Log的日志操作;
  你也可以参照若依框架的日志系统实现。2。新建一张日志表
  sysopercsplogNavicatPremiumDataTransferSourceServer:jpcscadminSourceServerType:MySQLSourceServerVersion:50728SourceHost:rmuf6miy84gu8u433x9。mysql。rds。aliyuncs。com:3306SourceSchema:jpomsTargetServerType:MySQLTargetServerVersion:50728FileEncoding:65001Date:0809202209:21:45SETNAMESutf8mb4;SETFOREIGNKEYCHECKS0;TablestructureforsysopercsplogDROPTABLEIFEXISTSCREATETABLEsysopercsplog(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。importcom。juepeiscm。admin。api。domain。SysOperLimportcom。juepeiscm。common。core。controller。BaseCimportcom。juepeiscm。common。core。domain。AjaxRimportcom。juepeiscm。common。core。page。TableDataIimportcom。juepeiscm。common。enums。BusinessTimportcom。juepeiscm。common。utils。poi。ExcelUimportcom。juepeiscm。csp。annotation。CspLimportcom。juepeiscm。csp。domain。csplog。SysOperCspLimportcom。juepeiscm。csp。service。csplog。ISysOperCspLogSimportorg。springframework。beans。factory。annotation。Aimportorg。springframework。security。access。prepost。PreAimportorg。springframework。web。bind。annotation。;importjava。util。L操作CSP系统ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志aAuthor:py。sunDate:20229714:51RestControllerRequestMapping({csplogopercsplog})publicclassSysOperCsplogControllerextendsBaseController{AutowiredprivateISysOperCspLogServiceoperCspLogSpublicSysOperCsplogController(){}查询操作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。importcom。juepeiscm。admin。api。domain。SysOperLimportcom。juepeiscm。csp。domain。csplog。SysOperCspLimportjava。util。LAuthor:py。sunDate:20229715:02publicinterfaceISysOperCspLogService{voidinsertOperlog(SysOperCspLogvar1);ListSysOperCspLogselectOperLogList(SysOperCspLogvar1);ListStringselectOperLogListTitle();intdeleteOperLogByIds(Long〔〕var1);SysOperLogselectOperLogById(Longvar1);voidcleanOperLog();}Service实现packagecom。juepeiscm。csp。service。impl。importcom。juepeiscm。admin。api。domain。SysOperLimportcom。juepeiscm。common。core。domain。AjaxRimportcom。juepeiscm。common。core。domain。entity。SysDimportcom。juepeiscm。common。core。domain。entity。SysUimportcom。juepeiscm。common。core。domain。model。LoginUimportcom。juepeiscm。common。exception。CustomEimportcom。juepeiscm。common。utils。SecurityUimportcom。juepeiscm。common。utils。ServletUimportcom。juepeiscm。common。utils。StringUimportcom。juepeiscm。csp。domain。csplog。SysOperCspLimportcom。juepeiscm。csp。mapper。csplog。SysOperCspLogMimportcom。juepeiscm。csp。service。csplog。ISysOperCspLogSimportcom。juepeiscm。framework。web。service。TokenSimportcom。juepeiscm。uam。service。ISysDeptSimportcom。juepeiscm。uam。version。UamVimportorg。apache。dubbo。config。annotation。Rimportorg。springframework。beans。factory。annotation。Aimportorg。springframework。stereotype。Simportjava。util。LAuthor:py。sunDate:20229715:03ServicepublicclassSysOperCspLogServiceImplimplementsISysOperCspLogService{AutowiredprivateSysOperCspLogMapperoperLogMAutowiredprivateTokenServicetokenSReference(versionUamVersion。idV)publicISysDeptServicedeptSOverridepublicvoidinsertOperlog(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。importcom。juepeiscm。admin。api。domain。SysOperLimportcom。juepeiscm。csp。domain。csplog。SysOperCspLimportjava。util。LAuthor:py。sunDate:20229715:06publicinterfaceSysOperCspLogMapper{voidinsertOperlog(SysOperCspLogvar1);ListSysOperCspLogselectOperLogList(SysOperCspLogsysOperCspLog);ListStringselectOperLogListTitle();intdeleteOperLogByIds(Long〔〕var1);SysOperLogselectOperLogById(Longvar1);voidcleanOperLog();}Mapper。xml(我用的是Mybatis)?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。importcom。juepeiscm。common。enums。BusinessTimportcom。juepeiscm。common。enums。OperatorTimportjava。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()功能returnBusinessTypebusinessType()defaultBusinessType。OTHER;操作人类别returnOperatorTypeoperatorType()defaultOperatorType。MANAGE;是否保存请求的参数returnbooleanisSaveRequestData()}实体类SysOperCspLogpackagecom。juepeiscm。csp。domain。importcom。fasterxml。jackson。annotation。JsonFimportcom。juepeiscm。common。annotation。Eimportcom。juepeiscm。common。core。domain。BaseEimportjava。util。DAuthor:py。sunDate:20229715:04publicclassSysOperCspLogextendsBaseEntity{privatestaticfinallongserialVersionUID1L;Excel(name操作序号,cellTypeExcel。ColumnType。NUMERIC)privateLongoperId;Excel(name操作模块)privateSExcel(name业务类型,readConverterExp0其它,1新增,2修改,3删除,4授权,5导出,6导入,7强退,8生成代码,9清空数据)privateIntegerbusinessTprivateInteger〔〕businessTExcel(name请求方法)privateSExcel(name请求方式)privateStringrequestMExcel(name操作类别,readConverterExp0其它,1后台用户,2手机端用户)privateIntegeroperatorTExcel(name操作人员)privateStringoperNExcel(name部门名称)privateStringdeptNExcel(name请求地址)privateStringoperUExcel(name操作地址)privateStringoperIp;Excel(name操作地点)privateStringoperLExcel(name请求参数)privateStringoperPExcel(name返回参数)privateStringjsonRExcel(name状态,readConverterExp0正常,1异常)privateIExcel(name错误消息)privateStringerrorMJsonFormat(patternyyyyMMddHH:mm:ss)Excel(name操作时间,width30。0D,dateFormatyyyyMMddHH:mm:ss)privateDateoperTpublicSysOperCspLog(){}publicLonggetOperId(){returnthis。operId;}publicvoidsetOperId(LongoperId){this。operIdoperId;}publicStringgetTitle(){returnthis。}publicvoidsetTitle(Stringtitle){this。}publicIntegergetBusinessType(){returnthis。businessT}publicvoidsetBusinessType(IntegerbusinessType){this。businessTypebusinessT}publicInteger〔〕getBusinessTypes(){returnthis。businessT}publicvoidsetBusinessTypes(Integer〔〕businessTypes){this。businessTypesbusinessT}publicStringgetMethod(){returnthis。}publicvoidsetMethod(Stringmethod){this。}publicStringgetRequestMethod(){returnthis。requestM}publicvoidsetRequestMethod(StringrequestMethod){this。requestMethodrequestM}publicIntegergetOperatorType(){returnthis。operatorT}publicvoidsetOperatorType(IntegeroperatorType){this。operatorTypeoperatorT}publicStringgetOperName(){returnthis。operN}publicvoidsetOperName(StringoperName){this。operNameoperN}publicStringgetDeptName(){returnthis。deptN}publicvoidsetDeptName(StringdeptName){this。deptNamedeptN}publicStringgetOperUrl(){returnthis。operU}publicvoidsetOperUrl(StringoperUrl){this。operUrloperU}publicStringgetOperIp(){returnthis。operIp;}publicvoidsetOperIp(StringoperIp){this。operIpoperIp;}publicStringgetOperLocation(){returnthis。operL}publicvoidsetOperLocation(StringoperLocation){this。operLocationoperL}publicStringgetOperParam(){returnthis。operP}publicvoidsetOperParam(StringoperParam){this。operParamoperP}publicStringgetJsonResult(){returnthis。jsonR}publicvoidsetJsonResult(StringjsonResult){this。jsonResultjsonR}publicIntegergetStatus(){returnthis。}publicvoidsetStatus(Integerstatus){this。}publicStringgetErrorMsg(){returnthis。errorM}publicvoidsetErrorMsg(StringerrorMsg){this。errorMsgerrorM}publicDategetOperTime(){returnthis。operT}publicvoidsetOperTime(DateoperTime){this。operTimeoperT}}10。定义日志管理的切面
  大家一定要记住哈,所有针对实体的SysOperCspLog赋值操作必须在这里main执行。packagecom。juepeiscm。csp。controller。importcom。alibaba。fastjson。JSON;importcom。juepeiscm。common。core。domain。entity。SysDimportcom。juepeiscm。common。core。domain。model。LoginUimportcom。juepeiscm。common。enums。BusinessSimportcom。juepeiscm。common。enums。HttpMimportcom。juepeiscm。common。utils。ServletUimportcom。juepeiscm。common。utils。StringUimportcom。juepeiscm。common。utils。ip。IpUimportcom。juepeiscm。common。utils。spring。SpringUimportcom。juepeiscm。csp。annotation。CspLimportcom。juepeiscm。csp。domain。csplog。SysOperCspLimportcom。juepeiscm。framework。aspectj。LogAimportcom。juepeiscm。framework。manager。AsyncMimportcom。juepeiscm。framework。web。service。TokenSimportcom。juepeiscm。uam。service。ISysDeptSimportcom。juepeiscm。uam。version。UamVimportorg。apache。dubbo。config。annotation。Rimportorg。aspectj。lang。JoinPimportorg。aspectj。lang。Simportorg。aspectj。lang。annotation。AfterRimportorg。aspectj。lang。annotation。AfterTimportorg。aspectj。lang。annotation。Aimportorg。aspectj。lang。annotation。Pimportorg。aspectj。lang。reflect。MethodSimportorg。slf4j。Limportorg。slf4j。LoggerFimportorg。springframework。stereotype。Cimportorg。springframework。validation。BindingRimportorg。springframework。web。multipart。MultipartFimportorg。springframework。web。servlet。HandlerMimportjavax。servlet。http。HttpServletRimportjavax。servlet。http。HttpServletRimportjava。lang。reflect。Mimportjava。util。Cimportjava。util。Iimportjava。util。MAuthor:py。sunDate:20229716:31操作ahrefhttps:www。bs178。comrizhitargetblankclassinfotextkey日志a记录处理AspectComponentpublicclassCspLogAspect{privatestaticfinalLoggerlogLoggerFactory。getLogger(CspLog。class);Reference(versionUamVersion。idV)publicISysDeptServicedeptSpublicCspLogAspect(){}把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){}获取当前的用户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)){M?,?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)MethodmethodmethodSignature。getMethod();returnmethod!null?(CspLog)method。getAnnotation(CspLog。class):}privateStringargsArrayToString(Object〔〕paramsArray){Sif(paramsArray!nullparamsArray。length0){for(inti0;iparamsArray。i){if(StringUtils。isNotNull(paramsArray〔i〕)!this。isFilterObject(paramsArray〔i〕)){ObjectjsonObjJSON。toJSON(paramsArray〔i〕);paramsparamsjsonObj。toString();}}}returnparams。trim();}publicbooleanisFilterObject(Objecto){C?clazzo。getClass();if(clazz。isArray()){returnclazz。getComponentType()。isAssignableFrom(MultipartFile。class);}else{Iif(Collection。class。isAssignableFrom(clazz)){Collectioncollection(Collection)o;itercollection。iterator();if(iter。hasNext()){returniter。next()instanceofMultipartF}}elseif(Map。class。isAssignableFrom(clazz)){Mapmap(Map)o;itermap。entrySet()。iterator();if(iter。hasNext()){Map。Entryentry(Map。Entry)iter。next();returnentry。getValue()instanceofMultipartF}}returnoinstanceofMultipartFileoinstanceofHttpServletRequestoinstanceofHttpServletResponseoinstanceofBindingR}}}AsyncFactoryCsppackagecom。juepeiscm。csp。controller。importcom。juepeiscm。common。utils。ip。AddressUimportcom。juepeiscm。common。utils。spring。SpringUimportcom。juepeiscm。csp。domain。csplog。SysOperCspLimportcom。juepeiscm。csp。service。csplog。ISysOperCspLogSimportorg。slf4j。Limportorg。slf4j。LoggerFimportjava。util。TimerTAuthor: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。importcom。alibaba。fastjson。JSON;importcom。juepeiscm。admin。api。service。ISysDictDataSimportcom。juepeiscm。common。annotation。RepeatSimportcom。juepeiscm。common。core。controller。BaseCimportcom。juepeiscm。common。core。domain。AjaxRimportcom。juepeiscm。common。core。domain。entity。SysDictDimportcom。juepeiscm。common。core。page。TableDataIimportcom。juepeiscm。common。enums。BusinessTimportcom。juepeiscm。common。exception。BaseEimportcom。juepeiscm。common。utils。StringUimportcom。juepeiscm。common。utils。poi。ExcelUimportcom。juepeiscm。csp。annotation。CspLimportcom。juepeiscm。csp。domain。order。CspGodownEimportcom。juepeiscm。csp。domain。order。CspGodownEntryDimportcom。juepeiscm。csp。service。common。MenuLogSimportcom。juepeiscm。csp。service。data。ICspGoodsdataSimportcom。juepeiscm。csp。service。order。ICspGodownEntrySimportcom。juepeiscm。csp。vo。GodownEntryEimportcom。juepeiscm。csp。vo。GoodsDataForGodownEntryDimportio。swagger。annotations。Aimportio。swagger。annotations。ApiOimportorg。slf4j。Limportorg。slf4j。LoggerFimportorg。springframework。beans。factory。annotation。Aimportorg。springframework。security。access。prepost。PreAimportorg。springframework。util。CollectionUimportorg。springframework。web。bind。annotation。;importorg。springframework。web。multipart。MultipartFimportjavax。validation。Vimportjava。math。BigDimportjava。math。RoundingMimportjava。util。;importjava。util。stream。C入库订单Controllerauthorjuepeiscmdate20210723Api(tags入库订单接口)RestControllerRequestMapping(ordergodownEntry)publicclassCspGodownEntryControllerextendsBaseController{privatestaticfinalLoggerloggerLoggerFactory。getLogger(CspGodownEntryController。class);AutowiredprivateICspGodownEntryServicecspGodownEntrySAutowiredprivateICspGoodsdataServicegoodsDataSAutowiredprivateMenuLogServicemenuLogSAutowiredprivateISysDictDataServicesysDictDataS新增入库订单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(新增失败,请联系管理员);}}}测试下,看看数据库内容
投诉 评论 转载

中国北斗应用大会在郑开幕北航国家大学科技园等20余项目签约9月21日,以智能时空创新引领为主题的中国北斗应用大会暨中国卫星导航与位置服务第十一届年会在河南郑州国际会展中心开幕。来自全国卫星导航与位置服务领域的院士、专家及企事业单……10月起,江苏养老金迎来新调整!另外多项待遇也有变化,你要知10月份起,江苏养老金将迎来新调整!另外多项待遇也有变化,你需要知道从10月份开始,江苏的养老金将迎来新调整,部分人的养老金会重算补发,此外,还有多项待遇也有变化,其中工……都是贵为品牌旗舰机,凭什么它们是零差评?对大多数人来说,买一部手机基本上要求能用上几年时间。因此,在选择手机时要慎重,特别是要避开某些手机。如果你打算在2022年更换手机,以下三款手机最有价值,几乎都是好评如潮,使用……上市1年降价1500元12G内存和120W快充骁龙888旗舰最近几年,国产安卓旗舰手机的价格有点虚高,骁龙888手机基本4000块钱起步,而骁龙8Gen1旗舰手机大多5000块钱起步了。对此,很多网友表示,国产安卓旗舰定价让人惊讶。……8年了,天赋只兑现10,得分才涨0。4分,谁能救救这个状元郎气炸了,威金斯,你还敢再差点吗?赛季之初有多期待,如今就有多失望,作为14届的状元,威金斯自带巨星光环,出色的身体天赋,外加无公害的笑容,让他无论在哪,都能成为焦点,特别……中医专家告诉你很平凡很便宜的龟龄集历史悠久,能防治多种疾病有好多中成药,很平凡,很便宜,时常待在药店很不起眼的角落,但功效却很神奇。今天的主角就是我国中药复方的瑰宝龟龄集。龟龄集是我国国产成药之中的一大珍品,被列为我国四大保密处……常见的颈肩腰腿痛,其实这些都是筋骨病筋骨病是以人体自然退变为主因的全身和局部的综合征。其实就是最常见的颈肩腰腿痛。中医的看法,肝主筋,肾主骨。筋骨病的劳损累及气血,老化伴随而来的肝肾不足,伤损传……中国女排五朵金花久违同框,满屏长腿,魏秋月逆生长,颜妮笑开花目前,2022年国家女排联赛已经全部结束。在最新的女排世界排名上,美国女排虽然卫冕失败,但仍然以392分居首。巴西女排在决赛中输给了意大利女排,以372分排名次席。排名第三的则……SpringBoot利用AOP写一个日志管理1。需求目前有这么个问题,有两个系统CSP和OMS,这俩系统共用的是同一套日志操作:L目前想区分下这俩系统的日志操作,那没办法了,只能重写一份Log的日志操作;……2022卡塔尔世界杯巴西国家队重返荣耀类型:世界杯资讯内容:巴西国家队地点:卡塔尔巴西主帅蒂特在2018年世界杯之前拒绝了巴黎圣日耳曼和皇家马德里,因为他的目标是结束巴西队在卡塔尔等待荣耀的20年……盘点50岁公认好用的抗老护肤品,虽然小贵但效果看得见,值得入女人爬上50岁后,明显感到缺失少女感了,再加上现在流行容貌焦虑、年龄焦虑,恨不得自己有不老术,加班熬夜,脸上细纹、粗糙、暗沉无光,纷纷出现。那今天就盘点50岁公认好用的抗老护肤……中国游客去巴基斯坦旅游,刚下车,就被女人带回家,就是因为巴铁巴基斯坦也是一个多民族国家,这里信奉伊斯兰教,并且处于热带地区,常年的温度都特别高。(此处已添加小程序,请到今日头条客户端查看)由于巴基斯坦的煤炭资源比较丰富,近些年来,……
岣嵝峰,岣嵝人河南藏着草原的县城,境内有中华第一古军校,山水绝美,历史厚重周笔畅整容顺利,坦诚自曝本来照着杨幂整,没想到整完像杨紫澳洲高科技,要弯道超车加速了欧莱雅染发剂原料供应商鼎龙科技IPO,营利增长停滞,过半收入硬汉007宠妻狂魔,妻子体重260斤依旧宠爱,28年只爱她一2023央视顶级跨年文案中纪委评华为mate50逆境下的砥砺前行网红防晒霜致多名儿童皮肤灼伤,成分表有这几个字的,都不安全罩杯可选吸奶器推荐!鹿小小C罩杯吸奶器D80,吸奶器罩杯大小秋染泉城在济南邂逅诗意秋天伊藤找到新工作,工资6070万,她该感谢刘国梁牵线

友情链接:中准网聚热点快百科快传网快生活快软网快好知文好找七猫云易事利