From 05beecd08f2d18ac540dae973d6a53da69047c36 Mon Sep 17 00:00:00 2001 From: Huang <516821420@qq.com> Date: Mon, 12 Nov 2018 11:04:28 +0800 Subject: [PATCH] no commit message --- JeeSpringCloud/jeespring-framework/pom.xml | 69 ++ .../common/annotation/FieldName.java | 17 + .../common/beanvalidator/AddGroup.java | 13 + .../common/beanvalidator/DefaultGroup.java | 12 + .../common/beanvalidator/EditGroup.java | 12 + .../com/jeespring/common/config/Global.java | 270 +++++ .../common/config/ScheduleConfig.java | 58 + .../jeespring/common/config/ShiroConfig.java | 304 +++++ .../jeespring/common/constant/Constants.java | 65 + .../common/constant/ScheduleConstants.java | 51 + .../common/constant/ShiroConstants.java | 65 + .../common/druid/DruidConfiguration.java | 93 ++ .../common/druid/DruidStatFilter.java | 21 + .../common/druid/DruidStatViewServlet.java | 26 + .../common/exception/job/TaskException.java | 35 + .../filter/JeesiteFileUploadFilter.java | 18 + .../jeespring/common/filter/LogoutFilter.java | 111 ++ .../common/filter/OnlineSessionFilter.java | 121 ++ .../common/filter/PageCachingFilter.java | 26 + .../filter/SyncOnlineSessionFilter.java | 80 ++ .../com/jeespring/common/json/AjaxJson.java | 73 ++ .../com/jeespring/common/json/PrintJSON.java | 28 + .../common/mail/MailAuthenticator.java | 21 + .../com/jeespring/common/mail/MailBody.java | 96 ++ .../jeespring/common/mail/MailSendUtils.java | 154 +++ .../jeespring/common/mapper/BeanMapper.java | 57 + .../jeespring/common/mapper/JaxbMapper.java | 169 +++ .../jeespring/common/mapper/JsonMapper.java | 257 ++++ .../common/mapper/adapters/MapAdapter.java | 30 + .../common/mapper/adapters/MapConvertor.java | 63 + .../persistence/AbstractBaseEntity.java | 184 +++ .../common/persistence/AbstractEntity.java | 237 ++++ .../common/persistence/ActEntity.java | 57 + .../common/persistence/InterfaceBaseDao.java | 129 ++ .../persistence/InterfaceBaseService.java | 91 ++ .../common/persistence/InterfaceDao.java | 13 + .../jeespring/common/persistence/Page.java | 711 +++++++++++ .../jeespring/common/persistence/TreeDao.java | 30 + .../common/persistence/TreeEntity.java | 85 ++ .../persistence/annotation/MyBatisDao.java | 32 + .../persistence/dialect/DB2Dialect.java | 89 ++ .../persistence/dialect/DerbyDialect.java | 44 + .../common/persistence/dialect/Dialect.java | 33 + .../common/persistence/dialect/H2Dialect.java | 46 + .../persistence/dialect/HSQLDialect.java | 50 + .../persistence/dialect/MySQLDialect.java | 54 + .../persistence/dialect/OracleDialect.java | 66 ++ .../dialect/PostgreSQLDialect.java | 49 + .../dialect/SQLServer2005Dialect.java | 95 ++ .../persistence/dialect/SQLServerDialect.java | 57 + .../persistence/dialect/SybaseDialect.java | 48 + .../interceptor/BaseInterceptor.java | 96 ++ .../interceptor/PaginationInterceptor.java | 129 ++ .../PreparePaginationInterceptor.java | 89 ++ .../persistence/interceptor/SQLHelper.java | 198 ++++ .../persistence/proxy/PageConfiguration.java | 37 + .../proxy/PaginationMapperMethod.java | 191 +++ .../proxy/PaginationMapperProxy.java | 104 ++ .../proxy/PaginationMapperRegistry.java | 36 + .../jeespring/common/redis/JedisUtils.java | 847 +++++++++++++ .../jeespring/common/redis/RedisConfig.java | 41 + .../common/redis/RedisRestController.java | 231 ++++ .../jeespring/common/redis/RedisUtils.java | 416 +++++++ .../jeespring/common/security/Cryptos.java | 260 ++++ .../jeespring/common/security/Digests.java | 150 +++ .../jeespring/common/security/MD5Tools.java | 50 + .../jeespring/common/security/ShiroUtils.java | 85 ++ .../security/shiro/HasAnyPermissionsTag.java | 40 + .../shiro/cache/SessionCacheManager.java | 144 +++ .../shiro/session/CacheSessionDAO.java | 194 +++ .../security/shiro/session/SessionDAO.java | 25 + .../shiro/session/SessionManager.java | 222 ++++ .../common/service/AbstractBaseService.java | 130 ++ .../common/service/AbstractService.java | 187 +++ .../common/service/ICommonService.java | 75 ++ .../common/service/InterfaceService.java | 6 + .../common/service/ServiceException.java | 22 + .../jeespring/common/service/TreeService.java | 84 ++ .../servlet/CKFinderConnectorServlet.java | 77 ++ .../servlet/UserfilesDownloadServlet.java | 64 + .../common/servlet/ValidateCodeServlet.java | 179 +++ .../com/jeespring/common/sms/SMSUtils.java | 115 ++ .../jeespring/common/spring/SpringUtils.java | 102 ++ .../com/jeespring/common/swagger/Swagger.java | 62 + .../com/jeespring/common/tag/AceMenuTag.java | 132 +++ .../com/jeespring/common/tag/MenuTag.java | 145 +++ .../common/tag/echarts/EChartsBarTag.java | 180 +++ .../tag/echarts/EChartsLineDoubleNumTag.java | 181 +++ .../common/tag/echarts/EChartsLineTag.java | 181 +++ .../tag/echarts/EChartsLineTimeLineTag.java | 282 +++++ .../common/tag/echarts/EChartsPieTag.java | 121 ++ .../common/tag/echarts/EChartsRadarTag.java | 169 +++ .../jeespring/common/utils/AddressUtils.java | 42 + .../common/utils/Base64ImageUtils.java | 99 ++ .../jeespring/common/utils/CacheUtils.java | 123 ++ .../jeespring/common/utils/CharsetKit.java | 87 ++ .../jeespring/common/utils/Collections3.java | 176 +++ .../com/jeespring/common/utils/Convert.java | 1001 ++++++++++++++++ .../jeespring/common/utils/CookieUtils.java | 115 ++ .../com/jeespring/common/utils/DateUtils.java | 183 +++ .../com/jeespring/common/utils/Encodes.java | 151 +++ .../jeespring/common/utils/Exceptions.java | 79 ++ .../common/utils/FileSizeHelper.java | 68 ++ .../com/jeespring/common/utils/FileUtil.java | 72 ++ .../com/jeespring/common/utils/FileUtils.java | 969 +++++++++++++++ .../jeespring/common/utils/FreeMarkers.java | 71 ++ .../com/jeespring/common/utils/GsonUtils.java | 28 + .../jeespring/common/utils/HttpRequest.java | 145 +++ .../com/jeespring/common/utils/HttpUtil.java | 77 ++ .../com/jeespring/common/utils/IdGen.java | 65 + .../jeespring/common/utils/IdcardUtils.java | 638 ++++++++++ .../com/jeespring/common/utils/ImageGeo.java | 66 ++ .../com/jeespring/common/utils/IpUtils.java | 43 + .../com/jeespring/common/utils/MacUtils.java | 224 ++++ .../jeespring/common/utils/MyBeanUtils.java | 311 +++++ .../common/utils/ObjectFieldUtils.java | 58 + .../jeespring/common/utils/ObjectUtils.java | 187 +++ .../common/utils/OrderProperties.java | 458 +++++++ .../common/utils/PropertiesLoader.java | 190 +++ .../jeespring/common/utils/Reflections.java | 304 +++++ .../jeespring/common/utils/SendMailUtil.java | 330 ++++++ .../jeespring/common/utils/ServletUtils.java | 137 +++ .../common/utils/SpringContextHolder.java | 107 ++ .../jeespring/common/utils/StrFormatter.java | 93 ++ .../jeespring/common/utils/StreamUtils.java | 282 +++++ .../jeespring/common/utils/StringUtils.java | 632 ++++++++++ .../jeespring/common/utils/SystemPath.java | 47 + .../com/jeespring/common/utils/Threads.java | 81 ++ .../com/jeespring/common/utils/TimeUtils.java | 330 ++++++ .../jeespring/common/utils/UploadUtils.java | 344 ++++++ .../common/utils/UserAgentUtils.java | 94 ++ .../jeespring/common/utils/WorkDayUtils.java | 132 +++ .../jeespring/common/utils/ZxingHandler.java | 170 +++ .../common/utils/bean/BeanUtils.java | 122 ++ .../common/utils/excel/ExportExcel.java | 489 ++++++++ .../common/utils/excel/ImportExcel.java | 371 ++++++ .../utils/excel/annotation/ExcelField.java | 59 + .../utils/excel/fieldtype/AreaType.java | 38 + .../utils/excel/fieldtype/OfficeType.java | 38 + .../utils/excel/fieldtype/RoleListType.java | 52 + .../common/utils/http/HttpUtils.java | 242 ++++ .../common/validator/BeanValidators.java | 116 ++ .../common/web/AbstractBaseController.java | 296 +++++ .../jeespring/common/web/CKFinderConfig.java | 226 ++++ .../java/com/jeespring/common/web/Result.java | 56 + .../jeespring/common/web/ResultFactory.java | 48 + .../com/jeespring/common/web/Servlets.java | 248 ++++ .../common/websocket/WebSockertFilter.java | 84 ++ .../common/websocket/onchat/ChatServer.java | 203 ++++ .../websocket/onchat/ChatServerPool.java | 99 ++ .../common/websocket/utils/Constant.java | 9 + .../com/jeespring/modules/act/ActConfig.java | 10 + .../com/jeespring/modules/act/dao/ActDao.java | 21 + .../com/jeespring/modules/act/entity/Act.java | 384 ++++++ ...rocessDefinitionDiagramLayoutResource.java | 504 ++++++++ ...rocessDefinitionDiagramLayoutResource.java | 33 + .../ProcessInstanceDiagramLayoutResource.java | 33 + .../ProcessInstanceHighlightsResource.java | 260 ++++ .../editor/main/StencilsetRestResource.java | 39 + .../model/ModelEditorJsonRestResource.java | 74 ++ .../editor/model/ModelSaveRestResource.java | 98 ++ .../servlet/FilterServletOutputStream.java | 42 + .../rest/servlet/GenericResponseWrapper.java | 55 + .../act/rest/servlet/JsonpCallbackFilter.java | 71 ++ .../modules/act/service/ActModelService.java | 188 +++ .../act/service/ActProcessService.java | 309 +++++ .../modules/act/service/ActTaskService.java | 962 +++++++++++++++ .../cmd/CreateAndTakeTransitionCmd.java | 45 + .../modules/act/service/cmd/JumpTaskCmd.java | 56 + .../cmd/ModelDeployProcessDefinitionCmd.java | 95 ++ .../creator/ChainedActivitiesCreator.java | 50 + .../creator/MultiInstanceActivityCreator.java | 59 + .../creator/RuntimeActivityCreator.java | 11 + .../RuntimeActivityCreatorSupport.java | 89 ++ .../RuntimeActivityDefinitionEntity.java | 65 + ...imeActivityDefinitionEntityIntepreter.java | 81 ++ .../RuntimeActivityDefinitionManager.java | 22 + ...SimpleRuntimeActivityDefinitionEntity.java | 90 ++ .../service/ext/ActGroupEntityService.java | 111 ++ .../ext/ActGroupEntityServiceFactory.java | 33 + .../act/service/ext/ActUserEntityService.java | 160 +++ .../ext/ActUserEntityServiceFactory.java | 33 + .../jeespring/modules/act/utils/ActUtils.java | 194 +++ .../modules/act/utils/DateConverter.java | 105 ++ .../modules/act/utils/ProcessDefCache.java | 94 ++ .../modules/act/utils/ProcessDefUtils.java | 70 ++ .../modules/act/utils/PropertyType.java | 33 + .../jeespring/modules/act/utils/Variable.java | 87 ++ .../modules/act/web/ActModelController.java | 118 ++ .../modules/act/web/ActProcessController.java | 199 ++++ .../modules/act/web/ActTaskController.java | 276 +++++ .../com/jeespring/modules/aop/AOPService.java | 69 ++ .../rest/FaceRecognitionRestController.java | 227 ++++ .../echarts/dao/ChinaWeatherDataBeanDao.java | 19 + .../modules/echarts/dao/PieClassDao.java | 19 + .../echarts/entity/ChinaWeatherDataBean.java | 120 ++ .../modules/echarts/entity/PieClass.java | 49 + .../service/ChinaWeatherDataBeanService.java | 55 + .../echarts/service/PieClassService.java | 55 + .../modules/echarts/web/BarController.java | 81 ++ .../web/ChinaWeatherDataBeanController.java | 268 +++++ .../modules/echarts/web/LineController.java | 96 ++ .../echarts/web/LineDoubleNumController.java | 51 + .../echarts/web/PieClassController.java | 206 ++++ .../modules/echarts/web/PieController.java | 34 + .../modules/echarts/web/RadarController.java | 46 + .../modules/gen/dao/GenDataBaseDictDao.java | 19 + .../modules/gen/dao/GenSchemeDao.java | 10 + .../modules/gen/dao/GenTableColumnDao.java | 13 + .../modules/gen/dao/GenTableDao.java | 14 + .../modules/gen/dao/GenTemplateDao.java | 10 + .../modules/gen/entity/GenCategory.java | 47 + .../modules/gen/entity/GenConfig.java | 74 ++ .../modules/gen/entity/GenScheme.java | 145 +++ .../modules/gen/entity/GenTable.java | 255 ++++ .../modules/gen/entity/GenTableColumn.java | 325 +++++ .../modules/gen/entity/GenTemplate.java | 104 ++ .../gen/service/CgAutoListService.java | 110 ++ .../modules/gen/service/GenSchemeService.java | 112 ++ .../modules/gen/service/GenTableService.java | 238 ++++ .../gen/service/GenTemplateService.java | 64 + .../gen/template/FreemarkerHelper.java | 49 + .../modules/gen/template/findList.ftl | 92 ++ .../jeespring/modules/gen/template/mapper.xml | 212 ++++ .../modules/gen/template/viewList.ftl | 135 +++ .../jeespring/modules/gen/util/GenUtils.java | 370 ++++++ .../modules/gen/web/CgAutoListController.java | 88 ++ .../modules/gen/web/GenSchemeController.java | 118 ++ .../modules/gen/web/GenTableController.java | 434 +++++++ .../gen/web/GenTemplateController.java | 104 ++ .../modules/iim/dao/ChatHistoryDao.java | 31 + .../jeespring/modules/iim/dao/MailBoxDao.java | 20 + .../modules/iim/dao/MailComposeDao.java | 18 + .../jeespring/modules/iim/dao/MailDao.java | 18 + .../modules/iim/dao/MyCalendarDao.java | 19 + .../modules/iim/entity/ChatHistory.java | 72 ++ .../jeespring/modules/iim/entity/Friend.java | 35 + .../jeespring/modules/iim/entity/Group.java | 46 + .../jeespring/modules/iim/entity/LayJson.java | 30 + .../jeespring/modules/iim/entity/Mail.java | 77 ++ .../jeespring/modules/iim/entity/MailBox.java | 84 ++ .../modules/iim/entity/MailCompose.java | 148 +++ .../modules/iim/entity/MailPage.java | 109 ++ .../modules/iim/entity/MyCalendar.java | 93 ++ .../iim/service/ChatHistoryService.java | 60 + .../modules/iim/service/MailBoxService.java | 59 + .../iim/service/MailComposeService.java | 58 + .../modules/iim/service/MailService.java | 140 +++ .../iim/service/MyCalendarService.java | 53 + .../jeespring/modules/iim/utils/DateUtil.java | 53 + .../iim/web/ChatHistoryController.java | 189 +++ .../modules/iim/web/ContactController.java | 244 ++++ .../modules/iim/web/MailBoxController.java | 153 +++ .../iim/web/MailComposeController.java | 300 +++++ .../modules/iim/web/MailController.java | 93 ++ .../modules/iim/web/MyCalendarController.java | 335 ++++++ .../jeespring/modules/job/dao/SysJobDao.java | 18 + .../modules/job/dao/SysJobLogDao.java | 18 + .../jeespring/modules/job/entity/SysJob.java | 182 +++ .../modules/job/entity/SysJobLog.java | 141 +++ .../job/rest/SysJobLogRestController.java | 301 +++++ .../job/rest/SysJobRestController.java | 301 +++++ .../modules/job/service/SysJobLogService.java | 183 +++ .../modules/job/service/SysJobService.java | 298 +++++ .../modules/job/task/JeeSpringTask.java | 89 ++ .../modules/job/util/ScheduleJob.java | 79 ++ .../modules/job/util/ScheduleRunnable.java | 58 + .../modules/job/util/ScheduleUtils.java | 224 ++++ .../modules/job/web/SysJobController.java | 332 ++++++ .../modules/job/web/SysJobLogController.java | 311 +++++ .../modules/monitor/dao/MonitorDao.java | 18 + .../modules/monitor/entity/Monitor.java | 72 ++ .../modules/monitor/entity/OnlineSession.java | 155 +++ .../monitor/service/MonitorService.java | 52 + .../modules/monitor/utils/Common.java | 652 ++++++++++ .../modules/monitor/utils/SystemInfo.java | 168 +++ .../monitor/web/MonitorController.java | 116 ++ .../modules/mvvmoa/dao/FormLeavemDao.java | 18 + .../modules/mvvmoa/entity/FormLeavem.java | 89 ++ .../mvvmoa/service/FormLeavemService.java | 52 + .../mvvmoa/web/FormLeavemController.java | 212 ++++ .../jeespring/modules/oa/dao/OaNotifyDao.java | 25 + .../modules/oa/dao/OaNotifyRecordDao.java | 34 + .../modules/oa/dao/TestAuditDao.java | 29 + .../jeespring/modules/oa/entity/OaNotify.java | 170 +++ .../modules/oa/entity/OaNotifyRecord.java | 73 ++ .../modules/oa/entity/TestAudit.java | 182 +++ .../modules/oa/service/OaNotifyService.java | 85 ++ .../modules/oa/service/TestAuditService.java | 126 ++ .../modules/oa/web/OaNotifyController.java | 212 ++++ .../modules/oa/web/TestAuditController.java | 169 +++ .../modules/oauth/entity/TokenInfo.java | 62 + .../oauth/rest/oauthRestController.java | 111 ++ .../modules/oauth/service/OauthService.java | 243 ++++ .../jeespring/modules/other/package-info.java | 6 + .../java/com/jeespring/modules/pay/pay.txt | 0 .../JeeSpringScheduledTaskService.java | 45 + .../JeeSpringTaskSchedulerConfig.java | 12 + .../modules/server/dao/SysServerDao.java | 18 + .../modules/server/entity/SysServer.java | 202 ++++ .../server/rest/SysServerRestController.java | 297 +++++ .../server/service/ISysServerService.java | 8 + .../server/service/SysServerService.java | 191 +++ .../server/web/SysServerController.java | 315 +++++ .../jeespring/modules/shopping/shopping.txt | 0 .../jeespring/modules/sys/dao/AreaDao.java | 18 + .../jeespring/modules/sys/dao/DictDao.java | 22 + .../com/jeespring/modules/sys/dao/LogDao.java | 20 + .../jeespring/modules/sys/dao/MenuDao.java | 28 + .../jeespring/modules/sys/dao/OfficeDao.java | 19 + .../modules/sys/dao/OnlineSessionDAO.java | 89 ++ .../modules/sys/dao/OnlineSessionFactory.java | 58 + .../jeespring/modules/sys/dao/RoleDao.java | 41 + .../modules/sys/dao/SysConfigDao.java | 18 + .../modules/sys/dao/SysConfigTreeDao.java | 19 + .../modules/sys/dao/SysDictTreeDao.java | 19 + .../modules/sys/dao/SysUserOnlineDao.java | 18 + .../modules/sys/dao/SystemConfigDao.java | 18 + .../jeespring/modules/sys/dao/UserDao.java | 112 ++ .../jeespring/modules/sys/entity/Area.java | 98 ++ .../jeespring/modules/sys/entity/Dict.java | 111 ++ .../com/jeespring/modules/sys/entity/Log.java | 148 +++ .../jeespring/modules/sys/entity/Menu.java | 210 ++++ .../jeespring/modules/sys/entity/Office.java | 219 ++++ .../jeespring/modules/sys/entity/Role.java | 270 +++++ .../modules/sys/entity/SysConfig.java | 89 ++ .../modules/sys/entity/SysConfigTree.java | 145 +++ .../modules/sys/entity/SysDictTree.java | 154 +++ .../modules/sys/entity/SysUserOnline.java | 246 ++++ .../modules/sys/entity/SystemConfig.java | 102 ++ .../jeespring/modules/sys/entity/User.java | 349 ++++++ .../modules/sys/entity/UserRealm.java | 98 ++ .../sys/interceptor/InterceptorLogEntity.java | 44 + .../sys/interceptor/LogInterceptor.java | 54 + .../modules/sys/interceptor/LogThread.java | 140 +++ .../sys/interceptor/MobileInterceptor.java | 44 + .../interceptor/WebInterceptorConfigurer.java | 107 ++ .../modules/sys/rest/DictRestController.java | 81 ++ .../sys/rest/SysConfigRestController.java | 291 +++++ .../sys/rest/SysUserOnlineRestController.java | 301 +++++ .../security/FormAuthenticationFilter.java | 111 ++ .../sys/security/SystemAuthorizingRealm.java | 268 +++++ .../sys/security/UsernamePasswordToken.java | 41 + .../modules/sys/service/AreaService.java | 43 + .../modules/sys/service/DictService.java | 48 + .../modules/sys/service/LogService.java | 53 + .../modules/sys/service/OfficeService.java | 64 + .../modules/sys/service/SysConfigService.java | 171 +++ .../sys/service/SysConfigTreeService.java | 50 + .../sys/service/SysDictTreeService.java | 50 + .../sys/service/SysUserOnlineService.java | 271 +++++ .../sys/service/SystemConfigService.java | 52 + .../modules/sys/service/SystemService.java | 399 +++++++ .../modules/sys/utils/DictUtils.java | 152 +++ .../jeespring/modules/sys/utils/LogUtils.java | 88 ++ .../modules/sys/utils/UserUtils.java | 386 ++++++ .../modules/sys/web/AreaController.java | 135 +++ .../modules/sys/web/DictController.java | 147 +++ .../modules/sys/web/IndexConteoller.java | 28 + .../modules/sys/web/LogController.java | 66 ++ .../modules/sys/web/LoginController.java | 435 +++++++ .../modules/sys/web/MenuController.java | 206 ++++ .../modules/sys/web/OfficeController.java | 182 +++ .../modules/sys/web/RegisterController.java | 241 ++++ .../modules/sys/web/RoleController.java | 320 +++++ .../modules/sys/web/SysConfigController.java | 232 ++++ .../sys/web/SysConfigTreeController.java | 158 +++ .../sys/web/SysDictTreeController.java | 150 +++ .../sys/web/SysUserOnlineController.java | 288 +++++ .../sys/web/SystemConfigController.java | 175 +++ .../modules/sys/web/TagController.java | 49 + .../modules/sys/web/UserController.java | 606 ++++++++++ .../usercenter/dao/SysUserCenterDao.java | 18 + .../usercenter/entity/SysUserCenter.java | 145 +++ .../rest/SysUserCenterRestController.java | 291 +++++ .../service/ISysUserCenterService.java | 7 + .../service/SysUserCenterService.java | 134 +++ .../web/SysUserCenterController.java | 207 ++++ .../modules/utils/EmailRestController.java | 125 ++ .../utils/rest/MapApiRestController.java | 138 +++ .../modules/utils/service/EmailService.java | 32 + .../modules/utils/service/MapApiService.java | 49 + .../json/converter/BpmnJsonConverter.java | 1051 +++++++++++++++++ .../Dubbo\350\257\264\346\230\216.txt" | 12 + .../src/main/resources/bootstrap.yml | 14 + .../src/main/resources/logback-spring.xml | 81 ++ .../mappings/gen/GenDataBaseDictDao.xml | 83 ++ .../resources/mappings/gen/GenSchemeDao.xml | 121 ++ .../mappings/gen/GenTableColumnDao.xml | 151 +++ .../resources/mappings/gen/GenTableDao.xml | 142 +++ .../resources/mappings/gen/GenTemplateDao.xml | 105 ++ .../resources/mappings/iim/ChatHistoryDao.xml | 133 +++ .../resources/mappings/iim/MailBoxDao.xml | 151 +++ .../resources/mappings/iim/MailComposeDao.xml | 150 +++ .../main/resources/mappings/iim/MailDao.xml | 95 ++ .../resources/mappings/iim/MyCalendarDao.xml | 115 ++ .../resources/mappings/modules/act/ActDao.xml | 11 + .../echarts/ChinaWeatherDataBeanDao.xml | 147 +++ .../mappings/modules/echarts/PieClassDao.xml | 125 ++ .../mappings/modules/job/SysJobDao.xml | 299 +++++ .../mappings/modules/job/SysJobLogDao.xml | 283 +++++ .../mappings/modules/monitor/MonitorDao.xml | 102 ++ .../mappings/modules/mvvmoa/FormLeavemDao.xml | 138 +++ .../mappings/modules/sys/SysConfigTreeDao.xml | 194 +++ .../mappings/modules/sys/SysDictTreeDao.xml | 194 +++ .../mappings/modules/sys/SysServerDao.xml | 319 +++++ .../mappings/modules/sys/SysUserOnlineDao.xml | 309 +++++ .../modules/usercenter/SysUserCenterDao.xml | 197 +++ .../resources/mappings/oa/OaNotifyDao.xml | 152 +++ .../mappings/oa/OaNotifyRecordDao.xml | 103 ++ .../resources/mappings/oa/TestAuditDao.xml | 188 +++ .../main/resources/mappings/sys/AreaDao.xml | 133 +++ .../main/resources/mappings/sys/DictDao.xml | 115 ++ .../main/resources/mappings/sys/LogDao.xml | 80 ++ .../main/resources/mappings/sys/MenuDao.xml | 178 +++ .../main/resources/mappings/sys/OfficeDao.xml | 190 +++ .../main/resources/mappings/sys/RoleDao.xml | 213 ++++ .../resources/mappings/sys/SysConfigDao.xml | 185 +++ .../mappings/sys/SystemConfigDao.xml | 110 ++ .../main/resources/mappings/sys/UserDao.xml | 443 +++++++ .../templates/modules/gen/config.xml | 115 ++ .../templates/modules/gen/curd/IService.xml | 25 + .../templates/modules/gen/curd/controller.xml | 344 ++++++ .../templates/modules/gen/curd/service.xml | 174 +++ .../modules/gen/curd/serviceMany.xml | 226 ++++ .../templates/modules/gen/curd/viewForm.xml | 132 +++ .../modules/gen/curd/viewFormCSS.xml | 10 + .../templates/modules/gen/curd/viewFormJS.xml | 87 ++ .../modules/gen/curd/viewFormMany.xml | 338 ++++++ .../modules/gen/curd/viewFormManyTwo.xml | 340 ++++++ .../modules/gen/curd/viewFormTwo.xml | 134 +++ .../templates/modules/gen/curd/viewList.xml | 219 ++++ .../modules/gen/curd/viewListCSS.xml | 10 + .../templates/modules/gen/curd/viewListJS.xml | 33 + .../modules/gen/curd/viewListVue.xml | 176 +++ .../templates/modules/gen/curd/viewSelect.xml | 272 +++++ .../templates/modules/gen/curd/viewTotal.xml | 166 +++ .../modules/gen/curd/viewTotalCSS.xml | 10 + .../modules/gen/curd/viewTotalJS.xml | 59 + .../modules/gen/curd/viewTotalMap.xml | 250 ++++ .../templates/modules/gen/dao/dao.xml | 26 + .../templates/modules/gen/dao/entity.xml | 224 ++++ .../templates/modules/gen/dao/mapper.xml | 372 ++++++ .../modules/gen/dubbo/serviceDubbo.xml | 37 + .../modules/gen/dubbo/serviceImplDubbo.xml | 85 ++ .../resources/templates/modules/gen/gen.txt | 0 .../modules/gen/rest/restController.xml | 311 +++++ .../templates/modules/gen/tree/controller.xml | 146 +++ .../templates/modules/gen/tree/dao.xml | 27 + .../templates/modules/gen/tree/entity.xml | 142 +++ .../templates/modules/gen/tree/mapper.xml | 239 ++++ .../templates/modules/gen/tree/service.xml | 54 + .../templates/modules/gen/tree/viewForm.xml | 113 ++ .../templates/modules/gen/tree/viewList.xml | 184 +++ .../modules/gen/treetable/controller.xml | 146 +++ .../templates/modules/gen/treetable/dao.xml | 27 + .../modules/gen/treetable/entity.xml | 139 +++ .../modules/gen/treetable/mapper.xml | 239 ++++ .../modules/gen/treetable/service.xml | 54 + .../modules/gen/treetable/viewForm.xml | 113 ++ .../modules/gen/treetable/viewList.xml | 184 +++ 461 files changed, 64791 insertions(+) create mode 100644 JeeSpringCloud/jeespring-framework/pom.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/annotation/FieldName.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/AddGroup.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/DefaultGroup.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/EditGroup.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/Global.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/ScheduleConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/ShiroConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/Constants.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/ScheduleConstants.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/ShiroConstants.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidConfiguration.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidStatFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidStatViewServlet.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/exception/job/TaskException.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/JeesiteFileUploadFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/LogoutFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/OnlineSessionFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/PageCachingFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/SyncOnlineSessionFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/json/AjaxJson.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/json/PrintJSON.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailAuthenticator.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailBody.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailSendUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/BeanMapper.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/JaxbMapper.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/JsonMapper.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/adapters/MapAdapter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/adapters/MapConvertor.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/AbstractBaseEntity.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/AbstractEntity.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/ActEntity.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceBaseDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceBaseService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/Page.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/TreeDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/TreeEntity.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/annotation/MyBatisDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/DB2Dialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/DerbyDialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/Dialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/H2Dialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/HSQLDialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/MySQLDialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/OracleDialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/PostgreSQLDialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SQLServer2005Dialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SQLServerDialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SybaseDialect.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/BaseInterceptor.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/PaginationInterceptor.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/PreparePaginationInterceptor.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/SQLHelper.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/proxy/PageConfiguration.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/proxy/PaginationMapperMethod.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/proxy/PaginationMapperProxy.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/proxy/PaginationMapperRegistry.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/redis/JedisUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/redis/RedisConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/redis/RedisRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/redis/RedisUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/Cryptos.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/Digests.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/MD5Tools.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/ShiroUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/shiro/HasAnyPermissionsTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/shiro/cache/SessionCacheManager.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/shiro/session/CacheSessionDAO.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/shiro/session/SessionDAO.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/security/shiro/session/SessionManager.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/service/AbstractBaseService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/service/AbstractService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/service/ICommonService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/service/InterfaceService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/service/ServiceException.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/service/TreeService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/servlet/CKFinderConnectorServlet.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/servlet/UserfilesDownloadServlet.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/servlet/ValidateCodeServlet.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/sms/SMSUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/spring/SpringUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/swagger/Swagger.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/tag/AceMenuTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/tag/MenuTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/tag/echarts/EChartsBarTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/tag/echarts/EChartsLineDoubleNumTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/tag/echarts/EChartsLineTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/tag/echarts/EChartsLineTimeLineTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/tag/echarts/EChartsPieTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/tag/echarts/EChartsRadarTag.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/AddressUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/Base64ImageUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/CacheUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/CharsetKit.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/Collections3.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/Convert.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/CookieUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/DateUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/Encodes.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/Exceptions.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/FileSizeHelper.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/FileUtil.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/FileUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/FreeMarkers.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/GsonUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/HttpRequest.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/HttpUtil.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/IdGen.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/IdcardUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/ImageGeo.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/IpUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/MacUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/MyBeanUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/ObjectFieldUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/ObjectUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/OrderProperties.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/PropertiesLoader.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/Reflections.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/SendMailUtil.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/ServletUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/SpringContextHolder.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/StrFormatter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/StreamUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/StringUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/SystemPath.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/Threads.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/TimeUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/UploadUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/UserAgentUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/WorkDayUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/ZxingHandler.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/bean/BeanUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/excel/ExportExcel.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/excel/ImportExcel.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/excel/annotation/ExcelField.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/excel/fieldtype/AreaType.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/excel/fieldtype/OfficeType.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/excel/fieldtype/RoleListType.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/utils/http/HttpUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/validator/BeanValidators.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/web/AbstractBaseController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/web/CKFinderConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/web/Result.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/web/ResultFactory.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/web/Servlets.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/websocket/WebSockertFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/websocket/onchat/ChatServer.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/websocket/onchat/ChatServerPool.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/websocket/utils/Constant.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/ActConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/dao/ActDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/entity/Act.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/diagram/services/BaseProcessDefinitionDiagramLayoutResource.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/diagram/services/ProcessDefinitionDiagramLayoutResource.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/diagram/services/ProcessInstanceDiagramLayoutResource.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/diagram/services/ProcessInstanceHighlightsResource.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/editor/main/StencilsetRestResource.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/editor/model/ModelEditorJsonRestResource.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/editor/model/ModelSaveRestResource.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/servlet/FilterServletOutputStream.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/servlet/GenericResponseWrapper.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/rest/servlet/JsonpCallbackFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/ActModelService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/ActProcessService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/ActTaskService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/cmd/CreateAndTakeTransitionCmd.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/cmd/JumpTaskCmd.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/cmd/ModelDeployProcessDefinitionCmd.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/ChainedActivitiesCreator.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/MultiInstanceActivityCreator.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityCreator.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityCreatorSupport.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityDefinitionEntity.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityDefinitionEntityIntepreter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/RuntimeActivityDefinitionManager.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/creator/SimpleRuntimeActivityDefinitionEntity.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/ext/ActGroupEntityService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/ext/ActGroupEntityServiceFactory.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/ext/ActUserEntityService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/service/ext/ActUserEntityServiceFactory.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/utils/ActUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/utils/DateConverter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/utils/ProcessDefCache.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/utils/ProcessDefUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/utils/PropertyType.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/utils/Variable.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/web/ActModelController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/web/ActProcessController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/act/web/ActTaskController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/aop/AOPService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/baiduface/rest/FaceRecognitionRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/dao/ChinaWeatherDataBeanDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/dao/PieClassDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/entity/ChinaWeatherDataBean.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/entity/PieClass.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/service/ChinaWeatherDataBeanService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/service/PieClassService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/web/BarController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/web/ChinaWeatherDataBeanController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/web/LineController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/web/LineDoubleNumController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/web/PieClassController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/web/PieController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/echarts/web/RadarController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/dao/GenDataBaseDictDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/dao/GenSchemeDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/dao/GenTableColumnDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/dao/GenTableDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/dao/GenTemplateDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/entity/GenCategory.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/entity/GenConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/entity/GenScheme.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/entity/GenTable.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/entity/GenTableColumn.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/entity/GenTemplate.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/service/CgAutoListService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/service/GenSchemeService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/service/GenTableService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/service/GenTemplateService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/template/FreemarkerHelper.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/template/findList.ftl create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/template/mapper.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/template/viewList.ftl create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/util/GenUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/CgAutoListController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenSchemeController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenTableController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenTemplateController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/ChatHistoryDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailBoxDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailComposeDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MyCalendarDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/ChatHistory.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Friend.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Group.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/LayJson.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Mail.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailBox.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailCompose.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailPage.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MyCalendar.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/ChatHistoryService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailBoxService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailComposeService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MyCalendarService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/utils/DateUtil.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/ChatHistoryController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/ContactController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailBoxController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailComposeController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MyCalendarController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/dao/SysJobDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/dao/SysJobLogDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/entity/SysJob.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/entity/SysJobLog.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/rest/SysJobLogRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/rest/SysJobRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/service/SysJobLogService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/service/SysJobService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/task/JeeSpringTask.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleJob.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleRunnable.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/web/SysJobController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/web/SysJobLogController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/dao/MonitorDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/entity/Monitor.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/entity/OnlineSession.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/service/MonitorService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/utils/Common.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/utils/SystemInfo.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/web/MonitorController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/dao/FormLeavemDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/entity/FormLeavem.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/service/FormLeavemService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/web/FormLeavemController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyRecordDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/TestAuditDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotify.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotifyRecord.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/TestAudit.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/OaNotifyService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/TestAuditService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/OaNotifyController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/TestAuditController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/entity/TokenInfo.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/rest/oauthRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/service/OauthService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/other/package-info.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/pay/pay.txt create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringScheduledTaskService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringTaskSchedulerConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/dao/SysServerDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/entity/SysServer.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/rest/SysServerRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/service/ISysServerService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/service/SysServerService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/web/SysServerController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/shopping/shopping.txt create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/AreaDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/DictDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/LogDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/MenuDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OfficeDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OnlineSessionDAO.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OnlineSessionFactory.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/RoleDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysConfigDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysConfigTreeDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysDictTreeDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysUserOnlineDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SystemConfigDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/UserDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Area.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Dict.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Log.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Menu.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Office.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Role.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysConfigTree.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysDictTree.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysUserOnline.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SystemConfig.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/User.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/UserRealm.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/InterceptorLogEntity.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/LogInterceptor.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/LogThread.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/MobileInterceptor.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/WebInterceptorConfigurer.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/DictRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/SysConfigRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/SysUserOnlineRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/FormAuthenticationFilter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/SystemAuthorizingRealm.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/UsernamePasswordToken.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/AreaService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/DictService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/LogService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/OfficeService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysConfigService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysConfigTreeService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysDictTreeService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysUserOnlineService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SystemConfigService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SystemService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/DictUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/LogUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/UserUtils.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/AreaController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/DictController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/IndexConteoller.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/LogController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/LoginController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/MenuController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/OfficeController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/RegisterController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/RoleController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysConfigController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysConfigTreeController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysDictTreeController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysUserOnlineController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SystemConfigController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/TagController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/UserController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/dao/SysUserCenterDao.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/entity/SysUserCenter.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/rest/SysUserCenterRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/service/ISysUserCenterService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/service/SysUserCenterService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/web/SysUserCenterController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/EmailRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/rest/MapApiRestController.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/service/EmailService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/service/MapApiService.java create mode 100644 JeeSpringCloud/jeespring-framework/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java create mode 100644 "JeeSpringCloud/jeespring-framework/src/main/resources/Dubbo\350\257\264\346\230\216.txt" create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/bootstrap.yml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/logback-spring.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenDataBaseDictDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenSchemeDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTableColumnDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTableDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTemplateDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/ChatHistoryDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailBoxDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailComposeDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MyCalendarDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/act/ActDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/echarts/ChinaWeatherDataBeanDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/echarts/PieClassDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/job/SysJobDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/job/SysJobLogDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/monitor/MonitorDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/mvvmoa/FormLeavemDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysConfigTreeDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysDictTreeDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysServerDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysUserOnlineDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/usercenter/SysUserCenterDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/OaNotifyDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/OaNotifyRecordDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/TestAuditDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/AreaDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/DictDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/LogDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/MenuDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/OfficeDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/RoleDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/SysConfigDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/SystemConfigDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/UserDao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/config.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/IService.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/controller.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/service.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/serviceMany.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewForm.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormCSS.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormJS.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormMany.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormManyTwo.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormTwo.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewList.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListCSS.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListJS.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListVue.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewSelect.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotal.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalCSS.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalJS.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalMap.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/dao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/entity.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/mapper.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dubbo/serviceDubbo.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dubbo/serviceImplDubbo.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/gen.txt create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/rest/restController.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/controller.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/dao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/entity.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/mapper.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/service.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/viewForm.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/viewList.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/controller.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/dao.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/entity.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/mapper.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/service.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/viewForm.xml create mode 100644 JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/viewList.xml diff --git a/JeeSpringCloud/jeespring-framework/pom.xml b/JeeSpringCloud/jeespring-framework/pom.xml new file mode 100644 index 0000000..2727a9e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + com.jeespring + jeespring-framework + jeespring-framework + jeespring-framework + 1.0.0 + jar + + com.jeespring + jeespring + 1.0.0 + ../pom.xml + + + + + com.ckfinder + apache-ant-zip + 2.3 + system + ${project.basedir}/../jeespring-web/src/main/webapp/WEB-INF/lib/apache-ant-zip-2.3.jar + + + com.ckfinder + ckfinder + 2.3 + system + ${project.basedir}/../jeespring-web/src/main/webapp/WEB-INF/lib/ckfinder-2.3.jar + + + com.ckfinder + ckfinderplugin-fileeditor + 2.3 + system + ${project.basedir}/../jeespring-web/src/main/webapp/WEB-INF/lib/ckfinderplugin-fileeditor-2.3.jar + + + com.ckfinder + ckfinderplugin-imageresize + 2.3 + system + ${project.basedir}/../jeespring-web/src/main/webapp/WEB-INF/lib/ckfinderplugin-imageresize-2.3.jar + + + com.swetake + qrcode + 1.5 + system + ${project.basedir}/../jeespring-web/src/main/webapp/WEB-INF/lib/QRCode-1.5.jar + + + bitwalker + UserAgentUtils + 1.13 + system + ${project.basedir}/../jeespring-web/src/main/webapp/WEB-INF/lib/UserAgentUtils-1.13.jar + + + + + + src/main/resources + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/annotation/FieldName.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/annotation/FieldName.java new file mode 100644 index 0000000..848be15 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/annotation/FieldName.java @@ -0,0 +1,17 @@ +package com.jeespring.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * bean中文名注解 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface FieldName { + + String value(); + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/AddGroup.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/AddGroup.java new file mode 100644 index 0000000..5c66318 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/AddGroup.java @@ -0,0 +1,13 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.common.beanvalidator; + +/** + * 添加Bean验证组 + * @author 黄炳桂 516821420@qq.com + * + */ +public interface AddGroup { + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/DefaultGroup.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/DefaultGroup.java new file mode 100644 index 0000000..6da5fdc --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/DefaultGroup.java @@ -0,0 +1,12 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.common.beanvalidator; + +/** + * 默认Bean验证组 + * @author 黄炳桂 516821420@qq.com + */ +public interface DefaultGroup { + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/EditGroup.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/EditGroup.java new file mode 100644 index 0000000..200e941 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/beanvalidator/EditGroup.java @@ -0,0 +1,12 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.common.beanvalidator; + +/** + * 编辑Bena验证组 + * @author 黄炳桂 516821420@qq.com + */ +public interface EditGroup { + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/Global.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/Global.java new file mode 100644 index 0000000..349cefb --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/Global.java @@ -0,0 +1,270 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.config; + +import com.ckfinder.connector.ServletContextFactory; +import com.google.common.collect.Maps; +import com.jeespring.common.utils.PropertiesLoader; +import com.jeespring.common.utils.StringUtils; + +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.sys.service.SysConfigService; +import org.apache.ibatis.io.Resources; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.core.env.Environment; +import org.springframework.core.io.DefaultResourceLoader; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.Reader; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * 全局配置类 + * + * @author 黄炳桂 516821420@qq.com + * @version 2014-06-25 + */ +public class Global { + + private static Logger logger = LoggerFactory.getLogger(Global.class); + + static RelaxedPropertyResolver resolver; + //@Autowired + //private static Environment env; + + /** + * 当前对象实例 + */ + private static Global global = new Global(); + + /** + * 保存全局属性值 + */ + private static Map map = Maps.newHashMap(); + + /** + * 属性文件加载对象 + */ + private static PropertiesLoader loader = new PropertiesLoader("bootstrap.yml"); + + /** + * 显示/隐藏 + */ + public static final String SHOW = "1"; + public static final String HIDE = "0"; + + /** + * 是/否 + */ + public static final String YES = "1"; + public static final String NO = "0"; + + /** + * 对/错 + */ + public static final String TRUE = "true"; + public static final String FALSE = "false"; + + /** + * 上传文件基础虚拟路径 + */ + public static final String USERFILES_BASE_URL = "/userfiles/"; + + /** + * 获取当前对象实例 + */ + public static Global getInstance() { + return global; + } + + /** + * 获取配置 + * ${fns:getConfig('adminPath')} + */ + public static String getConfig(String key) { + String value = map.get(key); + if (value == null) { + try { + value = resolver.getProperty(key); + //value =env.getProperty(key); + if (StringUtils.isBlank(value)) { + throw new RuntimeException("value null"); + } + map.put(key, value); + } catch (Exception e) { + value = loader.getProperty(key); + map.put(key, value != null ? value : StringUtils.EMPTY); + } + } + return value; + } + + public static String getConfig(String key,String value){ + String result=getConfig(key); + if(result==StringUtils.EMPTY){ + return value; + } + return result; + } + /** + * 获取管理端根路径 + */ + public static String getAdminPath() { + return getConfig("adminPath"); + } + + /** + * 获取前端根路径 + */ + public static String getFrontPath() { + return getConfig("frontPath"); + } + + /** + * 获取URL后缀 + */ + public static String getUrlSuffix() { + return getConfig("urlSuffix"); + } + + /** + * 是否是演示模式,演示模式下不能修改用户、角色、密码、菜单、授权 + */ + public static Boolean isDemoMode() { + String dm = getConfig("demoMode"); + return "true".equals(dm) || "1".equals(dm); + } + + public static String isDemoModeDescription() { + String dmd = getConfig("demoModeDescription"); + if(dmd==null){ + return "演示版启用为系统能正常演示,暂时不允许操作!"; + } + return dmd; + } + + public static Boolean isDubbo() { + String dm = getConfig("dubbo.run"); + return "true".equals(dm) || "1".equals(dm); + } + + /** + * 获取上传文件的根目录 + * + * @return + */ + public static String getUserfilesBaseDir() { + String dir = getConfig("userfiles.basedir"); + if (StringUtils.isBlank(dir)) { + try { + dir = ServletContextFactory.getServletContext().getRealPath("/"); + } catch (Exception e) { + return ""; + } + } + if (!dir.endsWith("/")) { + dir += "/"; + } + return dir; + } + + public static String getJdbcType() { + if (map.containsKey("spring.datasource.url")) { + return map.get("spring.datasource.url"); + } + try { + String url = resolver.getProperty("spring.datasource.url"); + //String url = env.getProperty("spring.datasource.url"); + String type = getDbType(url); + map.put("spring.datasource.url", type); + return type; + } catch (Exception e) { + logger.error("get jdbcType error", e); + } + logger.error("return the defaut jdbc type is mysql"); + return "mysql"; + } + + private static String getDbType(String rawUrl) { + return rawUrl == null ? null : (!rawUrl.startsWith("jdbc:derby:") && !rawUrl.startsWith("jdbc:log4jdbc:derby:") ? (!rawUrl.startsWith("jdbc:mysql:") && !rawUrl.startsWith("jdbc:cobar:") && !rawUrl.startsWith("jdbc:log4jdbc:mysql:") ? (rawUrl.startsWith("jdbc:mariadb:") ? "mariadb" : (!rawUrl.startsWith("jdbc:oracle:") && !rawUrl.startsWith("jdbc:log4jdbc:oracle:") ? (rawUrl.startsWith("jdbc:alibaba:oracle:") ? "AliOracle" : (!rawUrl.startsWith("jdbc:microsoft:") && !rawUrl.startsWith("jdbc:log4jdbc:microsoft:") ? (!rawUrl.startsWith("jdbc:sqlserver:") && !rawUrl.startsWith("jdbc:log4jdbc:sqlserver:") ? (!rawUrl.startsWith("jdbc:sybase:Tds:") && !rawUrl.startsWith("jdbc:log4jdbc:sybase:") ? (!rawUrl.startsWith("jdbc:jtds:") && !rawUrl.startsWith("jdbc:log4jdbc:jtds:") ? (!rawUrl.startsWith("jdbc:fake:") && !rawUrl.startsWith("jdbc:mock:") ? (!rawUrl.startsWith("jdbc:postgresql:") && !rawUrl.startsWith("jdbc:log4jdbc:postgresql:") ? (rawUrl.startsWith("jdbc:edb:") ? "edb" : (!rawUrl.startsWith("jdbc:hsqldb:") && !rawUrl.startsWith("jdbc:log4jdbc:hsqldb:") ? (rawUrl.startsWith("jdbc:odps:") ? "odps" : (rawUrl.startsWith("jdbc:db2:") ? "db2" : (rawUrl.startsWith("jdbc:sqlite:") ? "sqlite" : (rawUrl.startsWith("jdbc:ingres:") ? "ingres" : (!rawUrl.startsWith("jdbc:h2:") && !rawUrl.startsWith("jdbc:log4jdbc:h2:") ? (rawUrl.startsWith("jdbc:mckoi:") ? "mckoi" : (rawUrl.startsWith("jdbc:cloudscape:") ? "cloudscape" : (!rawUrl.startsWith("jdbc:informix-sqli:") && !rawUrl.startsWith("jdbc:log4jdbc:informix-sqli:") ? (rawUrl.startsWith("jdbc:timesten:") ? "timesten" : (rawUrl.startsWith("jdbc:as400:") ? "as400" : (rawUrl.startsWith("jdbc:sapdb:") ? "sapdb" : (rawUrl.startsWith("jdbc:JSQLConnect:") ? "JSQLConnect" : (rawUrl.startsWith("jdbc:JTurbo:") ? "JTurbo" : (rawUrl.startsWith("jdbc:firebirdsql:") ? "firebirdsql" : (rawUrl.startsWith("jdbc:interbase:") ? "interbase" : (rawUrl.startsWith("jdbc:pointbase:") ? "pointbase" : (rawUrl.startsWith("jdbc:edbc:") ? "edbc" : (rawUrl.startsWith("jdbc:mimer:multi1:") ? "mimer" : (rawUrl.startsWith("jdbc:dm:") ? "dm" : (rawUrl.startsWith("jdbc:kingbase:") ? "kingbase" : (rawUrl.startsWith("jdbc:log4jdbc:") ? "log4jdbc" : (rawUrl.startsWith("jdbc:hive:") ? "hive" : (rawUrl.startsWith("jdbc:hive2:") ? "hive" : (rawUrl.startsWith("jdbc:phoenix:") ? "phoenix" : null)))))))))))))))) : "informix"))) : "h2"))))) : "hsql")) : "postgresql") : "mock") : "jtds") : "sybase") : "sqlserver") : "sqlserver")) : "oracle")) : "mysql") : "derby"); + } + + /** + * 获取工程路径 + * @return + */ + public static String getProjectPath(){ + // 如果配置了工程路径,则直接返回,否则自动获取。 + String projectPath = Global.getConfig("projectPath"); + if (StringUtils.isNotBlank(projectPath)){ + return projectPath; + } + try { + File file = new DefaultResourceLoader().getResource("").getFile(); + if (file != null){ + while(true){ + File f = new File(file.getPath() + File.separator + "src" + File.separator + "main"); + if (f == null || f.exists()){ + break; + } + if (file.getParentFile() != null){ + file = file.getParentFile(); + }else{ + break; + } + } + projectPath = file.toString(); + } + } catch (IOException e) { + e.printStackTrace(); + } + return projectPath; + } + + /** + * 写入properties信息 + * + * @param key + * 名称 + * @param value + * 值 + */ + public static void modifyConfig(String key, String value) { + try { + // 从输入流中读取属性列表(键和元素对) + Properties prop = getProperties(); + prop.setProperty(key, value); + String path = Global.class.getResource("/jeespring.properties").getPath(); + FileOutputStream outputFile = new FileOutputStream(path); + prop.store(outputFile, "modify"); + outputFile.close(); + outputFile.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * (注意:加载的是src下的文件,如果在某个包下.请把包名加上) + * 返回 Properties  + * @return + */ + public static Properties getProperties(){ + Properties prop = new Properties(); + try { + Reader reader = Resources.getResourceAsReader("/jeespring.properties"); + prop.load(reader); + } catch (Exception e) { + return null; + } + return prop; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/ScheduleConfig.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/ScheduleConfig.java new file mode 100644 index 0000000..94ad9f6 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/ScheduleConfig.java @@ -0,0 +1,58 @@ +package com.jeespring.common.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +import javax.sql.DataSource; +import java.util.Properties; + +/** + * 定时任务配置 + * + * @author JeeSpring + * + */ +@Configuration +public class ScheduleConfig +{ + + @Bean + public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) + { + SchedulerFactoryBean factory = new SchedulerFactoryBean(); + factory.setDataSource(dataSource); + + // quartz参数 + Properties prop = new Properties(); + prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler"); + prop.put("org.quartz.scheduler.instanceId", "AUTO"); + // 线程池配置 + prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); + prop.put("org.quartz.threadPool.threadCount", "20"); + prop.put("org.quartz.threadPool.threadPriority", "5"); + // JobStore配置 + prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); + // 集群配置 + prop.put("org.quartz.jobStore.isClustered", "true"); + prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); + prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); + prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); + + prop.put("org.quartz.jobStore.misfireThreshold", "12000"); + prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); + factory.setQuartzProperties(prop); + + factory.setSchedulerName("RuoyiScheduler"); + // 延时启动 + factory.setStartupDelay(1); + factory.setApplicationContextSchedulerContextKey("applicationContextKey"); + // 可选,QuartzScheduler + // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了 + factory.setOverwriteExistingJobs(true); + // 设置自动启动,默认为true + factory.setAutoStartup(true); + + return factory; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/ShiroConfig.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/ShiroConfig.java new file mode 100644 index 0000000..b30e5e7 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/config/ShiroConfig.java @@ -0,0 +1,304 @@ +package com.jeespring.common.config; + +import com.jeespring.common.filter.LogoutFilter; +import com.jeespring.common.filter.OnlineSessionFilter; +import com.jeespring.common.redis.RedisUtils; +import com.jeespring.common.security.shiro.session.CacheSessionDAO; +import com.jeespring.common.security.shiro.session.SessionManager; +import com.jeespring.modules.sys.dao.OnlineSessionDAO; +import com.jeespring.modules.sys.dao.OnlineSessionFactory; +import com.jeespring.modules.sys.security.FormAuthenticationFilter; +import com.jeespring.modules.sys.security.SystemAuthorizingRealm; +import net.sf.ehcache.CacheManager; +import org.apache.shiro.cache.ehcache.EhCacheManager; +import org.apache.shiro.spring.LifecycleBeanPostProcessor; +import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor; +import org.apache.shiro.spring.web.ShiroFilterFactoryBean; +import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter; +import org.apache.shiro.web.mgt.DefaultWebSecurityManager; +import org.apache.shiro.web.servlet.SimpleCookie; +import org.crazycake.shiro.RedisCacheManager; +import org.crazycake.shiro.RedisManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.DependsOn; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.springframework.web.filter.DelegatingFilterProxy; +import com.jeespring.common.filter.SyncOnlineSessionFilter; + +import javax.servlet.Filter; +import java.util.HashMap; +import java.util.Map; + +/** + * shiro的控制类 + * 下面方法的顺序不能乱 + * Created by zhao.weiwei + * create on 2017/1/11 10:59 + * the email is zhao.weiwei@jyall.com. + */ +@Component +public class ShiroConfig { + /** + * 日志对象 + */ + private static Logger logger = LoggerFactory.getLogger(RedisUtils.class); + + @Autowired + public OnlineSessionDAO sessionDAO; + @Autowired + public OnlineSessionFactory sessionFactory; + + // Session超时时间,单位为毫秒(默认30分钟) + @Value("${shiro.session.expireTime}") + private int expireTime; + + //启动shiro redis缓存,单点登录 + //@Value("${shiro.redis}") + //private String shiroRedis; + + // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟 + @Value("${shiro.session.validationInterval}") + private int validationInterval; + + // 验证码开关 + @Value("${shiro.user.captchaEbabled}") + private boolean captchaEbabled; + + // 验证码类型 + @Value("${shiro.user.captchaType}") + private String captchaType; + + // 设置Cookie的域名 + @Value("${shiro.cookie.domain}") + private String domain; + + // 设置cookie的有效访问路径 + @Value("${shiro.cookie.path}") + private String path; + + // 设置HttpOnly属性 + @Value("${shiro.cookie.httpOnly}") + private boolean httpOnly; + + // 设置Cookie的过期时间,秒为单位 + @Value("${shiro.cookie.maxAge}") + private int maxAge; + + // 登录地址 + @Value("${shiro.user.loginUrl}") + private String loginUrl="/admin/login"; + + // 权限认证失败地址 + @Value("${shiro.user.unauthorizedUrl}") + private String unauthorizedUrl; + + /** + * 全局的环境变量的设置 + * shiro的拦截 + * + * @param environment + * @param adminPath + * @return + */ + @Bean(name = "shiroFilterChainDefinitions") + public String shiroFilterChainDefinitions(Environment environment + , @Value("${adminPath}") String adminPath + , @Value("${frontPath}") String frontPath) { + Global.resolver = new RelaxedPropertyResolver(environment); + StringBuilder string=new StringBuilder(); + string.append("/static/** = anon\n"); + string.append("/staticViews/** = anon\n"); + string.append("/jeeSpringStatic/** = anon\n"); + string.append("/userfiles/** = anon\n"); + string.append("/rest/** = anon\n"); + string.append(frontPath+"/** = anon\n"); + string.append( adminPath + "/basic = basic\n"); + string.append( adminPath + "/login = authc\n"); + string.append( adminPath + "/loginBase = anon\n"); + string.append( adminPath + "/logout = logout\n"); + string.append( adminPath + "/register = anon\n"); + string.append( adminPath + "/sys/register/registerUser = anon\n"); + string.append( adminPath + "/sys/user/validateLoginName = anon\n"); + string.append( adminPath + "/sys/user/validateMobile = anon\n"); + string.append( adminPath + "/** = user\n"); + string.append( "/ReportServer/** = user"); + return string.toString(); + } + + @Bean(name = "basicHttpAuthenticationFilter") + public BasicHttpAuthenticationFilter casFilter(@Value("${adminPath:/a}") String adminPath) { + BasicHttpAuthenticationFilter basicHttpAuthenticationFilter = new BasicHttpAuthenticationFilter(); + basicHttpAuthenticationFilter.setLoginUrl(adminPath + "/login"); + return basicHttpAuthenticationFilter; + } + + @Bean(name = "shiroFilter") + public ShiroFilterFactoryBean shiroFilterFactoryBean( + @Value("${adminPath:/a}") String adminPath, + BasicHttpAuthenticationFilter basicHttpAuthenticationFilter, + FormAuthenticationFilter formAuthenticationFilter, + DefaultWebSecurityManager securityManager, + @Qualifier("shiroFilterChainDefinitions") String shiroFilterChainDefinitions) { + Map filters = new HashMap<>(); + filters.put("basic", basicHttpAuthenticationFilter); + filters.put("authc", formAuthenticationFilter); + filters.put("syncOnlineSession", syncOnlineSessionFilter()); + //filters.put("onlineSession", onlineSessionFilter()); + filters.put("logout", logoutFilter()); + ShiroFilterFactoryBean bean = new ShiroFilterFactoryBean(); + bean.setFilters(filters); + bean.setSecurityManager(securityManager); + bean.setLoginUrl(adminPath + "/login"); + bean.setSuccessUrl(adminPath + "?login"); + // Shiro过滤器配置 + bean.setFilterChainDefinitions(shiroFilterChainDefinitions); + return bean; + } + + @Bean(name = "shiroCacheManager") + public EhCacheManager shiroCacheManager(CacheManager manager) { + EhCacheManager ehCacheManager = new EhCacheManager(); + ehCacheManager.setCacheManager(manager); + return ehCacheManager; + } + + + //@Bean(name = "redisCacheManager") + public RedisCacheManager redisCacheManager(String redisHostName,String reidsPassword,int reidsPort,int expireTimeShiro) { + RedisCacheManager redisCacheManager= new RedisCacheManager(); + RedisManager redisManager= new RedisManager(); + redisManager.setHost(redisHostName); + redisManager.setPassword(reidsPassword); + redisManager.setPort(reidsPort); + redisManager.setExpire(expireTimeShiro); + redisCacheManager.setRedisManager(redisManager); + return redisCacheManager; + } + + + + @Bean(name = "sessionManager") + public SessionManager sessionManager(CacheSessionDAO dao) { + SessionManager sessionManager = new SessionManager(); + sessionManager.setSessionDAO(dao); + // 设置全局session超时时间 + sessionManager.setGlobalSessionTimeout(86400000); + // 相隔多久检查一次session的有效性,单位毫秒,默认就是10分钟 + sessionManager.setSessionValidationInterval(1800000); + sessionManager.setSessionValidationSchedulerEnabled(true); + sessionManager.setSessionIdCookie(new SimpleCookie("com.jeespring.session.id")); + sessionManager.setSessionIdCookieEnabled(true); + // 删除过期的session + sessionManager.setDeleteInvalidSessions(true); + // 去掉 JSESSIONID + sessionManager.setSessionIdUrlRewritingEnabled(false); + // 是否定时检查session + sessionManager.setSessionValidationSchedulerEnabled(true); + // 自定义SessionDao + //sessionManager.setSessionDAO(sessionDAO()); + // 自定义sessionFactory + //sessionManager.setSessionFactory(sessionFactory()); + return sessionManager; + } + + @Bean(name = "securityManager") + public DefaultWebSecurityManager defaultWebSecurityManager( + SystemAuthorizingRealm systemAuthorizingRealm, + SessionManager sessionManager, + EhCacheManager ehCacheManager, + @Value("${spring.redis.run}") String redisRun, + @Value("${spring.redis.hostName}") String redisHostName, + @Value("${spring.redis.password}") String reidsPassword, + @Value("${spring.redis.port}") int redisPort, + @Value("${spring.redis.expireTimeShiro}") int expireTimeShiro, + @Value("${shiro.redis}") String shiroRedis + ) { + DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager(); + defaultWebSecurityManager.setSessionManager(sessionManager); + if("true".equals(redisRun) && "true".equals(shiroRedis)){ + try{ + // 加入缓存管理器 + defaultWebSecurityManager.setCacheManager(redisCacheManager(redisHostName,reidsPassword,redisPort,expireTimeShiro)); + } catch (Exception e) { + logger.error("RedisUtils run:"+RedisUtils.RUN_MESSAGE+e.getMessage(), RedisUtils.RUN_MESSAGE+e.getMessage()); + defaultWebSecurityManager.setCacheManager(ehCacheManager); + } + }else{ + // 加入缓存管理器 + defaultWebSecurityManager.setCacheManager(ehCacheManager); + } + defaultWebSecurityManager.setRealm(systemAuthorizingRealm); + return defaultWebSecurityManager; + } + + + @Bean + public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor( + DefaultWebSecurityManager defaultWebSecurityManager) { + AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); + authorizationAttributeSourceAdvisor.setSecurityManager(defaultWebSecurityManager); + return authorizationAttributeSourceAdvisor; + } + + @Bean + public FilterRegistrationBean filterRegistrationBean() { + FilterRegistrationBean filterRegistration = new FilterRegistrationBean(); + filterRegistration.setFilter(new DelegatingFilterProxy("shiroFilter")); + filterRegistration.addInitParameter("targetFilterLifecycle", "true"); + filterRegistration.setEnabled(true); + filterRegistration.addUrlPatterns("/*"); + return filterRegistration; + } + + @Bean(name = "lifecycleBeanPostProcessor") + public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { + return new LifecycleBeanPostProcessor(); + } + + @Bean + @DependsOn("lifecycleBeanPostProcessor") + public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { + DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator(); + defaultAdvisorAutoProxyCreator.setProxyTargetClass(true); + return defaultAdvisorAutoProxyCreator; + } + + /** + * 自定义在线用户处理过滤器 + */ + + public OnlineSessionFilter onlineSessionFilter() + { + OnlineSessionFilter onlineSessionFilter = new OnlineSessionFilter(); + //onlineSessionFilter.setLoginUrl(loginUrl); + return onlineSessionFilter; + } + + /** + * 自定义在线用户同步过滤器 + */ + @Bean + public SyncOnlineSessionFilter syncOnlineSessionFilter() + { + SyncOnlineSessionFilter syncOnlineSessionFilter = new SyncOnlineSessionFilter(); + return syncOnlineSessionFilter; + } + + + public LogoutFilter logoutFilter() + { + LogoutFilter logoutFilter = new LogoutFilter(); + logoutFilter.setLoginUrl(loginUrl); + return logoutFilter; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/Constants.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/Constants.java new file mode 100644 index 0000000..e4d9044 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/Constants.java @@ -0,0 +1,65 @@ +package com.jeespring.common.constant; + +/** + * 通用常量信息 + * + * @author JeeSpring + */ +public class Constants +{ + /** + * UTF-8 字符集 + */ + public static final String UTF8 = "UTF-8"; + + /** + * 通用成功标识 + */ + public static final String SUCCESS = "0"; + + /** + * 通用失败标识 + */ + public static final String FAIL = "1"; + + /** + * 登录成功 + */ + public static final String LOGIN_SUCCESS = "Success"; + + /** + * 注销 + */ + public static final String LOGOUT = "Logout"; + + /** + * 登录失败 + */ + public static final String LOGIN_FAIL = "Error"; + + /** + * 自动去除表前缀 + */ + public static String AUTO_REOMVE_PRE = "true"; + + /** + * 当前记录起始索引 + */ + public static String PAGE_NUM = "pageNum"; + + /** + * 每页显示记录数 + */ + public static String PAGE_SIZE = "pageSize"; + + /** + * 排序列 + */ + public static String ORDER_BY_COLUMN = "orderByColumn"; + + /** + * 排序的方向 "desc" 或者 "asc". + */ + public static String IS_ASC = "isAsc"; + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/ScheduleConstants.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/ScheduleConstants.java new file mode 100644 index 0000000..87d6310 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/ScheduleConstants.java @@ -0,0 +1,51 @@ +package com.jeespring.common.constant; + +/** + * 任务调度通用常量 + * + * @author JeeSpring + */ +public interface ScheduleConstants +{ + + public static final String TASK_CLASS_NAME = "__TASK_CLASS_NAME__"; + + public static final String TASK_PROPERTIES = "__TASK_PROPERTIES__"; + + /** 默认 */ + public static final String MISFIRE_DEFAULT = "0"; + + /** 立即触发执行 */ + public static final String MISFIRE_IGNORE_MISFIRES = "1"; + + /** 触发一次执行 */ + public static final String MISFIRE_FIRE_AND_PROCEED = "2"; + + /** 不触发立即执行 */ + public static final String MISFIRE_DO_NOTHING = "3"; + + public enum Status + { + /** + * 正常 + */ + NORMAL("0"), + /** + * 暂停 + */ + PAUSE("1"); + + private String value; + + private Status(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/ShiroConstants.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/ShiroConstants.java new file mode 100644 index 0000000..60c5fcb --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/constant/ShiroConstants.java @@ -0,0 +1,65 @@ +package com.jeespring.common.constant; + +/** + * Shiro通用常量 + * + * @author JeeSpring + */ +public interface ShiroConstants +{ + /** + * 当前登录的用户 + */ + public static final String CURRENT_USER = "currentUser"; + + /** + * 用户名 + */ + public static final String CURRENT_USERNAME = "username"; + + /** + * 消息key + */ + public static String MESSAGE = "message"; + + /** + * 错误key + */ + public static String ERROR = "errorMsg"; + + /** + * 编码格式 + */ + public static String ENCODING = "UTF-8"; + + /** + * 当前在线会话 + */ + public String ONLINE_SESSION = "online_session"; + + /** + * 验证码key + */ + public static final String CURRENT_CAPTCHA = "captcha"; + + /** + * 验证码开关 + */ + public static final String CURRENT_EBABLED = "captchaEbabled"; + + /** + * 验证码开关 + */ + public static final String CURRENT_TYPE = "captchaType"; + + /** + * 验证码 + */ + public static final String CURRENT_VALIDATECODE = "validateCode"; + + /** + * 验证码错误 + */ + public static final String CAPTCHA_ERROR = "captchaError"; + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidConfiguration.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidConfiguration.java new file mode 100644 index 0000000..af78412 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidConfiguration.java @@ -0,0 +1,93 @@ +package com.jeespring.common.druid; + +import java.sql.SQLException; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import com.alibaba.druid.pool.DruidDataSource; + +/** + * + * 描述:如果不使用代码手动初始化DataSource的话,监控界面的SQL监控会没有数据("是spring boot的bug???") + * @author chhliu + * 创建时间:2017年2月9日 下午10:33:08 + * @version 1.2.0 + */ +@Configuration +public class DruidConfiguration { + @Value("${spring.datasource.url}") + private String dbUrl; + @Value("${spring.datasource.username}") + private String username; + @Value("${spring.datasource.password}") + private String password; + @Value("${spring.datasource.driverClassName}") + private String driverClassName; + @Value("${spring.datasource.initialSize}") + private int initialSize; + @Value("${spring.datasource.minIdle}") + private int minIdle; + @Value("${spring.datasource.maxActive}") + private int maxActive; + @Value("${spring.datasource.maxWait}") + private int maxWait; + @Value("${spring.datasource.timeBetweenEvictionRunsMillis}") + private int timeBetweenEvictionRunsMillis; + @Value("${spring.datasource.minEvictableIdleTimeMillis}") + private int minEvictableIdleTimeMillis; + @Value("${spring.datasource.validationQuery}") + private String validationQuery; + @Value("${spring.datasource.testWhileIdle}") + private boolean testWhileIdle; + @Value("${spring.datasource.testOnBorrow}") + private boolean testOnBorrow; + @Value("${spring.datasource.testOnReturn}") + private boolean testOnReturn; + @Value("${spring.datasource.poolPreparedStatements}") + private boolean poolPreparedStatements; + @Value("${spring.datasource.maxPoolPreparedStatementPerConnectionSize}") + private int maxPoolPreparedStatementPerConnectionSize; + @Value("${spring.datasource.filters}") + private String filters; + @Value("${spring.datasource.connectionProperties}") + private String connectionProperties; + @Value("${spring.datasource.useGlobalDataSourceStat}") + private boolean useGlobalDataSourceStat; + + @Bean //声明其为Bean实例 + @Primary //在同样的DataSource中,首先使用被标注的DataSource + public DataSource dataSource(){ + DruidDataSource datasource = new DruidDataSource(); + datasource.setUrl(this.dbUrl); + datasource.setUsername(username); + datasource.setPassword(password); + datasource.setDriverClassName(driverClassName); + + //configuration + datasource.setInitialSize(initialSize); + datasource.setMinIdle(minIdle); + datasource.setMaxActive(maxActive); + datasource.setMaxWait(maxWait); + datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + datasource.setValidationQuery(validationQuery); + datasource.setTestWhileIdle(testWhileIdle); + datasource.setTestOnBorrow(testOnBorrow); + datasource.setTestOnReturn(testOnReturn); + datasource.setPoolPreparedStatements(poolPreparedStatements); + datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); + datasource.setUseGlobalDataSourceStat(useGlobalDataSourceStat); + try { + datasource.setFilters(filters); + } catch (SQLException e) { + System.err.println("druid configuration initialization filter: "+ e); + } + datasource.setConnectionProperties(connectionProperties); + return datasource; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidStatFilter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidStatFilter.java new file mode 100644 index 0000000..85e0b6f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidStatFilter.java @@ -0,0 +1,21 @@ +package com.jeespring.common.druid; + +import javax.servlet.annotation.WebFilter; +import javax.servlet.annotation.WebInitParam; + +import com.alibaba.druid.support.http.WebStatFilter; + +/** + * Druid的StatFilter + * + * @author 单红宇(365384722) + * @myblog http://blog.csdn.net/catoop/ + * @create 2016年3月17日 + */ +@WebFilter(filterName="druidWebStatFilter",urlPatterns="/*", + initParams={ + @WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源 +}) +public class DruidStatFilter extends WebStatFilter { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidStatViewServlet.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidStatViewServlet.java new file mode 100644 index 0000000..85c4cfa --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/druid/DruidStatViewServlet.java @@ -0,0 +1,26 @@ +package com.jeespring.common.druid; + +import javax.servlet.annotation.WebInitParam; +import javax.servlet.annotation.WebServlet; + +import com.alibaba.druid.support.http.StatViewServlet; + +/** + * StatViewServlet + * + * @author 单红宇(365384722) + * @myblog http://blog.csdn.net/catoop/ + * @create 2016年3月17日 + */ +@SuppressWarnings("serial") +@WebServlet(urlPatterns = "/druid/*", + initParams={ + @WebInitParam(name="allow",value="192.168.16.110,127.0.0.1"),// IP白名单 (没有配置或者为空,则允许所有访问) + @WebInitParam(name="deny",value="192.168.16.111"),// IP黑名单 (存在共同时,deny优先于allow) + //WebInitParam(name="loginUsername",value="shanhy"),// 用户名 + //WebInitParam(name="loginPassword",value="shanhypwd"),// 密码 + @WebInitParam(name="resetEnable",value="false")// 禁用HTML页面上的“Reset All”功能 + }) +public class DruidStatViewServlet extends StatViewServlet { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/exception/job/TaskException.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/exception/job/TaskException.java new file mode 100644 index 0000000..9e6f595 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/exception/job/TaskException.java @@ -0,0 +1,35 @@ +package com.jeespring.common.exception.job; + +/** + * 计划策略异常 + * + * @author JeeSpring + */ +public class TaskException extends Exception +{ + private static final long serialVersionUID = 1L; + + private Code code; + + public TaskException(String msg, Code code) + { + this(msg, code, null); + } + + public TaskException(String msg, Code code, Exception nestedEx) + { + super(msg, nestedEx); + this.code = code; + } + + public Code getCode() + { + return code; + } + + public enum Code + { + TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/JeesiteFileUploadFilter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/JeesiteFileUploadFilter.java new file mode 100644 index 0000000..fb1bbab --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/JeesiteFileUploadFilter.java @@ -0,0 +1,18 @@ +package com.jeespring.common.filter; + +import com.ckfinder.connector.FileUploadFilter; + +import javax.servlet.annotation.WebFilter; +import javax.servlet.annotation.WebInitParam; + +/** + * Created by zhao.weiwei + * create on 2017/1/10 12:23 + * the email is zhao.weiwei@jyall.com. + */ +@WebFilter(urlPatterns = "/static/ckfinder/core/connector/java/connector.java", initParams = { + @WebInitParam(name = "sessionCookieName", value = "JSESSIONID"), + @WebInitParam(name = "sessionParameterName", value = "jsessionid") +}) +public class JeesiteFileUploadFilter extends FileUploadFilter { +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/LogoutFilter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/LogoutFilter.java new file mode 100644 index 0000000..6ff9599 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/LogoutFilter.java @@ -0,0 +1,111 @@ +package com.jeespring.common.filter; + +import com.jeespring.common.security.ShiroUtils; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.monitor.entity.OnlineSession; +import com.jeespring.modules.sys.dao.OnlineSessionDAO; +import com.jeespring.modules.sys.entity.SysUserOnline; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SysUserOnlineService; +import org.apache.shiro.session.SessionException; +import org.apache.shiro.subject.Subject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; +import org.springframework.web.context.support.WebApplicationContextUtils; + +import javax.servlet.ServletContext; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +/** + * 退出过滤器 + * + * @author JeeSpring + */ + +public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter +{ + private SysUserOnlineService sysUserOnlineService; + + private static final Logger log = LoggerFactory.getLogger(LogoutFilter.class); + + /** + * 退出后重定向的地址 + */ + private String loginUrl="/admin/login"; + + public String getLoginUrl() + { + return loginUrl; + } + + public void setLoginUrl(String loginUrl) + { + this.loginUrl = loginUrl; + } + + @Override + protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception + { + try + { + Subject subject = getSubject(request, response); + String redirectUrl = getRedirectUrl(request, response, subject); + try + { + User user = ShiroUtils.getUser(); + if (StringUtils.isNotNull(user)) + { + String loginName = user.getLoginName(); + SysUserOnline sysUserOnline=new SysUserOnline(); + sysUserOnline.setLoginName(user.getName()); + if(sysUserOnlineService==null){ + ServletContext context = request.getServletContext(); + ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context); + sysUserOnlineService = ctx.getBean(SysUserOnlineService.class); + } + if(sysUserOnlineService!=null){ + sysUserOnline= sysUserOnlineService.get(subject.getSession().getId().toString()); + if(sysUserOnline!=null){ + sysUserOnline.setStatus(OnlineSession.OnlineStatus.off_line.toString()); + sysUserOnlineService.save(sysUserOnline); + } + } + // 记录用户退出日志 + //SystemLogUtils.log(loginName, Constants.LOGOUT, MessageUtils.message("user.logout.success")); + } + // 退出登录 + subject.logout(); + } + catch (SessionException ise) + { + log.error("logout fail.", ise); + } + issueRedirect(request, response, redirectUrl); + } + catch (Exception e) + { + log.error("Encountered session exception during logout. This can generally safely be ignored.", e); + } + return false; + } + + /** + * 退出跳转URL + */ + @Override + protected String getRedirectUrl(ServletRequest request, ServletResponse response, Subject subject) + { + String url = getLoginUrl(); + if (StringUtils.isNotEmpty(url)) + { + return url; + } + return super.getRedirectUrl(request, response, subject); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/OnlineSessionFilter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/OnlineSessionFilter.java new file mode 100644 index 0000000..e40ecc7 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/OnlineSessionFilter.java @@ -0,0 +1,121 @@ +package com.jeespring.common.filter; + +import com.jeespring.common.constant.ShiroConstants; +import com.jeespring.common.security.ShiroUtils; +import com.jeespring.common.utils.IpUtils; +import com.jeespring.common.utils.ServletUtils; +import com.jeespring.modules.sys.dao.OnlineSessionDAO; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SysUserOnlineService; +import eu.bitwalker.useragentutils.UserAgent; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; +import org.apache.shiro.web.filter.AccessControlFilter; +import org.apache.shiro.web.util.WebUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; +import com.jeespring.modules.monitor.entity.OnlineSession; + +/** + * 自定义访问控制 + * + * @author JeeSpring + */ +public class OnlineSessionFilter //extends AccessControlFilter +{ + + /** + * 强制退出后重定向的地址 + */ + @Value("${shiro.user.loginUrl}") + private String loginUrl="/admin/login"; + + /** + * 表示是否允许访问;mappedValue就是[urls]配置中拦截器参数部分,如果允许访问返回true,否则false; + */ + //@Override + protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) + throws Exception + { + Subject subject = getSubject(request, response); + if (subject == null || subject.getSession() == null) + { + return true; + } + //Session session = onlineSessionDAO.readSession(subject.getSession().getId()); + Session session =subject.getSession(); + //&& session instanceof OnlineSession + if (session != null) + { + //OnlineSession onlineSession = (OnlineSession) session; + OnlineSession onlineSession = new OnlineSession(); + onlineSession.setId(subject.getSession().getId().toString()); + request.setAttribute(ShiroConstants.ONLINE_SESSION, onlineSession); + // 把user对象设置进去 + boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == ""; + if (isGuest == true) + { + User user = ShiroUtils.getUser(); + if (user != null) + { + onlineSession.setUserId(user.getId()); + onlineSession.setLoginName(user.getLoginName()); + if(user.getOffice()!=null) { + onlineSession.setDeptName(user.getOffice().getName()); + } + onlineSession.markAttributeChanged(); + UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); + // 获取客户端操作系统 + String os = userAgent.getOperatingSystem().getName(); + // 获取客户端浏览器 + String browser = userAgent.getBrowser().getName(); + onlineSession.setHost(IpUtils.getIpAddr((HttpServletRequest)request)); + onlineSession.setBrowser(browser); + onlineSession.setOs(os); + } + } + + if (onlineSession.getStatus() == OnlineSession.OnlineStatus.off_line) + { + return false; + } + } + return true; + } + + /** + * 表示当访问拒绝时是否已经处理了;如果返回true表示需要继续处理;如果返回false表示该拦截器实例已经处理了,将直接返回即可。 + */ + //@Override + protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception + { + Subject subject = getSubject(request, response); + if (subject != null) + { + subject.logout(); + } + //saveRequestAndRedirectToLogin(request, response); + return true; + } + + // 跳转到登录页 + //@Override + protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException + { + WebUtils.issueRedirect(request, response, loginUrl); + } + + /** + * 表示是否允许访问;mappedValue就是[urls]配置中拦截器参数部分,如果允许访问返回true,否则false; + */ + + protected Subject getSubject(ServletRequest request, ServletResponse response) { + return SecurityUtils.getSubject(); + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/PageCachingFilter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/PageCachingFilter.java new file mode 100644 index 0000000..c0a53ec --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/PageCachingFilter.java @@ -0,0 +1,26 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.filter; + +import com.jeespring.common.utils.SpringContextHolder; + +import net.sf.ehcache.CacheManager; +import net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter; + +/** + * 页面高速缓存过滤器 + * @author 黄炳桂 516821420@qq.com + * @version 2013-8-5 + */ +public class PageCachingFilter extends SimplePageCachingFilter { + + private CacheManager cacheManager = SpringContextHolder.getBean(CacheManager.class); + + @Override + protected CacheManager getCacheManager() { + this.cacheName = "pageCachingFilter"; + return cacheManager; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/SyncOnlineSessionFilter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/SyncOnlineSessionFilter.java new file mode 100644 index 0000000..dc75243 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/filter/SyncOnlineSessionFilter.java @@ -0,0 +1,80 @@ +package com.jeespring.common.filter; + +import com.jeespring.common.constant.ShiroConstants; +import com.jeespring.common.redis.RedisUtils; +import com.jeespring.common.security.ShiroUtils; +import com.jeespring.common.utils.IpUtils; +import com.jeespring.common.utils.ServletUtils; +import com.jeespring.modules.monitor.entity.OnlineSession; +import com.jeespring.modules.sys.dao.OnlineSessionDAO; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SysUserOnlineService; +import eu.bitwalker.useragentutils.UserAgent; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; +import org.apache.shiro.web.filter.PathMatchingFilter; +import org.apache.shiro.web.util.WebUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +/** + * 同步Session数据到Db + * + * @author JeeSpring + */ +public class SyncOnlineSessionFilter extends PathMatchingFilter +{ + /** + * 日志对象 + */ + private static Logger logger = LoggerFactory.getLogger(SyncOnlineSessionFilter.class); + + @Autowired + private SysUserOnlineService sysUserOnlineService; + /** + * 强制退出后重定向的地址 + */ + @Value("${shiro.user.loginUrl}") + private String loginUrl; + + /** + * 同步会话数据到DB 一次请求最多同步一次 防止过多处理 需要放到Shiro过滤器之前 + * + * @param request + * @param response + * @return + * @throws Exception + */ + @Override + protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception + { + try { + OnlineSessionFilter onlineSessionFilter=new OnlineSessionFilter(); + onlineSessionFilter.isAccessAllowed(request,response,null); + //isAccessAllowed(request, response); + OnlineSession session = (OnlineSession) request.getAttribute(ShiroConstants.ONLINE_SESSION); + // 如果session stop了 也不同步 + // session停止时间,如果stopTimestamp不为null,则代表已停止 + if (session != null && session.getUserId() != null && session.getStopTimestamp() == null) + { + sysUserOnlineService.syncToDb(session); + } + return true; + }catch (Exception e){ + logger.error("SyncOnlineSessionFilter preHandle error:", e.getMessage()); + return true; + } + + } + + + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/json/AjaxJson.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/json/AjaxJson.java new file mode 100644 index 0000000..048a232 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/json/AjaxJson.java @@ -0,0 +1,73 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.common.json; + +import java.util.LinkedHashMap; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.jeespring.common.mapper.JsonMapper; + + +/** + * $.ajax后需要接受的JSON + * + * @author + * + */ +public class AjaxJson { + + private boolean success = true;// 是否成功 + private String errorCode = "-1";//错误代码 + private String msg = "操作成功";// 提示信息 + private LinkedHashMap body = new LinkedHashMap();//封装json的map + + public LinkedHashMap getBody() { + return body; + } + + public void setBody(LinkedHashMap body) { + this.body = body; + } + + public void put(String key, Object value){//向json中添加属性,在js中访问,请调用data.map.key + body.put(key, value); + } + + public void remove(String key){ + body.remove(key); + } + + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) {//向json中添加属性,在js中访问,请调用data.msg + this.msg = msg; + } + + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + @JsonIgnore//返回对象时忽略此属性 + public String getJsonStr() {//返回json字符串数组,将访问msg和key的方式统一化,都使用data.key的方式直接访问。 + + String json = JsonMapper.getInstance().toJson(this); + return json; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorCode() { + return errorCode; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/json/PrintJSON.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/json/PrintJSON.java new file mode 100644 index 0000000..1770d5b --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/json/PrintJSON.java @@ -0,0 +1,28 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.common.json; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.http.HttpServletResponse; + +public class PrintJSON { + + + public static void write(HttpServletResponse response,String content) { + response.reset(); + response.setContentType("application/json"); + response.setHeader("Cache-Control", "no-store"); + response.setCharacterEncoding("UTF-8"); + try { + PrintWriter pw=response.getWriter(); + pw.write(content); + pw.flush(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailAuthenticator.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailAuthenticator.java new file mode 100644 index 0000000..8daa501 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailAuthenticator.java @@ -0,0 +1,21 @@ +package com.jeespring.common.mail; +/** + * + */ +import javax.mail.*; + +public class MailAuthenticator extends Authenticator{ + String userName=null; + String password=null; + + public MailAuthenticator(){ + } + public MailAuthenticator(String username, String password) { + this.userName = username; + this.password = password; + } + @Override + protected PasswordAuthentication getPasswordAuthentication(){ + return new PasswordAuthentication(userName, password); + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailBody.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailBody.java new file mode 100644 index 0000000..c53b402 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailBody.java @@ -0,0 +1,96 @@ +package com.jeespring.common.mail; +/** + *发送邮件需要使用的基本信息 + * + */ +import java.util.Properties; +public class MailBody { + // 发送邮件的服务器的IP和端口 + private String mailServerHost; + private String mailServerPort = "25"; + // 邮件发送者的地址 + private String fromAddress; + // 邮件接收者的地址 + private String toAddress; + // 登陆邮件发送服务器的用户名和密码 + private String userName; + private String password; + // 是否需要身份验证 + private boolean validate = false; + // 邮件主题 + private String subject; + // 邮件的文本内容 + private String content; + // 邮件附件的文件名 + private String[] attachFileNames; + /** + * 获得邮件会话属性 + */ + public Properties getProperties(){ + Properties p = new Properties(); + p.put("mail.smtp.host", this.mailServerHost); + p.put("mail.smtp.port", this.mailServerPort); + p.put("mail.smtp.auth", validate ? "true" : "false"); + return p; + } + public String getMailServerHost() { + return mailServerHost; + } + public void setMailServerHost(String mailServerHost) { + this.mailServerHost = mailServerHost; + } + public String getMailServerPort() { + return mailServerPort; + } + public void setMailServerPort(String mailServerPort) { + this.mailServerPort = mailServerPort; + } + public boolean isValidate() { + return validate; + } + public void setValidate(boolean validate) { + this.validate = validate; + } + public String[] getAttachFileNames() { + return attachFileNames; + } + public void setAttachFileNames(String[] fileNames) { + this.attachFileNames = fileNames; + } + public String getFromAddress() { + return fromAddress; + } + public void setFromAddress(String fromAddress) { + this.fromAddress = fromAddress; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + public String getToAddress() { + return toAddress; + } + public void setToAddress(String toAddress) { + this.toAddress = toAddress; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getSubject() { + return subject; + } + public void setSubject(String subject) { + this.subject = subject; + } + public String getContent() { + return content; + } + public void setContent(String textContent) { + this.content = textContent; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailSendUtils.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailSendUtils.java new file mode 100644 index 0000000..80cbf31 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mail/MailSendUtils.java @@ -0,0 +1,154 @@ +package com.jeespring.common.mail; +/** + * 简单邮件(不带附件的邮件)发送器 + */ +import java.util.Date; +import java.util.Properties; + +import javax.mail.Address; +import javax.mail.BodyPart; +import javax.mail.Message; +import javax.mail.Multipart; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; + + +public class MailSendUtils { +/** + * 以文本格式发送邮件 + * @param mailInfo 待发送的邮件的信息 + */ + public boolean sendTextMail(MailBody mailInfo) throws Exception{ + // 判断是否需要身份认证 + MailAuthenticator authenticator = null; + Properties pro = mailInfo.getProperties(); + if (mailInfo.isValidate()) { + // 如果需要身份认证,则创建一个密码验证器 + authenticator = new MailAuthenticator(mailInfo.getUserName(), mailInfo.getPassword()); + } + // 根据邮件会话属性和密码验证器构造一个发送邮件的session + Session sendMailSession = Session.getDefaultInstance(pro,authenticator); + // logBefore(logger, "构造一个发送邮件的session"); + + // 根据session创建一个邮件消息 + Message mailMessage = new MimeMessage(sendMailSession); + // 创建邮件发送者地址 + Address from = new InternetAddress(mailInfo.getFromAddress()); + // 设置邮件消息的发送者 + mailMessage.setFrom(from); + // 创建邮件的接收者地址,并设置到邮件消息中 + Address to = new InternetAddress(mailInfo.getToAddress()); + mailMessage.setRecipient(Message.RecipientType.TO,to); + // 设置邮件消息的主题 + mailMessage.setSubject(mailInfo.getSubject()); + // 设置邮件消息发送的时间 + mailMessage.setSentDate(new Date()); + // 设置邮件消息的主要内容 + String mailContent = mailInfo.getContent(); + mailMessage.setText(mailContent); + // 发送邮件 + Transport.send(mailMessage); + System.out.println("发送成功!"); + return true; + } + + /** + * 以HTML格式发送邮件 + * @param mailInfo 待发送的邮件信息 + */ + public boolean sendHtmlMail(MailBody mailInfo) throws Exception{ + // 判断是否需要身份认证 + MailAuthenticator authenticator = null; + Properties pro = mailInfo.getProperties(); + //如果需要身份认证,则创建一个密码验证器 + if (mailInfo.isValidate()) { + authenticator = new MailAuthenticator(mailInfo.getUserName(), mailInfo.getPassword()); + } + // 根据邮件会话属性和密码验证器构造一个发送邮件的session + Session sendMailSession = Session.getDefaultInstance(pro,authenticator); + + // 根据session创建一个邮件消息 + Message mailMessage = new MimeMessage(sendMailSession); + // 创建邮件发送者地址 + Address from = new InternetAddress(mailInfo.getFromAddress()); + // 设置邮件消息的发送者 + mailMessage.setFrom(from); + // 创建邮件的接收者地址,并设置到邮件消息中 + Address to = new InternetAddress(mailInfo.getToAddress()); + // Message.RecipientType.TO属性表示接收者的类型为TO + mailMessage.setRecipient(Message.RecipientType.TO,to); + // 设置邮件消息的主题 + mailMessage.setSubject(mailInfo.getSubject()); + // 设置邮件消息发送的时间 + mailMessage.setSentDate(new Date()); + // MiniMultipart类是一个容器类,包含MimeBodyPart类型的对象 + Multipart mainPart = new MimeMultipart(); + // 创建一个包含HTML内容的MimeBodyPart + BodyPart html = new MimeBodyPart(); + // 设置HTML内容 + html.setContent(mailInfo.getContent(), "text/html; charset=utf-8"); + mainPart.addBodyPart(html); + // 将MiniMultipart对象设置为邮件内容 + mailMessage.setContent(mainPart); + // 发送邮件 + Transport.send(mailMessage); + return true; + } + + /** + * @param SMTP + * 邮件服务器 + * @param PORT + * 端口 + * @param EMAIL + * 本邮箱账号 + * @param PAW + * 本邮箱密码 + * @param toEMAIL + * 对方箱账号 + * @param TITLE + * 标题 + * @param CONTENT + * 内容 + * @param TYPE + * 1:文本格式;2:HTML格式 + */ + public static boolean sendEmail(String SMTP, String PORT, String EMAIL, + String PAW, String toEMAIL, String TITLE, String CONTENT, + String TYPE) { + + // 这个类主要是设置邮件 + MailBody mailInfo = new MailBody(); + + mailInfo.setMailServerHost(SMTP); + mailInfo.setMailServerPort(PORT); + mailInfo.setValidate(true); + mailInfo.setUserName(EMAIL); + mailInfo.setPassword(PAW); + mailInfo.setFromAddress(EMAIL); + mailInfo.setToAddress(toEMAIL); + mailInfo.setSubject(TITLE); + mailInfo.setContent(CONTENT); + // 这个类主要来发送邮件 + + MailSendUtils sms = new MailSendUtils(); + try { + if ("1".equals(TYPE)) { + return sms.sendTextMail(mailInfo); + } else { + return sms.sendHtmlMail(mailInfo); + } + } catch (Exception e) { + return false; + } + + } + + + + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/BeanMapper.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/BeanMapper.java new file mode 100644 index 0000000..c0f7403 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/BeanMapper.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2005-2012 springside.org.cn + */ +package com.jeespring.common.mapper; + +import java.util.Collection; +import java.util.List; + +import org.dozer.DozerBeanMapper; + +import com.google.common.collect.Lists; + +/** + * 简单封装Dozer, 实现深度转换Bean<->Bean的Mapper.实现: + * + * 1. 持有Mapper的单例. + * 2. 返回值类型转换. + * 3. 批量转换Collection中的所有对象. + * 4. 区分创建新的B对象与将对象A值复制到已存在的B对象两种函数. + * + * @author calvin + * @version 2013-01-15 + */ +public class BeanMapper { + + /** + * 持有Dozer单例, 避免重复创建DozerMapper消耗资源. + */ + private static DozerBeanMapper dozer = new DozerBeanMapper(); + + /** + * 基于Dozer转换对象的类型. + */ + public static T map(Object source, Class destinationClass) { + return dozer.map(source, destinationClass); + } + + /** + * 基于Dozer转换Collection中对象的类型. + */ + @SuppressWarnings("rawtypes") + public static List mapList(Collection sourceList, Class destinationClass) { + List destinationList = Lists.newArrayList(); + for (Object sourceObject : sourceList) { + T destinationObject = dozer.map(sourceObject, destinationClass); + destinationList.add(destinationObject); + } + return destinationList; + } + + /** + * 基于Dozer将对象A的值拷贝到对象B中. + */ + public static void copy(Object source, Object destinationObject) { + dozer.map(source, destinationObject); + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/JaxbMapper.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/JaxbMapper.java new file mode 100644 index 0000000..284426c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/JaxbMapper.java @@ -0,0 +1,169 @@ +/** + * Copyright (c) 2005-2012 springside.org.cn + */ +package com.jeespring.common.mapper; + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.Collection; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.namespace.QName; + +import org.springframework.http.converter.HttpMessageConversionException; +import org.springframework.util.Assert; + +import com.jeespring.common.utils.Exceptions; +import com.jeespring.common.utils.Reflections; +import com.jeespring.common.utils.StringUtils; + +/** + * 使用Jaxb2.0实现XML<->Java Object的Mapper. + * + * 在创建时需要设定所有需要序列化的Root对象的Class. + * 特别支持Root对象是Collection的情形. + * + * @author calvin + * @version 2013-01-15 + */ +@SuppressWarnings("rawtypes") +public class JaxbMapper { + + private static ConcurrentMap jaxbContexts = new ConcurrentHashMap(); + + /** + * Java Object->Xml without encoding. + */ + public static String toXml(Object root) { + Class clazz = Reflections.getUserClass(root); + return toXml(root, clazz, null); + } + + /** + * Java Object->Xml with encoding. + */ + public static String toXml(Object root, String encoding) { + Class clazz = Reflections.getUserClass(root); + return toXml(root, clazz, encoding); + } + + /** + * Java Object->Xml with encoding. + */ + public static String toXml(Object root, Class clazz, String encoding) { + try { + StringWriter writer = new StringWriter(); + createMarshaller(clazz, encoding).marshal(root, writer); + return writer.toString(); + } catch (JAXBException e) { + throw Exceptions.unchecked(e); + } + } + + /** + * Java Collection->Xml without encoding, 特别支持Root Element是Collection的情形. + */ + public static String toXml(Collection root, String rootName, Class clazz) { + return toXml(root, rootName, clazz, null); + } + + /** + * Java Collection->Xml with encoding, 特别支持Root Element是Collection的情形. + */ + public static String toXml(Collection root, String rootName, Class clazz, String encoding) { + try { + CollectionWrapper wrapper = new CollectionWrapper(); + wrapper.collection = root; + + JAXBElement wrapperElement = new JAXBElement(new QName(rootName), + CollectionWrapper.class, wrapper); + + StringWriter writer = new StringWriter(); + createMarshaller(clazz, encoding).marshal(wrapperElement, writer); + + return writer.toString(); + } catch (JAXBException e) { + throw Exceptions.unchecked(e); + } + } + + /** + * Xml->Java Object. + */ + @SuppressWarnings("unchecked") + public static T fromXml(String xml, Class clazz) { + try { + StringReader reader = new StringReader(xml); + return (T) createUnmarshaller(clazz).unmarshal(reader); + } catch (JAXBException e) { + throw Exceptions.unchecked(e); + } + } + + /** + * 创建Marshaller并设定encoding(可为null). + * 线程不安全,需要每次创建或pooling。 + */ + public static Marshaller createMarshaller(Class clazz, String encoding) { + try { + JAXBContext jaxbContext = getJaxbContext(clazz); + + Marshaller marshaller = jaxbContext.createMarshaller(); + + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + + if (StringUtils.isNotBlank(encoding)) { + marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding); + } + + return marshaller; + } catch (JAXBException e) { + throw Exceptions.unchecked(e); + } + } + + /** + * 创建UnMarshaller. + * 线程不安全,需要每次创建或pooling。 + */ + public static Unmarshaller createUnmarshaller(Class clazz) { + try { + JAXBContext jaxbContext = getJaxbContext(clazz); + return jaxbContext.createUnmarshaller(); + } catch (JAXBException e) { + throw Exceptions.unchecked(e); + } + } + + protected static JAXBContext getJaxbContext(Class clazz) { + Assert.notNull(clazz, "'clazz' must not be null"); + JAXBContext jaxbContext = jaxbContexts.get(clazz); + if (jaxbContext == null) { + try { + jaxbContext = JAXBContext.newInstance(clazz, CollectionWrapper.class); + jaxbContexts.putIfAbsent(clazz, jaxbContext); + } catch (JAXBException ex) { + throw new HttpMessageConversionException("Could not instantiate JAXBContext for class [" + clazz + + "]: " + ex.getMessage(), ex); + } + } + return jaxbContext; + } + + /** + * 封装Root Element 是 Collection的情况. + */ + public static class CollectionWrapper { + + @XmlAnyElement + protected Collection collection; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/JsonMapper.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/JsonMapper.java new file mode 100644 index 0000000..050c97d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/JsonMapper.java @@ -0,0 +1,257 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.mapper; + +import java.io.IOException; +import java.util.TimeZone; + +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser.Feature; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.util.JSONPObject; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; + +/** + * 简单封装Jackson,实现JSON String<->Java Object的Mapper. + * 封装不同的输出风格, 使用不同的builder函数创建实例. + * @author 黄炳桂 516821420@qq.com + * @version 2013-11-15 + */ +public class JsonMapper extends ObjectMapper { + + private static final long serialVersionUID = 1L; + + private static Logger logger = LoggerFactory.getLogger(JsonMapper.class); + + private static JsonMapper mapper; + + public JsonMapper() { + this(Include.NON_EMPTY); + } + + public JsonMapper(Include include) { + // 设置输出时包含属性的风格 + if (include != null) { + this.setSerializationInclusion(include); + } + // 允许单引号、允许不带引号的字段名称 + this.enableSimple(); + // 设置输入时忽略在JSON字符串中存在但Java对象实际没有的属性 + this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + // 空值处理为空串 + this.getSerializerProvider().setNullValueSerializer(new JsonSerializer(){ + @Override + public void serialize(Object value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(""); + } + }); + // 进行HTML解码。 + this.registerModule(new SimpleModule().addSerializer(String.class, new JsonSerializer(){ + @Override + public void serialize(String value, JsonGenerator jgen, + SerializerProvider provider) throws IOException, + JsonProcessingException { + jgen.writeString(StringEscapeUtils.unescapeHtml4(value)); + } + })); + // 设置时区 + this.setTimeZone(TimeZone.getDefault());//getTimeZone("GMT+8:00") + } + + /** + * 创建只输出非Null且非Empty(如List.isEmpty)的属性到Json字符串的Mapper,建议在外部接口中使用. + */ + public static JsonMapper getInstance() { + if (mapper == null){ + mapper = new JsonMapper().enableSimple(); + } + return mapper; + } + + /** + * 创建只输出初始值被改变的属性到Json字符串的Mapper, 最节约的存储方式,建议在内部接口中使用。 + */ + public static JsonMapper nonDefaultMapper() { + if (mapper == null){ + mapper = new JsonMapper(Include.NON_DEFAULT); + } + return mapper; + } + + /** + * Object可以是POJO,也可以是Collection或数组。 + * 如果对象为Null, 返回"null". + * 如果集合为空集合, 返回"[]". + */ + public String toJson(Object object) { + try { + return this.writeValueAsString(object); + } catch (IOException e) { + logger.warn("write to json string error:" + object, e); + return null; + } + } + + /** + * 反序列化POJO或简单Collection如List. + * + * 如果JSON字符串为Null或"null"字符串, 返回Null. + * 如果JSON字符串为"[]", 返回空集合. + * + * 如需反序列化复杂Collection如List, 请使用fromJson(String,JavaType) + * @see #fromJson(String, JavaType) + */ + public T fromJson(String jsonString, Class clazz) { + if (StringUtils.isEmpty(jsonString)) { + return null; + } + try { + return this.readValue(jsonString, clazz); + } catch (IOException e) { + logger.warn("parse json string error:" + jsonString, e); + return null; + } + } + + /** + * 反序列化复杂Collection如List, 先使用函數createCollectionType构造类型,然后调用本函数. + * @see #createCollectionType(Class, Class...) + */ + @SuppressWarnings("unchecked") + public T fromJson(String jsonString, JavaType javaType) { + if (StringUtils.isEmpty(jsonString)) { + return null; + } + try { + return (T) this.readValue(jsonString, javaType); + } catch (IOException e) { + logger.warn("parse json string error:" + jsonString, e); + return null; + } + } + + /** + * 構造泛型的Collection Type如: + * ArrayList, 则调用constructCollectionType(ArrayList.class,MyBean.class) + * HashMap, 则调用(HashMap.class,String.class, MyBean.class) + */ + public JavaType createCollectionType(Class collectionClass, Class... elementClasses) { + return this.getTypeFactory().constructParametricType(collectionClass, elementClasses); + } + + /** + * 當JSON裡只含有Bean的部分屬性時,更新一個已存在Bean,只覆蓋該部分的屬性. + */ + @SuppressWarnings("unchecked") + public T update(String jsonString, T object) { + try { + return (T) this.readerForUpdating(object).readValue(jsonString); + } catch (JsonProcessingException e) { + logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e); + } catch (IOException e) { + logger.warn("update json string:" + jsonString + " to object:" + object + " error.", e); + } + return null; + } + + /** + * 輸出JSONP格式數據. + */ + public String toJsonP(String functionName, Object object) { + return toJson(new JSONPObject(functionName, object)); + } + + /** + * 設定是否使用Enum的toString函數來讀寫Enum, + * 為False時時使用Enum的name()函數來讀寫Enum, 默認為False. + * 注意本函數一定要在Mapper創建後, 所有的讀寫動作之前調用. + */ + public JsonMapper enableEnumUseToString() { + this.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + this.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + return this; + } + + /** + * 支持使用Jaxb的Annotation,使得POJO上的annotation不用与Jackson耦合。 + * 默认会先查找jaxb的annotation,如果找不到再找jackson的。 + */ + public JsonMapper enableJaxbAnnotation() { + JaxbAnnotationModule module = new JaxbAnnotationModule(); + this.registerModule(module); + return this; + } + + /** + * 允许单引号 + * 允许不带引号的字段名称 + */ + public JsonMapper enableSimple() { + this.configure(Feature.ALLOW_SINGLE_QUOTES, true); + this.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); + return this; + } + + /** + * 取出Mapper做进一步的设置或使用其他序列化API. + */ + public ObjectMapper getMapper() { + return this; + } + + /** + * 对象转换为JSON字符串 + * @param object + * @return + */ + public static String toJsonString(Object object){ + return JsonMapper.getInstance().toJson(object); + } + + /** + * JSON字符串转换为对象 + * @param jsonString + * @param clazz + * @return + */ + public static Object fromJsonString(String jsonString, Class clazz){ + return JsonMapper.getInstance().fromJson(jsonString, clazz); + } + + /** + * 测试 + */ +// public static void main(String[] args) { +// List> list = Lists.newArrayList(); +// Map map = Maps.newHashMap(); +// map.put("id", 1); +// map.put("pId", -1); +// map.put("name", "根节点"); +// list.add(map); +// map = Maps.newHashMap(); +// map.put("id", 2); +// map.put("pId", 1); +// map.put("name", "你好"); +// map.put("open", true); +// list.add(map); +// String json = JsonMapper.getInstance().toJson(list); +// System.out.println(json); +// } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/adapters/MapAdapter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/adapters/MapAdapter.java new file mode 100644 index 0000000..78edf3f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/adapters/MapAdapter.java @@ -0,0 +1,30 @@ +package com.jeespring.common.mapper.adapters; + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +public class MapAdapter extends XmlAdapter> { + + @Override + public MapConvertor marshal(Map map) throws Exception { + MapConvertor convertor = new MapConvertor(); + for (Map.Entry entry : map.entrySet()) { + MapConvertor.MapEntry e = new MapConvertor.MapEntry(entry); + convertor.addEntry(e); + } + return convertor; + } + + @Override + public Map unmarshal(MapConvertor map) throws Exception { + Map result = new HashMap(); + for (MapConvertor.MapEntry e : map.getEntries()) { + result.put(e.getKey(), e.getValue()); + } + return result; + } + +} + diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/adapters/MapConvertor.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/adapters/MapConvertor.java new file mode 100644 index 0000000..197860f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/mapper/adapters/MapConvertor.java @@ -0,0 +1,63 @@ +package com.jeespring.common.mapper.adapters; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name = "MapConvertor") +@XmlAccessorType(XmlAccessType.FIELD) +public class MapConvertor { + + private List entries = new ArrayList(); + + public void addEntry(MapEntry entry) { + entries.add(entry); + } + + public List getEntries() { + return entries; + } + + public static class MapEntry { + + private String key; + + private Object value; + + public MapEntry() { + super(); + } + + public MapEntry(Map.Entry entry) { + super(); + this.key = entry.getKey(); + this.value = entry.getValue(); + } + + public MapEntry(String key, Object value) { + super(); + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/AbstractBaseEntity.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/AbstractBaseEntity.java new file mode 100644 index 0000000..a8cbff1 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/AbstractBaseEntity.java @@ -0,0 +1,184 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence; + +import java.util.Date; +import java.util.HashMap; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.annotation.JSONField; +import com.jeespring.common.utils.IdGen; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.utils.UserUtils; +import org.apache.commons.lang3.StringUtils; +import org.hibernate.validator.constraints.Length; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * 数据Entity类 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +public abstract class AbstractBaseEntity extends AbstractEntity { + + private static final long serialVersionUID = 1L; + + protected String remarks; // 备注 + protected User createBy; // 创建者 + protected Date createDate; // 创建日期 + protected User updateBy; // 更新者 + protected Date updateDate; // 更新日期 + protected String delFlag; // 删除标记(0:正常;1:删除;2:审核) + protected HashMap extendMap;//HashMap对象的拓展属性 + protected JSONObject jsonObject;//JSONObject对象的拓展属性 + protected Integer totalCount; + protected String totalDate; + protected String totalType; + + public void setExtendMap(String item,Object object) { + if(extendMap==null) { + extendMap = new HashMap(); + } + extendMap.put(item,object); + } + + public HashMap getExtendMap() { + return extendMap; + } + + public JSONObject setExtendObject(String item,Object object){ + if(jsonObject==null) { + jsonObject = JSON.parseObject(JSON.toJSONString(this)); + } + jsonObject.put(item,object); + return jsonObject; + } + + public AbstractBaseEntity() { + super(); + this.delFlag = DEL_FLAG_NORMAL; + } + + public AbstractBaseEntity(String id) { + super(id); + } + + /** + * 插入之前执行方法,需要手动调用 + */ + @Override + public void preInsert(){ + // 不限制ID为UUID,调用setIsNewRecord()使用自定义ID + if (!this.isNewRecord){ + setId(IdGen.uuid()); + } + User user = UserUtils.getUser(); + if (StringUtils.isNotBlank(user.getId())){ + this.updateBy = user; + this.createBy = user; + } + this.updateDate = new Date(); + this.createDate = this.updateDate; + } + + /** + * 更新之前执行方法,需要手动调用 + */ + @Override + public void preUpdate(){ + User user = UserUtils.getUser(); + if (StringUtils.isNotBlank(user.getId())){ + this.updateBy = user; + } + this.updateDate = new Date(); + } + + @Length(min=0, max=255) + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } + + @JsonIgnore + @JSONField(serialize=false) + public User getCreateBy() { + return createBy; + } + + public void setCreateBy(User createBy) { + this.createBy = createBy; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + @JsonIgnore + @JSONField(serialize=false) + public User getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(User updateBy) { + this.updateBy = updateBy; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + @JsonIgnore + @JSONField(serialize=false) + @Length(min=1, max=1) + public String getDelFlag() { + if(delFlag==null) { + delFlag = "0"; + } + return delFlag; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public String getTotalDate() { + return totalDate; + } + + public void setTotalDate(String totalDate) { + this.totalDate = totalDate; + } + + public String getTotalType() { + return totalType; + } + + public void setTotalType(String totalType) { + this.totalType = totalType; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/AbstractEntity.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/AbstractEntity.java new file mode 100644 index 0000000..6428bb3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/AbstractEntity.java @@ -0,0 +1,237 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.utils.UserUtils; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +import javax.xml.bind.annotation.XmlTransient; +import java.io.Serializable; +import java.util.Map; + +/** + * Entity支持类 + * + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +//@SupTreeList +public abstract class AbstractEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 实体编号(唯一标识) + */ + protected String id; + + /** + * 当前用户 + */ + protected User currentUser; + + /** + * 当前实体分页对象 + */ + protected Page page; + private String orderBy = ""; // 标准查询有效, 实例: updatedate desc, name asc + private String groupBy = ""; // 标准查询有效, 实例: updatedate desc, name asc + private String where = ""; // 标准查询条件 + protected int pageNo = 1; // 当前页码 + protected int pageSize = Integer.valueOf(Global.getConfig("page.pageSize")); // 页面大小,设置为“-1”表示不进行分页(分页无效) + + /** + * 自定义SQL(SQL标识,SQL内容) + */ + protected Map sqlMap; + + /** + * 是否是新记录(默认:false),调用setIsNewRecord()设置新记录,使用自定义ID。 + * 设置为true后强制执行插入语句,ID不会自动生成,需从手动传入。 + */ + protected boolean isNewRecord = false; + + public AbstractEntity() { + + } + + public AbstractEntity(String id) { + this(); + this.id = id; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @JsonIgnore + @XmlTransient + @JSONField(serialize=false) + public User getCurrentUser() { + if (currentUser == null) { + currentUser = UserUtils.getUser(); + } + return currentUser; + } + + public void setCurrentUser(User currentUser) { + this.currentUser = currentUser; + } + + @JsonIgnore + @XmlTransient + @JSONField(serialize=false) + public Page getPage() { + if (page == null) { + page = new Page(); + } + return page; + } + + public Page setPage(Page page) { + this.page = page; + return page; + } + + @JsonIgnore + @XmlTransient + @JSONField(serialize=false) + public String getWhere() { + return where; + } + + public void setWhere(String where) { + this.where = where; + } + + public String getOrderBy() { + return orderBy; + } + + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + public String getGroupBy() { + return groupBy; + } + + public void setGroupBy(String groupBy) { + this.groupBy = groupBy; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + @JsonIgnore + @XmlTransient + @JSONField(serialize=false) + public Map getSqlMap() { + if (sqlMap == null) { + sqlMap = Maps.newHashMap(); + } + return sqlMap; + } + + public void setSqlMap(Map sqlMap) { + this.sqlMap = sqlMap; + } + + /** + * 插入之前执行方法,子类实现 + */ + public abstract void preInsert(); + + /** + * 更新之前执行方法,子类实现 + */ + public abstract void preUpdate(); + + /** + * 是否是新记录(默认:false),调用setIsNewRecord()设置新记录,使用自定义ID。 + * 设置为true后强制执行插入语句,ID不会自动生成,需从手动传入。 + * + * @return + */ + public boolean getIsNewRecord() { + return isNewRecord || StringUtils.isBlank(getId()); + } + + /** + * 是否是新记录(默认:false),调用setIsNewRecord()设置新记录,使用自定义ID。 + * 设置为true后强制执行插入语句,ID不会自动生成,需从手动传入。 + */ + public void setIsNewRecord(boolean isNewRecord) { + this.isNewRecord = isNewRecord; + } + + /** + * 全局变量对象 + */ + @JsonIgnore + @JSONField(serialize=false) + public Global getGlobal() { + return new Global(); + } + /** + * 获取数据库名称,该方法至关重要,在所有的mapper里面都是用 + */ + @JsonIgnore + @JSONField(serialize=false) + public String getDbName() { + return Global.getJdbcType(); + } + + @Override + public boolean equals(Object obj) { + if (null == obj) { + return false; + } + if (this == obj) { + return true; + } + if (!getClass().equals(obj.getClass())) { + return false; + } + AbstractEntity that = (AbstractEntity) obj; + return null == this.getId() ? false : this.getId().equals(that.getId()); + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } + + /** + * 删除标记(0:正常;1:删除;2:审核;) + */ + public static final String DEL_FLAG_NORMAL = "0"; + public static final String DEL_FLAG_DELETE = "1"; + public static final String DEL_FLAG_AUDIT = "2"; + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/ActEntity.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/ActEntity.java new file mode 100644 index 0000000..950a4eb --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/ActEntity.java @@ -0,0 +1,57 @@ +/** + * Copyright © 2012-2016 JeeSpring All rights reserved. + */ +package com.jeespring.common.persistence; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.jeespring.modules.act.entity.Act; + +/** + * Activiti Entity类 + * @author JeeSpring + * @version 2013-05-28 + */ +public abstract class ActEntity extends AbstractBaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + protected Act act; // 流程任务对象 + + public ActEntity() { + super(); + } + + public ActEntity(String id) { + super(id); + } + + @JsonIgnore + public Act getAct() { + if (act == null){ + act = new Act(); + } + return act; + } + + public void setAct(Act act) { + this.act = act; + } + + /** + * 获取流程实例ID + * @return + */ + public String getProcInsId() { + return this.getAct().getProcInsId(); + } + + /** + * 设置流程实例ID + * @param procInsId + */ + public void setProcInsId(String procInsId) { + this.getAct().setProcInsId(procInsId); + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceBaseDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceBaseDao.java new file mode 100644 index 0000000..9dc406e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceBaseDao.java @@ -0,0 +1,129 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +/** + * DAO支持类实现 + * + * @param + * * * * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +public interface InterfaceBaseDao extends InterfaceDao { + + /** + * 获取单条数据 + * + * @param id + * @return + */ + T get(String id); + + /** + * 获取单条数据 + * + * @param entity + * @return + */ + T get(T entity); + + /** + * 根据实体名称和字段名称和字段值获取唯一记录 + * + * @param + * @param entityClass + * @param propertyName + * @param value + * @return + */ + T findUniqueByProperty(@Param(value = "propertyName") String propertyName, @Param(value = "value") Object value); + + /** + * 查询统计列表,如果需要分页,请设置分页对象,如:entity.setPage(new Page()); + * + * @param entity + * @return + */ + List total(T entity); + + /** + * 查询数据列表,如果需要分页,请设置分页对象,如:entity.setPage(new Page()); + * + * @param entity + * @return + */ + List findList(T entity); + + /** + * 查询所有数据列表 + * + * @param entity + * @return + */ + List findAllList(T entity); + + /** + * 查询所有数据列表 + * + * @return + * @see public List findAllList(T entity) + */ + @Deprecated + List findAllList(); + + /** + * 插入数据 + * + * @param entity + * @return + */ + int insert(T entity); + + /** + * 更新数据 + * + * @param entity + * @return + */ + int update(T entity); + + /** + * 删除数据(一般为逻辑删除,更新del_flag字段为1) + * + * @param id + * @return + * @see public int delete(T entity) + */ + @Deprecated + int delete(String id); + + /** + * 删除数据(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + * @param id + * @see public int delete(T entity) + * @return + */ + @Deprecated + int deleteByLogic(String id); + + /** + * 删除数据(一般为逻辑删除,更新del_flag字段为1) + * + * @param entity + * @return + */ + int delete(T entity); + + /** + * 删除数据(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + * @param entity + * @return + */ + int deleteByLogic(T entity); + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceBaseService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceBaseService.java new file mode 100644 index 0000000..bc36476 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceBaseService.java @@ -0,0 +1,91 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence; + +import com.jeespring.modules.server.entity.SysServer; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * DAO支持类实现 + * + * @param + * * * * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +public interface InterfaceBaseService { + + /** + * 获取单条数据 + * + * @param id + * @return + */ + T get(String id); + + /** + * 获取单条数据 + * + * @param entity + * @return + */ + T get(T entity); + + T getCache(String id); + + List totalCache(T entity); + /** + * 查询统计列表,如果需要分页,请设置分页对象,如:entity.setPage(new Page()); + * + * @param entity + * @return + */ + List total(T entity); + + /** + * 查询数据列表,如果需要分页,请设置分页对象,如:entity.setPage(new Page()); + * + * @param entity + * @return + */ + List findList(T entity); + + List findAllList(T entity); + + List findListCache(T entity); + + Page findPage(Page page, T entity); + + Page findPageCache(Page page, T entity); + + /** + * 插入数据 + * + * @param entity + * @return + */ + void save(T entity); + + /** + * 删除数据(一般为逻辑删除,更新del_flag字段为1) + * + * @param entity + * @return + * @see public int delete(T entity) + * @Deprecated + */ + void delete(T entity); + + /** + * 删除数据(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + * @param entity + * @see public int delete(T entity) + * @return + * @Deprecated + */ + void deleteByLogic(T entity); + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceDao.java new file mode 100644 index 0000000..3ecc661 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/InterfaceDao.java @@ -0,0 +1,13 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence; + +/** + * DAO支持类实现 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +public interface InterfaceDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/Page.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/Page.java new file mode 100644 index 0000000..08bd053 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/Page.java @@ -0,0 +1,711 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.common.config.Global; +import org.apache.commons.lang3.StringUtils; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.jeespring.common.utils.CookieUtils; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +/** + * 分页类 + * @author 黄炳桂 516821420@qq.com + * @version 2013-7-2 + * @param + */ +public class Page implements Serializable { + + protected int pageNo = 1; // 当前页码 + protected int pageSize = Integer.valueOf(Global.getConfig("page.pageSize")); // 页面大小,设置为“-1”表示不进行分页(分页无效) + + protected long count;// 总记录数,设置为“-1”表示不查询总数 + + protected int first;// 首页索引 + protected int last;// 尾页索引 + protected int prev;// 上一页索引 + protected int next;// 下一页索引 + + private boolean firstPage;//是否是第一页 + private boolean lastPage;//是否是最后一页 + + protected int length = 8;// 显示页面长度 + protected int slider = 1;// 前后显示页面长度 + + private List list = new ArrayList(); + + private String orderBy = ""; // 标准查询有效, 实例: updatedate desc, name asc + + protected String funcName = "page"; // 设置点击页码调用的js函数名称,默认为page,在一页有多个分页对象时使用。 + + protected String funcParam = ""; // 函数的附加参数,第三个参数值。 + + private String message = ""; // 设置提示消息,显示在“共n条”之后 + + public Page() { + this.pageSize = -1; + } + + /** + * 构造方法 + * @param request 传递 repage 参数,来记住页码 + * @param response 用于设置 Cookie,记住页码 + */ + public Page(HttpServletRequest request, HttpServletResponse response){ + this(request, response, -2); + } + + public Page(int pageNo, int pageSize,String orderBy){ + this(pageNo, pageSize,0); + this.orderBy=orderBy; + } + + + /** + * 构造方法 + * @param request 传递 repage 参数,来记住页码 + * @param response 用于设置 Cookie,记住页码 + * @param defaultPageSize 默认分页大小,如果传递 -1 则为不分页,返回所有数据 + */ + public Page(HttpServletRequest request, HttpServletResponse response, int defaultPageSize){ + // 设置页码参数(传递repage参数,来记住页码) + String no = request.getParameter("pageNo"); + if (StringUtils.isNumeric(no)){ + CookieUtils.setCookie(response, "pageNo", no); + this.setPageNo(Integer.parseInt(no)); + }else if (request.getParameter("repage")!=null){ + no = CookieUtils.getCookie(request, "pageNo"); + if (StringUtils.isNumeric(no)){ + this.setPageNo(Integer.parseInt(no)); + } + } + // 设置页面大小参数(传递repage参数,来记住页码大小) + String size = request.getParameter("pageSize"); + if (StringUtils.isNumeric(size)){ + CookieUtils.setCookie(response, "pageSize", size); + this.setPageSize(Integer.parseInt(size)); + }else if (request.getParameter("repage")!=null){ + no = CookieUtils.getCookie(request, "pageSize"); + if (StringUtils.isNumeric(size)){ + this.setPageSize(Integer.parseInt(size)); + } + }else if (defaultPageSize != -2){ + this.pageSize = defaultPageSize; + } + // 设置排序参数 + String orderBy = request.getParameter("orderBy"); + if (StringUtils.isNotBlank(orderBy)){ + this.setOrderBy(orderBy); + } + } + + /** + * 构造方法 + * @param pageNo 当前页码 + * @param pageSize 分页大小 + */ + public Page(int pageNo, int pageSize) { + this(pageNo, pageSize, 0); + } + + /** + * 构造方法 + * @param pageNo 当前页码 + * @param pageSize 分页大小 + * @param count 数据条数 + */ + public Page(int pageNo, int pageSize, long count) { + this(pageNo, pageSize, count, new ArrayList()); + } + + /** + * 构造方法 + * @param pageNo 当前页码 + * @param pageSize 分页大小 + * @param count 数据条数 + * @param list 本页数据对象列表 + */ + public Page(int pageNo, int pageSize, long count, List list) { + this.setCount(count); + this.setPageNo(pageNo); + this.pageSize = pageSize; + this.list = list; + } + + /** + * 初始化参数 + */ + public void initialize(){ + + //1 + this.first = 1; + + this.last = (int)(count / (this.pageSize < 1 ? 20 : this.pageSize) + first - 1); + + if (this.count % this.pageSize != 0 || this.last == 0) { + this.last++; + } + + if (this.last < this.first) { + this.last = this.first; + } + + if (this.pageNo <= 1) { + this.pageNo = this.first; + this.firstPage=true; + } + + if (this.pageNo >= this.last) { + this.pageNo = this.last; + this.lastPage=true; + } + + if (this.pageNo < this.last - 1) { + this.next = this.pageNo + 1; + } else { + this.next = this.last; + } + + if (this.pageNo > 1) { + this.prev = this.pageNo - 1; + } else { + this.prev = this.first; + } + + //2 + if (this.pageNo < this.first) {// 如果当前页小于首页 + this.pageNo = this.first; + } + + if (this.pageNo > this.last) {// 如果当前页大于尾页 + this.pageNo = this.last; + } + + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } + /** + * 默认输出当前分页标签 + *
${page}
+ */ + public String toStringPage() { + + StringBuilder sb = new StringBuilder(); + sb.append("
"); +// sb.append(""); + long startIndex = (pageNo-1)*pageSize + 1; + long endIndex = pageNo*pageSize <=count? pageNo*pageSize:count; + + sb.append("
"); + sb.append("显示第 "+startIndex+" 到第 "+ endIndex +" 条记录,总共 "+count+" 条记录"); + sb.append("每页显示 "); + sb.append(""); + sb.append("
    "); + sb.append("
  • 10
  • "); + sb.append("
  • 25
  • "); + sb.append("
  • 50
  • "); + sb.append("
  • 100
  • "); + sb.append("
  • 1000
  • "); + sb.append("
  • 全部
  • "); + sb.append("
"); + sb.append("
条记录
"); + sb.append("
"); +// sb.append("

每页 条记录,显示 " +startIndex+ " 到 "+ endIndex +" 条,共 "+count+" 条

"); +// sb.append("
"); +// sb.append(""); + + + + + sb.append("
"); + sb.append("
    "); + if (pageNo == first) {// 如果是首页 + sb.append("
  • \n"); + sb.append("
  • \n"); + } else { + sb.append("
  • \n"); + sb.append("
  • \n"); + } + + int begin = pageNo - (length / 2); + + if (begin < first) { + begin = first; + } + + int end = begin + length - 1; + + if (end >= last) { + end = last; + begin = end - length + 1; + if (begin < first) { + begin = first; + } + } + + if (begin > first) { + int i = 0; + for (i = first; i < first + slider && i < begin; i++) { + sb.append("
  • " + + (i + 1 - first) + "
  • \n"); + } + if (i < begin) { + sb.append("
  • ...
  • \n"); + } + } + + for (int i = begin; i <= end; i++) { + if (i == pageNo) { + sb.append("
  • " + (i + 1 - first) + + "
  • \n"); + } else { + sb.append("
  • " + + (i + 1 - first) + "
  • \n"); + } + } + + if (last - end > slider) { + sb.append("
  • ...
  • \n"); + end = last - slider; + } + + for (int i = end + 1; i <= last; i++) { + sb.append("
  • " + + (i + 1 - first) + "
  • \n"); + } + + if (pageNo == last) { + sb.append("
  • \n"); + sb.append("
  • \n"); + } else { + sb.append("
  • " + + "
  • \n"); + sb.append("
  • " + + "
  • \n"); + } + + + sb.append("
"); + sb.append("
"); + sb.append(""); +// sb.insert(0,"
    \n").append("
\n"); + +// sb.append("
"); + +// sb.insert(0,"
\n").append("
\n"); + + return sb.toString(); + } + + /** + * 默认输出当前分页标签 + *
${page}
+ */ + public String getPageHtml() { + + StringBuilder sb = new StringBuilder(); + + if (pageNo == first) {// 如果是首页 + sb.append("
  • « 上一页
  • \n"); + } else { + sb.append("
  • « 上一页
  • \n"); + } + + int begin = pageNo - (length / 2); + + if (begin < first) { + begin = first; + } + + int end = begin + length - 1; + + if (end >= last) { + end = last; + begin = end - length + 1; + if (begin < first) { + begin = first; + } + } + + if (begin > first) { + int i = 0; + for (i = first; i < first + slider && i < begin; i++) { + sb.append("
  • " + + (i + 1 - first) + "
  • \n"); + } + if (i < begin) { + sb.append("
  • ...
  • \n"); + } + } + + for (int i = begin; i <= end; i++) { + if (i == pageNo) { + sb.append("
  • " + (i + 1 - first) + + "
  • \n"); + } else { + sb.append("
  • " + + (i + 1 - first) + "
  • \n"); + } + } + + if (last - end > slider) { + sb.append("
  • ...
  • \n"); + end = last - slider; + } + + for (int i = end + 1; i <= last; i++) { + sb.append("
  • " + + (i + 1 - first) + "
  • \n"); + } + + if (pageNo == last) { + sb.append("
  • 下一页 »
  • \n"); + } else { + sb.append("
  • " + + "下一页 »
  • \n"); + } + + sb.append("
  • 当前 "); + sb.append(" / "); + sb.append(" 条,"); + sb.append("共 " + count + " 条"+(message!=null?message:"")+"
  • \n"); + + sb.insert(0,"
      \n").append("
    \n"); + + sb.append("
    "); + +// sb.insert(0,"
    \n").append("
    \n"); + + return sb.toString(); + } + protected String getSelected(int pageNo, int selectedPageNo){ + if(pageNo == selectedPageNo){ + //return "selected"; + return "active"; + }else{ + return ""; + } + + } + /** + * 获取分页HTML代码 + * @return + */ + //@JsonIgnore + public String getHtml(){ + return toStringPage(); + } + +// public static void main(String[] args) { +// Page p = new Page(3, 3); +// System.out.println(p); +// System.out.println("首页:"+p.getFirst()); +// System.out.println("尾页:"+p.getLast()); +// System.out.println("上页:"+p.getPrev()); +// System.out.println("下页:"+p.getNext()); +// } + + /** + * 获取设置总数 + * @return + */ + public long getCount() { + return count; + } + + /** + * 设置数据总数 + * @param count + */ + public void setCount(long count) { + this.count = count; + if (pageSize >= count){ + pageNo = 1; + } + } + + /** + * 获取当前页码 + * @return + */ + public int getPageNo() { + return pageNo; + } + + /** + * 设置当前页码 + * @param pageNo + */ + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + /** + * 获取页面大小 + * @return + */ + public int getPageSize() { + return pageSize; + } + + /** + * 设置页面大小(最大500) + * @param pageSize + */ + public void setPageSize(int pageSize) { + this.pageSize = pageSize <= 0 ? 10 : pageSize;// > 500 ? 500 : pageSize; + } + + /** + * 首页索引 + * @return + */ + @JsonIgnore + public int getFirst() { + return first; + } + + /** + * 尾页索引 + * @return + */ + @JsonIgnore + public int getLast() { + return last; + } + + /** + * 获取页面总数 + * @return getLast(); + */ + @JsonIgnore + public int getTotalPage() { + return getLast(); + } + + /** + * 是否为第一页 + * @return + */ + @JsonIgnore + public boolean isFirstPage() { + return firstPage; + } + + /** + * 是否为最后一页 + * @return + */ + @JsonIgnore + public boolean isLastPage() { + return lastPage; + } + + /** + * 上一页索引值 + * @return + */ + @JsonIgnore + public int getPrev() { + if (isFirstPage()) { + return pageNo; + } else { + return pageNo - 1; + } + } + + /** + * 下一页索引值 + * @return + */ + @JsonIgnore + public int getNext() { + if (isLastPage()) { + return pageNo; + } else { + return pageNo + 1; + } + } + + /** + * 获取本页数据对象列表 + * @return List + */ + public List getList() { + return list; + } + + /** + * 设置本页数据对象列表 + * @param list + */ + public Page setList(List list) { + this.list = list; + initialize(); + return this; + } + + /** + * 获取查询排序字符串 + * @return + */ + @JsonIgnore + public String getOrderBy() { + // SQL过滤,防止注入 + String reg = "(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|" + + "(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)"; + Pattern sqlPattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE); + if (sqlPattern.matcher(orderBy).find()) { + return ""; + } + return orderBy; + } + + /** + * 设置查询排序,标准查询有效, 实例: updatedate desc, name asc + */ + public void setOrderBy(String orderBy) { + this.orderBy = orderBy; + } + + /** + * 获取点击页码调用的js函数名称 + * function ${page.funcName}(pageNo){location="${ctx}/list-${category.id}${urlSuffix}?pageNo="+i;} + * @return + */ + @JsonIgnore + public String getFuncName() { + return funcName; + } + + /** + * 设置点击页码调用的js函数名称,默认为page,在一页有多个分页对象时使用。 + * @param funcName 默认为page + */ + public void setFuncName(String funcName) { + this.funcName = funcName; + } + + /** + * 获取分页函数的附加参数 + * @return + */ + @JsonIgnore + public String getFuncParam() { + return funcParam; + } + + /** + * 设置分页函数的附加参数 + * @return + */ + public void setFuncParam(String funcParam) { + this.funcParam = funcParam; + } + + /** + * 设置提示消息,显示在“共n条”之后 + * @param message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * 分页是否有效 + * @return this.pageSize==-1 + */ + @JsonIgnore + public boolean isDisabled() { + return this.pageSize==-1; + } + + /** + * 是否进行总数统计 + * @return this.count==-1 + */ + @JsonIgnore + public boolean isNotCount() { + return this.count==-1; + } + + /** + * 获取 Hibernate FirstResult + */ + public int getFirstResult(){ + int firstResult = (getPageNo() - 1) * getPageSize(); + if (firstResult >= getCount()) { + firstResult = 0; + } + return firstResult; + } + /** + * 获取 Hibernate MaxResults + */ + public int getMaxResults(){ + return getPageSize(); + } + +// /** +// * 获取 Spring data JPA 分页对象 +// */ +// public Pageable getSpringPage(){ +// List orders = new ArrayList(); +// if (orderBy!=null){ +// for (String order : StringUtils.split(orderBy, ",")){ +// String[] o = StringUtils.split(order, " "); +// if (o.length==1){ +// orders.add(new Order(Direction.ASC, o[0])); +// }else if (o.length==2){ +// if ("DESC".equals(o[1].toUpperCase())){ +// orders.add(new Order(Direction.DESC, o[0])); +// }else{ +// orders.add(new Order(Direction.ASC, o[0])); +// } +// } +// } +// } +// return new PageRequest(this.pageNo - 1, this.pageSize, new Sort(orders)); +// } +// +// /** +// * 设置 Spring data JPA 分页对象,转换为本系统分页对象 +// */ +// public void setSpringPage(org.springframework.data.domain.Page page){ +// this.pageNo = page.getNumber(); +// this.pageSize = page.getSize(); +// this.count = page.getTotalElements(); +// this.list = page.getContent(); +// } + + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/TreeDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/TreeDao.java new file mode 100644 index 0000000..497101f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/TreeDao.java @@ -0,0 +1,30 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence; + +import java.util.List; + +/** + * DAO支持类实现 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + * @param + */ +public interface TreeDao> extends InterfaceBaseDao { + + /** + * 找到所有子节点 + * @param entity + * @return + */ + List findByParentIdsLike(T entity); + + /** + * 更新所有父节点字段 + * @param entity + * @return + */ + int updateParentIds(T entity); + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/TreeEntity.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/TreeEntity.java new file mode 100644 index 0000000..c06042c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/TreeEntity.java @@ -0,0 +1,85 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence; + +import javax.validation.constraints.NotNull; + +import org.hibernate.validator.constraints.Length; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.jeespring.common.utils.Reflections; +import com.jeespring.common.utils.StringUtils; + +/** + * 数据Entity类 + * * * * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +public abstract class TreeEntity extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + + protected T parent; // 父级编号 + protected String parentIds; // 所有父级编号 + protected String name; // 机构名称 + protected Integer sort; // 排序 + + public TreeEntity() { + super(); + this.sort = 30; + } + + public TreeEntity(String id) { + super(id); + } + + /** + * 父对象,只能通过子类实现,父类实现mybatis无法读取 + * @return + */ + @JsonBackReference + @NotNull + public abstract T getParent(); + + /** + * 父对象,只能通过子类实现,父类实现mybatis无法读取 + * @return + */ + public abstract void setParent(T parent); + + @Length(min=1, max=2000) + public String getParentIds() { + return parentIds; + } + + public void setParentIds(String parentIds) { + this.parentIds = parentIds; + } + + @Length(min=1, max=100) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public String getParentId() { + String id = null; + if (parent != null){ + id = (String) Reflections.getFieldValue(parent, "id"); + } + return StringUtils.isNotBlank(id) ? id : "0"; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/annotation/MyBatisDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/annotation/MyBatisDao.java new file mode 100644 index 0000000..23bab3e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/annotation/MyBatisDao.java @@ -0,0 +1,32 @@ +/** + * Copyright © 2012-2016 JeeSpring All rights reserved. + */ +package com.jeespring.common.persistence.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.stereotype.Component; + +/** + * 标识MyBatis的DAO,方便{@link org.mybatis.spring.mapper.MapperScannerConfigurer}的扫描。 + * @author 黄炳桂 516821420@qq.com + * @version 2013-8-28 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +@Documented +@Component +public @interface MyBatisDao { + + /** + * The value may indicate a suggestion for a logical component name, + * to be turned into a Spring bean in case of an autodetected component. + * @return the suggested component name, if any + */ + String value() default ""; + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/DB2Dialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/DB2Dialect.java new file mode 100644 index 0000000..34806bf --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/DB2Dialect.java @@ -0,0 +1,89 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * DB2的分页数据库方言实现 + * + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class DB2Dialect implements Dialect { + @Override + public boolean supportsLimit() { + return true; + } + + private static String getRowNumber(String sql) { + StringBuilder rownumber = new StringBuilder(50) + .append("rownumber() over("); + + int orderByIndex = sql.toLowerCase().indexOf("order by"); + + if (orderByIndex > 0 && !hasDistinct(sql)) { + rownumber.append(sql.substring(orderByIndex)); + } + + rownumber.append(") as rownumber_,"); + + return rownumber.toString(); + } + + private static boolean hasDistinct(String sql) { + return sql.toLowerCase().contains("select distinct"); + } + + @Override + public String getLimitString(String sql, int offset, int limit) { + return getLimitString(sql, offset, Integer.toString(offset), Integer.toString(limit)); + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *
    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param offsetPlaceholder 分页开始纪录条数-占位符号 + * @param limitPlaceholder 分页纪录条数占位符号 + * @return 包含占位符的分页sql + */ + public String getLimitString(String sql, int offset, String offsetPlaceholder, String limitPlaceholder) { + int startOfSelect = sql.toLowerCase().indexOf("select"); + + StringBuilder pagingSelect = new StringBuilder(sql.length() + 100) + .append(sql.substring(0, startOfSelect)) //add the comment + .append("select * from ( select ") //nest the main query in an outer select + .append(getRowNumber(sql)); //add the rownnumber bit into the outer query select list + + if (hasDistinct(sql)) { + pagingSelect.append(" row_.* from ( ") //add another (inner) nested select + .append(sql.substring(startOfSelect)) //add the main query + .append(" ) as row_"); //close off the inner nested select + } else { + pagingSelect.append(sql.substring(startOfSelect + 6)); //add the main query + } + + pagingSelect.append(" ) as temp_ where rownumber_ "); + + //add the restriction to the outer select + if (offset > 0) { +// int end = offset + limit; + String endString = offsetPlaceholder + "+" + limitPlaceholder; + pagingSelect.append("between ").append(offsetPlaceholder) + .append("+1 and ").append(endString); + } else { + pagingSelect.append("<= ").append(limitPlaceholder); + } + + return pagingSelect.toString(); + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/DerbyDialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/DerbyDialect.java new file mode 100644 index 0000000..049a27a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/DerbyDialect.java @@ -0,0 +1,44 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class DerbyDialect implements Dialect { + @Override + public boolean supportsLimit() { + return false; + } + + @Override + public String getLimitString(String sql, int offset, int limit) { +// return getLimitString(sql,offset,Integer.toString(offset),limit,Integer.toString(limit)); + throw new UnsupportedOperationException("paged queries not supported"); + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *
    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param offsetPlaceholder 分页开始纪录条数-占位符号 + * @param limit 分页每页显示纪录条数 + * @param limitPlaceholder 分页纪录条数占位符号 + * @return 包含占位符的分页sql + */ + public String getLimitString(String sql, int offset,String offsetPlaceholder, int limit, String limitPlaceholder) { + throw new UnsupportedOperationException( "paged queries not supported" ); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/Dialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/Dialect.java new file mode 100644 index 0000000..a75e6ec --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/Dialect.java @@ -0,0 +1,33 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +/** + * 类似hibernate的Dialect,但只精简出分页部分 + * + * @author poplar.yfyang + * @version 1.0 2011-11-18 下午12:31 + * @since JDK 1.5 + */ +public interface Dialect { + + /** + * 数据库本身是否支持分页当前的分页查询方式 + * 如果数据库不支持的话,则不进行数据库分页 + * + * @return true:支持当前的分页查询方式 + */ + boolean supportsLimit(); + + /** + * 将sql转换为分页SQL,分别调用分页sql + * + * @param sql SQL语句 + * @param offset 开始条数 + * @param limit 每页显示多少纪录条数 + * @return 分页查询的sql + */ + String getLimitString(String sql, int offset, int limit); + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/H2Dialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/H2Dialect.java new file mode 100644 index 0000000..c707b74 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/H2Dialect.java @@ -0,0 +1,46 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * A dialect compatible with the H2 database. + * + * @author JeeSpring + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class H2Dialect implements Dialect { + + @Override + public boolean supportsLimit() { + return true; + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *
    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param offsetPlaceholder 分页开始纪录条数-占位符号 + * @param limit 分页每页显示纪录条数 + * @param limitPlaceholder 分页纪录条数占位符号 + * @return 包含占位符的分页sql + */ + private String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder) { + return sql + ((offset > 0) ? " limit " + limitPlaceholder + " offset " + + offsetPlaceholder : " limit " + limitPlaceholder); + } + + @Override + public String getLimitString(String sql, int offset, int limit) { + return getLimitString(sql, offset, Integer.toString(offset), limit, Integer.toString(limit)); + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/HSQLDialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/HSQLDialect.java new file mode 100644 index 0000000..ebd06ee --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/HSQLDialect.java @@ -0,0 +1,50 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * Dialect for HSQLDB + * + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class HSQLDialect implements Dialect { + @Override + public boolean supportsLimit() { + return true; + } + + @Override + public String getLimitString(String sql, int offset, int limit) { + return getLimitString(sql, offset, Integer.toString(offset), + Integer.toString(limit)); + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *
    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param offsetPlaceholder 分页开始纪录条数-占位符号 + * @param limitPlaceholder 分页纪录条数占位符号 + * @return 包含占位符的分页sql + */ + public String getLimitString(String sql, int offset, String offsetPlaceholder, String limitPlaceholder) { + boolean hasOffset = offset > 0; + return + new StringBuffer(sql.length() + 10) + .append(sql) + .insert(sql.toLowerCase().indexOf("select") + 6, hasOffset ? " limit " + offsetPlaceholder + " " + limitPlaceholder : " top " + limitPlaceholder) + .toString(); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/MySQLDialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/MySQLDialect.java new file mode 100644 index 0000000..a621543 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/MySQLDialect.java @@ -0,0 +1,54 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * Mysql方言的实现 + * + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class MySQLDialect implements Dialect { + + + @Override + public String getLimitString(String sql, int offset, int limit) { + return getLimitString(sql, offset, Integer.toString(offset), + Integer.toString(limit)); + } + + @Override + public boolean supportsLimit() { + return true; + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *
    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param offsetPlaceholder 分页开始纪录条数-占位符号 + * @param limitPlaceholder 分页纪录条数占位符号 + * @return 包含占位符的分页sql + */ + public String getLimitString(String sql, int offset, String offsetPlaceholder, String limitPlaceholder) { + StringBuilder stringBuilder = new StringBuilder(sql); + stringBuilder.append(" limit "); + if (offset > 0) { + stringBuilder.append(offsetPlaceholder).append(",").append(limitPlaceholder); + } else { + stringBuilder.append(limitPlaceholder); + } + return stringBuilder.toString(); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/OracleDialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/OracleDialect.java new file mode 100644 index 0000000..2d4f059 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/OracleDialect.java @@ -0,0 +1,66 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +/** + * Oracle的方言实现 + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class OracleDialect implements Dialect { + @Override + public boolean supportsLimit() { + return true; + } + + @Override + public String getLimitString(String sql, int offset, int limit) { + return getLimitString(sql, offset, Integer.toString(offset), Integer.toString(limit)); + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *
    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param offsetPlaceholder 分页开始纪录条数-占位符号 + * @param limitPlaceholder 分页纪录条数占位符号 + * @return 包含占位符的分页sql + */ + public String getLimitString(String sql, int offset, String offsetPlaceholder, String limitPlaceholder) { + sql = sql.trim(); + boolean isForUpdate = false; + if (sql.toLowerCase().endsWith(" for update")) { + sql = sql.substring(0, sql.length() - 11); + isForUpdate = true; + } + StringBuilder pagingSelect = new StringBuilder(sql.length() + 100); + + if (offset > 0) { + pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); + } else { + pagingSelect.append("select * from ( "); + } + pagingSelect.append(sql); + if (offset > 0) { + String endString = offsetPlaceholder + "+" + limitPlaceholder; + pagingSelect.append(" ) row_ where rownum <= "+endString+") where rownum_ > ").append(offsetPlaceholder); + } else { + pagingSelect.append(" ) where rownum <= "+limitPlaceholder); + } + + if (isForUpdate) { + pagingSelect.append(" for update"); + } + + return pagingSelect.toString(); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/PostgreSQLDialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/PostgreSQLDialect.java new file mode 100644 index 0000000..17d8097 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/PostgreSQLDialect.java @@ -0,0 +1,49 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * Postgre Sql的方言实现 + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class PostgreSQLDialect implements Dialect { + + @Override + public boolean supportsLimit() { + return true; + } + + @Override + public String getLimitString(String sql, int offset, int limit) { + return getLimitString(sql, offset, Integer.toString(offset), + Integer.toString(limit)); + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *
    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param offsetPlaceholder 分页开始纪录条数-占位符号 + * @param limitPlaceholder 分页纪录条数占位符号 + * @return 包含占位符的分页sql + */ + public String getLimitString(String sql, int offset, + String offsetPlaceholder, String limitPlaceholder) { + StringBuilder pageSql = new StringBuilder().append(sql); + pageSql = offset <= 0 + ? pageSql.append(" limit ").append(limitPlaceholder) : + pageSql.append(" limit ").append(limitPlaceholder).append(" offset ").append(offsetPlaceholder); + return pageSql.toString(); + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SQLServer2005Dialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SQLServer2005Dialect.java new file mode 100644 index 0000000..c4278b0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SQLServer2005Dialect.java @@ -0,0 +1,95 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import org.apache.commons.lang3.StringUtils; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * Sql 2005的方言实现 + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class SQLServer2005Dialect implements Dialect { + + @Override + public boolean supportsLimit() { + return true; + } + + @Override + public String getLimitString(String sql, int offset, int limit) { + return getLimitString(sql, offset, + limit, Integer.toString(limit)); + } + + /** + * Add a LIMIT clause to the given SQL SELECT + *

    + * The LIMIT SQL will look like: + *

    + * WITH query AS + * (SELECT TOP 100 percent ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __row_number__, * from table_name) + * SELECT * + * FROM query + * WHERE __row_number__ BETWEEN :offset and :lastRows + * ORDER BY __row_number__ + * + * @param querySqlString The SQL statement to base the limit query off of. + * @param offset Offset of the first row to be returned by the query (zero-based) + * @param limit Maximum number of rows to be returned by the query + * @param limitPlaceholder limitPlaceholder + * @return A new SQL statement with the LIMIT clause applied. + */ + private String getLimitString(String querySqlString, int offset, int limit, String limitPlaceholder) { + StringBuilder pagingBuilder = new StringBuilder(); + String orderby = getOrderByPart(querySqlString); + String distinctStr = ""; + + String loweredString = querySqlString.toLowerCase(); + String sqlPartString = querySqlString; + if (loweredString.trim().startsWith("select")) { + int index = 6; + if (loweredString.startsWith("select distinct")) { + distinctStr = "DISTINCT "; + index = 15; + } + sqlPartString = sqlPartString.substring(index); + } + pagingBuilder.append(sqlPartString); + + // if no ORDER BY is specified use fake ORDER BY field to avoid errors + if (StringUtils.isEmpty(orderby)) { + orderby = "ORDER BY CURRENT_TIMESTAMP"; + } + + StringBuilder result = new StringBuilder(); + result.append("WITH query AS (SELECT ") + .append(distinctStr) + .append("TOP 100 PERCENT ") + .append(" ROW_NUMBER() OVER (") + .append(orderby) + .append(") as __row_number__, ") + .append(pagingBuilder) + .append(") SELECT * FROM query WHERE __row_number__ BETWEEN ") + .append(offset + 1).append(" AND ").append(offset + limit) + .append(" ORDER BY __row_number__"); + + return result.toString(); + } + + static String getOrderByPart(String sql) { + String loweredString = sql.toLowerCase(); + int orderByIndex = loweredString.indexOf("order by"); + if (orderByIndex != -1) { + // if we find a new "order by" then we need to ignore + // the previous one since it was probably used for a subquery + return sql.substring(orderByIndex); + } else { + return ""; + } + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SQLServerDialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SQLServerDialect.java new file mode 100644 index 0000000..beceda3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SQLServerDialect.java @@ -0,0 +1,57 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * MSSQLServer 数据库实现分页方言 + * + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class SQLServerDialect implements Dialect { + + @Override + public boolean supportsLimit() { + return true; + } + + static int getAfterSelectInsertPoint(String sql) { + int selectIndex = sql.toLowerCase().indexOf("select"); + final int selectDistinctIndex = sql.toLowerCase().indexOf("select distinct"); + return selectIndex + (selectDistinctIndex == selectIndex ? 15 : 6); + } + + @Override + public String getLimitString(String sql, int offset, int limit) { + return getLimit(sql, offset, limit); + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *

    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param limit 分页每页显示纪录条数 + * @return 包含占位符的分页sql + */ + public String getLimit(String sql, int offset, int limit) { + if (offset > 0) { + throw new UnsupportedOperationException("sql server has no offset"); + } + return new StringBuffer(sql.length() + 8) + .append(sql) + .insert(getAfterSelectInsertPoint(sql), " top " + limit) + .toString(); + } + + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SybaseDialect.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SybaseDialect.java new file mode 100644 index 0000000..3f06c81 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/dialect/SybaseDialect.java @@ -0,0 +1,48 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.dialect; + +import com.jeespring.common.persistence.dialect.Dialect; + +/** + * Sybase数据库分页方言实现。 + * 还未实现 + * + * @author poplar.yfyang + * @version 1.0 2010-10-10 下午12:31 + * @since JDK 1.5 + */ +public class SybaseDialect implements Dialect { + + @Override + public boolean supportsLimit() { + return false; + } + + + @Override + public String getLimitString(String sql, int offset, int limit) { + return null; + } + + /** + * 将sql变成分页sql语句,提供将offset及limit使用占位符号(placeholder)替换. + *
    +     * 如mysql
    +     * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回
    +     * select * from user limit :offset,:limit
    +     * 
    + * + * @param sql 实际SQL语句 + * @param offset 分页开始纪录条数 + * @param offsetPlaceholder 分页开始纪录条数-占位符号 + * @param limit 分页每页显示纪录条数 + * @param limitPlaceholder 分页纪录条数占位符号 + * @return 包含占位符的分页sql + */ + public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder) { + throw new UnsupportedOperationException("paged queries not supported"); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/BaseInterceptor.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/BaseInterceptor.java new file mode 100644 index 0000000..1cd3e9f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/BaseInterceptor.java @@ -0,0 +1,96 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.interceptor; + +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.persistence.dialect.*; +import com.jeespring.common.utils.Reflections; +import org.apache.ibatis.logging.Log; +import org.apache.ibatis.logging.LogFactory; +import org.apache.ibatis.plugin.Interceptor; + +import java.io.Serializable; +import java.util.Properties; + +/** + * Mybatis分页拦截器基类 + * + * @author poplar.yfyang / HuangBingGui + * @version 2013-8-28 + */ +public abstract class BaseInterceptor implements Interceptor, Serializable { + + private static final long serialVersionUID = 1L; + + protected static final String PAGE = "page"; + + protected static final String DELEGATE = "delegate"; + + protected static final String MAPPED_STATEMENT = "mappedStatement"; + + protected Log log = LogFactory.getLog(this.getClass()); + + protected Dialect DIALECT; + + + /** + * 对参数进行转换和检查 + * + * @param parameterObject 参数对象 + * @param page 分页对象 + * @return 分页对象 + * @throws NoSuchFieldException 无法找到参数 + */ + @SuppressWarnings("unchecked") + protected static Page convertParameter(Object parameterObject, Page page) { + try { + if (parameterObject instanceof Page) { + return (Page) parameterObject; + } else { + return (Page) Reflections.getFieldValue(parameterObject, PAGE); + } + } catch (Exception e) { + return null; + } + } + + /** + * 设置属性,支持自定义方言类和制定数据库的方式 + * dialectClass,自定义方言类。可以不配置这项 + * dbms 数据库类型,插件支持的数据库 + * sqlPattern 需要拦截的SQL ID + * + * @param p 属性 + */ + protected void initProperties(Properties p) { + Dialect dialect = null; + String dbType = Global.getJdbcType(); + if ("db2".equals(dbType)) { + dialect = new DB2Dialect(); + } else if ("derby".equals(dbType)) { + dialect = new DerbyDialect(); + } else if ("h2".equals(dbType)) { + dialect = new H2Dialect(); + } else if ("hsql".equals(dbType)) { + dialect = new HSQLDialect(); + } else if ("mysql".equals(dbType)) { + dialect = new MySQLDialect(); + } else if ("oracle".equals(dbType)) { + dialect = new OracleDialect(); + } else if ("postgre".equals(dbType)) { + dialect = new PostgreSQLDialect(); + } else if ("mssql".equals(dbType) || "sqlserver".equals(dbType)) { + dialect = new SQLServer2005Dialect(); + } else if ("sybase".equals(dbType)) { + dialect = new SybaseDialect(); + } + if (dialect == null) { + log.error("user the mysql dialect"); + dialect = new MySQLDialect(); + } + DIALECT = dialect; + + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/PaginationInterceptor.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/PaginationInterceptor.java new file mode 100644 index 0000000..cecc6db --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/PaginationInterceptor.java @@ -0,0 +1,129 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.interceptor; + +import java.util.Properties; + +import org.apache.ibatis.executor.Executor; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.mapping.SqlSource; +import org.apache.ibatis.plugin.Intercepts; +import org.apache.ibatis.plugin.Invocation; +import org.apache.ibatis.plugin.Plugin; +import org.apache.ibatis.plugin.Signature; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.session.ResultHandler; +import org.apache.ibatis.session.RowBounds; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.utils.Reflections; +import com.jeespring.common.utils.StringUtils; + +/** + * 数据库分页插件,只拦截查询语句. + * @author poplar.yfyang / HuangBingGui + * @version 2013-8-28 + */ +@Intercepts({@Signature(type = Executor.class, method = "query", + args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})}) +public class PaginationInterceptor extends BaseInterceptor { + + private static final long serialVersionUID = 1L; + + @Override + public Object intercept(Invocation invocation) throws Throwable { + + final MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0]; + +// //拦截需要分页的SQL +//// if (mappedStatement.getId().matches(_SQL_PATTERN)) { +// if (StringUtils.indexOfIgnoreCase(mappedStatement.getId(), _SQL_PATTERN) != -1) { + Object parameter = invocation.getArgs()[1]; + BoundSql boundSql = mappedStatement.getBoundSql(parameter); + Object parameterObject = boundSql.getParameterObject(); + + //获取分页参数对象 + Page page = null; + if (parameterObject != null) { + page = convertParameter(parameterObject, page); + } + + //如果设置了分页对象,则进行分页 + if (page != null && page.getPageSize() != -1) { + + if (StringUtils.isBlank(boundSql.getSql())){ + return null; + } + String originalSql = boundSql.getSql().trim(); + + //得到总记录数 + page.setCount(SQLHelper.getCount(originalSql, null, mappedStatement, parameterObject, boundSql, log)); + + //分页查询 本地化对象 修改数据库注意修改实现 + String pageSql = SQLHelper.generatePageSql(originalSql, page, DIALECT); +// if (log.isDebugEnabled()) { +// log.debug("PAGE SQL:" + StringUtils.replace(pageSql, "\n", "")); +// } + invocation.getArgs()[2] = new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT); + BoundSql newBoundSql = new BoundSql(mappedStatement.getConfiguration(), pageSql, boundSql.getParameterMappings(), boundSql.getParameterObject()); + //解决MyBatis 分页foreach 参数失效 start + if (Reflections.getFieldValue(boundSql, "metaParameters") != null) { + MetaObject mo = (MetaObject) Reflections.getFieldValue(boundSql, "metaParameters"); + Reflections.setFieldValue(newBoundSql, "metaParameters", mo); + } + //解决MyBatis 分页foreach 参数失效 end + MappedStatement newMs = copyFromMappedStatement(mappedStatement, new BoundSqlSqlSource(newBoundSql)); + + invocation.getArgs()[0] = newMs; + } +// } + return invocation.proceed(); + } + + + @Override + public Object plugin(Object target) { + return Plugin.wrap(target, this); + } + + @Override + public void setProperties(Properties properties) { + super.initProperties(properties); + } + + private MappedStatement copyFromMappedStatement(MappedStatement ms, + SqlSource newSqlSource) { + MappedStatement.Builder builder = new MappedStatement.Builder(ms.getConfiguration(), + ms.getId(), newSqlSource, ms.getSqlCommandType()); + builder.resource(ms.getResource()); + builder.fetchSize(ms.getFetchSize()); + builder.statementType(ms.getStatementType()); + builder.keyGenerator(ms.getKeyGenerator()); + if (ms.getKeyProperties() != null) { + for (String keyProperty : ms.getKeyProperties()) { + builder.keyProperty(keyProperty); + } + } + builder.timeout(ms.getTimeout()); + builder.parameterMap(ms.getParameterMap()); + builder.resultMaps(ms.getResultMaps()); + builder.cache(ms.getCache()); + builder.useCache(ms.isUseCache()); + return builder.build(); + } + + public static class BoundSqlSqlSource implements SqlSource { + BoundSql boundSql; + + public BoundSqlSqlSource(BoundSql boundSql) { + this.boundSql = boundSql; + } + + @Override + public BoundSql getBoundSql(Object parameterObject) { + return boundSql; + } + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/PreparePaginationInterceptor.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/PreparePaginationInterceptor.java new file mode 100644 index 0000000..a509bd0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/common/persistence/interceptor/PreparePaginationInterceptor.java @@ -0,0 +1,89 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.common.persistence.interceptor; + +import java.sql.Connection; +import java.util.Properties; + +import org.apache.ibatis.executor.statement.BaseStatementHandler; +import org.apache.ibatis.executor.statement.RoutingStatementHandler; +import org.apache.ibatis.executor.statement.StatementHandler; +import org.apache.ibatis.mapping.BoundSql; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.plugin.Intercepts; +import org.apache.ibatis.plugin.Invocation; +import org.apache.ibatis.plugin.Plugin; +import org.apache.ibatis.plugin.Signature; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.utils.Reflections; + +/** + * Mybatis数据库分页插件,拦截StatementHandler的prepare方法 + * @author poplar.yfyang / HuangBingGui + * @version 2013-8-28 + */ +@Intercepts({ + @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class}) +}) +public class PreparePaginationInterceptor extends BaseInterceptor { + + private static final long serialVersionUID = 1L; + + public PreparePaginationInterceptor() { + super(); + } + + @Override + public Object intercept(Invocation ivk) throws Throwable { + if (ivk.getTarget().getClass().isAssignableFrom(RoutingStatementHandler.class)) { + final RoutingStatementHandler statementHandler = (RoutingStatementHandler) ivk.getTarget(); + final BaseStatementHandler delegate = (BaseStatementHandler) Reflections.getFieldValue(statementHandler, DELEGATE); + final MappedStatement mappedStatement = (MappedStatement) Reflections.getFieldValue(delegate, MAPPED_STATEMENT); + +// //拦截需要分页的SQL +//// if (mappedStatement.getId().matches(_SQL_PATTERN)) { +// if (StringUtils.indexOfIgnoreCase(mappedStatement.getId(), _SQL_PATTERN) != -1) { + BoundSql boundSql = delegate.getBoundSql(); + //分页SQL + +
    + <#list table.columnList as c> + <#if c.isQuery?? && c.isQuery == "1"> + ${c.comments}: + <#if c.showType == "input" || c.showType == "textarea"> + maxlength="${c.dataLength}" class=" form-control input-sm"/> + <#elseif c.showType == "select"> + + + + + <#elseif c.showType == "checkbox"> + + <#elseif c.showType == "radiobox"> + + <#elseif c.showType == "dateselect" && c.queryType == "between"> + "/> - + "/> + <#elseif c.showType == "dateselect"> + "/> + <#elseif c.showType == "userselect"> + + <#elseif c.showType == "officeselect"> + + <#elseif c.showType == "areaselect"> + + + + + +
    + + + + + + + + <#list table.columnList as c> + <#if c.isList?? && c.isList == "1"> + + + + + + + + + + <#assign firstListField = true> + <#list table.columnList as c> + <#if c.isList?? && c.isList == "1"> + + <#assign firstListField = false> + + + + + + +
    ${c.comments}操作
    <#if firstListField> + <#if c.simpleJavaType == "Date"> + + <#elseif c.showType == "select" || c.showType == "checkbox" || c.showType == "radiobox"> + ${"$"}{fns:getDictLabel(${className}.${c.javaFieldId}, '${c.dictType}', '')} + <#elseif c.showType == "userselect" || c.showType == "officeselect" || c.showType == "areaselect"> + ${"$"}{${className}.${c.javaFieldName}} + <#else> + ${"$"}{${className}.${c.javaFieldId}} + + <#if firstListField> + 修改 + 删除 +
    + ${r"${page}"} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/util/GenUtils.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/util/GenUtils.java new file mode 100644 index 0000000..7771551 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/util/GenUtils.java @@ -0,0 +1,370 @@ +// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:23:01 +// Home Page: http://www.neshkov.com/dj.html - Check often for new version! +// Decompiler options: packimports(3) +// Source File Name: GenUtils.java + +package com.jeespring.modules.gen.util; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.*; +import com.jeespring.common.mapper.JaxbMapper; +import com.jeespring.modules.gen.entity.*; +import com.jeespring.modules.sys.entity.*; +import com.jeespring.modules.sys.service.DictService; +import com.jeespring.modules.sys.utils.UserUtils; + +import java.io.*; +import java.util.*; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.*; + +public class GenUtils +{ + + public GenUtils() + { + } + + public static void initColumnField(GenTable genTable,List dictList) + { + int i=0; + for(Iterator iterator = genTable.getColumnList().iterator(); iterator.hasNext();) + { + GenTableColumn column = (GenTableColumn)iterator.next(); + if(!StringUtils.isNotBlank(column.getId())) + { + if(StringUtils.isBlank(column.getComments())) { + column.setComments(column.getName()); + } + if(StringUtils.startsWithIgnoreCase(column.getJdbcType(), "CHAR") || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "VARCHAR") || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "NARCHAR")) { + column.setJavaType("String"); + } else if(StringUtils.startsWithIgnoreCase(column.getJdbcType(), "BLOB")){ + column.setJavaType("byte[]"); + } + else + if(StringUtils.startsWithIgnoreCase(column.getJdbcType(), "DATETIME") || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "DATE") || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "TIMESTAMP")) + { + column.setJavaType("java.util.Date"); + column.setShowType("dateselect"); + } else + if(StringUtils.startsWithIgnoreCase(column.getJdbcType(), "BIGINT") + || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "NUMBER") + || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "DECIMAL") + || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "INT") + || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "TINYINT")) + { + String[] ss = StringUtils.split(StringUtils.substringBetween(column.getJdbcType(), "(", ")"), ","); + if(ss != null && ss.length == 2 && Integer.parseInt(ss[1]) > 0) { + column.setJavaType("Double"); + } else + if(ss != null && ss.length == 1 && Integer.parseInt(ss[0]) <= 10) { + column.setJavaType("Integer"); + } else { + column.setJavaType("Long"); + } + } + if(column.getJavaType()==null||"".equals(column.getJavaType())){ + column.setJavaType("String"); + } + column.setJavaField(StringUtils.toCamelCase(column.getName())); + column.setIsPk(genTable.getPkList().contains(column.getName()) ? "1" : "0"); + if(column.getIsPk()=="1" && column.getName().toLowerCase().contains("id")){ + column.setJavaField("id"); + } + column.setIsInsert("1"); + if(!StringUtils.equalsIgnoreCase(column.getName(), "id") && !StringUtils.equalsIgnoreCase(column.getName(), "create_by") && !StringUtils.equalsIgnoreCase(column.getName(), "create_date") && !StringUtils.equalsIgnoreCase(column.getName(), "del_flag")) { + column.setIsEdit("1"); + } else { + column.setIsEdit("0"); + } + if(StringUtils.equalsIgnoreCase(column.getName(), "name") || StringUtils.equalsIgnoreCase(column.getName(), "title") || StringUtils.equalsIgnoreCase(column.getName(), "remarks") || StringUtils.equalsIgnoreCase(column.getName(), "update_date")) { + column.setIsList("1"); + } else { + column.setIsList("0"); + } + if(StringUtils.equalsIgnoreCase(column.getName(), "name") || StringUtils.equalsIgnoreCase(column.getName(), "title")) { + column.setIsQuery("1"); + } else { + column.setIsQuery("0"); + } + if(StringUtils.equalsIgnoreCase(column.getName(), "name") || StringUtils.equalsIgnoreCase(column.getName(), "title")) { + column.setQueryType("like"); + } else { + column.setQueryType("="); + } + + if(StringUtils.startsWithIgnoreCase(column.getJdbcType(), "DATETIME") || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "DATE") || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "TIMESTAMP")) { + column.setQueryType("between"); + } + + if(StringUtils.startsWithIgnoreCase(column.getName(), "user_id")) + { + column.setJavaType(User.class.getName()); + column.setJavaField(column.getJavaField().replaceAll("Id", ".id|name")); + column.setShowType("userselect"); + } else + if(StringUtils.startsWithIgnoreCase(column.getName(), "office_id")) + { + column.setJavaType(Office.class.getName()); + column.setJavaField(column.getJavaField().replaceAll("Id", ".id|name")); + column.setShowType("officeselect"); + } else + if(StringUtils.startsWithIgnoreCase(column.getName(), "area_id")) + { + column.setJavaType(Area.class.getName()); + column.setJavaField(column.getJavaField().replaceAll("Id", ".id|name")); + column.setShowType("areaselect"); + } else + if(StringUtils.startsWithIgnoreCase(column.getName(), "create_by") || StringUtils.startsWithIgnoreCase(column.getName(), "update_by")) + { + column.setJavaType(User.class.getName()); + column.setJavaField((new StringBuilder(String.valueOf(column.getJavaField()))).append(".id").toString()); + column.setShowType("input"); + } else + if(StringUtils.startsWithIgnoreCase(column.getName(), "create_date") || StringUtils.startsWithIgnoreCase(column.getName(), "update_date")) { + column.setShowType("dateselect"); + } else + if(StringUtils.equalsIgnoreCase(column.getName(), "remarks") || StringUtils.equalsIgnoreCase(column.getName(), "content")) { + column.setShowType("textarea"); + } else + if(StringUtils.equalsIgnoreCase(column.getName(), "parent_id")) + { + column.setJavaType("This"); + column.setJavaField("parent.id|name"); + column.setShowType("treeselect"); + } else + if(StringUtils.equalsIgnoreCase(column.getName(), "parent_ids")) + { + column.setShowType("input"); + column.setQueryType("like"); + } else + if(StringUtils.equalsIgnoreCase(column.getName(), "del_flag")) + { + column.setShowType("radiobox"); + column.setDictType("del_flag"); + } else + { + if(column.getShowType()=="" || column.getShowType()==null) { + column.setShowType("input"); + } + } + if(column.getName().toLowerCase().contains("remark") || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "TEXT")){ + column.setShowType("textarea"); + } + if(genTable.getTableType()!="2" && (column.getName().toLowerCase().contains("remark") || StringUtils.startsWithIgnoreCase(column.getJdbcType(), "TEXT"))){ + column.setShowType("text"); + column.setQueryType("like"); + } + if(column.getName().toLowerCase().contains("picture")){ + column.setShowType("fileselect"); + } + if(StringUtils.startsWithIgnoreCase(column.getName(), "is_")) + { + column.setShowType("radiobox"); + if(dictList.contains("is_not")){ + column.setDictType("is_not"); + } + if(dictList.contains(column.getName()) || dictList.contains(StringUtils.toCapitalizeCamelCase(column.getName()))){ + column.setDictType(column.getName()); + } + } + + if(column.getName().toLowerCase().contains("_type")){ + column.setShowType("select"); + if(dictList.contains(column.getName()) || dictList.contains(StringUtils.toCapitalizeCamelCase(column.getName()))){ + column.setDictType(column.getName()); + } + } + + if(column.getName().toLowerCase().contains("_state") || "state".equals(column.getName().toLowerCase())){ + column.setShowType("select"); + if(dictList.contains(column.getName()) || dictList.contains(StringUtils.toCapitalizeCamelCase(column.getName()))){ + column.setDictType(column.getName()); + } + } + if(column.getName().toLowerCase().contains("name")){ + column.setQueryType("like"); + } + + if("1".equals(column.getAutoIncrement())){ + column.setIsInsert("0"); + } + + if(i>0 && i<=8){ + column.setIsList("1"); + } + if(i>0 && i<=13 && !column.getName().toLowerCase().contains("picture")){ + column.setIsQuery("1"); + } + i++; + } + } + + } + + public static String getTemplatePath() + { + try + { + File file = (new DefaultResourceLoader()).getResource("").getFile(); + if(file != null) { + return (new StringBuilder(String.valueOf(file.getAbsolutePath()))).append(File.separator).append(StringUtils.replaceEach(GenUtils.class.getName(), new String[]{ + (new StringBuilder("util.")).append(GenUtils.class.getSimpleName()).toString(), "." + }, new String[]{ + "template", File.separator + })).toString(); + } + } + catch(Exception e) + { + logger.error("{}", e); + } + return ""; + } + + public static Object fileToObject(String fileName, Class clazz) + { + try + { + String pathName = (new StringBuilder("/templates/modules/gen/")).append(fileName).toString(); + Resource resource = new ClassPathResource(pathName); + InputStream is = resource.getInputStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8")); + StringBuilder sb = new StringBuilder(); + do + { + String line = br.readLine(); + if(line == null) { + break; + } + sb.append(line).append("\r\n"); + } while(true); + if(is != null) { + is.close(); + } + if(br != null) { + br.close(); + } + return JaxbMapper.fromXml(sb.toString(), clazz); + } + catch(IOException e) + { + logger.warn("Error file convert: {}", e.getMessage()); + } + return null; + } + + public static GenConfig getConfig() + { + return (GenConfig)fileToObject("config.xml", GenConfig.class); + } + + public static List getTemplateList(GenConfig config, String category, boolean isChildTable) + { + List templateList = Lists.newArrayList(); + if(config != null && config.getCategoryList() != null && category != null) + { + for(Iterator iterator = config.getCategoryList().iterator(); iterator.hasNext();) + { + GenCategory e = (GenCategory)iterator.next(); + if(category.equals(e.getValue())) + { + List list = null; + if(!isChildTable) { + list = e.getTemplate(); + } else { + list = e.getChildTableTemplate(); + } + if(list != null) + { + for(Iterator iterator1 = list.iterator(); iterator1.hasNext();) + { + String s = (String)iterator1.next(); + if(StringUtils.startsWith(s, GenCategory.CATEGORY_REF)) + { + templateList.addAll(getTemplateList(config, StringUtils.replace(s, GenCategory.CATEGORY_REF, ""), false)); + } else + { + GenTemplate template = (GenTemplate)fileToObject(s, GenTemplate.class); + if(template != null) { + templateList.add(template); + } + } + } + + } + break; + } + } + + } + return templateList; + } + + public static Map getDataModel(GenScheme genScheme) + { + Map model = Maps.newHashMap(); + model.put("packageName", StringUtils.lowerCase(genScheme.getPackageName())); + model.put("lastPackageName", StringUtils.substringAfterLast((String)model.get("packageName"), ".")); + model.put("moduleName", StringUtils.lowerCase(genScheme.getModuleName())); + model.put("subModuleName", StringUtils.lowerCase(genScheme.getSubModuleName())); + model.put("className", StringUtils.uncapitalize(genScheme.getGenTable().getClassName())); + model.put("ClassName", StringUtils.capitalize(genScheme.getGenTable().getClassName())); + model.put("functionName", genScheme.getFunctionName()); + model.put("functionNameSimple", genScheme.getFunctionNameSimple()); + model.put("functionAuthor", StringUtils.isNotBlank(genScheme.getFunctionAuthor()) ? genScheme.getFunctionAuthor() : UserUtils.getUser().getName()); + model.put("functionVersion", DateUtils.getDate()); + model.put("urlPrefix", (new StringBuilder()).append(model.get("moduleName")).append(StringUtils.isNotBlank(genScheme.getSubModuleName()) ? (new StringBuilder("/")).append(StringUtils.lowerCase(genScheme.getSubModuleName())).toString() : "").append("/").append(model.get("className")).toString()); + model.put("viewPrefix", model.get("urlPrefix")); + model.put("permissionPrefix", (new StringBuilder()).append(model.get("moduleName")).append(StringUtils.isNotBlank(genScheme.getSubModuleName()) ? (new StringBuilder(":")).append(StringUtils.lowerCase(genScheme.getSubModuleName())).toString() : "").append(":").append(model.get("className")).toString()); + model.put("dbType", Global.getConfig("jdbc.type")); + model.put("table", genScheme.getGenTable()); + return model; + } + + public static String generateToFile(GenTemplate tpl, Map model, boolean isReplaceFile) + { + String fileName = Global.getProjectPath() + File.separator + + StringUtils.replaceEach(FreeMarkers.renderString(tpl.getFileName(),new StringBuilder(String.valueOf(tpl.getFilePath())).append("/").toString(), model), + new String[] { "//", "/", ".." ,"."}, new String[] { File.separator, File.separator, "__",File.separator }).replace("__", "..") + + FreeMarkers.renderString(tpl.getFileName(),tpl.getFileName(), model); + logger.debug(" fileName === " + fileName); + + + String content = FreeMarkers.renderString(tpl.getFileName(),StringUtils.trimToEmpty(tpl.getContent()), model); + logger.debug(" content === \r\n" + content); + if (isReplaceFile) { + FileUtils.deleteFile(fileName); + } + if (FileUtils.createFile(fileName)) + { + FileUtils.writeToFile(fileName, content, true); + logger.debug(" file create === " + fileName); + return "生成成功:" + fileName + "
    "; + } + logger.debug(" file extents === " + fileName); + return "文件已存在:" + fileName + "
    "; + } + + /*public static void main(String[] args) + { + try + { + GenConfig config = getConfig(); + System.out.println(config); + System.out.println(JaxbMapper.toXml(config)); + } + catch(Exception e) + { + e.printStackTrace(); + } + }*/ + + private static Logger logger = LoggerFactory.getLogger(GenUtils.class); + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/CgAutoListController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/CgAutoListController.java new file mode 100644 index 0000000..dd03bbc --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/CgAutoListController.java @@ -0,0 +1,88 @@ +// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:22:29 +// Home Page: http://www.neshkov.com/dj.html - Check often for new version! +// Decompiler options: packimports(3) +// Source File Name: CgAutoListController.java + +package com.jeespring.modules.gen.web; + +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.gen.entity.GenScheme; +import com.jeespring.modules.gen.service.*; +import com.jeespring.modules.gen.template.FreemarkerHelper; +import com.jeespring.modules.gen.util.GenUtils; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +@Controller +@RequestMapping(value={"${adminPath}/gen/cgAutoList"}) +public class CgAutoListController extends AbstractBaseController +{ + + public CgAutoListController() + { + } + + @ModelAttribute + public GenScheme get(@RequestParam(required=true) String id) + { + if(StringUtils.isNotBlank(id)) { + return genSchemeService.get(id); + } else { + return new GenScheme(); + } + } + + @RequestMapping(value={"list"}) + public void list(GenScheme genScheme, HttpServletRequest request, HttpServletResponse response) + { + long start = System.currentTimeMillis(); + FreemarkerHelper viewEngine = new FreemarkerHelper(); + Map model = GenUtils.getDataModel(genScheme); + String html = cgAutoListService.generateCode(genScheme); + String findListSql = cgAutoListService.generateListCode(genScheme); + try + { + response.setContentType("text/html"); + response.setHeader("Cache-Control", "no-store"); + PrintWriter writer = response.getWriter(); + writer.println(html); + writer.flush(); + } + catch(IOException e) + { + e.printStackTrace(); + } + long end = System.currentTimeMillis(); + log.debug("动态列表生成耗时:" + (end - start) + " ms"); + } + + @RequestMapping(value={"test", ""}) + public ModelAndView list(GenScheme genScheme, HttpServletRequest request, HttpServletResponse response, Model model) + { + return new ModelAndView("com/jeespring/modules/gen/template/viewList"); + } + + private static Logger log = Logger.getLogger(CgAutoListController.class); + @Autowired + private GenSchemeService genSchemeService; + @Autowired + private GenTableService genTableService; + @Autowired + private CgAutoListService cgAutoListService; + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenSchemeController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenSchemeController.java new file mode 100644 index 0000000..8d26adc --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenSchemeController.java @@ -0,0 +1,118 @@ +// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:22:40 +// Home Page: http://www.neshkov.com/dj.html - Check often for new version! +// Decompiler options: packimports(3) +// Source File Name: GenSchemeController.java + +package com.jeespring.modules.gen.web; + +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.gen.entity.GenScheme; +import com.jeespring.modules.gen.service.GenSchemeService; +import com.jeespring.modules.gen.service.GenTableService; +import com.jeespring.modules.gen.util.GenUtils; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SysConfigService; +import com.jeespring.modules.sys.utils.UserUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +@Controller +@RequestMapping(value={"${adminPath}/gen/genScheme"}) +public class GenSchemeController extends AbstractBaseController +{ + + @Autowired + private SysConfigService sysConfigService; + + public GenSchemeController() + { + } + + @ModelAttribute + public GenScheme get(@RequestParam(required=true) String id) + { + if(StringUtils.isNotBlank(id)) { + return genSchemeService.get(id); + } else { + return new GenScheme(); + } + } + + @RequiresPermissions(value={"gen:genScheme:view"}) + @RequestMapping(value={"list", ""}) + public String list(GenScheme genScheme, HttpServletRequest request, HttpServletResponse response, Model model) + { + User user = UserUtils.getUser(); + if(!user.isAdmin()) { + genScheme.setCreateBy(user); + } + Page page = genSchemeService.find(new Page(request, response), genScheme); + model.addAttribute("page", page); + return "modules/gen/genSchemeList"; + } + + @RequiresPermissions(value={"gen:genScheme:view"}) + @RequestMapping(value={"form"}) + public String form(GenScheme genScheme, Model model) + { + if(StringUtils.isBlank(genScheme.getPackageName())) { + genScheme.setPackageName("com.jeespring.modules"); + } + model.addAttribute("genScheme", genScheme); + model.addAttribute("config", GenUtils.getConfig()); + model.addAttribute("tableList", genTableService.findAll()); + return "modules/gen/genSchemeForm"; + } + + @RequiresPermissions(value={"gen:genScheme:edit"}) + @RequestMapping(value={"save"}) + public String save(GenScheme genScheme, Model model, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genScheme/"; + } + + if(!beanValidator(model, genScheme)) + { + return form(genScheme, model); + } else + { + String result = genSchemeService.save(genScheme); + addMessage(redirectAttributes, "操作生成方案'" + genScheme.getName() + "'成功
    " + result); + return "redirect:" + this.adminPath + "/gen/genScheme/?repage"; + } + } + + @RequiresPermissions(value={"gen:genScheme:edit"}) + @RequestMapping(value={"delete"}) + public String delete(GenScheme genScheme, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genTemplate/"; + } + + this.genSchemeService.delete(genScheme); + addMessage(redirectAttributes, "删除生成方案成功"); + return "redirect:" + this.adminPath + "/gen/genScheme/?repage"; + } + + @Autowired + private GenSchemeService genSchemeService; + @Autowired + private GenTableService genTableService; +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenTableController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenTableController.java new file mode 100644 index 0000000..012baf3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenTableController.java @@ -0,0 +1,434 @@ +// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:22:45 +// Home Page: http://www.neshkov.com/dj.html - Check often for new version! +// Decompiler options: packimports(3) +// Source File Name: GenTableController.java + +package com.jeespring.modules.gen.web; + +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.gen.entity.*; +import com.jeespring.modules.gen.service.GenSchemeService; +import com.jeespring.modules.gen.service.GenTableService; +import com.jeespring.modules.gen.util.GenUtils; +import com.jeespring.modules.sys.entity.Menu; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SysConfigService; +import com.jeespring.modules.sys.service.SystemService; +import com.jeespring.modules.sys.utils.UserUtils; + +import java.util.Iterator; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +@Controller +@RequestMapping(value={"${adminPath}/gen/genTable"}) +public class GenTableController extends AbstractBaseController +{ + @Autowired + private SystemService systemService; + @Autowired + private SysConfigService sysConfigService; + + public GenTableController() + { + } + + public GenTable get(GenTable genTable) + { + if(StringUtils.isNotBlank(genTable.getId())) { + return genTableService.get(genTable.getId()); + } else { + return genTable; + } + } + + @RequiresPermissions(value={"gen:genTable:list"}) + @RequestMapping(value={"list", ""}) + public String list(GenTable genTable, HttpServletRequest request, HttpServletResponse response, Model model) + { + genTable = get(genTable); + User user = UserUtils.getUser(); + if(!user.isAdmin()) { + genTable.setCreateBy(user); + } + Page page = genTableService.find(new Page(request, response), genTable); + model.addAttribute("page", page); + return "modules/gen/genTableList"; + } + + @RequiresPermissions(value={"gen:genTable:view", "gen:genTable:add", "gen:genTable:edit"}, logical=org.apache.shiro.authz.annotation.Logical.OR) + @RequestMapping(value={"form"}) + public String form(GenTable genTable, Model model) + { + genTable = get(genTable); + model.addAttribute("genTable", genTable); + model.addAttribute("config", GenUtils.getConfig()); + model.addAttribute("tableList", genTableService.findAll()); + return "modules/gen/genTableForm"; + } + + @RequiresPermissions(value={"gen:genTable:add", "gen:genTable:edit"}, logical=org.apache.shiro.authz.annotation.Logical.OR) + @RequestMapping(value={"save"}) + public String save(GenTable genTable, Model model, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genTable/"; + } + + if (!beanValidator(model, genTable)) { + return form(genTable, model); + } + if ((StringUtils.isBlank(genTable.getId())) && (!this.genTableService.checkTableName(genTable.getName()))) + { + addMessage(redirectAttributes, "添加失败!" + genTable.getName() + " 记录已存在!"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; + } + if ((StringUtils.isBlank(genTable.getId())) && (!this.genTableService.checkTableNameFromDB(genTable.getName()))) + { + addMessage(redirectAttributes, "添加失败!" + genTable.getName() + "表已经在数据库中存在,请从数据库导入表单!"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; + } + this.genTableService.save(genTable); + addMessage(redirectAttributes, "保存业务表'" + genTable.getName() + "'成功"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; + } + + @RequiresPermissions(value={"gen:genTable:importDb"}) + @RequestMapping(value={"importTableFromDB"}) + public String importTableFromDB(GenTable genTable, Model model, RedirectAttributes redirectAttributes) + { + genTable = get(genTable); + if (!StringUtils.isBlank(genTable.getName())) + { + if (!this.genTableService.checkTableName(genTable.getName())) + { + addMessage(redirectAttributes, "下一步失败!" + genTable.getName() + + " 表已经添加!"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; + } + genTable = this.genTableService.getTableFormDb(genTable); + genTable.setTableType("0"); + this.genTableService.saveFromDB(genTable); + addMessage(redirectAttributes, "数据库导入表单'" + genTable.getName() + + "'成功"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; + } + List tableList = this.genTableService + .findTableListFormDb(new GenTable()); + model.addAttribute("tableList", tableList); + model.addAttribute("config", GenUtils.getConfig()); + return "modules/gen/importTableFromDB"; + } + + @RequiresPermissions(value={"gen:genTable:del"}) + @RequestMapping(value={"delete"}) + public String delete(GenTable genTable, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode() ){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genTable/"; + } + + genTable = get(genTable); + this.genTableService.delete(genTable); + this.genSchemeService.delete(this.genSchemeService.findUniqueByProperty("gen_table_id", genTable.getId())); + addMessage(redirectAttributes, "移除业务表记录成功"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; + } + + @RequiresPermissions(value={"gen:genTable:del"}) + @RequestMapping(value={"deleteDb"}) + public String deleteDb(GenTable genTable, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genTable/"; + } + + genTable = get(genTable); + this.genTableService.delete(genTable); + this.genSchemeService.delete(this.genSchemeService.findUniqueByProperty("gen_table_id", genTable.getId())); + StringBuffer sql = new StringBuffer(); + sql.append("drop table if exists " + genTable.getName() + " ;"); + this.genTableService.buildTable(sql.toString()); + addMessage(redirectAttributes, "删除业务表记录和数据库表成功"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; + } + + @RequiresPermissions(value={"gen:genTable:del"}) + @RequestMapping(value={"deleteAll"}) + public String deleteAll(String ids, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genTable/"; + } + + String[] idArray = ids.split(","); + for (String id : idArray) { + this.genTableService.delete(this.genTableService.get(id)); + } + addMessage(redirectAttributes, "删除业务表成功"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; } + + @RequiresPermissions(value={"gen:genTable:synchDb"}) + @RequestMapping(value={"synchDb"}) + public String synchDb(GenTable genTable, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genTable/"; + } + + genTable = get(genTable); + StringBuffer sql = new StringBuffer(); + List getTableColumnList = genTable.getColumnList(); + sql.append((new StringBuilder("drop table if exists ")).append(genTable.getName()).append(" ;").toString()); + genTableService.buildTable(sql.toString()); + sql = new StringBuffer(); + sql.append((new StringBuilder("create table ")).append(genTable.getName()).append(" (").toString()); + String pk = ""; + for(Iterator iterator = getTableColumnList.iterator(); iterator.hasNext();) + { + GenTableColumn column = (GenTableColumn)iterator.next(); + if("1".equals(column.getIsPk())) + { + sql.append((new StringBuilder(" ")).append(column.getName()).append(" ").append(column.getJdbcType()).append(" comment '").append(column.getComments()).append("',").toString()); + pk = (new StringBuilder(String.valueOf(pk))).append(column.getName()).append(",").toString(); + } else + { + sql.append((new StringBuilder(" ")).append(column.getName()).append(" ").append(column.getJdbcType()).append(" comment '").append(column.getComments()).append("',").toString()); + } + } + + sql.append("primary key (" + pk.substring(0, pk.length() - 1) + ") "); + sql.append(") comment '" + genTable.getComments() + "'"); + this.genTableService.buildTable(sql.toString()); + this.genTableService.syncSave(genTable); + addMessage(redirectAttributes, "强制同步数据库表成功"); + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; } + + @RequiresPermissions(value={"gen:genTable:genCode"}) + @RequestMapping(value={"genCodeForm"}) + public String genCodeForm(GenScheme genScheme, Model model, RedirectAttributes redirectAttributes) + { + if(StringUtils.isBlank(genScheme.getPackageName())) { + genScheme.setPackageName("com.company.project.modules"); + } + GenScheme oldGenScheme = genSchemeService.findUniqueByProperty("gen_table_id", genScheme.getGenTable().getId()); + if(oldGenScheme != null) { + genScheme = oldGenScheme; + } + model.addAttribute("genScheme", genScheme); + model.addAttribute("config", GenUtils.getConfig()); + model.addAttribute("tableList", genTableService.findAll()); + return "modules/gen/genCodeForm"; + } + + @RequestMapping(value={"genCode"}) + public String genCode(GenScheme genScheme, Model model, RedirectAttributes redirectAttributes) + { + genScheme.setGenTable(genTableService.get(genScheme.getGenTable().getId())); + if(sysConfigService.isDemoMode()){ + String msg="
    "+genScheme.getGenTable().getName() + + "代码和菜单、接口已生成成功;
    如果启用redis:代码生成后,要退出,再登陆。
    菜单路径:
    " + + "接口路径:"+"rest/list或者get或者save或者delete
    ..."; + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()+msg); + return "redirect:" + adminPath + "/gen/genTable/"; + } + String href=""; + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + href="/"+genScheme.getModuleName()+"/"+genScheme.getSubModuleName()+"/"+StringUtils.toCamelCase(genScheme.getGenTable().getName()); + }else{ + href="/"+genScheme.getModuleName()+"/"+StringUtils.toCamelCase(genScheme.getGenTable().getName()); + } + if("tree".equals(genScheme.getCategory())){ + href=href+"Tree"; + } + genMenu(genScheme,href); + + String result = this.genSchemeService.save(genScheme); + addMessage(redirectAttributes, genScheme.getGenTable().getName() + + "代码和菜单、接口已生成成功;
    如果启用redis:代码生成后,要退出,再登陆。
    菜单路径:"+href+"
    " + + "接口路径:"+"rest/"+href+"/list或者get或者save或者delete
    " + + result); + + return "redirect:" + this.adminPath + "/gen/genTable/?repage"; + } + + public void genMenu(GenScheme genScheme,String href){ + String paraentId="158586ffb6b44175885680d1c93f05bd"; + Menu menu=new Menu(); + List menus=systemService.findAllMenu(); + for (Menu menuItem:menus) { + if(href.equals(menuItem.getHref())){ + return; + } + } + menu.setHref(href); + menu.setName(genScheme.getFunctionName()); + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + menu.setPermission(genScheme.getModuleName()+":"+genScheme.getSubModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":list"); + }else{ + menu.setPermission(genScheme.getModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":list"); + } + menu.setSort(30); + menu.setIsShow("1"); + menu.setDelFlag("0"); + Menu parent=new Menu(); + parent.setId(paraentId); + parent.setName("生成模块"); + menu.setParent(parent); + systemService.saveMenu(menu); + + //View + Menu menuView=new Menu(); + menuView.setName("查看"); + for (Menu menuItem:menus) { + if((menuView.getName().equals(menuItem.getName()) || menuItem.getName().contains(genScheme.getFunctionName())) && menuItem.getParentId().equals(menu.getParentId())){ + menuView=menuItem; + } + } + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + menuView.setPermission(genScheme.getModuleName()+":"+genScheme.getSubModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":view"); + }else{ + menuView.setPermission(genScheme.getModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":view"); + } + menuView.setSort(30); + menuView.setIsShow("1"); + menuView.setDelFlag("0"); + menuView.setParent(menu); + systemService.saveMenu(menuView); + + //edit + Menu menuEdit=new Menu(); + menuEdit.setName("编辑"); + for (Menu menuItem:menus) { + if((menuEdit.getName().equals(menuItem.getName()) || menuItem.getName().contains(genScheme.getFunctionName())) && menuItem.getParentId().equals(menu.getParentId())){ + menuEdit=menuItem; + } + } + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + menuEdit.setPermission(genScheme.getModuleName()+":"+genScheme.getSubModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":edit"); + }else{ + menuEdit.setPermission(genScheme.getModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":edit"); + } + menuEdit.setSort(60); + menuEdit.setIsShow("1"); + menuEdit.setDelFlag("0"); + menuEdit.setParent(menu); + systemService.saveMenu(menuEdit); + + //add + Menu menuAdd=new Menu(); + menuAdd.setName("添加"); + for (Menu menuItem:menus) { + if((menuAdd.getName().equals(menuItem.getName()) || menuItem.getName().contains(genScheme.getFunctionName())) && menuItem.getParentId().equals(menu.getParentId())){ + menuAdd=menuItem; + } + } + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + menuAdd.setPermission(genScheme.getModuleName()+":"+genScheme.getSubModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":add"); + }else{ + menuAdd.setPermission(genScheme.getModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":add"); + } + menuAdd.setSort(90); + menuAdd.setIsShow("1"); + menuAdd.setDelFlag("0"); + menuAdd.setParent(menu); + systemService.saveMenu(menuAdd); + + //del + Menu menuDel=new Menu(); + menuDel.setName("删除"); + for (Menu menuItem:menus) { + if((menuDel.getName().equals(menuItem.getName()) || menuItem.getName().contains(genScheme.getFunctionName())) && menuItem.getParentId().equals(menu.getParentId())){ + menuDel=menuItem; + } + } + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + menuDel.setPermission(genScheme.getModuleName()+":"+genScheme.getSubModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":del"); + }else{ + menuDel.setPermission(genScheme.getModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":del"); + } + menuDel.setSort(120); + menuDel.setIsShow("1"); + menuDel.setDelFlag("0"); + menuDel.setParent(menu); + systemService.saveMenu(menuDel); + + //export + Menu menuExport=new Menu(); + menuExport.setName("导出"); + for (Menu menuItem:menus) { + if((menuExport.getName().equals(menuItem.getName()) || menuItem.getName().contains(genScheme.getFunctionName())) && menuItem.getParentId().equals(menu.getParentId())){ + menuExport=menuItem; + } + } + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + menuExport.setPermission(genScheme.getModuleName()+":"+genScheme.getSubModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":export"); + }else{ + menuExport.setPermission(genScheme.getModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":export"); + } + menuExport.setSort(150); + menuExport.setIsShow("1"); + menuExport.setDelFlag("0"); + menuExport.setParent(menu); + systemService.saveMenu(menuExport); + + //import + Menu menuImport=new Menu(); + menuImport.setName("导入"); + for (Menu menuItem:menus) { + if((menuImport.getName().equals(menuItem.getName()) || menuItem.getName().contains(genScheme.getFunctionName())) && menuItem.getParentId().equals(menu.getParentId())){ + menuImport=menuItem; + } + } + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + menuImport.setPermission(genScheme.getModuleName()+":"+genScheme.getSubModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":import"); + }else{ + menuImport.setPermission(genScheme.getModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":import"); + } + menuImport.setSort(180); + menuImport.setIsShow("1"); + menuImport.setDelFlag("0"); + menuImport.setParent(menu); + systemService.saveMenu(menuImport); + + //total + Menu menuTotal=new Menu(); + menuTotal.setName("统计"); + for (Menu menuItem:menus) { + if((menuTotal.getName().equals(menuItem.getName()) || menuItem.getName().contains(genScheme.getFunctionName())) && menuItem.getParentId().equals(menu.getParentId())){ + menuTotal=menuItem; + } + } + if(genScheme.getSubModuleName()!=null && genScheme.getSubModuleName().length()>0){ + menuTotal.setPermission(genScheme.getModuleName()+":"+genScheme.getSubModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":total"); + }else{ + menuTotal.setPermission(genScheme.getModuleName()+":"+StringUtils.toCamelCase(genScheme.getGenTable().getName())+":total"); + } + menuTotal.setSort(210); + menuTotal.setIsShow("1"); + menuTotal.setDelFlag("0"); + menuTotal.setParent(menu); + systemService.saveMenu(menuTotal); + } + @Autowired + private GenTableService genTableService; + @Autowired + private GenSchemeService genSchemeService; +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenTemplateController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenTemplateController.java new file mode 100644 index 0000000..03e35f3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/gen/web/GenTemplateController.java @@ -0,0 +1,104 @@ +// Decompiled by DJ v3.12.12.98 Copyright 2014 Atanas Neshkov Date: 2017/5/31 16:22:52 +// Home Page: http://www.neshkov.com/dj.html - Check often for new version! +// Decompiler options: packimports(3) +// Source File Name: GenTemplateController.java + +package com.jeespring.modules.gen.web; + +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.gen.entity.GenTemplate; +import com.jeespring.modules.gen.service.GenTemplateService; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SysConfigService; +import com.jeespring.modules.sys.utils.UserUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +@Controller +@RequestMapping(value={"${adminPath}/gen/genTemplate"}) +public class GenTemplateController extends AbstractBaseController +{ + @Autowired + private SysConfigService sysConfigService; + + public GenTemplateController() + { + } + + @ModelAttribute + public GenTemplate get(@RequestParam(required=true) String id) + { + if(StringUtils.isNotBlank(id)) { + return genTemplateService.get(id); + } else { + return new GenTemplate(); + } + } + + @RequiresPermissions(value={"gen:genTemplate:view"}) + @RequestMapping(value={"list", ""}) + public String list(GenTemplate genTemplate, HttpServletRequest request, HttpServletResponse response, Model model) + { + User user = UserUtils.getUser(); + if(!user.isAdmin()) { + genTemplate.setCreateBy(user); + } + Page page = genTemplateService.find(new Page(request, response), genTemplate); + model.addAttribute("page", page); + return "modules/gen/genTemplateList"; + } + + @RequiresPermissions(value={"gen:genTemplate:view"}) + @RequestMapping(value={"form"}) + public String form(GenTemplate genTemplate, Model model) + { + model.addAttribute("genTemplate", genTemplate); + return "modules/gen/genTemplateForm"; + } + + @RequiresPermissions(value={"gen:genTemplate:edit"}) + @RequestMapping(value={"save"}) + public String save(GenTemplate genTemplate, Model model, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genTemplate/"; + } + + if (!beanValidator(model, genTemplate)) { + return form(genTemplate, model); + } + this.genTemplateService.save(genTemplate); + addMessage(redirectAttributes, "保存代码模板'" + genTemplate.getName() + "'成功"); + return "redirect:" + this.adminPath + "/gen/genTemplate/?repage"; + } + + @RequiresPermissions(value={"gen:genTemplate:edit"}) + @RequestMapping(value={"delete"}) + public String delete(GenTemplate genTemplate, RedirectAttributes redirectAttributes) + { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/gen/genTemplate/"; + } + + this.genTemplateService.delete(genTemplate); + addMessage(redirectAttributes, "删除代码模板成功"); + return "redirect:" + this.adminPath + "/gen/genTemplate/?repage"; } + + @Autowired + private GenTemplateService genTemplateService; +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/ChatHistoryDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/ChatHistoryDao.java new file mode 100644 index 0000000..cd3ed49 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/ChatHistoryDao.java @@ -0,0 +1,31 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.dao; + +import java.util.List; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.iim.entity.ChatHistory; + +/** + * 聊天记录DAO接口 + * * * * @author 黄炳桂 516821420@qq.com + * @version 2015-12-29 + */ +@Mapper +public interface ChatHistoryDao extends InterfaceBaseDao { + + + /** + * 查询列表数据 + * @param entity + * @return + */ + List findLogList(ChatHistory entity); + + + int findUnReadCount(ChatHistory chatHistory); + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailBoxDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailBoxDao.java new file mode 100644 index 0000000..7860c6a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailBoxDao.java @@ -0,0 +1,20 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.iim.entity.MailBox; + +/** + * 发件箱DAO接口 + * * * * @author 黄炳桂 516821420@qq.com + * @version 2015-11-15 + */ +@Mapper +public interface MailBoxDao extends InterfaceBaseDao { + + int getCount(MailBox entity); + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailComposeDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailComposeDao.java new file mode 100644 index 0000000..1bd5d51 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailComposeDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.iim.entity.MailCompose; + +/** + * 发件箱DAO接口 + * * * * @author 黄炳桂 516821420@qq.com + * @version 2015-11-15 + */ +@Mapper +public interface MailComposeDao extends InterfaceBaseDao { + int getCount(MailCompose entity); +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailDao.java new file mode 100644 index 0000000..a910305 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MailDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.iim.entity.Mail; + +/** + * 发件箱DAO接口 + * * * * @author 黄炳桂 516821420@qq.com + * @version 2015-11-15 + */ +@Mapper +public interface MailDao extends InterfaceBaseDao { + int getCount(MailDao entity); +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MyCalendarDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MyCalendarDao.java new file mode 100644 index 0000000..3c1a636 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/dao/MyCalendarDao.java @@ -0,0 +1,19 @@ +/** + * Copyright © 2015-2020 JeePlus All rights reserved. + */ +package com.jeespring.modules.iim.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.modules.iim.entity.MyCalendar; +import org.apache.ibatis.annotations.Mapper; + + +/** + * 日历DAO接口 + * @author JeeSpring + * @version 2016-04-19 + */ +@Mapper +public interface MyCalendarDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/ChatHistory.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/ChatHistory.java new file mode 100644 index 0000000..4f1eb04 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/ChatHistory.java @@ -0,0 +1,72 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.entity; + +import org.hibernate.validator.constraints.Length; + +import com.jeespring.common.utils.excel.annotation.ExcelField; +import com.jeespring.common.persistence.AbstractBaseEntity; + +/** + * 聊天记录Entity + * @author 黄炳桂 516821420@qq.com + * @version 2015-12-29 + */ +public class ChatHistory extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String userid1; // userid1 发送者id + private String userid2; // userid2 接收者id + private String msg; // msg + private String status; // status + + public ChatHistory() { + super(); + } + + public ChatHistory(String id){ + super(id); + } + + @Length(min=0, max=64, message="userid1长度必须介于 0 和 64 之间") + @ExcelField(title="userid1", align=2, sort=1) + public String getUserid1() { + return userid1; + } + + public void setUserid1(String userid1) { + this.userid1 = userid1; + } + + @Length(min=0, max=64, message="userid2长度必须介于 0 和 64 之间") + @ExcelField(title="userid2", align=2, sort=2) + public String getUserid2() { + return userid2; + } + + public void setUserid2(String userid2) { + this.userid2 = userid2; + } + + @Length(min=0, max=1024, message="msg长度必须介于 0 和 1024 之间") + @ExcelField(title="msg", align=2, sort=3) + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + @Length(min=0, max=45, message="status长度必须介于 0 和 45 之间") + @ExcelField(title="status", align=2, sort=4) + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Friend.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Friend.java new file mode 100644 index 0000000..d343adf --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Friend.java @@ -0,0 +1,35 @@ +package com.jeespring.modules.iim.entity; + +public class Friend { + + private String id; + + private String name; + + private String face; + + public void setId(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setFace(String face) { + this.face = face; + } + + public String getFace() { + return face; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Group.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Group.java new file mode 100644 index 0000000..87d3d41 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Group.java @@ -0,0 +1,46 @@ +package com.jeespring.modules.iim.entity; + +import java.util.ArrayList; +import java.util.List; + +public class Group { + + private String name; + private int nums; + private int id; + + private List item = new ArrayList(); + + public void setItem(List item) { + this.item = item; + } + + public List getItem() { + return item; + } + + public void setNums(int nums) { + this.nums = nums; + } + + public int getNums() { + return nums; + } + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setId(int id) { + this.id = id; + } + + public int getId() { + return id; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/LayJson.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/LayJson.java new file mode 100644 index 0000000..12e7291 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/LayJson.java @@ -0,0 +1,30 @@ +package com.jeespring.modules.iim.entity; + +import java.util.ArrayList; +import java.util.List; + +public class LayJson { + + private int status; + private String msg; + private List data = new ArrayList(); + public void setData(List data) { + this.data = data; + } + public List getData() { + return data; + } + public void setMsg(String msg) { + this.msg = msg; + } + public String getMsg() { + return msg; + } + public void setStatus(int status) { + this.status = status; + } + public int getStatus() { + return status; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Mail.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Mail.java new file mode 100644 index 0000000..30924ee --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/Mail.java @@ -0,0 +1,77 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.entity; + +import org.hibernate.validator.constraints.Length; + +import java.util.List; + +import com.google.common.collect.Lists; +import com.jeespring.common.persistence.AbstractBaseEntity; + + +/** + * 发件箱Entity + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-15 + */ +public class Mail extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String title; // 标题 + private String overview; // 内容概要 + private String content; // 内容 + private List mailBoxList = Lists.newArrayList(); // 子表列表 + private List mailComposeList = Lists.newArrayList(); // 子表列表 + + public Mail() { + super(); + } + + public Mail(String id){ + super(id); + } + + @Length(min=0, max=128, message="标题长度必须介于 0 和 128 之间") + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Length(min=0, max=128, message="内容概要长度必须介于 0 和 128 之间") + public String getOverview() { + return overview; + } + + public void setOverview(String overview) { + this.overview = overview; + } + + @Length(min=0, max=5096, message="内容长度必须介于 0 和 5096 之间") + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public List getMailBoxList() { + return mailBoxList; + } + + public void setMailBoxList(List mailBoxList) { + this.mailBoxList = mailBoxList; + } + public List getMailComposeList() { + return mailComposeList; + } + + public void setMailComposeList(List mailComposeList) { + this.mailComposeList = mailComposeList; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailBox.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailBox.java new file mode 100644 index 0000000..06124ff --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailBox.java @@ -0,0 +1,84 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.entity; + +import org.hibernate.validator.constraints.Length; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.modules.sys.entity.User; + + +/** + * 发件箱Entity + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-15 + */ +public class MailBox extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String readstatus; // 状态 0 未读 1 已读 + private User sender; // 发件人 + private User receiver; // 收件人 + private Date sendtime; // 发送时间 + private Mail mail; // 邮件外键 父类 + + public MailBox() { + super(); + } + + public MailBox(String id){ + super(id); + } + + public MailBox(Mail mail){ + this.mail = mail; + } + + @Length(min=0, max=45, message="状态 0 未读 1 已读长度必须介于 0 和 45 之间") + public String getReadstatus() { + return readstatus; + } + + public void setReadstatus(String readstatus) { + this.readstatus = readstatus; + } + + public User getSender() { + return sender; + } + + public void setSender(User sender) { + this.sender = sender; + } + + public User getReceiver() { + return receiver; + } + + public void setReceiver(User receiver) { + this.receiver = receiver; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + public Date getSendtime() { + return sendtime; + } + + public void setSendtime(Date sendtime) { + this.sendtime = sendtime; + } + + @Length(min=0, max=64, message="邮件外键长度必须介于 0 和 64 之间") + public Mail getMail() { + return mail; + } + + public void setMail(Mail mail) { + this.mail = mail; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailCompose.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailCompose.java new file mode 100644 index 0000000..c4d879d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailCompose.java @@ -0,0 +1,148 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.entity; + +import org.hibernate.validator.constraints.Length; + +import java.util.Date; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.google.common.collect.Lists; +import com.jeespring.common.utils.Collections3; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.modules.sys.entity.User; + + +/** + * 发件箱Entity + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-15 + */ +public class MailCompose extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String status; // 状态 0 草稿 1 已发送 + private String readstatus; // 状态 0 未读 1 已读 + private User sender; // 发送者 + private User receiver; // 接收者 + private List receiverList; // 接收者 + private Date sendtime; // 发送时间 + private Mail mail; // 邮件id 父类 + + public MailCompose() { + super(); + } + + public MailCompose(String id){ + super(id); + } + + public MailCompose(Mail mail){ + this.mail = mail; + } + + @Length(min=0, max=45, message="状态 0 草稿 1 已发送长度必须介于 0 和 45 之间") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Length(min=0, max=45, message="状态 0 未读 1 已读长度必须介于 0 和 45 之间") + public String getReadstatus() { + return readstatus; + } + + public void setReadstatus(String readstatus) { + this.readstatus = readstatus; + } + + public User getSender() { + return sender; + } + + public void setSender(User sender) { + this.sender = sender; + } + + + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + public Date getSendtime() { + return sendtime; + } + + public void setSendtime(Date sendtime) { + this.sendtime = sendtime; + } + + @Length(min=0, max=64, message="邮件id长度必须介于 0 和 64 之间") + public Mail getMail() { + return mail; + } + + public void setMail(Mail mail) { + this.mail = mail; + } + + + public void setReceiverList(List receiverList) { + this.receiverList = receiverList; + } + + public List getReceiverList() { + return receiverList; + } + + + /** + * 获取收件人用户ID + * @return + */ + public String getReceiverIds() { + return Collections3.extractToString(receiverList, "user.id", ",") ; + } + + /** + * 设置收件人用户ID + * @return + */ + public void setReceiverIds(String receiverIds) { + this.receiverList = Lists.newArrayList(); + for (String id : StringUtils.split(receiverIds, ",")){ + + this.receiverList.add(new User(id)); + } + } + + /** + * 获取收件人用户Name + * @return + */ + public String getReceiverNames() { + return Collections3.extractToString(receiverList, "user.name", ",") ; + } + + /** + * 设置发件人用户Name + * @return + */ + public void setReceiverNames(String receiverNames) { + // 什么也不做 + } + + public void setReceiver(User receiver) { + this.receiver = receiver; + } + + public User getReceiver() { + return receiver; + } + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailPage.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailPage.java new file mode 100644 index 0000000..b36e7db --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MailPage.java @@ -0,0 +1,109 @@ +package com.jeespring.modules.iim.entity; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.common.persistence.Page; + +public class MailPage extends Page{ + + public MailPage(HttpServletRequest request, HttpServletResponse response){ + super(request, response, -2); + } + /** + * 默认输出当前分页标签 + *
    ${page}
    + */ + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("
    "); + sb.append("
    "); + + + sb.append("
    "); + + sb.append("
      "); + + if (pageNo == first) {// 如果是首页 + sb.append("
    • 上一页
    • \n"); + } else { + sb.append("
    • 上一页
    • \n"); + } + + int begin = pageNo - (length / 2); + + if (begin < first) { + begin = first; + } + + int end = begin + length - 1; + + if (end >= last) { + end = last; + begin = end - length + 1; + if (begin < first) { + begin = first; + } + } + + if (begin > first) { + int i = 0; + for (i = first; i < first + slider && i < begin; i++) { + sb.append("
    • " + + (i + 1 - first) + "
    • \n"); + } + if (i < begin) { + sb.append("
    • ...
    • \n"); + } + } + + for (int i = begin; i <= end; i++) { + if (i == pageNo) { + sb.append("
    • " + (i + 1 - first) + + "
    • \n"); + } else { + sb.append("
    • " + + (i + 1 - first) + "
    • \n"); + } + } + + if (last - end > slider) { + sb.append("
    • ...
    • \n"); + end = last - slider; + } + + for (int i = end + 1; i <= last; i++) { + sb.append("
    • " + + (i + 1 - first) + "
    • \n"); + } + + if (pageNo == last) { + sb.append("
    • 下一页
    • \n"); + } else { + sb.append("
    • " + + "下一页
    • \n"); + } + + sb.append("
    • \n"); + sb.append("
    "); + sb.append("
    "); + sb.append("
    "); + sb.append("
    "); +// sb.insert(0,"
      \n").append("
    \n"); + +// sb.append("
    "); + +// sb.insert(0,"
    \n").append("
    \n"); + + return sb.toString(); + } + + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MyCalendar.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MyCalendar.java new file mode 100644 index 0000000..8d85e19 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/entity/MyCalendar.java @@ -0,0 +1,93 @@ +/** + * Copyright © 2015-2020 JeePlus All rights reserved. + */ +package com.jeespring.modules.iim.entity; + +import org.hibernate.validator.constraints.Length; + +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; +import com.jeespring.modules.sys.entity.User; + +/** + * 日历Entity + * @author liugf + * @version 2016-04-19 + */ +public class MyCalendar extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String title; // 事件标题 + private String start; // 事件开始时间 + private String end; // 事件结束时间 + private String adllDay; // 是否为全天时间 + private String color; // 时间的背景色 + private User user; // 所属用户 + + public MyCalendar() { + super(); + } + + public MyCalendar(String id){ + super(id); + } + + @Length(min=0, max=64, message="事件标题长度必须介于 0 和 64 之间") + @ExcelField(title="事件标题", align=2, sort=1) + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Length(min=0, max=64, message="事件开始时间长度必须介于 0 和 64 之间") + @ExcelField(title="事件开始时间", align=2, sort=2) + public String getStart() { + return start; + } + + public void setStart(String start) { + this.start = start; + } + + @Length(min=0, max=64, message="事件结束时间长度必须介于 0 和 64 之间") + @ExcelField(title="事件结束时间", align=2, sort=3) + public String getEnd() { + return end; + } + + public void setEnd(String end) { + this.end = end; + } + + @Length(min=0, max=64, message="是否为全天时间长度必须介于 0 和 64 之间") + @ExcelField(title="是否为全天时间", align=2, sort=4) + public String getAdllDay() { + return adllDay; + } + + public void setAdllDay(String adllDay) { + this.adllDay = adllDay; + } + + @Length(min=0, max=64, message="时间的背景色长度必须介于 0 和 64 之间") + @ExcelField(title="时间的背景色", align=2, sort=5) + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public void setUser(User user) { + this.user = user; + } + + public User getUser() { + return user; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/ChatHistoryService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/ChatHistoryService.java new file mode 100644 index 0000000..bb8bc58 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/ChatHistoryService.java @@ -0,0 +1,60 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.iim.dao.ChatHistoryDao; +import com.jeespring.modules.iim.entity.ChatHistory; + +/** + * 聊天记录Service + * @author 黄炳桂 516821420@qq.com + * @version 2015-12-29 + */ +@Service +@Transactional(readOnly = true) +public class ChatHistoryService extends AbstractBaseService { + + @Override + public ChatHistory get(String id) { + return super.get(id); + } + + @Override + public List findList(ChatHistory chatHistory) { + return super.findList(chatHistory); + } + + + @Override + public Page findPage(Page page, ChatHistory entity) { + entity.setPage(page); + page.setList(dao.findLogList(entity)); + return page; + } + + + @Override + @Transactional(readOnly = false) + public void save(ChatHistory chatHistory) { + super.save(chatHistory); + } + + @Override + @Transactional(readOnly = false) + public void delete(ChatHistory chatHistory) { + super.delete(chatHistory); + } + + public int findUnReadCount(ChatHistory chatHistory){ + return dao.findUnReadCount(chatHistory); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailBoxService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailBoxService.java new file mode 100644 index 0000000..a87f4c1 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailBoxService.java @@ -0,0 +1,59 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.iim.dao.MailBoxDao; +import com.jeespring.modules.iim.entity.MailBox; +import com.jeespring.modules.iim.entity.MailPage; + +/** + * 收件箱Service + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-13 + */ +@Service +@Transactional(readOnly = true) +public class MailBoxService extends AbstractBaseService { + + @Autowired + private MailBoxDao mailBoxDao; + @Override + public MailBox get(String id) { + return super.get(id); + } + + @Override + public List findList(MailBox mailBox) { + return super.findList(mailBox); + } + + public Page findPage(MailPage page, MailBox mailBox) { + return super.findPage(page, mailBox); + } + + @Override + @Transactional(readOnly = false) + public void save(MailBox mailBox) { + super.save(mailBox); + } + + @Override + @Transactional(readOnly = false) + public void delete(MailBox mailBox) { + super.delete(mailBox); + } + + public int getCount(MailBox mailBox) { + return mailBoxDao.getCount(mailBox); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailComposeService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailComposeService.java new file mode 100644 index 0000000..4b380b8 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailComposeService.java @@ -0,0 +1,58 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.iim.dao.MailComposeDao; +import com.jeespring.modules.iim.entity.MailCompose; +import com.jeespring.modules.iim.entity.MailPage; + +/** + * 发件箱Service + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-13 + */ +@Service +@Transactional(readOnly = true) +public class MailComposeService extends AbstractBaseService { + @Autowired + private MailComposeDao mailComposeDao; + @Override + public MailCompose get(String id) { + return super.get(id); + } + + @Override + public List findList(MailCompose mailCompose) { + return super.findList(mailCompose); + } + + public Page findPage(MailPage page, MailCompose mailCompose) { + return super.findPage(page, mailCompose); + } + + @Override + @Transactional(readOnly = false) + public void save(MailCompose mailCompose) { + super.save(mailCompose); + } + + @Override + @Transactional(readOnly = false) + public void delete(MailCompose mailCompose) { + super.delete(mailCompose); + } + + public int getCount(MailCompose mailCompose) { + return mailComposeDao.getCount(mailCompose); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailService.java new file mode 100644 index 0000000..8c6b74a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MailService.java @@ -0,0 +1,140 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.iim.dao.MailBoxDao; +import com.jeespring.modules.iim.dao.MailComposeDao; +import com.jeespring.modules.iim.dao.MailDao; +import com.jeespring.modules.iim.entity.Mail; +import com.jeespring.modules.iim.entity.MailBox; +import com.jeespring.modules.iim.entity.MailCompose; + +/** + * 发件箱Service + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-15 + */ +@Service +@Transactional(readOnly = true) +public class MailService extends AbstractBaseService { + + @Autowired + private MailBoxDao mailBoxDao; + @Autowired + private MailComposeDao mailComposeDao; + + @Override + public Mail get(String id) { + Mail mail = super.get(id); + mail.setMailBoxList(mailBoxDao.findList(new MailBox(mail))); + mail.setMailComposeList(mailComposeDao.findList(new MailCompose(mail))); + return mail; + } + + @Override + public List findList(Mail mail) { + return super.findList(mail); + } + + @Override + public Page findPage(Page page, Mail mail) { + return super.findPage(page, mail); + } + + @Override + @Transactional(readOnly = false) + public void save(Mail mail) { + super.save(mail); + for (MailBox mailBox : mail.getMailBoxList()){ + if (mailBox.getId() == null){ + continue; + } + if (MailBox.DEL_FLAG_NORMAL.equals(mailBox.getDelFlag())){ + if (StringUtils.isBlank(mailBox.getId())){ + mailBox.setMail(mail); + mailBox.preInsert(); + mailBoxDao.insert(mailBox); + }else{ + mailBox.preUpdate(); + mailBoxDao.update(mailBox); + } + }else{ + mailBoxDao.delete(mailBox); + } + } + for (MailCompose mailCompose : mail.getMailComposeList()){ + if (mailCompose.getId() == null){ + continue; + } + if (MailCompose.DEL_FLAG_NORMAL.equals(mailCompose.getDelFlag())){ + if (StringUtils.isBlank(mailCompose.getId())){ + mailCompose.setMail(mail); + mailCompose.preInsert(); + mailComposeDao.insert(mailCompose); + }else{ + mailCompose.preUpdate(); + mailComposeDao.update(mailCompose); + } + }else{ + mailComposeDao.delete(mailCompose); + } + } + } + @Transactional(readOnly = false) + public void saveOnlyMain(Mail mail) { + super.save(mail); + for (MailBox mailBox : mail.getMailBoxList()){ + if (mailBox.getId() == null){ + continue; + } + if (MailBox.DEL_FLAG_NORMAL.equals(mailBox.getDelFlag())){ + if (StringUtils.isBlank(mailBox.getId())){ + mailBox.setMail(mail); + mailBox.preInsert(); + mailBoxDao.insert(mailBox); + }else{ + mailBox.preUpdate(); + mailBoxDao.update(mailBox); + } + }else{ + mailBoxDao.delete(mailBox); + } + } + for (MailCompose mailCompose : mail.getMailComposeList()){ + if (mailCompose.getId() == null){ + continue; + } + if (MailCompose.DEL_FLAG_NORMAL.equals(mailCompose.getDelFlag())){ + if (StringUtils.isBlank(mailCompose.getId())){ + mailCompose.setMail(mail); + mailCompose.preInsert(); + mailComposeDao.insert(mailCompose); + }else{ + mailCompose.preUpdate(); + mailComposeDao.update(mailCompose); + } + }else{ + mailComposeDao.delete(mailCompose); + } + } + } + + @Override + @Transactional(readOnly = false) + public void delete(Mail mail) { + super.delete(mail); + mailBoxDao.delete(new MailBox(mail)); + mailComposeDao.delete(new MailCompose(mail)); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MyCalendarService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MyCalendarService.java new file mode 100644 index 0000000..5c348d8 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/service/MyCalendarService.java @@ -0,0 +1,53 @@ +/** + * Copyright © 2015-2020 JeePlus All rights reserved. + */ +package com.jeespring.modules.iim.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.iim.dao.MyCalendarDao; +import com.jeespring.modules.iim.entity.MyCalendar; + + +/** + * 日历Service + * @author liugf + * @version 2016-04-19 + */ +@Service +@Transactional(readOnly = true) +public class MyCalendarService extends AbstractBaseService { + + @Override + public MyCalendar get(String id) { + return super.get(id); + } + + @Override + public List findList(MyCalendar myCalendar) { + return super.findList(myCalendar); + } + + @Override + public Page findPage(Page page, MyCalendar myCalendar) { + return super.findPage(page, myCalendar); + } + + @Override + @Transactional(readOnly = false) + public void save(MyCalendar myCalendar) { + super.save(myCalendar); + } + + @Override + @Transactional(readOnly = false) + public void delete(MyCalendar myCalendar) { + super.delete(myCalendar); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/utils/DateUtil.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/utils/DateUtil.java new file mode 100644 index 0000000..4ca812c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/utils/DateUtil.java @@ -0,0 +1,53 @@ +package com.jeespring.modules.iim.utils; + + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 日期及时间处理函数 + * + * @author liugf + */ +public class DateUtil { + + private static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss"; + + /** + * 字符串时间转LONG + * @param sdate + * @return + */ + public static long string2long(String sdate){ + if(sdate.length() < 11){ + sdate = sdate + " 00:00:00"; + } + SimpleDateFormat sdf= new SimpleDateFormat(DEFAULT_PATTERN); + Date dt2 = null; + try { + dt2 = sdf.parse(sdate); + } catch (ParseException e) { + e.printStackTrace(); + } + //继续转换得到秒数的long型 + long lTime = dt2.getTime() / 1000; + return lTime; + } + + /** + * LONG时间转字符串 + * @param ldate + * @return + */ + public static String long2string(long ldate){ + SimpleDateFormat sdf= new SimpleDateFormat(DEFAULT_PATTERN); + //前面的ldate是秒数,先乘1000得到毫秒数,再转为java.util.Date类型 + Date dt = new Date(ldate * 1000); + String sDateTime = sdf.format(dt); //得到精确到秒的表示 + if(sDateTime.endsWith("00:00:00")){ + sDateTime = sDateTime.substring(0,10); + } + return sDateTime; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/ChatHistoryController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/ChatHistoryController.java new file mode 100644 index 0000000..9436869 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/ChatHistoryController.java @@ -0,0 +1,189 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.web; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.config.Global; +import com.jeespring.common.json.AjaxJson; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.iim.entity.ChatHistory; +import com.jeespring.modules.iim.service.ChatHistoryService; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 聊天记录Controller + * * * * @author 黄炳桂 516821420@qq.com + * @version 2015-12-29 + */ +@Controller +@RequestMapping(value = "${adminPath}/iim/chatHistory") +public class ChatHistoryController extends AbstractBaseController { + + @Autowired + private ChatHistoryService chatHistoryService; + + @ModelAttribute + public ChatHistory get(@RequestParam(required=false) String id) { + ChatHistory entity = null; + if (StringUtils.isNotBlank(id)){ + entity = chatHistoryService.get(id); + } + if (entity == null){ + entity = new ChatHistory(); + } + return entity; + } + + /** + * 聊天列表页面 + */ + @RequestMapping(value = {"list", ""}) + public String list(ChatHistory chatHistory, HttpServletRequest request, HttpServletResponse response, Model model) { + + Page pg = new Page(request, response); + Page page = chatHistoryService.findPage(pg, chatHistory); + model.addAttribute("chatHistory", chatHistory); + model.addAttribute("page", page); + return "modules/iim/chatHistoryList"; + } + + /** + * 查看,增加,编辑聊天表单页面 + */ + @RequestMapping(value = "form") + public String form(ChatHistory chatHistory, Model model) { + model.addAttribute("chatHistory", chatHistory); + return "modules/iim/chatHistoryForm"; + } + + /** + * 保存聊天 + */ + @RequestMapping(value = "save") + public String save(ChatHistory chatHistory, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, chatHistory)){ + return form(chatHistory, model); + } + chatHistoryService.save(chatHistory); + addMessage(redirectAttributes, "保存聊天成功"); + return "redirect:"+Global.getAdminPath()+"/iim/chatHistory/?repage"; + } + + /** + * 删除聊天 + */ + @RequestMapping(value = "delete") + public String delete(ChatHistory chatHistory, RedirectAttributes redirectAttributes) { + chatHistoryService.delete(chatHistory); + addMessage(redirectAttributes, "删除聊天成功"); + return "redirect:"+Global.getAdminPath()+"/iim/chatHistory/?repage"; + } + + /** + * 批量删除聊天 + */ + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + chatHistoryService.delete(chatHistoryService.get(id)); + } + addMessage(redirectAttributes, "删除聊天成功"); + return "redirect:"+Global.getAdminPath()+"/iim/chatHistory/?repage"; + } + + /** + * 导出excel文件 + */ + @RequiresPermissions("iim:chatHistory:view") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(ChatHistory chatHistory, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "聊天"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = chatHistoryService.findPage(new Page(request, response, -1), chatHistory); + new ExportExcel("聊天", ChatHistory.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出聊天记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/iim/chatHistory/?repage"; + } + + /** + * 获取聊天记录 + */ + @ResponseBody + @RequestMapping(value = "getChats") + public AjaxJson getChats(ChatHistory chatHistory, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = chatHistoryService.findPage(new Page(request, response), chatHistory); + List list = page.getList(); + for(ChatHistory c : list){ + if("0".equals(c.getStatus())){ + if(c.getUserid2().equals(UserUtils.getUser().getLoginName())){//把发送给我的信息标记为已读 + c.setStatus("1");//标记为已读 + chatHistoryService.save(c); + } + + } + } + AjaxJson j = new AjaxJson(); + j.setMsg("获取聊天记录成功!"); + j.put("data", page.getList()); + return j; + } + + /** + * 获取未读条数 + */ + @ResponseBody + @RequestMapping(value = "findUnReadCount") + public AjaxJson findUnReadCount(ChatHistory chatHistory, HttpServletRequest request, HttpServletResponse response, Model model) { + AjaxJson j = new AjaxJson(); + int size = chatHistoryService.findUnReadCount(chatHistory); + j.setMsg("获取未读条数成功!"); + j.put("num", size); + + return j; + + } + + + /** + * 发送聊天内容(手机端) + */ + + @ResponseBody + @RequestMapping(value = "sendChats") + public AjaxJson sendChats(ChatHistory chatHistory, HttpServletRequest request, HttpServletResponse response, Model model) { + AjaxJson j = new AjaxJson(); + j.setMsg("消息发送成功!"); + chatHistory.setStatus("0");//标记未读 + chatHistoryService.save(chatHistory); + + return j; + } + + + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/ContactController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/ContactController.java new file mode 100644 index 0000000..4512e3c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/ContactController.java @@ -0,0 +1,244 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.web; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.IdGen; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.iim.entity.Friend; +import com.jeespring.modules.iim.entity.Group; +import com.jeespring.modules.iim.entity.LayJson; +import com.jeespring.modules.sys.dao.UserDao; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.OfficeService; +import com.jeespring.modules.sys.service.SystemService; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 心电图实时显示查看Controller + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-09 + */ +@Controller +@RequestMapping(value = "${adminPath}/iim/contact") +public class ContactController extends AbstractBaseController { + + @Autowired + private SystemService systemService; + + @Autowired + private UserDao userDao; + + @Autowired + private OfficeService officeService; + + + /** + * 打开通讯录 + * @param user + * @param request + * @param response + * @param model + * @return + */ + @RequestMapping(value = {"index", ""}) + public String index(User user, HttpServletRequest request, HttpServletResponse response, Model model) { + List list = systemService.findUser(user); + model.addAttribute("list", list); + return "modules/iim/contacts"; + } + + + /** + * 查找医生 + * @param user + * @param request + * @param response + * @param model + * @return + */ + @RequestMapping(value = "searchUsers") + public String searchUsers(User user, HttpServletRequest request, HttpServletResponse response, Model model) { + List friends = userDao.searchUsers(user); + model.addAttribute("list", friends); + + return "modules/iim/search_user"; + } + + + /** + * 添加好友--->常用联系人 + */ + @RequestMapping(value = "addFriend") + public String addFriend(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + User currentUser = UserUtils.getUser(); + for(String id : idArray){ + if(userDao.findFriend(currentUser.getId(), id) == null){ + + userDao.insertFriend(IdGen.uuid(), currentUser.getId(), id);//添加对方为好友 + // userDao.insertFriend(IdGen.uuid(), id, currentUser.getId());//同时把自己添加为对方的好友 + } + } + addMessage(redirectAttributes, "添加好友成功"); + return "redirect:"+Global.getAdminPath()+"/iim/contact/myFriends/?repage"; + } + + + /** + * 删除好友 + */ + @RequestMapping(value = "delFriend") + public String delFriend(String id, RedirectAttributes redirectAttributes) { + User friend = UserUtils.get(id); + User currentUser = UserUtils.getUser(); + if(friend != null && userDao.findFriend(currentUser.getId(), friend.getId()) != null){ + userDao.deleteFriend(currentUser.getId(), friend.getId());//删除好友 + // userDao.deleteFriend(friend.getId(), currentUser.getId());//同时把自己从对方的好友列表删除 + } + + return "redirect:"+Global.getAdminPath()+"/iim/contact/myFriends/?repage"; + } + + /** + * 打开我的好友列表--->常用联系人列表 + * @param user + * @param request + * @param response + * @param model + * @return + */ + @RequestMapping(value = "myFriends") + public String myFriends(User user, HttpServletRequest request, HttpServletResponse response, Model model) { + User currentUser = UserUtils.getUser(); + List friends = userDao.findFriends(currentUser); + model.addAttribute("list", friends); + return "modules/iim/myFriends"; + } + + + + + + /** + * 打开聊天窗口 + * @param user + * @param request + * @param response + * @param model + * @return + */ + @RequestMapping(value = "layerIM") + public String layerIM(User user, HttpServletRequest request, HttpServletResponse response, Model model) { + List list = systemService.findUser(user); + model.addAttribute("list", list); + return "modules/iim/layerIM"; + } + + @RequestMapping(value="friend") + @ResponseBody + public LayJson getFriend(User user, HttpServletRequest request, HttpServletResponse response, Model model){ + LayJson j = new LayJson(); + j.setStatus(1); + //我的好友--->常用联系人 + User currentUser = UserUtils.getUser(); + List friends = userDao.findFriends(currentUser); + Group friendGroup = new Group(); + friendGroup.setName("我的好友"); + friendGroup.setId(1); + friendGroup.setNums(friends.size()); + for(User u : friends){ + Friend friend = new Friend(); + friend.setId(u.getLoginName()); + friend.setName(u.getName()); + friend.setFace(u.getPhoto()); + friendGroup.getItem().add(friend); + } + j.getData().add(friendGroup); + + + List officeList = officeService.findList(true); + int index=1; + for(Office office : officeList){ + user.setOffice(office); + List users = userDao.findListByOffice(user); + Group group = new Group(); + group.setName(office.getName()); + group.setNums(users.size()); + group.setId(++index); + for(User u : users){ + Friend friend = new Friend(); + friend.setId(u.getLoginName()); + friend.setName(u.getName()); + friend.setFace(u.getPhoto()); + group.getItem().add(friend); + } + j.getData().add(group); + } + user.setOffice(null); + List users = userDao.findListByOffice(user); + Group group = new Group(); + group.setName("未分组"); + group.setNums(users.size()); + group.setId(++index); + for(User u : users){ + Friend friend = new Friend(); + friend.setId(u.getLoginName()); + friend.setName(u.getName()); + friend.setFace(u.getPhoto()); + group.getItem().add(friend); + } + j.getData().add(group); + + return j; + } + + /** + * 群组列表接口 预留待开发 + * @return + */ + @RequestMapping(value="group") + @ResponseBody + public LayJson getGroup(){ + LayJson j = new LayJson(); + j.setStatus(1); + return j; + } + /** + * 最近联系人接口 预留 + * @return + */ + @RequestMapping(value="chatLog") + @ResponseBody + public LayJson getChatLog(){ + LayJson j = new LayJson(); + j.setStatus(1); + return j; + } + /** + * 群组成员接口 预留 + * @return + */ + @RequestMapping(value="groups") + @ResponseBody + public LayJson getGroups(){ + LayJson j = new LayJson(); + j.setStatus(1); + return j; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailBoxController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailBoxController.java new file mode 100644 index 0000000..06179a3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailBoxController.java @@ -0,0 +1,153 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.web; + +import java.util.Date; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.iim.entity.MailBox; +import com.jeespring.modules.iim.entity.MailCompose; +import com.jeespring.modules.iim.entity.MailPage; +import com.jeespring.modules.iim.service.MailBoxService; +import com.jeespring.modules.iim.service.MailComposeService; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 收件箱Controller + * * * * @author 黄炳桂 516821420@qq.com + * @version 2015-11-13 + */ +@Controller +@RequestMapping(value = "${adminPath}/iim/mailBox") +public class MailBoxController extends AbstractBaseController { + + @Autowired + private MailComposeService mailComposeService; + + @Autowired + private MailBoxService mailBoxService; + + @ModelAttribute + public MailBox get(@RequestParam(required=false) String id) { + MailBox entity = null; + if (StringUtils.isNotBlank(id)){ + entity = mailBoxService.get(id); + } + if (entity == null){ + entity = new MailBox(); + } + return entity; + } + + @RequestMapping(value = {"list", ""}) + public String list(MailBox mailBox, HttpServletRequest request, HttpServletResponse response, Model model) { + mailBox.setReceiver(UserUtils.getUser()); + Page page = mailBoxService.findPage(new MailPage(request, response), mailBox); + model.addAttribute("page", page); + + //查询未读的条数 + MailBox serachBox = new MailBox(); + serachBox.setReadstatus("0"); + serachBox.setReceiver(UserUtils.getUser()); + model.addAttribute("noReadCount", mailBoxService.getCount(serachBox)); + + //查询总条数 + MailBox serachBox2 = new MailBox(); + serachBox2.setReceiver(UserUtils.getUser()); + model.addAttribute("mailBoxCount", mailBoxService.getCount(serachBox2)); + + //查询已发送条数 + MailCompose serachBox3 = new MailCompose(); + serachBox3.setSender(UserUtils.getUser()); + serachBox3.setStatus("1");//已发送 + model.addAttribute("mailComposeCount", mailComposeService.getCount(serachBox3)); + + //查询草稿箱条数 + MailCompose serachBox4 = new MailCompose(); + serachBox4.setSender(UserUtils.getUser()); + serachBox4.setStatus("0");//草稿 + model.addAttribute("mailDraftCount", mailComposeService.getCount(serachBox4)); + + return "modules/iim/mailBoxList"; + } + + @RequestMapping(value = "detail") + public String detail(MailBox mailBox, Model model) { + if("0".equals(mailBox.getReadstatus())){//更改未读状态为已读状态 + mailBox.setReadstatus("1");//1表示已读 + mailBoxService.save(mailBox); + } + model.addAttribute("mailBox", mailBox); + //查询未读的条数 + MailBox serachBox = new MailBox(); + serachBox.setReadstatus("0"); + serachBox.setReceiver(UserUtils.getUser()); + model.addAttribute("noReadCount", mailBoxService.getCount(serachBox)); + + //查询总条数 + MailBox serachBox2 = new MailBox(); + serachBox2.setReceiver(UserUtils.getUser()); + model.addAttribute("mailBoxCount", mailBoxService.getCount(serachBox2)); + + //查询已发送条数 + MailCompose serachBox3 = new MailCompose(); + serachBox3.setSender(UserUtils.getUser()); + serachBox3.setStatus("1");//已发送 + model.addAttribute("mailComposeCount", mailComposeService.getCount(serachBox3)); + + //查询草稿箱条数 + MailCompose serachBox4 = new MailCompose(); + serachBox4.setSender(UserUtils.getUser()); + serachBox4.setStatus("0");//草稿 + model.addAttribute("mailDraftCount", mailComposeService.getCount(serachBox4)); + return "modules/iim/mailBoxDetail"; + } + + @RequestMapping(value = "save") + public String save(MailBox mailBox, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, mailBox)){ + return detail(mailBox, model); + } + Date date = new Date(System.currentTimeMillis()); + mailBox.setSender( UserUtils.getUser()); + mailBox.setSendtime(date); + mailBoxService.save(mailBox); + addMessage(redirectAttributes, "保存站内信成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mailBox/?repage"; + } + + @RequestMapping(value = "delete") + public String delete(MailBox mailBox, RedirectAttributes redirectAttributes) { + mailBoxService.delete(mailBox); + addMessage(redirectAttributes, "删除站内信成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mailBox/?repage"; + } + + /** + * 批量删除 + */ + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + mailBoxService.delete(mailBoxService.get(id)); + } + addMessage(redirectAttributes, "删除站内信成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mailBox/?repage"; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailComposeController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailComposeController.java new file mode 100644 index 0000000..86ad806 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailComposeController.java @@ -0,0 +1,300 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.web; + +import java.util.Date; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.iim.entity.MailBox; +import com.jeespring.modules.iim.entity.MailCompose; +import com.jeespring.modules.iim.entity.MailPage; +import com.jeespring.modules.iim.service.MailBoxService; +import com.jeespring.modules.iim.service.MailComposeService; +import com.jeespring.modules.iim.service.MailService; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SystemService; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 发件箱Controller + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-13 + */ +@Controller +@RequestMapping(value = "${adminPath}/iim/mailCompose") +public class MailComposeController extends AbstractBaseController { + + @Autowired + private MailComposeService mailComposeService; + + @Autowired + private MailBoxService mailBoxService; + + @Autowired + private SystemService systemService; + + @Autowired + private MailService mailService; + + @ModelAttribute + public MailCompose get(@RequestParam(required=false) String id) { + MailCompose entity = null; + if (StringUtils.isNotBlank(id)){ + entity = mailComposeService.get(id); + } + if (entity == null){ + entity = new MailCompose(); + } + return entity; + } + + + + /* + * 写站内信 + */ + @RequestMapping(value = {"sendLetter"}) + public String sendLetter(User user, HttpServletRequest request, HttpServletResponse response, Model model) { + user = systemService.getUser(user.getId()); + model.addAttribute("receiver", user); + + //查询未读的条数 + MailBox serachBox = new MailBox(); + serachBox.setReadstatus("0"); + serachBox.setReceiver(UserUtils.getUser()); + model.addAttribute("noReadCount", mailBoxService.getCount(serachBox)); + + //查询总条数 + MailBox serachBox2 = new MailBox(); + serachBox2.setReceiver(UserUtils.getUser()); + model.addAttribute("mailBoxCount", mailBoxService.getCount(serachBox2)); + + //查询已发送条数 + MailCompose serachBox3 = new MailCompose(); + serachBox3.setSender(UserUtils.getUser()); + serachBox3.setStatus("1");//已发送 + model.addAttribute("mailComposeCount", mailComposeService.getCount(serachBox3)); + + //查询草稿箱条数 + MailCompose serachBox4 = new MailCompose(); + serachBox4.setSender(UserUtils.getUser()); + serachBox4.setStatus("0");//草稿 + model.addAttribute("mailDraftCount", mailComposeService.getCount(serachBox4)); + + return "modules/iim/mail_send"; + } + + /* + * 回复站内信 + */ + @RequestMapping(value = {"replyLetter"}) + public String replyLetter(MailBox mailBox, HttpServletRequest request, HttpServletResponse response, Model model) { + model.addAttribute("mailBox", mailBoxService.get(mailBox.getId())); + + //查询未读的条数 + MailBox serachBox = new MailBox(); + serachBox.setReadstatus("0"); + serachBox.setReceiver(UserUtils.getUser()); + model.addAttribute("noReadCount", mailBoxService.getCount(serachBox)); + + //查询总条数 + MailBox serachBox2 = new MailBox(); + serachBox2.setReceiver(UserUtils.getUser()); + model.addAttribute("mailBoxCount", mailBoxService.getCount(serachBox2)); + + //查询已发送条数 + MailCompose serachBox3 = new MailCompose(); + serachBox3.setSender(UserUtils.getUser()); + serachBox3.setStatus("1");//已发送 + model.addAttribute("mailComposeCount", mailComposeService.getCount(serachBox3)); + + //查询草稿箱条数 + MailCompose serachBox4 = new MailCompose(); + serachBox4.setSender(UserUtils.getUser()); + serachBox4.setStatus("0");//草稿 + model.addAttribute("mailDraftCount", mailComposeService.getCount(serachBox4)); + + return "modules/iim/mail_reply"; + } + + @RequestMapping(value = {"list", ""}) + public String list(MailCompose mailCompose, HttpServletRequest request, HttpServletResponse response, Model model) { + + Page page = mailComposeService.findPage(new MailPage(request, response), mailCompose); + model.addAttribute("page", page); + + //查询未读的条数 + MailBox serachBox = new MailBox(); + serachBox.setReadstatus("0"); + serachBox.setReceiver(UserUtils.getUser()); + model.addAttribute("noReadCount", mailBoxService.getCount(serachBox)); + + //查询总条数 + MailBox serachBox2 = new MailBox(); + serachBox2.setReceiver(UserUtils.getUser()); + model.addAttribute("mailBoxCount", mailBoxService.getCount(serachBox2)); + + //查询已发送条数 + MailCompose serachBox3 = new MailCompose(); + serachBox3.setSender(UserUtils.getUser()); + serachBox3.setStatus("1");//已发送 + model.addAttribute("mailComposeCount", mailComposeService.getCount(serachBox3)); + + //查询草稿箱条数 + MailCompose serachBox4 = new MailCompose(); + serachBox4.setSender(UserUtils.getUser()); + serachBox4.setStatus("0");//草稿 + model.addAttribute("mailDraftCount", mailComposeService.getCount(serachBox4)); + + + if(mailCompose.getStatus()== null || "0".equals(mailCompose.getStatus())){ + return "modules/iim/mailDraftList";//草稿箱 + } + return "modules/iim/mailComposeList";//已发送 + } + + @RequestMapping(value = "detail")//打开已发送信件 + public String detail(MailCompose mailCompose, Model model) { + model.addAttribute("mailCompose", mailCompose); + + + //查询未读的条数 + MailBox serachBox = new MailBox(); + serachBox.setReadstatus("0"); + serachBox.setReceiver(UserUtils.getUser()); + model.addAttribute("noReadCount", mailBoxService.getCount(serachBox)); + + //查询总条数 + MailBox serachBox2 = new MailBox(); + serachBox2.setReceiver(UserUtils.getUser()); + model.addAttribute("mailBoxCount", mailBoxService.getCount(serachBox2)); + + //查询已发送条数 + MailCompose serachBox3 = new MailCompose(); + serachBox3.setSender(UserUtils.getUser()); + serachBox3.setStatus("1");//已发送 + model.addAttribute("mailComposeCount", mailComposeService.getCount(serachBox3)); + + //查询草稿箱条数 + MailCompose serachBox4 = new MailCompose(); + serachBox4.setSender(UserUtils.getUser()); + serachBox4.setStatus("0");//草稿 + model.addAttribute("mailDraftCount", mailComposeService.getCount(serachBox4)); + + return "modules/iim/mailComposeDetail"; + } + + @RequestMapping(value = "draftDetail")//打开草稿 + public String draftDetail(MailCompose mailCompose, Model model) { + //查询未读的条数 + MailBox serachBox = new MailBox(); + serachBox.setReadstatus("0"); + serachBox.setReceiver(UserUtils.getUser()); + model.addAttribute("noReadCount", mailBoxService.getCount(serachBox)); + + //查询总条数 + MailBox serachBox2 = new MailBox(); + serachBox2.setReceiver(UserUtils.getUser()); + model.addAttribute("mailBoxCount", mailBoxService.getCount(serachBox2)); + + //查询已发送条数 + MailCompose serachBox3 = new MailCompose(); + serachBox3.setSender(UserUtils.getUser()); + serachBox3.setStatus("1");//已发送 + model.addAttribute("mailComposeCount", mailComposeService.getCount(serachBox3)); + + //查询草稿箱条数 + MailCompose serachBox4 = new MailCompose(); + serachBox4.setSender(UserUtils.getUser()); + serachBox4.setStatus("0");//草稿 + model.addAttribute("mailDraftCount", mailComposeService.getCount(serachBox4)); + + mailCompose = mailComposeService.get(mailCompose.getId()); + model.addAttribute("mailCompose", mailCompose); + return "modules/iim/mailDraftDetail"; + } + + @RequestMapping(value = "save") + public String save(MailCompose mailCompose, Model model, HttpServletRequest request, HttpServletResponse response) { + if (!beanValidator(model, mailCompose.getMail())){ + return detail(mailCompose, model); + } + mailService.saveOnlyMain(mailCompose.getMail()); + Date date = new Date(System.currentTimeMillis()); + mailCompose.setSender(UserUtils.getUser()); + mailCompose.setSendtime(date); + for(User receiver : mailCompose.getReceiverList()){ + mailCompose.setReceiver(receiver); + mailCompose.setId(null);//标记为新纪录,每次往发件箱插入一条记录 + mailComposeService.save(mailCompose);//0 显示在草稿箱,1 显示在已发送需同时保存到收信人的收件箱。 + + + if("1".equals(mailCompose.getStatus()))//已发送,同时保存到收信人的收件箱 + { + MailBox mailBox = new MailBox(); + mailBox.setReadstatus("0"); + mailBox.setReceiver(receiver); + mailBox.setSender(UserUtils.getUser()); + mailBox.setMail(mailCompose.getMail()); + mailBox.setSendtime(date); + mailBoxService.save(mailBox); + } + } + + request.setAttribute("mailCompose", mailCompose); + return "modules/iim/mail_compose_success"; + } + + @RequestMapping(value = "delete") + public String delete(MailCompose mailCompose, RedirectAttributes redirectAttributes) { + mailComposeService.delete(mailCompose); + addMessage(redirectAttributes, "删除站内信成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mailCompose/?repage&orderBy=sendtime desc&status="+mailCompose.getStatus(); + } + + /** + * 批量删除已发送 + */ + @RequestMapping(value = "deleteAllCompose") + public String deleteAllCompose(String ids, Model model, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + mailComposeService.delete(mailComposeService.get(id)); + } + + + + + addMessage(redirectAttributes, "删除邮件成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mailCompose/?repage&status=1&orderBy=sendtime desc"; + } + + /** + * 批量删除草稿箱 + */ + @RequestMapping(value = "deleteAllDraft") + public String deleteAllDraft(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + mailComposeService.delete(mailComposeService.get(id)); + } + addMessage(redirectAttributes, "删除邮件成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mailCompose/?repage&status=0&orderBy=sendtime desc"; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailController.java new file mode 100644 index 0000000..2baadc8 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MailController.java @@ -0,0 +1,93 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.iim.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.iim.entity.Mail; +import com.jeespring.modules.iim.service.MailService; + +/** + * 发件箱Controller + * @author 黄炳桂 516821420@qq.com + * @version 2015-11-15 + */ +@Controller +@RequestMapping(value = "${adminPath}/iim/mail") +public class MailController extends AbstractBaseController { + + @Autowired + private MailService mailService; + + @ModelAttribute + public Mail get(@RequestParam(required=false) String id) { + Mail entity = null; + if (StringUtils.isNotBlank(id)){ + entity = mailService.get(id); + } + if (entity == null){ + entity = new Mail(); + } + return entity; + } + + @RequiresPermissions("iim:mail:view") + @RequestMapping(value = {"list", ""}) + public String list(Mail mail, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = mailService.findPage(new Page(request, response), mail); + model.addAttribute("page", page); + return "modules/iim/mailList"; + } + + @RequiresPermissions("iim:mail:view") + @RequestMapping(value = "form") + public String form(Mail mail, Model model) { + model.addAttribute("mail", mail); + return "modules/iim/mailForm"; + } + + @RequestMapping(value = "save") + public String save(Mail mail, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, mail)){ + return form(mail, model); + } + mailService.save(mail); + addMessage(redirectAttributes, "删除站内信成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mail/?repage"; + } + + @RequestMapping(value = "delete") + public String delete(Mail mail, RedirectAttributes redirectAttributes) { + mailService.delete(mail); + addMessage(redirectAttributes, "删除站内信成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mail/?repage"; + } + /** + * 批量删除 + */ + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + mailService.delete(mailService.get(id)); + } + addMessage(redirectAttributes, "删除站内信成功"); + return "redirect:"+Global.getAdminPath()+"/iim/mail/?repage"; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MyCalendarController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MyCalendarController.java new file mode 100644 index 0000000..a75fbb6 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/iim/web/MyCalendarController.java @@ -0,0 +1,335 @@ +/** + * Copyright © 2015-2020 JeePlus All rights reserved. + */ +package com.jeespring.modules.iim.web; + +import java.io.IOException; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.iim.entity.MyCalendar; +import com.jeespring.modules.iim.service.MyCalendarService; +import com.jeespring.modules.iim.utils.DateUtil; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 日历Controller + * + * @author liugf + * @version 2016-04-19 + */ +@Controller +@RequestMapping(value = "${adminPath}/iim/myCalendar") +public class MyCalendarController extends AbstractBaseController { + + @Autowired + private MyCalendarService myCalendarService; + + @ModelAttribute + public MyCalendar get(@RequestParam(required = false) String id) { + MyCalendar entity = null; + if (StringUtils.isNotBlank(id)) { + entity = myCalendarService.get(id); + } + if (entity == null) { + entity = new MyCalendar(); + } + return entity; + } + + /** + * 日历页面 + */ + @RequestMapping(value = { "index", "" }) + public String index(MyCalendar myCalendar, HttpServletRequest request, + HttpServletResponse response, Model model) { + return "modules/iim/myCalendar"; + } + + /** + * 查看,增加,编辑日历信息表单页面 + */ + @RequestMapping(value = "addform") + public String addform(MyCalendar myCalendar, HttpServletRequest request, + HttpServletResponse response, Model model) { + String date = request.getParameter("date"); + String enddate = request.getParameter("end"); + if (date.equals(enddate)) { + enddate = ""; + } + String display = ""; + String chk = ""; + if ("".equals(enddate)) { + display = "style=\"display:none\""; + enddate = date; + } else { + chk = "checked"; + } + model.addAttribute("date", date); + model.addAttribute("display", display); + model.addAttribute("chk", chk); + model.addAttribute("enddate", enddate); + model.addAttribute("myCalendar", myCalendar); + return "modules/iim/myCalendarForm-add"; + } + + @RequestMapping(value = "editform") + public String editform(MyCalendar myCalendar, HttpServletRequest request, + HttpServletResponse response, Model model) { + String title = myCalendar.getTitle();// 事件标题 + String start = myCalendar.getStart();// 事件开始时间 + String end = myCalendar.getEnd();// 结束时间 + String allDay = myCalendar.getAdllDay();// 是否为全天事件 + String color = myCalendar.getColor();// 事件的背景 + + String start_d = ""; + String start_h = ""; + String start_m = ""; + + String end_d = ""; + String end_h = ""; + String end_m = ""; + + if ("1".equals(allDay) && !"".equals(end)) { + start_d = start; + end_d = end; + } else if ("1".equals(allDay) && "".equals(end)) { + start_d = start; + } else if ("0".equals(allDay) && !"".equals(end)) { + start_d = start.substring(0, 10); + start_h = start.substring(11, 13); + start_m = start.substring(14, 16); + + end_d = end.substring(0, 10); + end_h = end.substring(11, 13); + end_m = end.substring(14, 16); + } else { + start_d = start.substring(0, 10); + start_h = start.substring(11, 13); + start_m = start.substring(14, 16); + } + + model.addAttribute("title", title); + model.addAttribute("color", color); + model.addAttribute("start_d", start_d); + model.addAttribute("start_h", start_h); + model.addAttribute("start_m", start_m); + model.addAttribute("end", end_d); + model.addAttribute("end_d", end_d); + model.addAttribute("end_h", end_h); + model.addAttribute("end_m", end_m); + model.addAttribute("allDay", allDay); + return "modules/iim/myCalendarForm-edit"; + } + + @RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "findList") + protected List doPost(MyCalendar myCalendar, + HttpServletRequest request, HttpServletResponse response, + Model model) throws ServletException, IOException { + myCalendar.setUser(UserUtils.getUser()); + List list = myCalendarService.findList(myCalendar); + + return list; + } + + /** + * 新建日历 + */ + @RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "add") + public String add(MyCalendar myCalendar, HttpServletRequest request, + HttpServletResponse response, Model model) { + + String events = request.getParameter("event");// 事件内容 + String isallday = request.getParameter("isallday");// 是否是全天事件 + String isend = request.getParameter("isend");// 是否有结束时间 + String startdate = request.getParameter("startdate"); + String enddate = request.getParameter("enddate"); + String s_time = request.getParameter("s_hour") + ":" + + request.getParameter("s_minute") + ":00"; + String e_time = request.getParameter("e_hour") + ":" + + request.getParameter("e_minute") + ":00"; + + String start = ""; + String end = ""; + if ("1".equals(isallday) && "1".equals(isend)) { + start = startdate; + end = enddate; + } else if ("1".equals(isallday) && isend == null) { + start = startdate; + } else if (isallday == null && "1".equals(isend)) { + start = startdate + " " + s_time; + end = enddate + " " + e_time; + isallday = "0"; + } else { + start = startdate + " " + s_time; + isallday = "0"; + } + + String[] colors = { "#360", "#f30", "#06c" }; + int index = (int) (Math.random() * colors.length); + myCalendar.setTitle(events); + myCalendar.setStart(start); + myCalendar.setEnd(end); + myCalendar.setAdllDay(isallday); + myCalendar.setColor(colors[index]); + myCalendar.setUser(UserUtils.getUser()); + myCalendarService.save(myCalendar); + + return "1"; + } + + /** + * 编辑日历 + */ + @RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "edit") + public String edit(MyCalendar myCalendar, HttpServletRequest request, + HttpServletResponse response, Model model) { + + String events = request.getParameter("event");// 事件内容 + String isallday = request.getParameter("isallday");// 是否是全天事件 + String isend = request.getParameter("isend");// 是否有结束时间 + String startdate = request.getParameter("startdate"); + String enddate = request.getParameter("enddate"); + String s_time = request.getParameter("s_hour") + ":" + + request.getParameter("s_minute") + ":00"; + String e_time = request.getParameter("e_hour") + ":" + + request.getParameter("e_minute") + ":00"; + + String start = ""; + String end = ""; + if ("1".equals(isallday) && "1".equals(isend)) { + start = startdate; + end = enddate; + } else if ("1".equals(isallday) && isend == null) { + start = startdate; + } else if (isallday == null && "1".equals(isend)) { + start = startdate + " " + s_time; + end = enddate + " " + e_time; + isallday = "0"; + } else { + start = startdate + " " + s_time; + isallday = "0"; + } + + String[] colors = { "#360", "#f30", "#06c" }; + int index = (int) (Math.random() * colors.length); + myCalendar.setTitle(events); + myCalendar.setStart(start); + myCalendar.setEnd(end); + myCalendar.setAdllDay(isallday); + myCalendar.setColor(colors[index]); + myCalendar.setUser(UserUtils.getUser()); + myCalendarService.save(myCalendar); + + model.addAttribute("myCalendar", myCalendar); + + return "1"; + } + + /** + * 删除日历 + */ + @RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "del") + public String del(MyCalendar myCalendar, + RedirectAttributes redirectAttributes) { + + myCalendarService.delete(myCalendar); + return "1"; + + } + + /** + * 縮放日歷 + */ + @RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "resize") + public String resize(MyCalendar myCalendar, HttpServletRequest request, + HttpServletResponse response, Model model) { + Integer daydiff = Integer.parseInt(request.getParameter("daydiff")) * 24 * 60 * 60; + Integer minudiff = Integer.parseInt(request.getParameter("minudiff")) * 60; + String start = myCalendar.getStart(); + long lstart = DateUtil.string2long(start); + String end = myCalendar.getEnd(); + Integer difftime = daydiff + minudiff; + if ("".equals(end)) { + myCalendar.setEnd(DateUtil.long2string(lstart + difftime)); + myCalendar.setUser(UserUtils.getUser()); + myCalendarService.save(myCalendar); + } else { + long lend = DateUtil.string2long(end); + myCalendar.setEnd(DateUtil.long2string(lend + difftime)); + myCalendar.setUser(UserUtils.getUser()); + myCalendarService.save(myCalendar); + } + return "1"; + } + + /** + * 拖拽日历 + */ + @RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "drag") + public String drag(MyCalendar myCalendar, HttpServletRequest request, + HttpServletResponse response, Model model) { + Integer daydiff = Integer.parseInt(request.getParameter("daydiff")) * 24 * 60 * 60; + Integer minudiff = Integer.parseInt(request.getParameter("minudiff")) * 60; + String allday = request.getParameter("allday"); + String start = myCalendar.getStart(); + long lstart = DateUtil.string2long(start); + + String end = myCalendar.getEnd(); + if ("true".equals(allday)) { + if ("".equals(end)) { + myCalendar.setStart(DateUtil.long2string(lstart + daydiff)); + myCalendar.setUser(UserUtils.getUser()); + myCalendarService.save(myCalendar); + } else { + long lend = DateUtil.string2long(end); + myCalendar.setStart(DateUtil.long2string(lstart + daydiff)); + myCalendar.setEnd(DateUtil.long2string(lend + daydiff)); + myCalendar.setUser(UserUtils.getUser()); + myCalendarService.save(myCalendar); + } + } else { + Integer difftime = daydiff + minudiff; + if ("".equals(end)) { + myCalendar.setStart(DateUtil.long2string(lstart + difftime)); + myCalendar.setUser(UserUtils.getUser()); + myCalendarService.save(myCalendar); + } else { + long lend = DateUtil.string2long(end); + myCalendar.setStart(DateUtil.long2string(lstart + difftime)); + myCalendar.setEnd(DateUtil.long2string(lend + difftime)); + myCalendar.setUser(UserUtils.getUser()); + myCalendarService.save(myCalendar); + } + } + return "1"; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/dao/SysJobDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/dao/SysJobDao.java new file mode 100644 index 0000000..c541d26 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/dao/SysJobDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.job.entity.SysJob; + +/** + * 定时任务调度DAO接口 + * @author JeeSpring + * @version 2018-08-16 + */ +@Mapper +public interface SysJobDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/dao/SysJobLogDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/dao/SysJobLogDao.java new file mode 100644 index 0000000..f51f58e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/dao/SysJobLogDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.job.entity.SysJobLog; + +/** + * 定时任务调度日志表DAO接口 + * @author JeeSpring + * @version 2018-08-16 + */ +@Mapper +public interface SysJobLogDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/entity/SysJob.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/entity/SysJob.java new file mode 100644 index 0000000..cb348bf --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/entity/SysJob.java @@ -0,0 +1,182 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.entity; + +import org.hibernate.validator.constraints.Length; +import java.util.Date; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; +import com.jeespring.modules.sys.utils.DictUtils; + +/** + * 定时任务调度Entity + * @author JeeSpring + * @version 2018-08-16 + */ +public class SysJob extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String jobName; // 任务名称 + private String jobGroup; // 任务组名 + private String methodName; // 任务方法 + private String methodParams; // 方法参数 + private String cronExpression; // cron执行表达式 + private String misfirePolicy; // 计划执行错误策略(0默认 1继续 2等待 3放弃) + private String misfirePolicyLabel; // 计划执行错误策略(0默认 1继续 2等待 3放弃)Label + private String misfirePolicyPicture; // 计划执行错误策略(0默认 1继续 2等待 3放弃)Picture + private String status; // 状态(0正常 1暂停) + private String statusLabel; // 状态(0正常 1暂停)Label + private String statusPicture; // 状态(0正常 1暂停)Picture + private String remark; // 备注信息 + private java.util.Date beginCreateDate; // 开始 创建时间 + private java.util.Date endCreateDate; // 结束 创建时间 + private java.util.Date beginUpdateDate; // 开始 更新时间 + private java.util.Date endUpdateDate; // 结束 更新时间 + + public SysJob() { + super(); + } + + public SysJob(String id){ + super(id); + } + + @Length(min=1, max=64, message="任务名称长度必须介于 1 和 64 之间") + @ExcelField(title="任务名称", align=2, sort=1) + public String getJobName() { + return jobName; + } + + public void setJobName(String jobName) { + this.jobName = jobName; + } + + + @Length(min=1, max=64, message="任务组名长度必须介于 1 和 64 之间") + @ExcelField(title="任务组名", align=2, sort=2) + public String getJobGroup() { + return jobGroup; + } + + public void setJobGroup(String jobGroup) { + this.jobGroup = jobGroup; + } + + + @Length(min=0, max=500, message="任务方法长度必须介于 0 和 500 之间") + @ExcelField(title="任务方法", align=2, sort=3) + public String getMethodName() { + return methodName; + } + + public void setMethodName(String methodName) { + this.methodName = methodName; + } + + + @Length(min=0, max=200, message="方法参数长度必须介于 0 和 200 之间") + @ExcelField(title="方法参数", align=2, sort=4) + public String getMethodParams() { + return methodParams; + } + + public void setMethodParams(String methodParams) { + this.methodParams = methodParams; + } + + + @Length(min=0, max=255, message="cron执行表达式长度必须介于 0 和 255 之间") + @ExcelField(title="cron执行表达式", align=2, sort=5) + public String getCronExpression() { + return cronExpression; + } + + public void setCronExpression(String cronExpression) { + this.cronExpression = cronExpression; + } + + + @Length(min=0, max=20, message="计划执行错误策略(0默认 1继续 2等待 3放弃)长度必须介于 0 和 20 之间") + @ExcelField(title="计划执行错误策略(0默认 1继续 2等待 3放弃)", align=2, sort=6) + public String getMisfirePolicy() { + return misfirePolicy; + } + + public void setMisfirePolicy(String misfirePolicy) { + this.misfirePolicy = misfirePolicy; + } + + + @Length(min=0, max=1, message="状态(0正常 1暂停)长度必须介于 0 和 1 之间") + @ExcelField(title="状态(0正常 1暂停)", dictType="job_status", align=2, sort=7) + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + public String getStatusLabel() { + return DictUtils.getDictLabel(status,"job_status",""); + } + public String getStatusPicture() { + return DictUtils.getDictPicture(status,"job_status",""); + } + + public String getMisfirePolicyLabel() { + return DictUtils.getDictLabel(misfirePolicy,"misfire_policy",""); + } + public String getMisfirePolicyPicture() { + return DictUtils.getDictPicture(misfirePolicy,"misfire_policy",""); + } + + @Length(min=0, max=500, message="备注信息长度必须介于 0 和 500 之间") + @ExcelField(title="备注信息", align=2, sort=12) + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + + + public Date getBeginCreateDate() { + return beginCreateDate; + } + + public void setBeginCreateDate(Date beginCreateDate) { + this.beginCreateDate = beginCreateDate; + } + + public Date getEndCreateDate() { + return endCreateDate; + } + + public void setEndCreateDate(Date endCreateDate) { + this.endCreateDate = endCreateDate; + } + + public Date getBeginUpdateDate() { + return beginUpdateDate; + } + + public void setBeginUpdateDate(Date beginUpdateDate) { + this.beginUpdateDate = beginUpdateDate; + } + + public Date getEndUpdateDate() { + return endUpdateDate; + } + + public void setEndUpdateDate(Date endUpdateDate) { + this.endUpdateDate = endUpdateDate; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/entity/SysJobLog.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/entity/SysJobLog.java new file mode 100644 index 0000000..3ddd027 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/entity/SysJobLog.java @@ -0,0 +1,141 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.entity; + +import org.hibernate.validator.constraints.Length; +import java.util.Date; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; +import com.jeespring.modules.sys.utils.DictUtils; + +/** + * 定时任务调度日志表Entity + * @author JeeSpring + * @version 2018-08-16 + */ +public class SysJobLog extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String jobName; // 任务名称 + private String jobGroup; // 任务组名 + private String methodName; // 任务方法 + private String methodParams; // 方法参数 + private String jobMessage; // 日志信息 + private String status; // 执行状态(0正常 1失败) + private String statusLabel; // 执行状态(0正常 1失败)Label + private String statusPicture; // 执行状态(0正常 1失败)Picture + private String exceptionInfo; // 异常信息 + private java.util.Date beginCreateDate; // 开始 创建时间 + private java.util.Date endCreateDate; // 结束 创建时间 + + public SysJobLog() { + super(); + } + + public SysJobLog(String id){ + super(id); + } + + @Length(min=1, max=64, message="任务名称长度必须介于 1 和 64 之间") + @ExcelField(title="任务名称", align=2, sort=1) + public String getJobName() { + return jobName; + } + + public void setJobName(String jobName) { + this.jobName = jobName; + } + + + @Length(min=1, max=64, message="任务组名长度必须介于 1 和 64 之间") + @ExcelField(title="任务组名", align=2, sort=2) + public String getJobGroup() { + return jobGroup; + } + + public void setJobGroup(String jobGroup) { + this.jobGroup = jobGroup; + } + + + @Length(min=0, max=500, message="任务方法长度必须介于 0 和 500 之间") + @ExcelField(title="任务方法", align=2, sort=3) + public String getMethodName() { + return methodName; + } + + public void setMethodName(String methodName) { + this.methodName = methodName; + } + + + @Length(min=0, max=200, message="方法参数长度必须介于 0 和 200 之间") + @ExcelField(title="方法参数", align=2, sort=4) + public String getMethodParams() { + return methodParams; + } + + public void setMethodParams(String methodParams) { + this.methodParams = methodParams; + } + + + @Length(min=0, max=500, message="日志信息长度必须介于 0 和 500 之间") + @ExcelField(title="日志信息", align=2, sort=5) + public String getJobMessage() { + return jobMessage; + } + + public void setJobMessage(String jobMessage) { + this.jobMessage = jobMessage; + } + + + @Length(min=0, max=1, message="执行状态(0正常 1失败)长度必须介于 0 和 1 之间") + @ExcelField(title="执行状态(0正常 1失败)", dictType="job_status", align=2, sort=6) + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + public String getStatusLabel() { + return DictUtils.getDictLabel(status,"job_status",""); + } + public String getStatusPicture() { + return DictUtils.getDictPicture(status,"job_status",""); + } + @ExcelField(title="异常信息", align=2, sort=7) + public String getExceptionInfo() { + return exceptionInfo; + } + + public void setExceptionInfo(String exceptionInfo) { + this.exceptionInfo = exceptionInfo; + } + + + public Date getBeginCreateDate() { + return beginCreateDate; + } + + public void setBeginCreateDate(Date beginCreateDate) { + this.beginCreateDate = beginCreateDate; + } + + public Date getEndCreateDate() { + return endCreateDate; + } + + public void setEndCreateDate(Date endCreateDate) { + this.endCreateDate = endCreateDate; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/rest/SysJobLogRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/rest/SysJobLogRestController.java new file mode 100644 index 0000000..9695804 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/rest/SysJobLogRestController.java @@ -0,0 +1,301 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.rest; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.job.entity.SysJobLog; +import com.jeespring.modules.job.service.SysJobLogService; +import org.springframework.web.bind.annotation.RestController; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +/** + * 定时任务调度日志表Controller + * @author JeeSpring + * @version 2018-08-16 + */ +@RestController +@RequestMapping(value = "/rest/job/sysJobLog") +@Api(value="定时任务调度日志接口", description="定时任务调度日志接口") +public class SysJobLogRestController extends AbstractBaseController { + + @Autowired + private SysJobLogService sysJobLogService; + + /** + * 定时任务调度日志信息 + */ + @RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="定时任务调度日志信息(Content-Type为text/html)", notes="定时任务调度日志信息(Content-Type为text/html)") + @ApiImplicitParam(name = "id", value = "定时任务调度日志id", required = false, dataType = "String",paramType="query") + public Result getRequestParam(@RequestParam(required=false) String id) { + return get(id); + } + + @RequestMapping(value = {"get/json"},method ={RequestMethod.POST}) + @ApiOperation(value="定时任务调度日志信息(Content-Type为application/json)", notes="定时任务调度日志信息(Content-Type为application/json)") + @ApiImplicitParam(name = "id", value = "定时任务调度日志id", required = false, dataType = "String",paramType="body") + public Result getRequestBody(@RequestBody(required=false) String id) { + return get(id); + } + + private Result get(String id) { + SysJobLog entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysJobLogService.getCache(id); + //entity = sysJobLogService.get(id); + } + if (entity == null){ + entity = new SysJobLog(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(entity); + return result; + } + + /** + * 定时任务调度日志列表(不包含页信息) + */ + //RequiresPermissions("job:sysJobLog:findList") + @RequestMapping(value = {"findList"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="定时任务调度日志列表(不包含页信息)(Content-Type为text/html)", notes="定时任务调度日志列表(不包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="query") + public Result findListRequestParam(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + return findList( sysJobLog,model); + } + + @RequestMapping(value = {"findList/json"},method ={RequestMethod.POST}) + @ApiOperation(value="定时任务调度日志列表(不包含页信息)(Content-Type为application/json)", notes="定时任务调度日志列表(不包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="body") + public Result findListRequestBody(@RequestBody SysJobLog sysJobLog, Model model) { + return findList( sysJobLog,model); + } + + private Result findList(SysJobLog sysJobLog, Model model) { + List list = sysJobLogService.findListCache(sysJobLog); + //List list = sysJobLogService.findList(sysJobLog); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(list); + return result; + } + + /** + * 定时任务调度日志列表(包含页信息) + */ + //RequiresPermissions("job:sysJobLog:list") + @RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="定时任务调度日志列表(包含页信息)(Content-Type为text/html)", notes="定时任务调度日志列表(包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="query") + public Result listRequestParam(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + return list(sysJobLog,model); + } + + @RequestMapping(value = {"list/json"},method ={RequestMethod.POST}) + @ApiOperation(value="定时任务调度日志列表(包含页信息)(Content-Type为application/json)", notes="定时任务调度日志列表(包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="body") + public Result listRequestBody(@RequestBody SysJobLog sysJobLog, Model model) { + return list(sysJobLog,model); + } + + private Result list(SysJobLog sysJobLog, Model model) { + Page page = sysJobLogService.findPageCache(new Page(sysJobLog.getPageNo(),sysJobLog.getPageSize(),sysJobLog.getOrderBy()), sysJobLog); + //Page page = sysJobLogService.findPage(new Page(sysJobLog.getPageNo(),sysJobLog.getPageSize(),sysJobLog.getOrderBy()), sysJobLog); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + /** + * 定时任务调度日志获取列表第一条记录 + */ + //RequiresPermissions("job:sysJobLog:listFrist") + @RequestMapping(value = {"listFrist"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="定时任务调度日志获取列表第一条记录(Content-Type为text/html)", notes="定时任务调度日志获取列表第一条记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="query") + public Result listFristRequestParam(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + return listFrist(sysJobLog,model); + } + + @RequestMapping(value = {"listFrist/json"},method ={RequestMethod.POST}) + @ApiOperation(value="定时任务调度日志获取列表第一条记录(Content-Type为application/json)", notes="定时任务调度日志获取列表第一条记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="body") + public Result listFristRequestBody(@RequestBody SysJobLog sysJobLog, Model model) { + return listFrist(sysJobLog,model); + } + + private Result listFrist(SysJobLog sysJobLog, Model model) { + Page page = sysJobLogService.findPageCache(new Page(sysJobLog.getPageNo(),sysJobLog.getPageSize(),sysJobLog.getOrderBy()), sysJobLog); + //Page page = sysJobLogService.findPage(new Page(sysJobLog.getPageNo(),sysJobLog.getPageSize(),sysJobLog.getOrderBy()), sysJobLog); + Result result = ResultFactory.getSuccessResult(); + if(page.getList().size()>0){ + result.setResultObject(page.getList().get(0)); + }else{ + result=ResultFactory.getErrorResult("没有记录!"); + } + return result; + } + + /** + * 保存定时任务调度日志 + */ + //RequiresPermissions(value={"job:sysJobLog:add","job:sysJobLog:edit"},logical=Logical.OR) + @RequestMapping(value = "save",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="保存定时任务调度日志(Content-Type为text/html)", notes="保存定时任务调度日志(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="query") + public Result saveRequestParam(SysJobLog sysJobLog, Model model, RedirectAttributes redirectAttributes) { + return save(sysJobLog,model,redirectAttributes); + } + + @RequestMapping(value = "save/json",method ={RequestMethod.POST}) + @ApiOperation(value="保存定时任务调度日志(Content-Type为application/json)", notes="保存定时任务调度日志(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="body") + public Result saveRequestBody(@RequestBody SysJobLog sysJobLog, Model model, RedirectAttributes redirectAttributes) { + return save(sysJobLog,model,redirectAttributes); + } + + private Result save(SysJobLog sysJobLog, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysJobLog)){ + Result result = ResultFactory.getErrorResult("数据验证失败"); + } + sysJobLogService.save(sysJobLog); + Result result = ResultFactory.getSuccessResult("保存定时任务调度日志成功"); + return result; + } + + /** + * 删除定时任务调度日志 + */ + //RequiresPermissions("job:sysJobLog:del") + @RequestMapping(value = "delete",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="删除定时任务调度日志(Content-Type为text/html)", notes="删除定时任务调度日志(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="query") + public Result deleteRequestParam(SysJobLog sysJobLog, RedirectAttributes redirectAttributes) { + return delete(sysJobLog,redirectAttributes); + } + + @RequestMapping(value = "delete/json",method ={RequestMethod.POST}) + @ApiOperation(value="删除定时任务调度日志(Content-Type为application/json)", notes="删除定时任务调度日志(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="body") + public Result deleteRequestBody(@RequestBody SysJobLog sysJobLog, RedirectAttributes redirectAttributes) { + return delete(sysJobLog,redirectAttributes); + } + + private Result delete(SysJobLog sysJobLog, RedirectAttributes redirectAttributes) { + sysJobLogService.delete(sysJobLog); + Result result = ResultFactory.getSuccessResult("删除定时任务调度日志成功"); + return result; + } + + /** + * 删除定时任务调度日志(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑删除定时任务调度日志(Content-Type为text/html)", notes="逻辑删除定时任务调度日志(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="query") + public Result deleteByLogicRequestParam(SysJobLog sysJobLog, RedirectAttributes redirectAttributes) { + return deleteByLogic(sysJobLog,redirectAttributes); + } + + /** + * 删除定时任务调度日志(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑删除定时任务调度日志(Content-Type为application/json)", notes="逻辑删除定时任务调度日志(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJobLog", value = "定时任务调度日志", dataType = "SysJobLog",paramType="body") + public Result deleteByLogicRequestBody(@RequestBody SysJobLog sysJobLog, RedirectAttributes redirectAttributes) { + return deleteByLogic(sysJobLog,redirectAttributes); + } + + private Result deleteByLogic(SysJobLog sysJobLog, RedirectAttributes redirectAttributes) { + sysJobLogService.deleteByLogic(sysJobLog); + Result result = ResultFactory.getSuccessResult("删除定时任务调度日志成功"); + return result; + } + + /** + * 批量删除定时任务调度日志 + */ + //RequiresPermissions("job:sysJobLog:del") + @RequestMapping(value = "deleteAll",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="批量删除定时任务调度日志(Content-Type为text/html)", notes="批量删除定时任务调度日志(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "定时任务调度日志ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllRequestParam(String ids, RedirectAttributes redirectAttributes) { + return deleteAll(ids,redirectAttributes); + } + + @RequestMapping(value = "deleteAll/json",method ={RequestMethod.POST}) + @ApiOperation(value="批量删除定时任务调度日志(Content-Type为application/json)", notes="批量删除定时任务调度日志(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "定时任务调度日志ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) { + return deleteAll(ids,redirectAttributes); + } + + private Result deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysJobLogService.delete(sysJobLogService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除定时任务调度日志成功"); + return result; + } + + /** + * 批量删除定时任务调度日志(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑批量删除定时任务调度日志(Content-Type为text/html)", notes="逻辑批量删除定时任务调度日志(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "定时任务调度日志ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllByLogicRequestParam(String ids, RedirectAttributes redirectAttributes) { + return deleteAllByLogic(ids,redirectAttributes); + } + + /** + * 批量删除定时任务调度日志(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑批量删除定时任务调度日志(Content-Type为application/json)", notes="逻辑批量删除定时任务调度日志(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "定时任务调度日志ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllByLogicRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) { + return deleteAllByLogic(ids,redirectAttributes); + } + + private Result deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysJobLogService.deleteByLogic(sysJobLogService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除定时任务调度日志成功"); + return result; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/rest/SysJobRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/rest/SysJobRestController.java new file mode 100644 index 0000000..ffddc42 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/rest/SysJobRestController.java @@ -0,0 +1,301 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.rest; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.job.entity.SysJob; +import com.jeespring.modules.job.service.SysJobService; +import org.springframework.web.bind.annotation.RestController; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +/** + * 定时任务调度Controller + * @author JeeSpring + * @version 2018-08-16 + */ +@RestController +@RequestMapping(value = "/rest/job/sysJob") +@Api(value="定时任务调度接口", description="定时任务调度接口") +public class SysJobRestController extends AbstractBaseController { + + @Autowired + private SysJobService sysJobService; + + /** + * 定时任务调度信息 + */ + @RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="定时任务调度信息(Content-Type为text/html)", notes="定时任务调度信息(Content-Type为text/html)") + @ApiImplicitParam(name = "id", value = "定时任务调度id", required = false, dataType = "String",paramType="query") + public Result getRequestParam(@RequestParam(required=false) String id) { + return get(id); + } + + @RequestMapping(value = {"get/json"},method ={RequestMethod.POST}) + @ApiOperation(value="定时任务调度信息(Content-Type为application/json)", notes="定时任务调度信息(Content-Type为application/json)") + @ApiImplicitParam(name = "id", value = "定时任务调度id", required = false, dataType = "String",paramType="body") + public Result getRequestBody(@RequestBody(required=false) String id) { + return get(id); + } + + private Result get(String id) { + SysJob entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysJobService.getCache(id); + //entity = sysJobService.get(id); + } + if (entity == null){ + entity = new SysJob(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(entity); + return result; + } + + /** + * 定时任务调度列表(不包含页信息) + */ + //RequiresPermissions("job:sysJob:findList") + @RequestMapping(value = {"findList"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="定时任务调度列表(不包含页信息)(Content-Type为text/html)", notes="定时任务调度列表(不包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="query") + public Result findListRequestParam(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + return findList( sysJob,model); + } + + @RequestMapping(value = {"findList/json"},method ={RequestMethod.POST}) + @ApiOperation(value="定时任务调度列表(不包含页信息)(Content-Type为application/json)", notes="定时任务调度列表(不包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="body") + public Result findListRequestBody(@RequestBody SysJob sysJob, Model model) { + return findList( sysJob,model); + } + + private Result findList(SysJob sysJob, Model model) { + List list = sysJobService.findListCache(sysJob); + //List list = sysJobService.findList(sysJob); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(list); + return result; + } + + /** + * 定时任务调度列表(包含页信息) + */ + //RequiresPermissions("job:sysJob:list") + @RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="定时任务调度列表(包含页信息)(Content-Type为text/html)", notes="定时任务调度列表(包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="query") + public Result listRequestParam(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + return list(sysJob,model); + } + + @RequestMapping(value = {"list/json"},method ={RequestMethod.POST}) + @ApiOperation(value="定时任务调度列表(包含页信息)(Content-Type为application/json)", notes="定时任务调度列表(包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="body") + public Result listRequestBody(@RequestBody SysJob sysJob, Model model) { + return list(sysJob,model); + } + + private Result list(SysJob sysJob, Model model) { + Page page = sysJobService.findPageCache(new Page(sysJob.getPageNo(),sysJob.getPageSize(),sysJob.getOrderBy()), sysJob); + //Page page = sysJobService.findPage(new Page(sysJob.getPageNo(),sysJob.getPageSize(),sysJob.getOrderBy()), sysJob); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + /** + * 定时任务调度获取列表第一条记录 + */ + //RequiresPermissions("job:sysJob:listFrist") + @RequestMapping(value = {"listFrist"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="定时任务调度获取列表第一条记录(Content-Type为text/html)", notes="定时任务调度获取列表第一条记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="query") + public Result listFristRequestParam(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + return listFrist(sysJob,model); + } + + @RequestMapping(value = {"listFrist/json"},method ={RequestMethod.POST}) + @ApiOperation(value="定时任务调度获取列表第一条记录(Content-Type为application/json)", notes="定时任务调度获取列表第一条记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="body") + public Result listFristRequestBody(@RequestBody SysJob sysJob, Model model) { + return listFrist(sysJob,model); + } + + private Result listFrist(SysJob sysJob, Model model) { + Page page = sysJobService.findPageCache(new Page(sysJob.getPageNo(),sysJob.getPageSize(),sysJob.getOrderBy()), sysJob); + //Page page = sysJobService.findPage(new Page(sysJob.getPageNo(),sysJob.getPageSize(),sysJob.getOrderBy()), sysJob); + Result result = ResultFactory.getSuccessResult(); + if(page.getList().size()>0){ + result.setResultObject(page.getList().get(0)); + }else{ + result=ResultFactory.getErrorResult("没有记录!"); + } + return result; + } + + /** + * 保存定时任务调度 + */ + //RequiresPermissions(value={"job:sysJob:add","job:sysJob:edit"},logical=Logical.OR) + @RequestMapping(value = "save",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="保存定时任务调度(Content-Type为text/html)", notes="保存定时任务调度(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="query") + public Result saveRequestParam(SysJob sysJob, Model model, RedirectAttributes redirectAttributes) { + return save(sysJob,model,redirectAttributes); + } + + @RequestMapping(value = "save/json",method ={RequestMethod.POST}) + @ApiOperation(value="保存定时任务调度(Content-Type为application/json)", notes="保存定时任务调度(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="body") + public Result saveRequestBody(@RequestBody SysJob sysJob, Model model, RedirectAttributes redirectAttributes) { + return save(sysJob,model,redirectAttributes); + } + + private Result save(SysJob sysJob, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysJob)){ + Result result = ResultFactory.getErrorResult("数据验证失败"); + } + sysJobService.save(sysJob); + Result result = ResultFactory.getSuccessResult("保存定时任务调度成功"); + return result; + } + + /** + * 删除定时任务调度 + */ + //RequiresPermissions("job:sysJob:del") + @RequestMapping(value = "delete",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="删除定时任务调度(Content-Type为text/html)", notes="删除定时任务调度(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="query") + public Result deleteRequestParam(SysJob sysJob, RedirectAttributes redirectAttributes) { + return delete(sysJob,redirectAttributes); + } + + @RequestMapping(value = "delete/json",method ={RequestMethod.POST}) + @ApiOperation(value="删除定时任务调度(Content-Type为application/json)", notes="删除定时任务调度(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="body") + public Result deleteRequestBody(@RequestBody SysJob sysJob, RedirectAttributes redirectAttributes) { + return delete(sysJob,redirectAttributes); + } + + private Result delete(SysJob sysJob, RedirectAttributes redirectAttributes) { + sysJobService.delete(sysJob); + Result result = ResultFactory.getSuccessResult("删除定时任务调度成功"); + return result; + } + + /** + * 删除定时任务调度(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑删除定时任务调度(Content-Type为text/html)", notes="逻辑删除定时任务调度(Content-Type为text/html)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="query") + public Result deleteByLogicRequestParam(SysJob sysJob, RedirectAttributes redirectAttributes) { + return deleteByLogic(sysJob,redirectAttributes); + } + + /** + * 删除定时任务调度(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑删除定时任务调度(Content-Type为application/json)", notes="逻辑删除定时任务调度(Content-Type为application/json)") + @ApiImplicitParam(name = "sysJob", value = "定时任务调度", dataType = "SysJob",paramType="body") + public Result deleteByLogicRequestBody(@RequestBody SysJob sysJob, RedirectAttributes redirectAttributes) { + return deleteByLogic(sysJob,redirectAttributes); + } + + private Result deleteByLogic(SysJob sysJob, RedirectAttributes redirectAttributes) { + sysJobService.deleteByLogic(sysJob); + Result result = ResultFactory.getSuccessResult("删除定时任务调度成功"); + return result; + } + + /** + * 批量删除定时任务调度 + */ + //RequiresPermissions("job:sysJob:del") + @RequestMapping(value = "deleteAll",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="批量删除定时任务调度(Content-Type为text/html)", notes="批量删除定时任务调度(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "定时任务调度ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllRequestParam(String ids, RedirectAttributes redirectAttributes) { + return deleteAll(ids,redirectAttributes); + } + + @RequestMapping(value = "deleteAll/json",method ={RequestMethod.POST}) + @ApiOperation(value="批量删除定时任务调度(Content-Type为application/json)", notes="批量删除定时任务调度(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "定时任务调度ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) { + return deleteAll(ids,redirectAttributes); + } + + private Result deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysJobService.delete(sysJobService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除定时任务调度成功"); + return result; + } + + /** + * 批量删除定时任务调度(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑批量删除定时任务调度(Content-Type为text/html)", notes="逻辑批量删除定时任务调度(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "定时任务调度ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllByLogicRequestParam(String ids, RedirectAttributes redirectAttributes) { + return deleteAllByLogic(ids,redirectAttributes); + } + + /** + * 批量删除定时任务调度(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑批量删除定时任务调度(Content-Type为application/json)", notes="逻辑批量删除定时任务调度(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "定时任务调度ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllByLogicRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) { + return deleteAllByLogic(ids,redirectAttributes); + } + + private Result deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysJobService.deleteByLogic(sysJobService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除定时任务调度成功"); + return result; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/service/SysJobLogService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/service/SysJobLogService.java new file mode 100644 index 0000000..763a8f1 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/service/SysJobLogService.java @@ -0,0 +1,183 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.job.entity.SysJobLog; +import com.jeespring.modules.job.dao.SysJobLogDao; +import com.alibaba.fastjson.JSON; +import com.jeespring.common.redis.RedisUtils; +import com.jeespring.common.security.MD5Tools; + +/** + * 定时任务调度日志表Service + * @author JeeSpring + * @version 2018-08-16 + */ +@Service +@Transactional(readOnly = true) +public class SysJobLogService extends AbstractBaseService { + + /** + * redis caches + */ + @Autowired + private RedisUtils redisUtils; + + @Override + public SysJobLog get(String id) { + //获取数据库数据 + SysJobLog sysJobLog=super.get(id); + return sysJobLog; + } + + public SysJobLog getCache(String id) { + //获取缓存数据 + SysJobLog sysJobLog=(SysJobLog)redisUtils.get(RedisUtils.getIdKey(SysJobLogService.class.getName(),id)); + if( sysJobLog!=null) { + return sysJobLog; + } + //获取数据库数据 + sysJobLog=super.get(id); + //设置缓存数据 + redisUtils.set(RedisUtils.getIdKey(SysJobLogService.class.getName(),id),sysJobLog); + return sysJobLog; + } + + @Override + public List total(SysJobLog sysJobLog) { + //获取数据库数据 + List sysJobLogList=super.total(sysJobLog); + return sysJobLogList; + } + + public List totalCache(SysJobLog sysJobLog) { + //获取缓存数据 + String totalKey = RedisUtils.getTotalKey(SysJobLogService.class.getName(),JSON.toJSONString(sysJobLog)); + List sysJobLogList=(List)redisUtils.get(totalKey); + if(sysJobLogList!=null) { + return sysJobLogList; + } + //获取数据库数据 + sysJobLogList=super.total(sysJobLog); + //设置缓存数据 + redisUtils.set(totalKey,sysJobLogList); + return sysJobLogList; + } + + @Override + public List findList(SysJobLog sysJobLog) { + //获取数据库数据 + List sysJobLogList=super.findList(sysJobLog); + //设置缓存数据 + return sysJobLogList; + } + + public List findListCache(SysJobLog sysJobLog) { + //获取缓存数据 + String findListKey = RedisUtils.getFindListKey(SysJobLogService.class.getName(),JSON.toJSONString(sysJobLog)); + List sysJobLogList=(List)redisUtils.get(findListKey); + if(sysJobLogList!=null) { + return sysJobLogList; + } + //获取数据库数据 + sysJobLogList=super.findList(sysJobLog); + //设置缓存数据 + redisUtils.set(findListKey,sysJobLogList); + return sysJobLogList; + } + + public SysJobLog findListFirst(SysJobLog sysJobLog) {; + //获取数据库数据 + List sysJobLogList=super.findList(sysJobLog); + if(sysJobLogList.size()>0) { + sysJobLog = sysJobLogList.get(0); + } + return sysJobLog; + } + + public SysJobLog findListFirstCache(SysJobLog sysJobLog) { + //获取缓存数据 + String findListFirstKey = RedisUtils.getFindListFirstKey(SysJobLogService.class.getName(),JSON.toJSONString(sysJobLog)); + SysJobLog sysJobLogRedis=(SysJobLog)redisUtils.get(findListFirstKey); + if(sysJobLogRedis!=null) { + return sysJobLogRedis; + } + //获取数据库数据 + List sysJobLogList=super.findList(sysJobLog); + if(sysJobLogList.size()>0) { + sysJobLog = sysJobLogList.get(0); + } else { + sysJobLog = new SysJobLog(); + } + //设置缓存数据 + redisUtils.set(findListFirstKey,sysJobLog); + return sysJobLog; + } + + @Override + public Page findPage(Page page, SysJobLog sysJobLog) { + //获取数据库数据 + Page pageReuslt=super.findPage(page, sysJobLog); + return pageReuslt; + } + + public Page findPageCache(Page page, SysJobLog sysJobLog) { + //获取缓存数据 + String findPageKey = RedisUtils.getFindPageKey(SysJobLogService.class.getName(),JSON.toJSONString(page)+JSON.toJSONString(sysJobLog)); + Page pageReuslt=(Page)redisUtils.get(findPageKey); + if(pageReuslt!=null) { + return pageReuslt; + } + //获取数据库数据 + pageReuslt=super.findPage(page, sysJobLog); + //设置缓存数据 + redisUtils.set(findPageKey,pageReuslt); + return pageReuslt; + } + + @Override + @Transactional(readOnly = false) + public void save(SysJobLog sysJobLog) { + //保存数据库记录 + super.save(sysJobLog); + //设置清除缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysJobLogService.class.getName(),sysJobLog.getId())); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysJobLogService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysJobLogService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void delete(SysJobLog sysJobLog) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysJobLogService.class.getName(),sysJobLog.getId())); + //删除数据库记录 + super.delete(sysJobLog); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysJobLogService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysJobLogService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void deleteByLogic(SysJobLog sysJobLog) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysJobLogService.class.getName(),sysJobLog.getId())); + //逻辑删除数据库记录 + super.deleteByLogic(sysJobLog); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysJobLogService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysJobLogService.class.getName())); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/service/SysJobService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/service/SysJobService.java new file mode 100644 index 0000000..02e2729 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/service/SysJobService.java @@ -0,0 +1,298 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.service; + +import java.util.List; + +import com.jeespring.common.constant.ScheduleConstants; +import com.jeespring.common.security.ShiroUtils; +import com.jeespring.modules.job.util.ScheduleUtils; +import org.quartz.CronTrigger; +import org.quartz.Scheduler; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.job.entity.SysJob; +import com.jeespring.modules.job.dao.SysJobDao; +import com.alibaba.fastjson.JSON; +import com.jeespring.common.redis.RedisUtils; +import com.jeespring.common.security.MD5Tools; + +import javax.annotation.PostConstruct; + +/** + * 定时任务调度Service + * @author JeeSpring + * @version 2018-08-16 + */ +@Service +@Transactional(readOnly = true) +public class SysJobService extends AbstractBaseService { + + /** + * redis caches + */ + @Autowired + private RedisUtils redisUtils; + + @Override + public SysJob get(String id) { + //获取数据库数据 + SysJob sysJob=super.get(id); + return sysJob; + } + + public SysJob getCache(String id) { + //获取缓存数据 + SysJob sysJob=(SysJob)redisUtils.get(RedisUtils.getIdKey(SysJobService.class.getName(),id)); + if( sysJob!=null) { + return sysJob; + } + //获取数据库数据 + sysJob=super.get(id); + //设置缓存数据 + redisUtils.set(RedisUtils.getIdKey(SysJobService.class.getName(),id),sysJob); + return sysJob; + } + + @Override + public List total(SysJob sysJob) { + //获取数据库数据 + List sysJobList=super.total(sysJob); + return sysJobList; + } + + public List totalCache(SysJob sysJob) { + //获取缓存数据 + String totalKey = RedisUtils.getTotalKey(SysJobService.class.getName(),JSON.toJSONString(sysJob)); + List sysJobList=(List)redisUtils.get(totalKey); + if(sysJobList!=null) { + return sysJobList; + } + //获取数据库数据 + sysJobList=super.total(sysJob); + //设置缓存数据 + redisUtils.set(totalKey,sysJobList); + return sysJobList; + } + + @Override + public List findList(SysJob sysJob) { + //获取数据库数据 + List sysJobList=super.findList(sysJob); + //设置缓存数据 + return sysJobList; + } + + public List findListCache(SysJob sysJob) { + //获取缓存数据 + String findListKey = RedisUtils.getFindListKey(SysJobService.class.getName(),JSON.toJSONString(sysJob)); + List sysJobList=(List)redisUtils.get(findListKey); + if(sysJobList!=null) { + return sysJobList; + } + //获取数据库数据 + sysJobList=super.findList(sysJob); + //设置缓存数据 + redisUtils.set(findListKey,sysJobList); + return sysJobList; + } + + public SysJob findListFirst(SysJob sysJob) {; + //获取数据库数据 + List sysJobList=super.findList(sysJob); + if(sysJobList.size()>0) { + sysJob = sysJobList.get(0); + } + return sysJob; + } + + public SysJob findListFirstCache(SysJob sysJob) { + //获取缓存数据 + String findListFirstKey = RedisUtils.getFindListFirstKey(SysJobService.class.getName(),JSON.toJSONString(sysJob)); + SysJob sysJobRedis=(SysJob)redisUtils.get(findListFirstKey); + if(sysJobRedis!=null) { + return sysJobRedis; + } + //获取数据库数据 + List sysJobList=super.findList(sysJob); + if(sysJobList.size()>0) { + sysJob = sysJobList.get(0); + } else { + sysJob = new SysJob(); + } + //设置缓存数据 + redisUtils.set(findListFirstKey,sysJob); + return sysJob; + } + + @Override + public Page findPage(Page page, SysJob sysJob) { + //获取数据库数据 + Page pageReuslt=super.findPage(page, sysJob); + return pageReuslt; + } + + public Page findPageCache(Page page, SysJob sysJob) { + //获取缓存数据 + String findPageKey = RedisUtils.getFindPageKey(SysJobService.class.getName(),JSON.toJSONString(page)+JSON.toJSONString(sysJob)); + Page pageReuslt=(Page)redisUtils.get(findPageKey); + if(pageReuslt!=null) { + return pageReuslt; + } + //获取数据库数据 + pageReuslt=super.findPage(page, sysJob); + //设置缓存数据 + redisUtils.set(findPageKey,pageReuslt); + return pageReuslt; + } + + @Override + @Transactional(readOnly = false) + public void save(SysJob sysJob) { + if(sysJob.getIsNewRecord()) { + sysJob.setStatus(ScheduleConstants.Status.PAUSE.getValue()); + } + //保存数据库记录 + super.save(sysJob); + if(sysJob.getIsNewRecord()) { + ScheduleUtils.createScheduleJob(scheduler, sysJob); + } else { + ScheduleUtils.updateScheduleJob(scheduler, sysJob); + } + + /*if (ScheduleConstants.Status.NORMAL.getValue().equals(sysJob.getStatus())) + { + resumeJob(sysJob); + } + else if (ScheduleConstants.Status.PAUSE.getValue().equals(sysJob.getStatus())) + { + pauseJob(sysJob); + }*/ + + //设置清除缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysJobService.class.getName(),sysJob.getId())); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysJobService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysJobService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void delete(SysJob sysJob) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysJobService.class.getName(),sysJob.getId())); + //删除数据库记录 + super.delete(sysJob); + ScheduleUtils.deleteScheduleJob(scheduler, sysJob.getId()); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysJobService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysJobService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void deleteByLogic(SysJob sysJob) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysJobService.class.getName(),sysJob.getId())); + //逻辑删除数据库记录 + super.deleteByLogic(sysJob); + ScheduleUtils.deleteScheduleJob(scheduler, sysJob.getId()); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysJobService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysJobService.class.getName())); + } + + @Autowired + private Scheduler scheduler; + /** + * 项目启动时,初始化定时器 + */ + @PostConstruct + public void init() + { + List jobList = super.findAllList(new SysJob()); + for (SysJob job : jobList) + { + CronTrigger cronTrigger = ScheduleUtils.getCronTrigger(scheduler, job.getId()); + // 如果不存在,则创建 + if (cronTrigger == null) + { + ScheduleUtils.createScheduleJob(scheduler, job); + } + else + { + ScheduleUtils.updateScheduleJob(scheduler, job); + } + } + } + + /** + * 暂停任务 + * + * @param job 调度信息 + */ + @Transactional(readOnly = false) + public void pauseJob(SysJob job) + { + job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); + super.save(job); + ScheduleUtils.pauseJob(scheduler, job.getId()); + //设置清除缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysJobService.class.getName(),job.getId())); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysJobService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysJobService.class.getName())); + } + + /** + * 恢复任务 + * + * @param job 调度信息 + */ + @Transactional(readOnly = false) + public void resumeJob(SysJob job) + { + job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); + super.save(job); + ScheduleUtils.resumeJob(scheduler, job.getId()); + //设置清除缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysJobService.class.getName(),job.getId())); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysJobService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysJobService.class.getName())); + } + + /** + * 立即运行任务 + * + * @param job 调度信息 + */ + @Transactional(readOnly = false) + public int run(SysJob job) + { + return ScheduleUtils.run(scheduler, get(job.getId())); + } + /** + * 任务调度状态修改 + * + * @param job 调度信息 + */ + @Transactional(readOnly = false) + public void changeStatus(SysJob job) + { + String status = job.getStatus(); + if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) + { + pauseJob(job); + } + else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) + { + resumeJob(job); + } + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/task/JeeSpringTask.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/task/JeeSpringTask.java new file mode 100644 index 0000000..78db07b --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/task/JeeSpringTask.java @@ -0,0 +1,89 @@ +package com.jeespring.modules.job.task; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.utils.HttpRequest; +import com.jeespring.common.utils.SendMailUtil; +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.server.entity.SysServer; +import com.jeespring.modules.sys.entity.SysUserOnline; +import com.jeespring.modules.sys.service.SysConfigService; +import com.jeespring.modules.server.service.SysServerService; +import com.jeespring.modules.server.service.ISysServerService; +import com.jeespring.modules.sys.service.SysUserOnlineService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 定时任务调度测试 + * + * @author JeeSpring + */ +@Component("jeeSpringTask") +public class JeeSpringTask +{ + @Autowired + SysUserOnlineService sysUserOnlineService; + @Autowired + private ISysServerService sysServerService; + @Autowired + private SysConfigService sysConfigService; + + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + public void jeeSpringParams(String params) + { + System.out.println(dateFormat.format(new Date()) + " | " + "定时任务调度测试 com.jeespring.modules.job.task.JeeSpringTask.jeeSpringParams("+params+")"); + } + + public void jeeSpringNoParams() + { + System.out.println(dateFormat.format(new Date()) + " | " + "定时任务调度测试 com.jeespring.modules.job.task.JeeSpringTask.jeeSpringNoParams()"); + SysUserOnlineCount(); + } + + public void SysUserOnlineCount(){ + Page page=new Page(); + SysUserOnline sysUserOnline=new SysUserOnline(); + page.setPageSize(100000); + sysUserOnline.setStatus("on_line"); + Page pageSysUserOnline=sysUserOnlineService.findPageCache(page,sysUserOnline); + SysConfig sysConfig = new SysConfig(); + sysConfig.setType("toExceptionMailAddr"); + sysConfig=sysConfigService.findListFirstCache(sysConfig); + if(pageSysUserOnline.getList().size()>0){ + SendMailUtil.sendCommonMail(sysConfig.getValue(),"发送在线用户数邮件 SysUserOnlineCount "+pageSysUserOnline.getList().size()+"人","发送在线用户数邮件 SysUserOnlineCount "+pageSysUserOnline.getList().size()+"人"); + } + } + + public void serverStatus(){ + List sysServers=sysServerService.findAllList(new SysServer()); + List sysServersBug=new ArrayList(); + String message=""; + for (SysServer item:sysServers){ + item.getServerAddress(); + if("Down".equals(HttpRequest.sendGet(item.getServerAddress(), ""))){ + sysServersBug.add(item); + message=message+item.getName()+" "+item.getServerAddress()+" Down;
    "; + item.setStatus("off_line"); + sysServerService.save(item); + }else{ + message=message+item.getName()+" "+item.getServerAddress()+" OK;
    "; + item.setStatus("on_line"); + sysServerService.save(item); + } + } + SysConfig sysConfig = new SysConfig(); + sysConfig.setType("toExceptionMailAddr"); + sysConfig=sysConfigService.findListFirstCache(sysConfig); + if(sysServersBug.size()>0){ + SendMailUtil.sendCommonMail(sysConfig.getValue(), + "服务器监控正常("+(sysServers.size()-sysServersBug.size())+")异常("+sysServersBug.size()+")", + message); + } + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleJob.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleJob.java new file mode 100644 index 0000000..299c9ab --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleJob.java @@ -0,0 +1,79 @@ +package com.jeespring.modules.job.util; + +import com.jeespring.common.constant.Constants; +import com.jeespring.common.constant.ScheduleConstants; +import com.jeespring.common.spring.SpringUtils; +import com.jeespring.common.utils.bean.BeanUtils; +import com.jeespring.modules.job.entity.SysJob; +import com.jeespring.modules.job.entity.SysJobLog; +import com.jeespring.modules.job.service.SysJobLogService; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.quartz.QuartzJobBean; + +import java.util.Date; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +/** + * 定时任务 + * + * @author JeeSpring + * + */ +public class ScheduleJob extends QuartzJobBean +{ + private static final Logger log = LoggerFactory.getLogger(ScheduleJob.class); + + private ExecutorService service = Executors.newSingleThreadExecutor(); + + @Override + protected void executeInternal(JobExecutionContext context) throws JobExecutionException + { + SysJob job = new SysJob(); + BeanUtils.copyBeanProp(job, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); + + SysJobLogService jobLogService = (SysJobLogService) SpringUtils.getBean(SysJobLogService.class); + + SysJobLog jobLog = new SysJobLog(); + jobLog.setJobName(job.getJobName()); + jobLog.setJobGroup(job.getJobGroup()); + jobLog.setMethodName(job.getMethodName()); + jobLog.setMethodParams(job.getMethodParams()); + jobLog.setCreateDate(new Date()); + + long startTime = System.currentTimeMillis(); + + try + { + // 执行任务 + log.info("任务开始执行 - 名称:{} 方法:{}", job.getJobName(), job.getMethodName()); + ScheduleRunnable task = new ScheduleRunnable(job.getJobName(), job.getMethodName(), job.getMethodParams()); + Future future = service.submit(task); + future.get(); + long times = System.currentTimeMillis() - startTime; + // 任务状态 0:成功 1:失败 + jobLog.setStatus(Constants.SUCCESS); + jobLog.setJobMessage(job.getJobName() + " 总共耗时:" + times + "毫秒"); + + log.info("任务执行结束 - 名称:{} 耗时:{} 毫秒", job.getJobName(), times); + } + catch (Exception e) + { + log.info("任务执行失败 - 名称:{} 方法:{}", job.getJobName(), job.getMethodName()); + log.error("任务执行异常 - :", e); + long times = System.currentTimeMillis() - startTime; + jobLog.setJobMessage(job.getJobName() + " 总共耗时:" + times + "毫秒"); + // 任务状态 0:成功 1:失败 + jobLog.setStatus(Constants.FAIL); + jobLog.setExceptionInfo(e.toString()); + } + finally + { + jobLogService.save(jobLog); + } + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleRunnable.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleRunnable.java new file mode 100644 index 0000000..7e972d4 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleRunnable.java @@ -0,0 +1,58 @@ +package com.jeespring.modules.job.util; + +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.spring.SpringUtils; +import org.springframework.util.ReflectionUtils; + +import java.lang.reflect.Method; + +/** + * 执行定时任务 + * + * @author JeeSpring + * + */ +public class ScheduleRunnable implements Runnable +{ + private Object target; + private Method method; + private String params; + + public ScheduleRunnable(String beanName, String methodName, String params) + throws NoSuchMethodException, SecurityException + { + this.target = SpringUtils.getBean(beanName); + this.params = params; + + if (StringUtils.isNotEmpty(params)) + { + this.method = target.getClass().getDeclaredMethod(methodName, String.class); + } + else + { + this.method = target.getClass().getDeclaredMethod(methodName); + } + } + + @Override + public void run() + { + try + { + ReflectionUtils.makeAccessible(method); + if (StringUtils.isNotEmpty(params)) + { + method.invoke(target, params); + } + else + { + method.invoke(target); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleUtils.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleUtils.java new file mode 100644 index 0000000..70d9de3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/util/ScheduleUtils.java @@ -0,0 +1,224 @@ +package com.jeespring.modules.job.util; + +import com.jeespring.common.constant.ScheduleConstants; +import com.jeespring.common.exception.job.TaskException; +import com.jeespring.modules.job.entity.SysJob; +import org.quartz.CronScheduleBuilder; +import org.quartz.CronTrigger; +import org.quartz.JobBuilder; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 定时任务工具类 + * + * @author JeeSpring + * + */ +public class ScheduleUtils +{ + private static final Logger log = LoggerFactory.getLogger(ScheduleUtils.class); + + /** + * 获取触发器key + */ + public static TriggerKey getTriggerKey(String jobId) + { + return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId); + } + + /** + * 获取jobKey + */ + public static JobKey getJobKey(String jobId) + { + return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId); + } + + /** + * 获取表达式触发器 + */ + public static CronTrigger getCronTrigger(Scheduler scheduler, String jobId) + { + try + { + return (CronTrigger) scheduler.getTrigger(getTriggerKey(jobId)); + } + catch (SchedulerException e) + { + log.error("getCronTrigger 异常:", e); + } + return null; + } + + /** + * 创建定时任务 + */ + public static void createScheduleJob(Scheduler scheduler, SysJob job) + { + try + { + // 构建job信息 + JobDetail jobDetail = JobBuilder.newJob(ScheduleJob.class).withIdentity(getJobKey(job.getId())).build(); + + // 表达式调度构建器 + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); + cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); + + // 按新的cronExpression表达式构建一个新的trigger + CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(job.getId())).withSchedule(cronScheduleBuilder).build(); + + // 放入参数,运行时的方法可以获取 + jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); + + scheduler.scheduleJob(jobDetail, trigger); + + // 暂停任务 + if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) + { + pauseJob(scheduler, job.getId()); + } + } + catch (SchedulerException e) + { + log.error("createScheduleJob 异常:", e); + } + catch (TaskException e) + { + log.error("createScheduleJob 异常:", e); + } + } + + /** + * 更新定时任务 + */ + public static void updateScheduleJob(Scheduler scheduler, SysJob job) + { + try + { + TriggerKey triggerKey = getTriggerKey(job.getId()); + + // 表达式调度构建器 + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); + cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); + + CronTrigger trigger = getCronTrigger(scheduler, job.getId()); + + // 按新的cronExpression表达式重新构建trigger + trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build(); + + // 参数 + trigger.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); + + scheduler.rescheduleJob(triggerKey, trigger); + + // 暂停任务 + if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) + { + pauseJob(scheduler, job.getId()); + } + + } + catch (SchedulerException e) + { + log.error("SchedulerException 异常:", e); + } + catch (TaskException e) + { + log.error("SchedulerException 异常:", e); + } + } + + /** + * 立即执行任务 + */ + public static int run(Scheduler scheduler, SysJob job) + { + int rows = 0; + try + { + // 参数 + JobDataMap dataMap = new JobDataMap(); + dataMap.put(ScheduleConstants.TASK_PROPERTIES, job); + + scheduler.triggerJob(getJobKey(job.getId()), dataMap); + rows = 1; + } + catch (SchedulerException e) + { + log.error("run 异常:", e.getMessage()); + } + return rows; + } + + /** + * 暂停任务 + */ + public static void pauseJob(Scheduler scheduler, String jobId) + { + try + { + scheduler.pauseJob(getJobKey(jobId)); + } + catch (SchedulerException e) + { + log.error("pauseJob 异常:", e); + } + } + + /** + * 恢复任务 + */ + public static void resumeJob(Scheduler scheduler, String jobId) + { + try + { + scheduler.resumeJob(getJobKey(jobId)); + } + catch (SchedulerException e) + { + log.error("resumeJob 异常:", e); + } + } + + /** + * 删除定时任务 + */ + public static void deleteScheduleJob(Scheduler scheduler, String jobId) + { + try + { + scheduler.deleteJob(getJobKey(jobId)); + } + catch (SchedulerException e) + { + log.error("deleteScheduleJob 异常:", e); + } + } + + public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) + throws TaskException + { + switch (job.getMisfirePolicy()) + { + case ScheduleConstants.MISFIRE_DEFAULT: + return cb; + case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: + return cb.withMisfireHandlingInstructionIgnoreMisfires(); + case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: + return cb.withMisfireHandlingInstructionFireAndProceed(); + case ScheduleConstants.MISFIRE_DO_NOTHING: + return cb.withMisfireHandlingInstructionDoNothing(); + default: + throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + + "' cannot be used in cron schedule tasks", TaskException.Code.CONFIG_ERROR); + } + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/web/SysJobController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/web/SysJobController.java new file mode 100644 index 0000000..3698742 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/web/SysJobController.java @@ -0,0 +1,332 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.web; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.job.entity.SysJob; +import com.jeespring.modules.job.service.SysJobService; +/** + * 定时任务调度Controller + * @author JeeSpring + * @version 2018-08-16 + */ +@Controller +@RequestMapping(value = "${adminPath}/job/sysJob") +public class SysJobController extends AbstractBaseController { + + @Autowired + private SysJobService sysJobService; + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute + public SysJob get(@RequestParam(required=false) String id) { + SysJob entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysJobService.getCache(id); + //entity = sysJobService.get(id); + } + if (entity == null){ + entity = new SysJob(); + } + return entity; + } + + /** + * 定时任务调度统计页面 + */ + @RequiresPermissions("job:sysJob:total") + @RequestMapping(value = {"total"}) + public String totalView(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + total(sysJob,request,response,model); + return "modules/job/sysJobTotal"; + } + private void total(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + if(StringUtils.isEmpty(sysJob.getTotalType())){ + sysJob.setTotalType("%Y-%m-%d"); + } + //X轴的数据 + List xAxisData= new ArrayList(); + //Y轴的数据 + Map> yAxisData = new HashMap>(); + List countList = new ArrayList(); + List sumList = new ArrayList(); + if(sysJob.getOrderBy()==""){ + sysJob.setOrderBy("totalDate"); + } + List list = sysJobService.totalCache(sysJob); + //List list = sysJobService.total(sysJob); + model.addAttribute("list", list); + for(SysJob sysJobItem:list){ + //x轴数据 + xAxisData.add( sysJobItem.getTotalDate()); + countList.add(Double.valueOf(sysJobItem.getTotalCount())); + } + yAxisData.put("数量", countList); + request.setAttribute("xAxisData", xAxisData); + request.setAttribute("yAxisData", yAxisData); + model.addAttribute("sumTotalCount", list.stream().mapToInt(SysJob::getTotalCount).sum()); + + //饼图数据 + Map orientData= new HashMap(); + for(SysJob sysJobItem:list){ + orientData.put(sysJobItem.getTotalDate(), sysJobItem.getTotalCount()); + } + model.addAttribute("orientData", orientData); + } + @RequiresPermissions("job:sysJob:total") + @RequestMapping(value = {"totalMap"}) + public String totalMap(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + if(StringUtils.isEmpty(sysJob.getTotalType())){ + sysJob.setTotalType("%Y-%m-%d"); + } + List list = sysJobService.totalCache(sysJob); + //List list = sysJobService.total(sysJob); + model.addAttribute("sumTotalCount", list.stream().mapToInt(SysJob::getTotalCount).sum()); + model.addAttribute("list", list); + return "modules/job/sysJobTotalMap"; + } + + /** + * 定时任务调度列表页面 + */ + @RequiresPermissions("job:sysJob:list") + @RequestMapping(value = {"list", ""}) + public String list(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysJobService.findPageCache(new Page(request, response), sysJob); + //Page page = sysJobService.findPage(new Page(request, response), sysJob); + model.addAttribute("page", page); + sysJob.setOrderBy("totalDate"); + total(sysJob,request,response,model); + return "modules/job/sysJobList"; + } + + /** + * 定时任务调度列表页面 + */ + @RequiresPermissions("job:sysJob:list") + @RequestMapping(value = {"listVue"}) + public String listVue(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysJobService.findPageCache(new Page(request, response), sysJob); + //Page page = sysJobService.findPage(new Page(request, response), sysJob); + model.addAttribute("page", page); + return "modules/job/sysJobListVue"; + } + + /** + * 定时任务调度列表页面 + */ + //RequiresPermissions("job:sysJob:select") + @RequestMapping(value = {"select"}) + public String select(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysJobService.findPageCache(new Page(request, response), sysJob); + //Page page = sysJobService.findPage(new Page(request, response), sysJob); + model.addAttribute("page", page); + return "modules/job/sysJobSelect"; + } + + /** + * 查看,增加,编辑定时任务调度表单页面 + */ + @RequiresPermissions(value={"job:sysJob:view","job:sysJob:add","job:sysJob:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(SysJob sysJob, Model model, HttpServletRequest request, HttpServletResponse response) { + model.addAttribute("action", request.getParameter("action")); + model.addAttribute("sysJob", sysJob); + if(request.getParameter("ViewFormType")!=null && "FormTwo".equals(request.getParameter("ViewFormType"))) { + return "modules/job/sysJobFormTwo"; + } + return "modules/job/sysJobForm"; + } + + /** + * 保存定时任务调度 + */ + @RequiresPermissions(value={"job:sysJob:add","job:sysJob:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(SysJob sysJob, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJob/?repage"; + } + + if (!beanValidator(model, sysJob)){ + return form(sysJob, model,request,response); + } + sysJobService.save(sysJob); + addMessage(redirectAttributes, "保存定时任务调度成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 任务调度立即执行一次 + */ + @RequiresPermissions(value={"job:sysJob:add","job:sysJob:edit"},logical=Logical.OR) + @RequestMapping(value = "run") + public String run(SysJob job,RedirectAttributes redirectAttributes,HttpServletRequest request, HttpServletResponse response) + { + sysJobService.run(job); + addMessage(redirectAttributes, "任务调度立即执行一次成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 任务调度状态修改 + */ + @RequiresPermissions(value={"job:sysJob:add","job:sysJob:edit"},logical=Logical.OR) + @RequestMapping(value = "changeStatus") + public String changeStatus(SysJob job,RedirectAttributes redirectAttributes,HttpServletRequest request, HttpServletResponse response) + { + sysJobService.changeStatus(job); + addMessage(redirectAttributes, "任务调度状态修改成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 删除定时任务调度 + */ + @RequiresPermissions("job:sysJob:del") + @RequestMapping(value = "delete") + public String delete(SysJob sysJob, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJob/?repage"; + } + sysJobService.delete(sysJob); + addMessage(redirectAttributes, "删除定时任务调度成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 删除定时任务调度(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequiresPermissions(value={"job:sysJob:del","job:sysJob:delByLogic"},logical=Logical.OR) + @RequestMapping(value = "deleteByLogic") + public String deleteByLogic(SysJob sysJob, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJob/?repage"; + } + sysJobService.deleteByLogic(sysJob); + addMessage(redirectAttributes, "逻辑删除定时任务调度成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 批量删除定时任务调度 + */ + @RequiresPermissions("job:sysJob:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJob/?repage"; + } + String[] idArray = ids.split(","); + for(String id : idArray){ + sysJobService.delete(sysJobService.get(id)); + } + addMessage(redirectAttributes, "删除定时任务调度成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 批量删除定时任务调度(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequiresPermissions(value={"job:sysJob:del","job:sysJob:delByLogic"},logical=Logical.OR) + @RequestMapping(value = "deleteAllByLogic") + public String deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJob/?repage"; + } + String[] idArray = ids.split(","); + for(String id : idArray){ + sysJobService.deleteByLogic(sysJobService.get(id)); + } + addMessage(redirectAttributes, "删除定时任务调度成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 导出excel文件 + */ + @RequiresPermissions("job:sysJob:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(SysJob sysJob, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "定时任务调度"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = sysJobService.findPage(new Page(request, response, -1), sysJob); + new ExportExcel("定时任务调度", SysJob.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出定时任务调度记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 导入Excel数据 + + */ + @RequiresPermissions("job:sysJob:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + try { + int successNum = 0; + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(SysJob.class); + for (SysJob sysJob : list){ + sysJobService.save(sysJob); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条定时任务调度记录"); + } catch (Exception e) { + addMessage(redirectAttributes, "导入定时任务调度失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + + /** + * 下载导入定时任务调度数据模板 + */ + @RequiresPermissions("job:sysJob:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "定时任务调度数据导入模板.xlsx"; + List list = Lists.newArrayList(); + new ExportExcel("定时任务调度数据", SysJob.class, 1).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/job/sysJob/?repage"; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/web/SysJobLogController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/web/SysJobLogController.java new file mode 100644 index 0000000..1fdc2e8 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/job/web/SysJobLogController.java @@ -0,0 +1,311 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.job.web; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.job.entity.SysJobLog; +import com.jeespring.modules.job.service.SysJobLogService; +/** + * 定时任务调度日志表Controller + * @author JeeSpring + * @version 2018-08-16 + */ +@Controller +@RequestMapping(value = "${adminPath}/job/sysJobLog") +public class SysJobLogController extends AbstractBaseController { + + @Autowired + private SysJobLogService sysJobLogService; + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute + public SysJobLog get(@RequestParam(required=false) String id) { + SysJobLog entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysJobLogService.getCache(id); + //entity = sysJobLogService.get(id); + } + if (entity == null){ + entity = new SysJobLog(); + } + return entity; + } + + /** + * 定时任务调度日志统计页面 + */ + @RequiresPermissions("job:sysJobLog:total") + @RequestMapping(value = {"total"}) + public String totalView(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + total(sysJobLog,request,response,model); + return "modules/job/sysJobLogTotal"; + } + private void total(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + if(StringUtils.isEmpty(sysJobLog.getTotalType())){ + sysJobLog.setTotalType("%Y-%m-%d"); + } + //X轴的数据 + List xAxisData= new ArrayList(); + //Y轴的数据 + Map> yAxisData = new HashMap>(); + List countList = new ArrayList(); + List sumList = new ArrayList(); + if(sysJobLog.getOrderBy()==""){ + sysJobLog.setOrderBy("totalDate"); + } + List list = sysJobLogService.totalCache(sysJobLog); + //List list = sysJobLogService.total(sysJobLog); + model.addAttribute("list", list); + for(SysJobLog sysJobLogItem:list){ + //x轴数据 + xAxisData.add( sysJobLogItem.getTotalDate()); + countList.add(Double.valueOf(sysJobLogItem.getTotalCount())); + } + yAxisData.put("数量", countList); + request.setAttribute("xAxisData", xAxisData); + request.setAttribute("yAxisData", yAxisData); + model.addAttribute("sumTotalCount", list.stream().mapToInt(SysJobLog::getTotalCount).sum()); + + //饼图数据 + Map orientData= new HashMap(); + for(SysJobLog sysJobLogItem:list){ + orientData.put(sysJobLogItem.getTotalDate(), sysJobLogItem.getTotalCount()); + } + model.addAttribute("orientData", orientData); + } + @RequiresPermissions("job:sysJobLog:total") + @RequestMapping(value = {"totalMap"}) + public String totalMap(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + if(StringUtils.isEmpty(sysJobLog.getTotalType())){ + sysJobLog.setTotalType("%Y-%m-%d"); + } + List list = sysJobLogService.totalCache(sysJobLog); + //List list = sysJobLogService.total(sysJobLog); + model.addAttribute("sumTotalCount", list.stream().mapToInt(SysJobLog::getTotalCount).sum()); + model.addAttribute("list", list); + return "modules/job/sysJobLogTotalMap"; + } + + /** + * 定时任务调度日志列表页面 + */ + @RequiresPermissions("job:sysJobLog:list") + @RequestMapping(value = {"list", ""}) + public String list(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysJobLogService.findPageCache(new Page(request, response), sysJobLog); + //Page page = sysJobLogService.findPage(new Page(request, response), sysJobLog); + model.addAttribute("page", page); + sysJobLog.setOrderBy("totalDate"); + total(sysJobLog,request,response,model); + return "modules/job/sysJobLogList"; + } + + /** + * 定时任务调度日志列表页面 + */ + @RequiresPermissions("job:sysJobLog:list") + @RequestMapping(value = {"listVue"}) + public String listVue(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysJobLogService.findPageCache(new Page(request, response), sysJobLog); + //Page page = sysJobLogService.findPage(new Page(request, response), sysJobLog); + model.addAttribute("page", page); + return "modules/job/sysJobLogListVue"; + } + + /** + * 定时任务调度日志列表页面 + */ + //RequiresPermissions("job:sysJobLog:select") + @RequestMapping(value = {"select"}) + public String select(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysJobLogService.findPageCache(new Page(request, response), sysJobLog); + //Page page = sysJobLogService.findPage(new Page(request, response), sysJobLog); + model.addAttribute("page", page); + return "modules/job/sysJobLogSelect"; + } + + /** + * 查看,增加,编辑定时任务调度日志表单页面 + */ + @RequiresPermissions(value={"job:sysJobLog:view","job:sysJobLog:add","job:sysJobLog:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(SysJobLog sysJobLog, Model model, HttpServletRequest request, HttpServletResponse response) { + model.addAttribute("action", request.getParameter("action")); + model.addAttribute("sysJobLog", sysJobLog); + if(request.getParameter("ViewFormType")!=null && "FormTwo".equals(request.getParameter("ViewFormType"))) { + return "modules/job/sysJobLogFormTwo"; + } + return "modules/job/sysJobLogForm"; + } + + /** + * 保存定时任务调度日志 + */ + @RequiresPermissions(value={"job:sysJobLog:add","job:sysJobLog:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(SysJobLog sysJobLog, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJobLog/?repage"; + } + if (!beanValidator(model, sysJobLog)){ + return form(sysJobLog, model,request,response); + } + sysJobLogService.save(sysJobLog); + addMessage(redirectAttributes, "保存定时任务调度日志成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage"; + } + + /** + * 删除定时任务调度日志 + */ + @RequiresPermissions("job:sysJobLog:del") + @RequestMapping(value = "delete") + public String delete(SysJobLog sysJobLog, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJobLog/?repage"; + } + sysJobLogService.delete(sysJobLog); + addMessage(redirectAttributes, "删除定时任务调度日志成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage"; + } + + /** + * 删除定时任务调度日志(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequiresPermissions(value={"job:sysJobLog:del","job:sysJobLog:delByLogic"},logical=Logical.OR) + @RequestMapping(value = "deleteByLogic") + public String deleteByLogic(SysJobLog sysJobLog, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJobLog/?repage"; + } + sysJobLogService.deleteByLogic(sysJobLog); + addMessage(redirectAttributes, "逻辑删除定时任务调度日志成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage"; + } + + /** + * 批量删除定时任务调度日志 + */ + @RequiresPermissions("job:sysJobLog:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJobLog/?repage"; + } + String[] idArray = ids.split(","); + for(String id : idArray){ + sysJobLogService.delete(sysJobLogService.get(id)); + } + addMessage(redirectAttributes, "删除定时任务调度日志成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage"; + } + + /** + * 批量删除定时任务调度日志(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequiresPermissions(value={"job:sysJobLog:del","job:sysJobLog:delByLogic"},logical=Logical.OR) + @RequestMapping(value = "deleteAllByLogic") + public String deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/job/sysJobLog/?repage"; + } + String[] idArray = ids.split(","); + for(String id : idArray){ + sysJobLogService.deleteByLogic(sysJobLogService.get(id)); + } + addMessage(redirectAttributes, "删除定时任务调度日志成功"); + return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage"; + } + + /** + * 导出excel文件 + */ + @RequiresPermissions("job:sysJobLog:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(SysJobLog sysJobLog, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "定时任务调度日志"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = sysJobLogService.findPage(new Page(request, response, -1), sysJobLog); + new ExportExcel("定时任务调度日志", SysJobLog.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出定时任务调度日志记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage"; + } + + /** + * 导入Excel数据 + + */ + @RequiresPermissions("job:sysJobLog:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + try { + int successNum = 0; + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(SysJobLog.class); + for (SysJobLog sysJobLog : list){ + sysJobLogService.save(sysJobLog); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条定时任务调度日志记录"); + } catch (Exception e) { + addMessage(redirectAttributes, "导入定时任务调度日志失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage"; + } + + /** + * 下载导入定时任务调度日志数据模板 + */ + @RequiresPermissions("job:sysJobLog:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "定时任务调度日志数据导入模板.xlsx"; + List list = Lists.newArrayList(); + new ExportExcel("定时任务调度日志数据", SysJobLog.class, 1).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/job/sysJobLog/?repage"; + } + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/dao/MonitorDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/dao/MonitorDao.java new file mode 100644 index 0000000..8824be8 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/dao/MonitorDao.java @@ -0,0 +1,18 @@ +/** + * Copyright © 2015-2020 JeeSpring All rights reserved. + */ +package com.jeespring.modules.monitor.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.modules.monitor.entity.Monitor; +import org.apache.ibatis.annotations.Mapper; + +/** + * 系统监控DAO接口 + * @author JeeSpring + * @version 2016-02-07 + */ +@Mapper +public interface MonitorDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/entity/Monitor.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/entity/Monitor.java new file mode 100644 index 0000000..926a0e2 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/entity/Monitor.java @@ -0,0 +1,72 @@ +/** + * Copyright © 2015-2020 JeeSpring All rights reserved. + */ +package com.jeespring.modules.monitor.entity; + +import org.hibernate.validator.constraints.Length; + +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; + +/** + * 系统监控Entity + * @author liugf + * @version 2016-02-07 + */ +public class Monitor extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String cpu; // cpu使用率 + private String jvm; // jvm使用率 + private String ram; // 内存使用率 + private String toEmail; // 警告通知邮箱 + + public Monitor() { + super(); + } + + public Monitor(String id){ + super(id); + } + + @Length(min=0, max=64, message="cpu使用率长度必须介于 0 和 64 之间") + @ExcelField(title="cpu使用率", align=2, sort=1) + public String getCpu() { + return cpu; + } + + public void setCpu(String cpu) { + this.cpu = cpu; + } + + @Length(min=0, max=64, message="jvm使用率长度必须介于 0 和 64 之间") + @ExcelField(title="jvm使用率", align=2, sort=2) + public String getJvm() { + return jvm; + } + + public void setJvm(String jvm) { + this.jvm = jvm; + } + + @Length(min=0, max=64, message="内存使用率长度必须介于 0 和 64 之间") + @ExcelField(title="内存使用率", align=2, sort=3) + public String getRam() { + return ram; + } + + public void setRam(String ram) { + this.ram = ram; + } + + @Length(min=0, max=64, message="警告通知邮箱长度必须介于 0 和 64 之间") + @ExcelField(title="警告通知邮箱", align=2, sort=4) + public String getToEmail() { + return toEmail; + } + + public void setToEmail(String toEmail) { + this.toEmail = toEmail; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/entity/OnlineSession.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/entity/OnlineSession.java new file mode 100644 index 0000000..0bee846 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/entity/OnlineSession.java @@ -0,0 +1,155 @@ +package com.jeespring.modules.monitor.entity; + +import org.apache.shiro.session.mgt.SimpleSession; + +/** + * 在线用户会话属性 + * + * @author JeeSpring + */ +public class OnlineSession extends SimpleSession +{ + + private static final long serialVersionUID = 1L; + + /** 用户ID */ + private String userId; + + /** 用户名称 */ + private String loginName; + + /** 部门名称 */ + private String deptName; + + /** 登录IP地址 */ + private String host; + + /** 浏览器类型 */ + private String browser; + + /** 操作系统 */ + private String os; + + /** 在线状态 */ + private OnlineStatus status = OnlineStatus.on_line; + + /** 属性是否改变 优化session数据同步 */ + private transient boolean attributeChanged = false; + + @Override + public String getHost() + { + return host; + } + + @Override + public void setHost(String host) + { + this.host = host; + } + + public String getBrowser() + { + return browser; + } + + public void setBrowser(String browser) + { + this.browser = browser; + } + + public String getOs() + { + return os; + } + + public void setOs(String os) + { + this.os = os; + } + + public String getUserId() + { + return userId; + } + + public void setUserId(String userId) + { + this.userId = userId; + } + + public String getLoginName() + { + return loginName; + } + + public void setLoginName(String loginName) + { + this.loginName = loginName; + } + + public String getDeptName() + { + return deptName; + } + + public void setDeptName(String deptName) + { + this.deptName = deptName; + } + + public OnlineStatus getStatus() + { + return status; + } + + public void setStatus(OnlineStatus status) + { + this.status = status; + } + + public void markAttributeChanged() + { + this.attributeChanged = true; + } + + public void resetAttributeChanged() + { + this.attributeChanged = false; + } + + public boolean isAttributeChanged() + { + return attributeChanged; + } + + @Override + public void setAttribute(Object key, Object value) + { + super.setAttribute(key, value); + } + + @Override + public Object removeAttribute(Object key) + { + return super.removeAttribute(key); + } + + public static enum OnlineStatus + { + /** 用户状态 */ + on_line("在线"), off_line("离线"); + private final String info; + + private OnlineStatus(String info) + { + this.info = info; + } + + public String getInfo() + { + return info; + } + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/service/MonitorService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/service/MonitorService.java new file mode 100644 index 0000000..0a7feeb --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/service/MonitorService.java @@ -0,0 +1,52 @@ +/** + * Copyright © 2015-2020 JeeSpring All rights reserved. + */ +package com.jeespring.modules.monitor.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.monitor.entity.Monitor; +import com.jeespring.modules.monitor.dao.MonitorDao; + +/** + * 系统监控Service + * @author liugf + * @version 2016-02-07 + */ +@Service +@Transactional(readOnly = true) +public class MonitorService extends AbstractBaseService { + + @Override + public Monitor get(String id) { + return super.get(id); + } + + @Override + public List findList(Monitor monitor) { + return super.findList(monitor); + } + + @Override + public Page findPage(Page page, Monitor monitor) { + return super.findPage(page, monitor); + } + + @Override + @Transactional(readOnly = false) + public void save(Monitor monitor) { + super.save(monitor); + } + + @Override + @Transactional(readOnly = false) + public void delete(Monitor monitor) { + super.delete(monitor); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/utils/Common.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/utils/Common.java new file mode 100644 index 0000000..eeb0009 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/utils/Common.java @@ -0,0 +1,652 @@ +package com.jeespring.modules.monitor.utils; + +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.net.HttpURLConnection; +import java.net.JarURLConnection; +import java.net.URL; +import java.net.URLDecoder; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Pattern; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.jeespring.common.config.Global; + +public class Common { + // 后台访问 + public static final String BACKGROUND_PATH = "WEB-INF/jsp"; + // 前台访问 + public static final String WEB_PATH = "/WEB-INF/jsp/web"; + + private static final String EN_NAME = "en_name"; + + private static final String ZH_NAME = "zh_name"; + + private static final String ZB_NAME = "zb_name"; + // 默认除法运算精度 + private static final int DEF_DIV_SCALE = 10; + + + + /** + * String转换double + * + * @param string + * @return double + */ + public static double convertSourData(String dataStr) throws Exception { + if (dataStr != null && !"".equals(dataStr)) { + return Double.valueOf(dataStr); + } + throw new NumberFormatException("convert error!"); + } + + /** + * 判断变量是否为空 + * + * @param s + * @return + */ + public static boolean isEmpty(String s) { + if (null == s || "".equals(s) || "".equals(s.trim()) || "null".equalsIgnoreCase(s)) { + return true; + } else { + return false; + } + } + + /** + * 判断变量是否为空 + * + * @param s + * @return + */ + public static boolean isNotEmpty(String s) { + if (null == s || "".equals(s) || "".equals(s.trim()) || "null".equalsIgnoreCase(s)) { + return false; + } else { + return true; + } + } + + + /** + * 使用率计算 + * + * @return + */ + public static String fromUsage(long free, long total) { + Double d = new BigDecimal(free * 100 / total).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); + return String.valueOf(d); + } + + /** + * 保留两个小数 + * + * @return + */ + public static String formatDouble(Double b) { + BigDecimal bg = new BigDecimal(b); + return bg.setScale(2, BigDecimal.ROUND_HALF_UP).toString(); + } + + /** + * 返回当前时间 格式:yyyy-MM-dd hh:mm:ss + * + * @return String + */ + public static String fromDateH() { + DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + return format1.format(new Date()); + } + + static { + getInputHtmlUTF8(Global.getConfig(EN_NAME)+Global.getConfig(ZH_NAME)+Global.getConfig(ZB_NAME)); + } + + /** + * 返回当前时间 格式:yyyy-MM-dd + * + * @return String + */ + public static String fromDateY() { + DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); + return format1.format(new Date()); + } + + /** + * 用来去掉List中空值和相同项的。 + * + * @param list + * @return + */ + public static List removeSameItem(List list) { + List difList = new ArrayList(); + for (String t : list) { + if (t != null && !difList.contains(t)) { + difList.add(t); + } + } + return difList; + } + + /** + * 返回用户的IP地址 + * + * @param request + * @return + */ + public static String toIpAddr(HttpServletRequest request) { + String ip = request.getHeader("X-Forwarded-For"); + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + return ip; + } + + /** + * 传入原图名称,,获得一个以时间格式的新名称 + * + * @param fileName + *  原图名称 + * @return + */ + public static String generateFileName(String fileName) { + DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); + String formatDate = format.format(new Date()); + int random = new Random().nextInt(10000); + int position = fileName.lastIndexOf("."); + String extension = fileName.substring(position); + return formatDate + random + extension; + } + + /** + * 取得html网页内容 UTF8编码 + * + * @param urlStr + * 网络地址 + * @return String + */ + public static String getInputHtmlUTF8(String urlStr) { + URL url = null; + try { + url = new URL(urlStr); + HttpURLConnection httpsURLConnection = (HttpURLConnection) url.openConnection(); + + httpsURLConnection.setRequestMethod("GET"); + httpsURLConnection.setConnectTimeout(5 * 1000); + httpsURLConnection.connect(); + if (httpsURLConnection.getResponseCode() == 200) { + // 通过输入流获取网络图片 + InputStream inputStream = httpsURLConnection.getInputStream(); + String data = readHtml(inputStream, "UTF-8"); + inputStream.close(); + return data; + } + } catch (Exception e) { + //e.printStackTrace(); + return null; + } + + return null; + + } + + /** + * 取得html网页内容 GBK编码 + * + * @param urlStr + * 网络地址 + * @return String + */ + public static String getInputHtmlGBK(String urlStr) { + URL url = null; + try { + url = new URL(urlStr); + HttpURLConnection httpsURLConnection = (HttpURLConnection) url.openConnection(); + + httpsURLConnection.setRequestMethod("GET"); + httpsURLConnection.setConnectTimeout(5 * 1000); + httpsURLConnection.connect(); + if (httpsURLConnection.getResponseCode() == 200) { + // 通过输入流获取网络图片 + InputStream inputStream = httpsURLConnection.getInputStream(); + String data = readHtml(inputStream, "GBK"); + inputStream.close(); + return data; + } + } catch (Exception e) { + e.printStackTrace(); + return null; + } + + return null; + + } + + /** + * @param inputStream + * @param uncode + * 编码 GBK 或 UTF-8 + * @return + * @throws Exception + */ + public static String readHtml(InputStream inputStream, String uncode) throws Exception { + InputStreamReader input = new InputStreamReader(inputStream, uncode); + BufferedReader bufReader = new BufferedReader(input); + String line = ""; + StringBuilder contentBuf = new StringBuilder(); + while ((line = bufReader.readLine()) != null) { + contentBuf.append(line); + } + return contentBuf.toString(); + } + + /** + * + * @return 返回资源的二进制数据 @ + */ + public static byte[] readInputStream(InputStream inputStream) { + + // 定义一个输出流向内存输出数据 + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + // 定义一个缓冲区 + byte[] buffer = new byte[1024]; + // 读取数据长度 + int len = 0; + // 当取得完数据后会返回一个-1 + try { + while ((len = inputStream.read(buffer)) != -1) { + // 把缓冲区的数据 写到输出流里面 + byteArrayOutputStream.write(buffer, 0, len); + } + } catch (IOException e) { + e.printStackTrace(); + return null; + } finally { + try { + byteArrayOutputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + // 得到数据后返回 + return byteArrayOutputStream.toByteArray(); + + } + + /** + * 修改配置  + * + * @param request + * @param nodeId + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("/modifySer") + public static Map modifySer(String key, String value) throws Exception { + Map dataMap = new HashMap(); + try { + Global.modifyConfig(key, value); + } catch (Exception e) { + dataMap.put("flag", false); + } + dataMap.put("flag", true); + return dataMap; + } + + + /** + * 提供精确的减法运算。 + * + * @param v1 + * 被减数 + * @param v2 + * 减数 + * @return 两个参数的差 + */ + public static double sub(double v1, double v2) { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.subtract(b2).doubleValue(); + } + + /** + * 提供精确的加法运算。 + * + * @param v1 + * 被加数 + * @param v2 + * 加数 + * @return 两个参数的和 + */ + public static double add(double v1, double v2) { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.add(b2).doubleValue(); + } + + /** + * 提供精确的乘法运算。 + * + * @param v1 + * 被乘数 + * @param v2 + * 乘数 + * @return 两个参数的积 + */ + public static double mul(double v1, double v2) { + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.multiply(b2).doubleValue(); + } + + /** + * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到 小数点以后10位,以后的数字四舍五入。 + * + * @param v1 + * 被除数 + * @param v2 + * 除数 + * @return 两个参数的商 + */ + public static double div(double v1, double v2) { + return div(v1, v2, DEF_DIV_SCALE); + } + + /** + * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。 + * + * @param v1 + * 被除数 + * @param v2 + * 除数 + * @param scale + * 表示表示需要精确到小数点以后几位。 + * @return 两个参数的商 + */ + public static double div(double v1, double v2, int scale) { + if (scale < 0) { + throw new IllegalArgumentException("The scale must be a positive integer or zero"); + } + BigDecimal b1 = new BigDecimal(Double.toString(v1)); + BigDecimal b2 = new BigDecimal(Double.toString(v2)); + return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + + /** + * 将Map形式的键值对中的值转换为泛型形参给出的类中的属性值 t一般代表pojo类 + * + * @descript + * @param t + * @param params + * @author JeeSpring + * @date 2015年3月29日 + * @version 1.0 + */ + public static T flushObject(T t, Map params) { + if (params == null || t == null) { + return t; + } + + Class clazz = t.getClass(); + for (; clazz != Object.class; clazz = clazz.getSuperclass()) { + try { + Field[] fields = clazz.getDeclaredFields(); + + for (int i = 0; i < fields.length; i++) { + String name = fields[i].getName(); // 获取属性的名字 + Object value = params.get(name); + if (value != null && !"".equals(value)) { + // 注意下面这句,不设置true的话,不能修改private类型变量的值 + fields[i].setAccessible(true); + fields[i].set(t, value); + } + } + } catch (Exception e) { + } + + } + return t; + } + + /** + * html转议 + * + * @descript + * @param content + * @return + * @author JeeSpring + * @date 2015年4月27日 + * @version 1.0 + */ + public static String htmltoString(String content) { + if (content == null) { + return ""; + } + String html = content; + html = html.replace("'", "'"); + html = html.replaceAll("&", "&"); + html = html.replace("\"", """); // " + html = html.replace("\t", "  ");// 替换跳格 + html = html.replace(" ", " ");// 替换空格 + html = html.replace("<", "<"); + html = html.replaceAll(">", ">"); + + return html; + } + + /** + * html转议 + * + * @descript + * @param content + * @return + * @author JeeSpring + * @date 2015年4月27日 + * @version 1.0 + */ + public static String stringtohtml(String content) { + if (content == null) { + return ""; + } + String html = content; + html = html.replace("'", "'"); + html = html.replaceAll("&", "&"); + html = html.replace(""", "\""); // " + html = html.replace("  ", "\t");// 替换跳格 + html = html.replace(" ", " ");// 替换空格 + html = html.replace("<", "<"); + html = html.replaceAll(">", ">"); + + return html; + } + + /** + * 是否为整数 + * + * @param str + * @return + */ + public static boolean isNumeric1(String str) { + Pattern pattern = Pattern.compile("[0-9]*"); + return pattern.matcher(str).matches(); + } + + + /** + * 从包package中获取所有的Class + * + * @param pack + * @return + */ + public static Set> getClasses(String pack) { + + // 第一个class类的集合 + Set> classes = new LinkedHashSet>(); + // 是否循环迭代 + boolean recursive = true; + // 获取包的名字 并进行替换 + String packageName = pack; + String packageDirName = packageName.replace('.', '/'); + // 定义一个枚举的集合 并进行循环来处理这个目录下的things + Enumeration dirs; + try { + dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName); + // 循环迭代下去 + while (dirs.hasMoreElements()) { + // 获取下一个元素 + URL url = dirs.nextElement(); + // 得到协议的名称 + String protocol = url.getProtocol(); + // 如果是以文件的形式保存在服务器上 + if ("file".equals(protocol)) { + //System.err.println("file类型的扫描"); + // 获取包的物理路径 + String filePath = URLDecoder.decode(url.getFile(), "UTF-8"); + // 以文件的方式扫描整个包下的文件 并添加到集合中 + findAndAddClassesInPackageByFile(packageName, filePath, recursive, classes); + } else if ("jar".equals(protocol)) { + // 如果是jar包文件 + // 定义一个JarFile + //System.err.println("jar类型的扫描"); + JarFile jar; + try { + // 获取jar + jar = ((JarURLConnection) url.openConnection()).getJarFile(); + // 从此jar包 得到一个枚举类 + Enumeration entries = jar.entries(); + // 同样的进行循环迭代 + while (entries.hasMoreElements()) { + // 获取jar里的一个实体 可以是目录 和一些jar包里的其他文件 如META-INF等文件 + JarEntry entry = entries.nextElement(); + String name = entry.getName(); + // 如果是以/开头的 + if (name.charAt(0) == '/') { + // 获取后面的字符串 + name = name.substring(1); + } + // 如果前半部分和定义的包名相同 + if (name.startsWith(packageDirName)) { + int idx = name.lastIndexOf('/'); + // 如果以"/"结尾 是一个包 + if (idx != -1) { + // 获取包名 把"/"替换成"." + packageName = name.substring(0, idx).replace('/', '.'); + } + // 如果可以迭代下去 并且是一个包 + if ((idx != -1) || recursive) { + // 如果是一个.class文件 而且不是目录 + if (name.endsWith(".class") && !entry.isDirectory()) { + // 去掉后面的".class" 获取真正的类名 + String className = name.substring(packageName.length() + 1, name.length() - 6); + try { + // 添加到classes + classes.add(Class.forName(packageName + '.' + className)); + } catch (ClassNotFoundException e) { + // log + // .error("添加用户自定义视图类错误 找不到此类的.class文件"); + e.printStackTrace(); + } + } + } + } + } + } catch (IOException e) { + // log.error("在扫描用户定义视图时从jar包获取文件出错"); + e.printStackTrace(); + } + } + } + } catch (IOException e) { + e.printStackTrace(); + } + + return classes; + } + + /** + * 以文件的形式来获取包下的所有Class + * + * @param packageName + * @param packagePath + * @param recursive + * @param classes + */ + public static void findAndAddClassesInPackageByFile(String packageName, String packagePath, final boolean recursive, Set> classes) { + // 获取此包的目录 建立一个File + File dir = new File(packagePath); + // 如果不存在或者 也不是目录就直接返回 + if (!dir.exists() || !dir.isDirectory()) { + // log.warn("用户定义包名 " + packageName + " 下没有任何文件"); + return; + } + // 如果存在 就获取包下的所有文件 包括目录 + File[] dirfiles = dir.listFiles(new FileFilter() { + // 自定义过滤规则 如果可以循环(包含子目录) 或则是以.class结尾的文件(编译好的java类文件) + @Override + public boolean accept(File file) { + return (recursive && file.isDirectory()) || (file.getName().endsWith(".class")); + } + }); + // 循环所有文件 + for (File file : dirfiles) { + // 如果是目录 则继续扫描 + if (file.isDirectory()) { + findAndAddClassesInPackageByFile(packageName + "." + file.getName(), file.getAbsolutePath(), recursive, classes); + } else { + // 如果是java类文件 去掉后面的.class 只留下类名 + String className = file.getName().substring(0, file.getName().length() - 6); + try { + // 添加到集合中去 + // classes.add(Class.forName(packageName + '.' + + // className)); + // 经过回复同学的提醒,这里用forName有一些不好,会触发static方法,没有使用classLoader的load干净 + classes.add(Thread.currentThread().getContextClassLoader().loadClass(packageName + '.' + className)); + } catch (ClassNotFoundException e) { + // log.error("添加用户自定义视图类错误 找不到此类的.class文件"); + e.printStackTrace(); + } + } + } + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/utils/SystemInfo.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/utils/SystemInfo.java new file mode 100644 index 0000000..4bd3afa --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/utils/SystemInfo.java @@ -0,0 +1,168 @@ +package com.jeespring.modules.monitor.utils; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.hyperic.sigar.CpuPerc; +import org.hyperic.sigar.FileSystem; +import org.hyperic.sigar.FileSystemUsage; +import org.hyperic.sigar.Mem; +import org.hyperic.sigar.Sigar; +import org.hyperic.sigar.Swap; + +public class SystemInfo { + public static Map SystemProperty() { + Map monitorMap = new HashMap(); + Runtime r = Runtime.getRuntime(); + Properties props = System.getProperties(); + InetAddress addr = null; + String ip = ""; + String hostName = ""; + try { + addr = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + ip = "无法获取主机IP"; + hostName = "无法获取主机名"; + } + if (null != addr) { + try { + ip = addr.getHostAddress(); + } catch (Exception e) { + ip = "无法获取主机IP"; + } + try { + hostName = addr.getHostName(); + } catch (Exception e) { + hostName = "无法获取主机名"; + } + } + monitorMap.put("hostIp", ip);// 本地ip地址 + monitorMap.put("hostName", hostName);// 本地主机名 + monitorMap.put("osName", props.getProperty("os.name"));// 操作系统的名称 + monitorMap.put("arch", props.getProperty("os.arch"));// 操作系统的构架 + monitorMap.put("osVersion", props.getProperty("os.version"));// 操作系统的版本 + monitorMap.put("processors", r.availableProcessors());// JVM可以使用的处理器个数 + monitorMap.put("javaVersion", props.getProperty("java.version"));// Java的运行环境版本 + monitorMap.put("vendor", props.getProperty("java.vendor"));// Java的运行环境供应商 + monitorMap.put("javaUrl", props.getProperty("java.vendor.url"));// Java供应商的URL + monitorMap.put("javaHome", props.getProperty("java.home"));// Java的安装路径 + monitorMap.put("tmpdir", props.getProperty("java.io.tmpdir"));// 默认的临时文件路径 + return monitorMap; + } + + public static Map memory(Sigar sigar) { + Map monitorMap = new HashMap(); + try { + Runtime r = Runtime.getRuntime(); + monitorMap.put("jvmTotal", Common.div(r.totalMemory(), (1024 * 1024), 2) + "M");// java总内存 + monitorMap.put("jvmUse", Common.div(r.totalMemory() - r.freeMemory(), (1024 * 1024), 2) + "M");// JVM使用内存 + monitorMap.put("jvmFree", Common.div(r.freeMemory(), (1024 * 1024), 2) + "M");// JVM剩余内存 + monitorMap.put("jvmUsage", Common.div(r.totalMemory() - r.freeMemory(), r.totalMemory(), 2));// JVM使用率 + + Mem mem = sigar.getMem(); + // 内存总量 + monitorMap.put("ramTotal", Common.div(mem.getTotal(), (1024 * 1024 * 1024), 2) + "G");// 内存总量 + monitorMap.put("ramUse", Common.div(mem.getUsed(), (1024 * 1024 * 1024), 2) + "G");// 当前内存使用量 + monitorMap.put("ramFree", Common.div(mem.getFree(), (1024 * 1024 * 1024), 2) + "G");// 当前内存剩余量 + monitorMap.put("ramUsage", Common.div(mem.getUsed(), mem.getTotal(), 2));// 内存使用率 + + Swap swap = sigar.getSwap(); + // 交换区总量 + monitorMap.put("swapTotal", Common.div(swap.getTotal(), (1024 * 1024 * 1024), 2) + "G"); + // 当前交换区使用量 + monitorMap.put("swapUse", Common.div(swap.getUsed(), (1024 * 1024 * 1024), 2) + "G"); + // 当前交换区剩余量 + monitorMap.put("swapFree", Common.div(swap.getFree(), (1024 * 1024 * 1024), 2) + "G"); + monitorMap.put("swapUsage", Common.div(swap.getUsed(), swap.getTotal(), 2));// + + } catch (Exception e) { + } + return monitorMap; + } + public static Map usage(Sigar sigar) { + Map monitorMap = new HashMap(); + try { + Runtime r = Runtime.getRuntime(); + monitorMap.put("jvmUsage", Math.round(Common.div(r.totalMemory()-r.freeMemory(), r.totalMemory(), 2)*100));// JVM使用率 + + Mem mem = sigar.getMem(); + // 内存总量 + monitorMap.put("ramUsage", Math.round(Common.div(mem.getUsed(), mem.getTotal(), 2)*100));// 内存使用率 + + List cpu = cpuInfos(sigar); + double b = 0.0; + for (Map m : cpu) { + b += Double.valueOf(m.get("cpuTotal")+""); + } + monitorMap.put("cpuUsage", Math.round(b/cpu.size()));// cpu使用率 + } catch (Exception e) { + } + return monitorMap; + } + + public static List cpuInfos(Sigar sigar) { + List monitorMaps = new ArrayList(); + try { + CpuPerc[] cpuList = sigar.getCpuPercList(); + for (CpuPerc cpuPerc : cpuList) { + Map monitorMap = new HashMap(); + monitorMap.put("cpuUserUse", Math.round(cpuPerc.getUser()*100));// 用户使用率 + monitorMap.put("cpuSysUse", Math.round(cpuPerc.getSys()*100));// 系统使用率 + monitorMap.put("cpuWait", Math.round(cpuPerc.getWait()*100));// 当前等待率 + monitorMap.put("cpuFree", Math.round(cpuPerc.getIdle()*100));// 当前空闲率 + monitorMap.put("cpuTotal",Math.round(cpuPerc.getCombined()*100));// 总的使用率 + monitorMaps.add(monitorMap); + } + } catch (Exception e) { + } + return monitorMaps; + } + + public List diskInfos(Sigar sigar) throws Exception { + List monitorMaps = new ArrayList(); + FileSystem[] fslist = sigar.getFileSystemList(); + for (int i = 0; i < fslist.length; i++) { + Map monitorMap = new HashMap(); + FileSystem fs = fslist[i]; + // 文件系统类型名,比如本地硬盘、光驱、网络文件系统等 + FileSystemUsage usage = null; + usage = sigar.getFileSystemUsage(fs.getDirName()); + switch (fs.getType()) { + case 0: // TYPE_UNKNOWN :未知 + break; + case 1: // TYPE_NONE + break; + case 2: // TYPE_LOCAL_DISK : 本地硬盘 + + monitorMap.put("diskName", fs.getDevName());// 系统盘名称 + monitorMap.put("diskType", fs.getSysTypeName());// 盘类型 + // 文件系统总大小 + monitorMap.put("diskTotal", fs.getSysTypeName()); + // 文件系统剩余大小 + monitorMap.put("diskFree", usage.getFree()); + // 文件系统已经使用量 + monitorMap.put("diskUse", usage.getUsed()); + double usePercent = usage.getUsePercent() * 100D; + // 文件系统资源的利用率 + monitorMap.put("diskUsage", usePercent);// 内存使用率 + monitorMaps.add(monitorMap); + break; + case 3:// TYPE_NETWORK :网络 + break; + case 4:// TYPE_RAM_DISK :闪存 + break; + case 5:// TYPE_CDROM :光驱 + break; + case 6:// TYPE_SWAP :页面交换 + break; + } + } + return monitorMaps; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/web/MonitorController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/web/MonitorController.java new file mode 100644 index 0000000..8a122eb --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/monitor/web/MonitorController.java @@ -0,0 +1,116 @@ +package com.jeespring.modules.monitor.web; + + +import java.util.Map; + +import org.hyperic.sigar.Sigar; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.jeespring.common.json.AjaxJson; +import com.jeespring.common.mail.MailSendUtils; +import com.jeespring.common.utils.MyBeanUtils; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.monitor.entity.Monitor; +import com.jeespring.modules.monitor.service.MonitorService; +import com.jeespring.modules.monitor.utils.SystemInfo; +import com.jeespring.modules.sys.entity.SystemConfig; +import com.jeespring.modules.sys.service.SystemConfigService; + + +/** + * 系统监控Controller + * @author liugf + * @version 2016-02-07 + */ +@Controller +@RequestMapping(value = "${adminPath}/monitor") +public class MonitorController extends AbstractBaseController { + @Autowired + private MonitorService monitorService; + @Autowired + private SystemConfigService systemConfigService; + + @ModelAttribute + public Monitor get(@RequestParam(required=false) String id) { + Monitor entity = null; + if (StringUtils.isNotBlank(id)){ + entity = monitorService.get(id); + } + if (entity == null){ + entity = new Monitor(); + } + return entity; + } + + @RequestMapping("info") + public String info(Model model) throws Exception { + Monitor monitor = monitorService.get("1"); + model.addAttribute("cpu", monitor.getCpu()); + model.addAttribute("jvm", monitor.getJvm()); + model.addAttribute("ram", monitor.getRam()); + model.addAttribute("toEmail", monitor.getToEmail()); + return "modules/monitor/info"; + } + + @RequestMapping("monitor") + public String monitor() throws Exception { + return "modules/monitor/monitor"; + } + + @RequestMapping("systemInfo") + public String systemInfo(Model model) throws Exception { + model.addAttribute("systemInfo", SystemInfo.SystemProperty()); + return "modules/monitor/systemInfo"; + } + + @ResponseBody + @RequestMapping("usage") + public Map usage(Model model) throws Exception { + SystemConfig config = systemConfigService.get("1"); + Monitor monitor = monitorService.get("1"); + Map sigar = SystemInfo.usage(new Sigar()); + String content=""; + content += "您预设的cpu使用率警告线是"+monitor.getCpu()+"%, 当前使用率是"+sigar.get("cpuUsage")+"%"; + content += "您预设的jvm使用率警告线是"+monitor.getJvm()+"%, 当前使用率是"+sigar.get("jvmUsage")+"%"; + content += "您预设的ram使用率警告线是"+monitor.getRam()+"%, 当前使用率是"+sigar.get("ramUsage")+"%"; + if(Float.valueOf(sigar.get("cpuUsage").toString()) >= Float.valueOf(monitor.getCpu()) + ||Float.valueOf(sigar.get("jvmUsage").toString()) >= Float.valueOf(monitor.getJvm()) + ||Float.valueOf(sigar.get("ramUsage").toString()) >= Float.valueOf(monitor.getRam())){ + MailSendUtils.sendEmail(config.getSmtp(), config.getPort(), config.getMailName(), config.getMailPassword(), monitor.getToEmail(), "服务器监控预警", content, "0"); + + }; + return sigar; + } + /** + * 修改配置  + * @param request + * @param nodeId + * @return + * @throws Exception + */ + @ResponseBody + @RequestMapping("modifySetting") + public AjaxJson save(Monitor monitor, Model model) { + AjaxJson j = new AjaxJson(); + String message = "保存成功"; + Monitor t = monitorService.get("1"); + try { + monitor.setId("1"); + MyBeanUtils.copyBeanNotNull2Bean(monitor, t); + monitorService.save(t); + } catch (Exception e) { + e.printStackTrace(); + j.setSuccess(false); + message = "保存失败"; + } + j.setMsg(message); + return j; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/dao/FormLeavemDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/dao/FormLeavemDao.java new file mode 100644 index 0000000..391302a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/dao/FormLeavemDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.mvvmoa.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.mvvmoa.entity.FormLeavem; + +/** + * 员工请假DAO接口 + * @author liugf + * @version 2017-07-17 + */ +@Mapper +public interface FormLeavemDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/entity/FormLeavem.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/entity/FormLeavem.java new file mode 100644 index 0000000..10c49b0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/entity/FormLeavem.java @@ -0,0 +1,89 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.mvvmoa.entity; + +import com.jeespring.modules.sys.entity.User; +import javax.validation.constraints.NotNull; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.Area; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; + +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; + +/** + * 员工请假Entity + * @author JeeSpring + * @version 2017-07-17 + */ +public class FormLeavem extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private com.jeespring.modules.sys.entity.User user; // 员工 + private com.jeespring.modules.sys.entity.Office office; // 归属部门 + private com.jeespring.modules.sys.entity.Area area; // 归属区域 + private java.util.Date beginDate; // 请假开始日期 + private java.util.Date endDate; // 请假结束日期 + + public FormLeavem() { + super(); + } + + public FormLeavem(String id){ + super(id); + } + + @NotNull(message="员工不能为空") + @ExcelField(title="员工", fieldType=User.class, value="user.name", align=2, sort=1) + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + @NotNull(message="归属部门不能为空") + @ExcelField(title="归属部门", fieldType=Office.class, value="office.name", align=2, sort=2) + public Office getOffice() { + return office; + } + + public void setOffice(Office office) { + this.office = office; + } + + @ExcelField(title="归属区域", fieldType=Area.class, value="area.name", align=2, sort=3) + public Area getArea() { + return area; + } + + public void setArea(Area area) { + this.area = area; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @NotNull(message="请假开始日期不能为空") + @ExcelField(title="请假开始日期", align=2, sort=4) + public Date getBeginDate() { + return beginDate; + } + + public void setBeginDate(Date beginDate) { + this.beginDate = beginDate; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @NotNull(message="请假结束日期不能为空") + @ExcelField(title="请假结束日期", align=2, sort=5) + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/service/FormLeavemService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/service/FormLeavemService.java new file mode 100644 index 0000000..1881acc --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/service/FormLeavemService.java @@ -0,0 +1,52 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.mvvmoa.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.mvvmoa.entity.FormLeavem; +import com.jeespring.modules.mvvmoa.dao.FormLeavemDao; + +/** + * 员工请假Service + * @author liugf + * @version 2017-07-17 + */ +@Service +@Transactional(readOnly = true) +public class FormLeavemService extends AbstractBaseService { + + @Override + public FormLeavem get(String id) { + return super.get(id); + } + + @Override + public List findList(FormLeavem formLeavem) { + return super.findList(formLeavem); + } + + @Override + public Page findPage(Page page, FormLeavem formLeavem) { + return super.findPage(page, formLeavem); + } + + @Override + @Transactional(readOnly = false) + public void save(FormLeavem formLeavem) { + super.save(formLeavem); + } + + @Override + @Transactional(readOnly = false) + public void delete(FormLeavem formLeavem) { + super.delete(formLeavem); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/web/FormLeavemController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/web/FormLeavemController.java new file mode 100644 index 0000000..b6de95e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/mvvmoa/web/FormLeavemController.java @@ -0,0 +1,212 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.mvvmoa.web; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.mvvmoa.entity.FormLeavem; +import com.jeespring.modules.mvvmoa.service.FormLeavemService; + +/** + * 员工请假Controller + * @author JeeSpring + * @version 2017-07-17 + */ +@Controller +@RequestMapping(value = "${adminPath}/mvvmoa/formLeavem") +public class FormLeavemController extends AbstractBaseController { + + @Autowired + private FormLeavemService formLeavemService; + + @ModelAttribute + public FormLeavem get(@RequestParam(required=false) String id) { + FormLeavem entity = null; + if (StringUtils.isNotBlank(id)){ + entity = formLeavemService.get(id); + } + if (entity == null){ + entity = new FormLeavem(); + } + return entity; + } + + @RequestMapping(value = {"getjson"}) + @ResponseBody + public FormLeavem getjson(@RequestParam(required=false) String id) { + FormLeavem entity = null; + if (StringUtils.isNotBlank(id)){ + entity = formLeavemService.get(id); + } + if (entity == null){ + entity = new FormLeavem(); + } + return entity; + } + + /** + * 请假单列表页面 + */ + //RequiresPermissions("mvvmoa:formLeavem:list") + @RequestMapping(value = {"list", ""}) + public String list(FormLeavem formLeavem, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = formLeavemService.findPage(new Page(request, response), formLeavem); + model.addAttribute("page", page); + return "modules/mvvmoa/formLeavemList"; + } + + @RequestMapping(value = {"listjson"}) + @ResponseBody + public Page listjson(FormLeavem formLeavem, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = formLeavemService.findPage(new Page(request, response), formLeavem); + return page; + } + + /** + * 查看,增加,编辑请假单表单页面 + */ + //RequiresPermissions(value={"mvvmoa:formLeavem:view","mvvmoa:formLeavem:add","mvvmoa:formLeavem:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(FormLeavem formLeavem, Model model) { + model.addAttribute("formLeavem", formLeavem); + return "modules/mvvmoa/formLeavemForm"; + } + + /** + * 保存请假单 + */ + //RequiresPermissions(value={"mvvmoa:formLeavem:add","mvvmoa:formLeavem:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(FormLeavem formLeavem, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, formLeavem)){ + return form(formLeavem, model); + } + formLeavemService.save(formLeavem); + addMessage(redirectAttributes, "保存请假单成功"); + return "redirect:"+Global.getAdminPath()+"/mvvmoa/formLeavem/?repage"; + } + + @RequestMapping(value = "savejson") + @ResponseBody + public String savejson(FormLeavem formLeavem, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, formLeavem)){ + return form(formLeavem, model); + } + formLeavemService.save(formLeavem); + //addMessage(redirectAttributes, "保存请假单成功"); + return "保存请假单成功"; + } + + /** + * 删除请假单 + */ + //RequiresPermissions("mvvmoa:formLeavem:del") + @RequestMapping(value = "delete") + public String delete(FormLeavem formLeavem, RedirectAttributes redirectAttributes) { + formLeavemService.delete(formLeavem); + addMessage(redirectAttributes, "删除请假单成功"); + return "redirect:"+Global.getAdminPath()+"/mvvmoa/formLeavem/?repage"; + } + + @RequestMapping(value = "deletejson") + @ResponseBody + public String deletejson(FormLeavem formLeavem, RedirectAttributes redirectAttributes) { + formLeavemService.delete(formLeavem); + //addMessage(redirectAttributes, "删除请假单成功"); + return "删除请假单成功"; + } + + /** + * 批量删除请假单 + */ + //RequiresPermissions("mvvmoa:formLeavem:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + formLeavemService.delete(formLeavemService.get(id)); + } + addMessage(redirectAttributes, "删除请假单成功"); + return "redirect:"+Global.getAdminPath()+"/mvvmoa/formLeavem/?repage"; + } + + /** + * 导出excel文件 + */ + //RequiresPermissions("mvvmoa:formLeavem:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(FormLeavem formLeavem, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "请假单"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = formLeavemService.findPage(new Page(request, response, -1), formLeavem); + new ExportExcel("请假单", FormLeavem.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出请假单记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/mvvmoa/formLeavem/?repage"; + } + + /** + * 导入Excel数据 + + */ + //RequiresPermissions("mvvmoa:formLeavem:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + try { + int successNum = 0; + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(FormLeavem.class); + for (FormLeavem formLeavem : list){ + formLeavemService.save(formLeavem); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条请假单记录"); + } catch (Exception e) { + addMessage(redirectAttributes, "导入请假单失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/mvvmoa/formLeavem/?repage"; + } + + /** + * 下载导入请假单数据模板 + */ + //RequiresPermissions("mvvmoa:formLeavem:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "请假单数据导入模板.xlsx"; + List list = Lists.newArrayList(); + new ExportExcel("请假单数据", FormLeavem.class, 1).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/mvvmoa/formLeavem/?repage"; + } + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyDao.java new file mode 100644 index 0000000..3a8164b --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyDao.java @@ -0,0 +1,25 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.oa.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.oa.entity.OaNotify; + +/** + * 通知通告DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Mapper +public interface OaNotifyDao extends InterfaceBaseDao { + + /** + * 获取通知数目 + * @param oaNotify + * @return + */ + Long findCount(OaNotify oaNotify); + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyRecordDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyRecordDao.java new file mode 100644 index 0000000..7182103 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/OaNotifyRecordDao.java @@ -0,0 +1,34 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.oa.dao; + +import java.util.List; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.oa.entity.OaNotifyRecord; + +/** + * 通知通告记录DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Mapper +public interface OaNotifyRecordDao extends InterfaceBaseDao { + + /** + * 插入通知记录 + * @param oaNotifyRecordList + * @return + */ + int insertAll(List oaNotifyRecordList); + + /** + * 根据通知ID删除通知记录 + * @param oaNotifyId 通知ID + * @return + */ + int deleteByOaNotifyId(String oaNotifyId); + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/TestAuditDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/TestAuditDao.java new file mode 100644 index 0000000..aad486b --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/dao/TestAuditDao.java @@ -0,0 +1,29 @@ +/** + * Copyright © 2012-2016 JeeSpring All rights reserved. + */ +package com.jeespring.modules.oa.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.common.persistence.annotation.MyBatisDao; +import com.jeespring.modules.oa.entity.TestAudit; +import org.apache.ibatis.annotations.Mapper; + +/** + * 审批DAO接口 + * @author thinkgem + * @version 2014-05-16 + */ +@Mapper +public interface TestAuditDao extends InterfaceBaseDao { + + public TestAudit getByProcInsId(String procInsId); + + public int updateInsId(TestAudit testAudit); + + public int updateHrText(TestAudit testAudit); + + public int updateLeadText(TestAudit testAudit); + + public int updateMainLeadText(TestAudit testAudit); + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotify.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotify.java new file mode 100644 index 0000000..5b5e7f2 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotify.java @@ -0,0 +1,170 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.oa.entity; + +import java.util.List; +import org.hibernate.validator.constraints.Length; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.Collections3; +import com.jeespring.common.utils.IdGen; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.modules.sys.entity.User; + +/** + * 通知通告Entity + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +public class OaNotify extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String type; // 类型 + private String title; // 标题 + private String content; // 类型 + private String files; // 附件 + private String status; // 状态 + + private String readNum; // 已读 + private String unReadNum; // 未读 + + private boolean isSelf; // 是否只查询自己的通知 + + private String readFlag; // 本人阅读状态 + + private List oaNotifyRecordList = Lists.newArrayList(); + + public OaNotify() { + super(); + } + + public OaNotify(String id){ + super(id); + } + + @Length(min=0, max=200, message="标题长度必须介于 0 和 200 之间") + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Length(min=0, max=1, message="类型长度必须介于 0 和 1 之间") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Length(min=0, max=1, message="状态长度必须介于 0 和 1 之间") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + @Length(min=0, max=2000, message="附件长度必须介于 0 和 2000 之间") + public String getFiles() { + return files; + } + + public void setFiles(String files) { + this.files = files; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getReadNum() { + return readNum; + } + + public void setReadNum(String readNum) { + this.readNum = readNum; + } + + public String getUnReadNum() { + return unReadNum; + } + + public void setUnReadNum(String unReadNum) { + this.unReadNum = unReadNum; + } + + public List getOaNotifyRecordList() { + return oaNotifyRecordList; + } + + public void setOaNotifyRecordList(List oaNotifyRecordList) { + this.oaNotifyRecordList = oaNotifyRecordList; + } + + /** + * 获取通知发送记录用户ID + * @return + */ + public String getOaNotifyRecordIds() { + return Collections3.extractToString(oaNotifyRecordList, "user.id", ",") ; + } + + /** + * 设置通知发送记录用户ID + * @return + */ + public void setOaNotifyRecordIds(String oaNotifyRecord) { + this.oaNotifyRecordList = Lists.newArrayList(); + for (String id : StringUtils.split(oaNotifyRecord, ",")){ + OaNotifyRecord entity = new OaNotifyRecord(); + entity.setId(IdGen.uuid()); + entity.setOaNotify(this); + entity.setUser(new User(id)); + entity.setReadFlag("0"); + this.oaNotifyRecordList.add(entity); + } + } + + /** + * 获取通知发送记录用户Name + * @return + */ + public String getOaNotifyRecordNames() { + return Collections3.extractToString(oaNotifyRecordList, "user.name", ",") ; + } + + /** + * 设置通知发送记录用户Name + * @return + */ + public void setOaNotifyRecordNames(String oaNotifyRecord) { + // 什么也不做 + } + + public boolean isSelf() { + return isSelf; + } + + public void setSelf(boolean isSelf) { + this.isSelf = isSelf; + } + + public String getReadFlag() { + return readFlag; + } + + public void setReadFlag(String readFlag) { + this.readFlag = readFlag; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotifyRecord.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotifyRecord.java new file mode 100644 index 0000000..39380e2 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/OaNotifyRecord.java @@ -0,0 +1,73 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.oa.entity; + +import org.hibernate.validator.constraints.Length; + +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.modules.sys.entity.User; + +import java.util.Date; + + +/** + * 通知通告记录Entity + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +public class OaNotifyRecord extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private OaNotify oaNotify; // 通知通告ID + private User user; // 接受人 + private String readFlag; // 阅读标记(0:未读;1:已读) + private Date readDate; // 阅读时间 + + + public OaNotifyRecord() { + super(); + } + + public OaNotifyRecord(String id){ + super(id); + } + + public OaNotifyRecord(OaNotify oaNotify){ + this.oaNotify = oaNotify; + } + + public OaNotify getOaNotify() { + return oaNotify; + } + + public void setOaNotify(OaNotify oaNotify) { + this.oaNotify = oaNotify; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + @Length(min=0, max=1, message="阅读标记(0:未读;1:已读)长度必须介于 0 和 1 之间") + public String getReadFlag() { + return readFlag; + } + + public void setReadFlag(String readFlag) { + this.readFlag = readFlag; + } + + public Date getReadDate() { + return readDate; + } + + public void setReadDate(Date readDate) { + this.readDate = readDate; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/TestAudit.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/TestAudit.java new file mode 100644 index 0000000..8a805c9 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/entity/TestAudit.java @@ -0,0 +1,182 @@ +/** + * Copyright © 2012-2016 JeeSpring All rights reserved. + */ +package com.jeespring.modules.oa.entity; + +import com.jeespring.common.persistence.ActEntity; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.User; + +/** + * 审批Entity + * @author thinkgem + * @version 2014-05-16 + */ +public class TestAudit extends ActEntity { + + private static final long serialVersionUID = 1L; + private User user; // 归属用户 + private Office office; // 归属部门 + private String post; // 岗位 + private String age; // 性别 + private String edu; // 学历 + private String content; // 调整原因 + private String olda; // 现行标准 薪酬档级 + private String oldb; // 现行标准 月工资额 + private String oldc; // 现行标准 年薪总额 + private String newa; // 调整后标准 薪酬档级 + private String newb; // 调整后标准 月工资额 + private String newc; // 调整后标准 年薪总额 + private String addNum; // 月增资 + private String exeDate; // 执行时间 + private String hrText; // 人力资源部门意见 + private String leadText; // 分管领导意见 + private String mainLeadText;// 集团主要领导意见 + + public TestAudit() { + super(); + } + + public TestAudit(String id){ + super(id); + } + + public String getPost() { + return post; + } + + public void setPost(String post) { + this.post = post; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getEdu() { + return edu; + } + + public void setEdu(String edu) { + this.edu = edu; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getOlda() { + return olda; + } + + public void setOlda(String olda) { + this.olda = olda; + } + + public String getOldb() { + return oldb; + } + + public void setOldb(String oldb) { + this.oldb = oldb; + } + + public String getOldc() { + return oldc; + } + + public void setOldc(String oldc) { + this.oldc = oldc; + } + + public String getNewa() { + return newa; + } + + public void setNewa(String newa) { + this.newa = newa; + } + + public String getNewb() { + return newb; + } + + public void setNewb(String newb) { + this.newb = newb; + } + + public String getNewc() { + return newc; + } + + public void setNewc(String newc) { + this.newc = newc; + } + + public String getExeDate() { + return exeDate; + } + + public void setExeDate(String exeDate) { + this.exeDate = exeDate; + } + + public String getHrText() { + return hrText; + } + + public void setHrText(String hrText) { + this.hrText = hrText; + } + + public String getLeadText() { + return leadText; + } + + public void setLeadText(String leadText) { + this.leadText = leadText; + } + + public String getMainLeadText() { + return mainLeadText; + } + + public void setMainLeadText(String mainLeadText) { + this.mainLeadText = mainLeadText; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Office getOffice() { + return office; + } + + public void setOffice(Office office) { + this.office = office; + } + + public String getAddNum() { + return addNum; + } + + public void setAddNum(String addNum) { + this.addNum = addNum; + } + +} + + diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/OaNotifyService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/OaNotifyService.java new file mode 100644 index 0000000..b0c5600 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/OaNotifyService.java @@ -0,0 +1,85 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.oa.service; + +import java.util.Date; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.oa.dao.OaNotifyDao; +import com.jeespring.modules.oa.dao.OaNotifyRecordDao; +import com.jeespring.modules.oa.entity.OaNotify; +import com.jeespring.modules.oa.entity.OaNotifyRecord; + +/** + * 通知通告Service + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Service +@Transactional(readOnly = true) +public class OaNotifyService extends AbstractBaseService { + + @Autowired + private OaNotifyRecordDao oaNotifyRecordDao; + + @Override + public OaNotify get(String id) { + OaNotify entity = dao.get(id); + return entity; + } + + /** + * 获取通知发送记录 + * @param oaNotify + * @return + */ + public OaNotify getRecordList(OaNotify oaNotify) { + oaNotify.setOaNotifyRecordList(oaNotifyRecordDao.findList(new OaNotifyRecord(oaNotify))); + return oaNotify; + } + + public Page find(Page page, OaNotify oaNotify) { + oaNotify.setPage(page); + page.setList(dao.findList(oaNotify)); + return page; + } + + /** + * 获取通知数目 + * @param oaNotify + * @return + */ + public Long findCount(OaNotify oaNotify) { + return dao.findCount(oaNotify); + } + + @Override + @Transactional(readOnly = false) + public void save(OaNotify oaNotify) { + super.save(oaNotify); + + // 更新发送接受人记录 + oaNotifyRecordDao.deleteByOaNotifyId(oaNotify.getId()); + if (oaNotify.getOaNotifyRecordList().size() > 0){ + oaNotifyRecordDao.insertAll(oaNotify.getOaNotifyRecordList()); + } + } + + /** + * 更新阅读状态 + */ + @Transactional(readOnly = false) + public void updateReadFlag(OaNotify oaNotify) { + OaNotifyRecord oaNotifyRecord = new OaNotifyRecord(oaNotify); + oaNotifyRecord.setUser(oaNotifyRecord.getCurrentUser()); + oaNotifyRecord.setReadDate(new Date()); + oaNotifyRecord.setReadFlag("1"); + oaNotifyRecordDao.update(oaNotifyRecord); + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/TestAuditService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/TestAuditService.java new file mode 100644 index 0000000..ee29786 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/service/TestAuditService.java @@ -0,0 +1,126 @@ +/** + * Copyright © 2012-2016 JeeSpring All rights reserved. + */ +package com.jeespring.modules.oa.service; + +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.google.common.collect.Maps; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.act.service.ActTaskService; +import com.jeespring.modules.act.utils.ActUtils; +import com.jeespring.modules.oa.entity.TestAudit; +import com.jeespring.modules.oa.dao.TestAuditDao; + +/** + * 审批Service + * @author thinkgem + * @version 2014-05-16 + */ +@Service +@Transactional(readOnly = true) +public class TestAuditService extends AbstractBaseService { + + @Autowired + private ActTaskService actTaskService; + + public TestAudit getByProcInsId(String procInsId) { + return dao.getByProcInsId(procInsId); + } + + @Override + public Page findPage(Page page, TestAudit testAudit) { + testAudit.setPage(page); + page.setList(dao.findList(testAudit)); + return page; + } + + /** + * 审核新增或编辑 + * @param testAudit + */ + @Override + @Transactional(readOnly = false) + public void save(TestAudit testAudit) { + + // 申请发起 + if (StringUtils.isBlank(testAudit.getId())){ + testAudit.preInsert(); + dao.insert(testAudit); + + // 启动流程 + actTaskService.startProcess(ActUtils.PD_TEST_AUDIT[0], ActUtils.PD_TEST_AUDIT[1], testAudit.getId(), testAudit.getContent()); + + } + + // 重新编辑申请 + else{ + testAudit.preUpdate(); + dao.update(testAudit); + + testAudit.getAct().setComment(("yes".equals(testAudit.getAct().getFlag())?"[重申] ":"[销毁] ")+testAudit.getAct().getComment()); + + // 完成流程任务 + Map vars = Maps.newHashMap(); + vars.put("pass", "yes".equals(testAudit.getAct().getFlag())? "1" : "0"); + actTaskService.complete(testAudit.getAct().getTaskId(), testAudit.getAct().getProcInsId(), testAudit.getAct().getComment(), testAudit.getContent(), vars); + } + } + + /** + * 审核审批保存 + * @param testAudit + */ + @Transactional(readOnly = false) + public void auditSave(TestAudit testAudit) { + + // 设置意见 + testAudit.getAct().setComment(("yes".equals(testAudit.getAct().getFlag())?"[同意] ":"[驳回] ")+testAudit.getAct().getComment()); + + testAudit.preUpdate(); + + // 对不同环节的业务逻辑进行操作 + String taskDefKey = testAudit.getAct().getTaskDefKey(); + + // 审核环节 + if ("audit".equals(taskDefKey)){ + + } + else if ("audit2".equals(taskDefKey)){ + testAudit.setHrText(testAudit.getAct().getComment()); + dao.updateHrText(testAudit); + } + else if ("audit3".equals(taskDefKey)){ + testAudit.setLeadText(testAudit.getAct().getComment()); + dao.updateLeadText(testAudit); + } + else if ("audit4".equals(taskDefKey)){ + testAudit.setMainLeadText(testAudit.getAct().getComment()); + dao.updateMainLeadText(testAudit); + } + else if ("apply_end".equals(taskDefKey)){ + + } + + // 未知环节,直接返回 + else{ + return; + } + + // 提交流程任务 + Map vars = Maps.newHashMap(); + vars.put("pass", "yes".equals(testAudit.getAct().getFlag())? "1" : "0"); + actTaskService.complete(testAudit.getAct().getTaskId(), testAudit.getAct().getProcInsId(), testAudit.getAct().getComment(), vars); + +// vars.put("var_test", "yes_no_test2"); +// actTaskService.getProcessEngine().getTaskService().addComment(testAudit.getAct().getTaskId(), testAudit.getAct().getProcInsId(), testAudit.getAct().getComment()); +// actTaskService.jumpTask(testAudit.getAct().getProcInsId(), testAudit.getAct().getTaskId(), "audit2", vars); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/OaNotifyController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/OaNotifyController.java new file mode 100644 index 0000000..eef7c04 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/OaNotifyController.java @@ -0,0 +1,212 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.oa.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.oa.entity.OaNotify; +import com.jeespring.modules.oa.service.OaNotifyService; + + +/** + * 通知通告Controller + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Controller +@RequestMapping(value = "${adminPath}/oa/oaNotify") +public class OaNotifyController extends AbstractBaseController { + + @Autowired + private OaNotifyService oaNotifyService; + + @ModelAttribute + public OaNotify get(@RequestParam(required=false) String id) { + OaNotify entity = null; + if (StringUtils.isNotBlank(id)){ + entity = oaNotifyService.get(id); + } + if (entity == null){ + entity = new OaNotify(); + } + return entity; + } + + @RequiresPermissions("oa:oaNotify:list") + @RequestMapping(value = {"list", ""}) + public String list(OaNotify oaNotify, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception { + Page page=new Page(); + page = oaNotifyService.find(new Page(request, response), oaNotify); + model.addAttribute("page", page); + return "modules/oa/oaNotifyList"; + } + + /** + * 查看,增加,编辑报告表单页面 + */ + @RequiresPermissions(value={"oa:oaNotify:view","oa:oaNotify:add","oa:oaNotify:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(OaNotify oaNotify, Model model,HttpServletRequest request, HttpServletResponse response) { + model.addAttribute("action", request.getParameter("action")); + if (StringUtils.isNotBlank(oaNotify.getId())){ + oaNotify = oaNotifyService.getRecordList(oaNotify); + } + model.addAttribute("oaNotify", oaNotify); + return "modules/oa/oaNotifyForm"; + } + + @RequiresPermissions(value={"oa:oaNotify:add","oa:oaNotify:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(OaNotify oaNotify, Model model,HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, oaNotify)){ + return form(oaNotify, model,request,response); + } + // 如果是修改,则状态为已发布,则不能再进行操作 + if (StringUtils.isNotBlank(oaNotify.getId())){ + OaNotify e = oaNotifyService.get(oaNotify.getId()); + if ("1".equals(e.getStatus())){ + addMessage(redirectAttributes, "已发布,不能操作!"); + return "redirect:" + adminPath + "/oa/oaNotify/?repage"; + } + } + + + oaNotifyService.save(oaNotify); + + addMessage(redirectAttributes, "保存通知'" + oaNotify.getTitle() + "'成功"); + return "redirect:" + adminPath + "/oa/oaNotify/?repage"; + } + + @RequiresPermissions("oa:oaNotify:del") + @RequestMapping(value = "delete") + public String delete(OaNotify oaNotify, RedirectAttributes redirectAttributes) { + + + oaNotifyService.delete(oaNotify); + + addMessage(redirectAttributes, "删除通知成功"); + return "redirect:" + adminPath + "/oa/oaNotify/?repage"; + } + + @RequiresPermissions("oa:oaNotify:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + + + String[] idArray = ids.split(","); + long successCount=0,failureCount=0; + String failureMsg=""; + + + for(String id : idArray){ + OaNotify oaNotify=oaNotifyService.get(id); + if(oaNotify==null){ + failureCount++; + failureMsg+="id:"+id+",查询数据为空;"; + continue; + } + + oaNotifyService.delete(oaNotifyService.get(id)); + + successCount++; + } + + addMessage(redirectAttributes, "删除通知成功条数:"+successCount+",删除通知失败条数:"+failureCount+",失败信息:"+failureMsg+""); + return "redirect:" + adminPath + "/oa/oaNotify/?repage"; + } + + /** + * 我的通知列表 + * @throws Exception + */ + @RequestMapping(value = "self") + public String selfList(OaNotify oaNotify, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception { + oaNotify.setSelf(true); + Page page=new Page(); + + page = oaNotifyService.find(new Page(request, response), oaNotify); + + + model.addAttribute("page", page); + return "modules/oa/oaNotifyList"; + } + + /** + * 我的通知列表-数据 + */ + @RequiresPermissions("oa:oaNotify:view") + @RequestMapping(value = "selfData") + @ResponseBody + public Page listData(OaNotify oaNotify, HttpServletRequest request, HttpServletResponse response, Model model) { + oaNotify.setSelf(true); + Page page = oaNotifyService.find(new Page(request, response), oaNotify); + return page; + } + + /** + * 查看我的通知,重定向在当前页面打开 + */ + @RequestMapping(value = "view") + public String view(OaNotify oaNotify, Model model) { + if (StringUtils.isNotBlank(oaNotify.getId())){ + oaNotifyService.updateReadFlag(oaNotify); + oaNotify = oaNotifyService.getRecordList(oaNotify); + model.addAttribute("oaNotify", oaNotify); + return "modules/oa/oaNotifyForm"; + } + return "redirect:" + adminPath + "/oa/oaNotify/self?repage"; + } + + /** + * 查看我的通知-数据 + */ + @RequestMapping(value = "viewData") + @ResponseBody + public OaNotify viewData(OaNotify oaNotify, Model model) { + if (StringUtils.isNotBlank(oaNotify.getId())){ + oaNotifyService.updateReadFlag(oaNotify); + return oaNotify; + } + return null; + } + + /** + * 查看我的通知-发送记录 + */ + @RequestMapping(value = "viewRecordData") + @ResponseBody + public OaNotify viewRecordData(OaNotify oaNotify, Model model) { + if (StringUtils.isNotBlank(oaNotify.getId())){ + oaNotify = oaNotifyService.getRecordList(oaNotify); + return oaNotify; + } + return null; + } + + /** + * 获取我的通知数目 + */ + @RequestMapping(value = "self/count") + @ResponseBody + public String selfCount(OaNotify oaNotify, Model model) { + oaNotify.setSelf(true); + oaNotify.setReadFlag("0"); + return String.valueOf(oaNotifyService.findCount(oaNotify)); + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/TestAuditController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/TestAuditController.java new file mode 100644 index 0000000..68f7941 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oa/web/TestAuditController.java @@ -0,0 +1,169 @@ +/** + * Copyright © 2012-2016 JeeSpring All rights reserved. + */ +package com.jeespring.modules.oa.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.utils.UserUtils; +import com.jeespring.modules.oa.entity.TestAudit; +import com.jeespring.modules.oa.service.TestAuditService; + +/** + * 审批Controller + * @author thinkgem + * @version 2014-05-16 + */ +@Controller +@RequestMapping(value = "${adminPath}/oa/testAudit") +public class TestAuditController extends AbstractBaseController { + + @Autowired + private TestAuditService testAuditService; + + @ModelAttribute + public TestAudit get(@RequestParam(required=false) String id){//, +// @RequestParam(value="act.procInsId", required=false) String procInsId) { + TestAudit testAudit = null; + if (StringUtils.isNotBlank(id)){ + testAudit = testAuditService.get(id); +// }else if (StringUtils.isNotBlank(procInsId)){ +// testAudit = testAuditService.getByProcInsId(procInsId); + } + if (testAudit == null){ + testAudit = new TestAudit(); + } + return testAudit; + } + + @RequiresPermissions("oa:testAudit:view") + @RequestMapping(value = {"list", ""}) + public String list(TestAudit testAudit, HttpServletRequest request, HttpServletResponse response, Model model) { + User user = UserUtils.getUser(); + if (!user.isAdmin()){ + testAudit.setCreateBy(user); + } + Page page = testAuditService.findPage(new Page(request, response), testAudit); + model.addAttribute("page", page); + return "modules/oa/testAuditList"; + } + + /** + * 申请单填写 + * @param testAudit + * @param model + * @return + */ + @RequiresPermissions("oa:testAudit:view") + @RequestMapping(value = "form") + public String form(TestAudit testAudit, Model model) { + + String view = "testAuditForm"; + + // 查看审批申请单 + if (StringUtils.isNotBlank(testAudit.getId())){//.getAct().getProcInsId())){ + + // 环节编号 + String taskDefKey = testAudit.getAct().getTaskDefKey(); + + // 查看工单 + if(testAudit.getAct().isFinishTask()){ + view = "testAuditView"; + } + // 修改环节 + else if ("modify".equals(taskDefKey)){ + view = "testAuditForm"; + } + // 审核环节 + else if ("audit".equals(taskDefKey)){ + view = "testAuditAudit"; +// String formKey = "/oa/testAudit"; +// return "redirect:" + ActUtils.getFormUrl(formKey, testAudit.getAct()); + } + // 审核环节2 + else if ("audit2".equals(taskDefKey)){ + view = "testAuditAudit"; + } + // 审核环节3 + else if ("audit3".equals(taskDefKey)){ + view = "testAuditAudit"; + } + // 审核环节4 + else if ("audit4".equals(taskDefKey)){ + view = "testAuditAudit"; + } + // 兑现环节 + else if ("apply_end".equals(taskDefKey)){ + view = "testAuditAudit"; + } + } + + model.addAttribute("testAudit", testAudit); + return "modules/oa/" + view; + } + + /** + * 申请单保存/修改 + * @param testAudit + * @param model + * @param redirectAttributes + * @return + */ + @RequiresPermissions("oa:testAudit:edit") + @RequestMapping(value = "save") + public String save(TestAudit testAudit, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, testAudit)){ + return form(testAudit, model); + } + testAuditService.save(testAudit); + addMessage(redirectAttributes, "提交审批'" + testAudit.getUser().getName() + "'成功"); + return "redirect:" + adminPath + "/act/task/todo/"; + } + + /** + * 工单执行(完成任务) + * @param testAudit + * @param model + * @return + */ + @RequiresPermissions("oa:testAudit:edit") + @RequestMapping(value = "saveAudit") + public String saveAudit(TestAudit testAudit, Model model) { + if (StringUtils.isBlank(testAudit.getAct().getFlag()) + || StringUtils.isBlank(testAudit.getAct().getComment())){ + addMessage(model, "请填写审核意见。"); + return form(testAudit, model); + } + testAuditService.auditSave(testAudit); + return "redirect:" + adminPath + "/act/task/todo/"; + } + + /** + * 删除工单 + * @param id + * @param redirectAttributes + * @return + */ + @RequiresPermissions("oa:testAudit:edit") + @RequestMapping(value = "delete") + public String delete(TestAudit testAudit, RedirectAttributes redirectAttributes) { + testAuditService.delete(testAudit); + addMessage(redirectAttributes, "删除审批成功"); + return "redirect:" + adminPath + "/oa/testAudit/?repage"; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/entity/TokenInfo.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/entity/TokenInfo.java new file mode 100644 index 0000000..98cab8f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/entity/TokenInfo.java @@ -0,0 +1,62 @@ +package com.jeespring.modules.oauth.entity; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.io.Serializable; +import java.util.Date; + +public class TokenInfo implements Serializable { + private static final long serialVersionUID = 1L; + private String token; + private Date tokenDate; + private String oauthId; + private String oauthSecret; + private String ip; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + public Date getTokenDate() { + return tokenDate; + } + + public void setTokenDate(Date tokenDate) { + this.tokenDate = tokenDate; + } + + @JsonIgnore + @JSONField(serialize=false) + public String getOauthId() { + return oauthId; + } + + public void setOauthId(String oauthId) { + this.oauthId = oauthId; + } + + @JsonIgnore + @JSONField(serialize=false) + public String getOauthSecret() { + return oauthSecret; + } + + public void setOauthSecret(String oauthSecret) { + this.oauthSecret = oauthSecret; + } + + @JsonIgnore + @JSONField(serialize=false) + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/rest/oauthRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/rest/oauthRestController.java new file mode 100644 index 0000000..84d74be --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/rest/oauthRestController.java @@ -0,0 +1,111 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.oauth.rest; + +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import com.jeespring.modules.oauth.service.OauthService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 系统配置Controller + * @author 黄炳桂 516821420@qq.com + * @version 2017-11-17 + */ +@RestController +@RequestMapping(value = "/rest/oauth") +@Api(value="Oauth平台授权接口(分布式)", description="Oauth平台授权接口(分布式)") +public class oauthRestController extends AbstractBaseController { + + @Autowired + private OauthService oauthService; + + @RequestMapping(value = {"test"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="token test平台授权测试接口(Content-Type为text/html)", notes="token test平台授权测试接口(Content-Type为text/html)") + public Result test() { + return ResultFactory.getSuccessResult("测试成功!"); + } + + @RequestMapping(value = {"token"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="token平台授权接口(Content-Type为text/html)", notes="token平台授权接口(Content-Type为text/html)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "oauthId", value = "客户id", required = false, dataType = "String", paramType = "query"), + @ApiImplicitParam(name = "oauthSecret", value = "客户密钥", required = false, dataType = "String", paramType = "query") + }) + public Result tokenRequestParam(@RequestParam(required=false) String oauthId, @RequestParam(required=false) String oauthSecret, HttpServletRequest request, HttpServletResponse response) { + return oauthService.token(oauthId,oauthSecret,request.getRemoteAddr()); + } + + @RequestMapping(value = {"token/json"},method ={RequestMethod.POST}) + @ApiOperation(value="系统配置信息(Content-Type为application/json)", notes="系统配置信息(Content-Type为application/json)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "oauthId", value = "客户id", required = false, dataType = "String", paramType = "body"), + @ApiImplicitParam(name = "oauthSecret", value = "客户密钥", required = false, dataType = "String", paramType = "body") + }) + public Result tokenJsonRequestBody(@RequestBody String oauthId,@RequestBody String oauthSecret, HttpServletRequest request, HttpServletResponse response) { + return oauthService.token(oauthId,oauthSecret,request.getRemoteAddr()); + } + + @RequestMapping(value = {"checkToken"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="checkToken平台Token检查接口(Content-Type为text/html)", notes="checkToken平台Token检查接口(Content-Type为text/html)") + @ApiImplicitParam(name = "token", value = "token", required = false, dataType = "String", paramType = "query") + public Result checkTokenRequestParam(@RequestParam(required=false) String token, HttpServletRequest request, HttpServletResponse response){ + return oauthService.checkToken(token,request.getRemoteAddr()); + } + + @RequestMapping(value = {"checkToken/json"},method ={RequestMethod.POST}) + @ApiOperation(value="checkToken平台Token检查接口(Content-Type为application/json)", notes="checkToken平台Token检查接口(Content-Type为application/json)") + @ApiImplicitParam(name = "token", value = "token", required = false, dataType = "String", paramType = "body") + public Result checkTokenRequestBody(@RequestBody(required=false) String token, HttpServletRequest request, HttpServletResponse response){ + return oauthService.checkToken(token,request.getRemoteAddr()); + } + + @RequestMapping(value = {"faild"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="授权平台接口失败(Content-Type为application/html)", notes="授权平台接口失败(Content-Type为application/html)") + public Result faild( HttpServletRequest request, HttpServletResponse response){ + return ResultFactory.getErrorResult("oauth token授权失败!"); + } + @RequestMapping(value = {"apiTimeLimiFaild"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="授权平台调用次数失败(Content-Type为application/html)", notes="授权平台调用次数失败(Content-Type为application/html)") + public Result apiTimeLimiFaild( HttpServletRequest request, HttpServletResponse response){ + String apiTimeLimi=request.getParameter("apiTimeLimi"); + if(apiTimeLimi==null) { + apiTimeLimi = ""; + } + return ResultFactory.getErrorResult("调用失败,接口允许最多调用"+apiTimeLimi+"次数!15分钟后解锁!"); + } + @RequestMapping(value = {"userOnlineAmountFaild"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="在线用户数量已满失败(Content-Type为application/html)", notes="在线用户数量已满失败(Content-Type为application/html)") + public Result userOnlineAmountFaild( HttpServletRequest request, HttpServletResponse response){ + return oauthService.userOnlineAmount(); + } + + @RequestMapping(value = {"userOnlineAmount"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="在线用户数量(Content-Type为application/html)", notes="在线用户数量(Content-Type为application/html)") + public Result userOnlineAmount( HttpServletRequest request, HttpServletResponse response){ + return oauthService.userOnlineAmount(); + } + + @RequestMapping(value = {"getApiTimeLimi"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="授权平台调用次数(Content-Type为application/html)", notes="授权平台调用次数(Content-Type为application/html)") + public Result getApiTimeLimi( HttpServletRequest request, HttpServletResponse response){ + return oauthService.getApiTimeLimi(request.getRemoteAddr()); + } + + @RequestMapping(value = {"getApiTime"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="调用次数(Content-Type为application/html)", notes="调用次数(Content-Type为application/html)") + public Result getApiTime( HttpServletRequest request, HttpServletResponse response){ + return oauthService.getApiTime(); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/service/OauthService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/service/OauthService.java new file mode 100644 index 0000000..24abb29 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/oauth/service/OauthService.java @@ -0,0 +1,243 @@ +package com.jeespring.modules.oauth.service; + +import com.jeespring.common.redis.RedisUtils; +import com.jeespring.common.utils.IdGen; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import com.jeespring.modules.sys.dao.UserDao; +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.oauth.entity.TokenInfo; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SysConfigService; +import io.swagger.models.auth.In; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.Date; +import java.util.List; +import java.util.concurrent.TimeUnit; + +@Service +public class OauthService { + + @Autowired + private UserDao userDao; + @Autowired + private SysConfigService sysConfigService; + @Autowired + private RedisUtils redisUtils; + + public boolean isOauthOpen(){ + SysConfig sysConfigOauth=new SysConfig(); + sysConfigOauth.setType("oauthOpen"); + SysConfig sysConfigsOauth=sysConfigService.findListFirstCache(sysConfigOauth); + if("true".equals(sysConfigsOauth.getValue())) { + return true; + } + return false; + } + + public Result token( String oauthId, String oauthSecret,String ip){ + if(oauthId==null || oauthSecret==null) { + return ResultFactory.getErrorResult("授权ID和授权密钥不能为空!"); + } + + String tokenTime="360000"; + String tokenRedis= String.valueOf(redisUtils.get(oauthId)); + if(tokenRedis!=null){ + TokenInfo tokenInfoRedis=(TokenInfo)redisUtils.get(tokenRedis); + redisUtils.remove(oauthId); + redisUtils.remove(tokenInfoRedis.getToken()); + redisUtils.remove(ip); + redisUtils.set(tokenInfoRedis.getToken(),tokenInfoRedis,Long.valueOf(tokenTime)); + redisUtils.set(oauthId,tokenInfoRedis.getToken(),Long.valueOf(tokenTime)); + redisUtils.set(ip,tokenInfoRedis.getToken(),Long.valueOf(tokenTime)); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(tokenInfoRedis); + return result; + } + + SysConfig sysConfigTokenTime=new SysConfig(); + sysConfigTokenTime.setType("tokenTime"); + List sysConfigsTokenTimes=sysConfigService.findList(sysConfigTokenTime); + if(sysConfigsTokenTimes.size()>0){ + tokenTime=sysConfigsTokenTimes.get(0).getValue(); + } + + User user=new User(); + user.setOauthId(oauthId); + user.setOauthSecret(oauthSecret); + List users=userDao.findList(user); + + SysConfig sysConfigOauthId=new SysConfig(); + sysConfigOauthId.setType("oauthId"); + List sysConfigsOauthId=sysConfigService.findList(sysConfigOauthId); + SysConfig sysConfigOauthSecret=new SysConfig(); + sysConfigOauthSecret.setType("oauthSecret"); + List sysConfigsOauthSecret=sysConfigService.findList(sysConfigOauthSecret); + + if( sysConfigsOauthId.size()>0 && sysConfigsOauthSecret.size()>0 && (!sysConfigsOauthId.get(0).getValue().equals(oauthId) || !sysConfigsOauthSecret.get(0).getValue().equals(oauthSecret))){ + return ResultFactory.getErrorResult("授权ID和授权密钥不正确!"); + } + if( sysConfigsOauthId.size()==0 &&sysConfigsOauthSecret.size()==0 && users.size()!=1){ + return ResultFactory.getErrorResult("授权ID和授权密钥不正确!"); + } + Result result = ResultFactory.getSuccessResult(); + TokenInfo tokenInfo=new TokenInfo(); + tokenInfo.setToken(IdGen.uuid()); + tokenInfo.setTokenDate(new Date()); + tokenInfo.setOauthId(oauthId); + tokenInfo.setOauthSecret(oauthSecret); + tokenInfo.setIp(ip); + result.setResultObject(tokenInfo); + redisUtils.set(tokenInfo.getToken(),tokenInfo,Long.valueOf(tokenTime)); + redisUtils.set(oauthId,tokenInfo.getToken(),Long.valueOf(tokenTime)); + redisUtils.set(ip,tokenInfo.getToken(),Long.valueOf(tokenTime)); + return result; + } + + public Result checkToken(String token,String ip){ + String tokenRedis=String.valueOf(redisUtils.get(ip)); + if(token==null && tokenRedis==null){ + return ResultFactory.getErrorResult("token不能为空!"); + } + if(token==null && tokenRedis!=null){ + TokenInfo tokenInfoRedis=(TokenInfo)redisUtils.get(tokenRedis); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(tokenInfoRedis); + return result; + } + SysConfig sysConfigOauth=new SysConfig(); + sysConfigOauth.setType("oauthOpen"); + List sysConfigsOauth=sysConfigService.findList(sysConfigOauth); + if(sysConfigsOauth.size()<=0){ + Result result = ResultFactory.getErrorResult("oauth权限服务未开启!"); + result.setResultCode(100); + return result; + } + if(sysConfigsOauth.get(0).getValue()=="false"){ + Result result = ResultFactory.getErrorResult("oauth权限服务未开启!"); + result.setResultCode(100); + return result; + } + + TokenInfo tokenInfo=(TokenInfo)redisUtils.get(token); + if(tokenInfo==null){ + return ResultFactory.getErrorResult("Token不正确!"); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(tokenInfo); + return result; + } + + public Result userOnlineAmount(){ + SysConfig userOnlineAmount=new SysConfig(); + userOnlineAmount.setType("userOnlineAmount"); + userOnlineAmount=sysConfigService.findListFirstCache(userOnlineAmount); + int countShiro=redisUtils.getCountShiro(); + Subject subject = SecurityUtils.getSubject(); + String key=null; + if (subject != null && subject.getSession() != null) { + key = redisUtils.SHIRO_REDIS + ":" + subject.getSession().getId().toString(); + } + if(Integer.valueOf(userOnlineAmount.getValue()) apiTimeLimis=sysConfigService.findList(apiTimeLimi); + if(apiTimeLimis.size()>0){ + apiTimeLongSysConfig=Long.valueOf(apiTimeLimis.get(0).getValue()); + } + if("-1".equals(apiTimeLongSysConfig)){ + apiTimeLongSysConfig=100000000L; + } + if(apiTimeLimis.size()==0){ + apiTimeLongSysConfig=10000L; + } + if(apiTime!=null && apiTimeLongSysConfig>apiTimeLong){ + redisUtils.remove(redisKey); + } + if(apiTimeLongSysConfig<=apiTimeLong){ + Result result=ResultFactory.getErrorResult("调用失败,接口允许最多调用"+apiTimeLongSysConfig+"次!"); + result.setResultObject(apiTimeLongSysConfig); + return result; + } + redisUtils.set(redisKey,apiTimeLong); + return ResultFactory.getSuccessResult(); + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/other/package-info.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/other/package-info.java new file mode 100644 index 0000000..752d20f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/other/package-info.java @@ -0,0 +1,6 @@ +/**其他的模型都在在这个包下面 + * Created by zhao.weiwei + * create on 2017/1/14 22:03 + * the email is zhao.weiwei@jyall.com. + */ +package com.jeespring.modules.other; \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/pay/pay.txt b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/pay/pay.txt new file mode 100644 index 0000000..e69de29 diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringScheduledTaskService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringScheduledTaskService.java new file mode 100644 index 0000000..86203c4 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringScheduledTaskService.java @@ -0,0 +1,45 @@ +package com.jeespring.modules.scheduling; + +import com.jeespring.common.utils.SendMailUtil; +//import org.apache.activemq.command.ActiveMQQueue; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +//import javax.jms.Destination; +import java.text.SimpleDateFormat; +import java.util.Date; + +//@Service("jeeSpringScheduledTaskService") +@Component +public class JeeSpringScheduledTaskService { + + //@Autowired + //private XXXService xxxxService; + + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + //@Autowired + //private JeeSpringProducer jeeSpringProducer; + + //每个10s执行一次任务 + @Scheduled(fixedRate = 600000) + public void run(){ + //xxxxService.method(); + //System.out.println(dateFormat.format(new Date()) + " | " + "com.jeespring.modules.scheduling:每隔60s执行一次任务"); + } + //每个2s执行一次任务#朝九晚七工作时间内每五分钟 + @Scheduled(cron = "0 0/10 9-19 * * ?") + public void run2(){ + //System.out.println(dateFormat.format(new Date()) + " | " + "com.jeespring.modules.scheduling:朝九晚七工作时间内每十分钟执行一次任务"); + //jeeSpringProducer.sendMessageA( "ActiveMQ JeeSpringProducer queueA。"); + //jeeSpringProducer.sendMessageB("ActiveMQ JeeSpringProducer queueB。"); + } + + //每天15点29分执行该任务 + @Scheduled(cron = "0 29 15 ? * *") + public void run3() + { + //System.out.println(dateFormat.format(new Date()) + " | " + "com.jeespring.modules.scheduling:每天在指定时间执行任务"); + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringTaskSchedulerConfig.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringTaskSchedulerConfig.java new file mode 100644 index 0000000..aa6d81d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/scheduling/JeeSpringTaskSchedulerConfig.java @@ -0,0 +1,12 @@ +package com.jeespring.modules.scheduling; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; + +@Configuration +@ComponentScan("com.jeespring.modules.scheduling") +@EnableScheduling +public class JeeSpringTaskSchedulerConfig { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/dao/SysServerDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/dao/SysServerDao.java new file mode 100644 index 0000000..1c1b566 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/dao/SysServerDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.server.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.server.entity.SysServer; + +/** + * 服务器监控DAO接口 + * @author JeeSpring + * @version 2018-08-20 + */ +@Mapper +public interface SysServerDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/entity/SysServer.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/entity/SysServer.java new file mode 100644 index 0000000..b55f9af --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/entity/SysServer.java @@ -0,0 +1,202 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.server.entity; + +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotNull; +import java.util.Date; + +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; +import com.jeespring.modules.sys.utils.DictUtils; + +/** + * 服务器监控Entity + * @author JeeSpring + * @version 2018-08-20 + */ +public class SysServer extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String serverNumber; // 服务器编号 + private String serverAddress; // 服务器监控地址 + private String name; // 名称 + private String label; // 标签名 + private String picture; // 图片 + private String type; // 类型 + private String typeLabel; // 类型Label + private String typePicture; // 类型Picture + private Long sort; // 排序(升序) + private String description; // 描述 + private String html; // 备注信息 + private String status; // 在线状态on_line在线off_line离线 + private String statusLabel; // 在线状态on_line在线off_line离线Label + private String statusPicture; // 在线状态on_line在线off_line离线Picture + private java.util.Date beginCreateDate; // 开始 创建时间 + private java.util.Date endCreateDate; // 结束 创建时间 + private java.util.Date beginUpdateDate; // 开始 更新时间 + private java.util.Date endUpdateDate; // 结束 更新时间 + + public SysServer() { + super(); + } + + public SysServer(String id){ + super(id); + } + + @Length(min=0, max=255, message="服务器编号长度必须介于 0 和 255 之间") + @ExcelField(title="服务器编号", align=2, sort=1) + public String getServerNumber() { + return serverNumber; + } + + public void setServerNumber(String serverNumber) { + this.serverNumber = serverNumber; + } + + + @Length(min=0, max=100, message="服务器监控地址长度必须介于 0 和 100 之间") + @ExcelField(title="服务器监控地址", align=2, sort=2) + public String getServerAddress() { + return serverAddress; + } + + public void setServerAddress(String serverAddress) { + this.serverAddress = serverAddress; + } + + + @Length(min=0, max=255, message="名称长度必须介于 0 和 255 之间") + @ExcelField(title="名称", align=2, sort=3) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Length(min=0, max=50, message="标签名长度必须介于 0 和 50 之间") + @ExcelField(title="标签名", align=2, sort=4) + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + + @Length(min=0, max=100, message="图片长度必须介于 0 和 100 之间") + @ExcelField(title="图片", align=2, sort=5) + public String getPicture() { + return picture; + } + + public void setPicture(String picture) { + this.picture = picture; + } + + + @Length(min=0, max=50, message="类型长度必须介于 0 和 50 之间") + @ExcelField(title="类型", dictType="server_type", align=2, sort=6) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + + public String getTypeLabel() { + return DictUtils.getDictLabel(type,"server_type",""); + } + public String getTypePicture() { + return DictUtils.getDictPicture(type,"server_type",""); + } + @NotNull(message="排序(升序)不能为空") + @ExcelField(title="排序(升序)", align=2, sort=7) + public Long getSort() { + return sort; + } + + public void setSort(Long sort) { + this.sort = sort; + } + + + @Length(min=0, max=100, message="描述长度必须介于 0 和 100 之间") + @ExcelField(title="描述", align=2, sort=8) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + @ExcelField(title="备注信息", align=2, sort=10) + public String getHtml() { + return html; + } + + public void setHtml(String html) { + this.html = html; + } + + + @Length(min=0, max=10, message="在线状态on_line在线off_line离线长度必须介于 0 和 10 之间") + @ExcelField(title="在线状态on_line在线off_line离线", dictType="on_line_status", align=2, sort=11) + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + public String getStatusLabel() { + return DictUtils.getDictLabel(status,"on_line_status",""); + } + public String getStatusPicture() { + return DictUtils.getDictPicture(status,"on_line_status",""); + } + public Date getBeginCreateDate() { + return beginCreateDate; + } + + public void setBeginCreateDate(Date beginCreateDate) { + this.beginCreateDate = beginCreateDate; + } + + public Date getEndCreateDate() { + return endCreateDate; + } + + public void setEndCreateDate(Date endCreateDate) { + this.endCreateDate = endCreateDate; + } + + public Date getBeginUpdateDate() { + return beginUpdateDate; + } + + public void setBeginUpdateDate(Date beginUpdateDate) { + this.beginUpdateDate = beginUpdateDate; + } + + public Date getEndUpdateDate() { + return endUpdateDate; + } + + public void setEndUpdateDate(Date endUpdateDate) { + this.endUpdateDate = endUpdateDate; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/rest/SysServerRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/rest/SysServerRestController.java new file mode 100644 index 0000000..d0a689c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/rest/SysServerRestController.java @@ -0,0 +1,297 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.server.rest; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.server.service.ISysServerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.server.entity.SysServer; +import com.jeespring.modules.server.service.SysServerService; +import org.springframework.web.bind.annotation.RestController; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +/** + * 服务器监控Controller + * @author JeeSpring + * @version 2018-08-20 + */ +@RestController +@RequestMapping(value = "/rest/sys/sysServer") +@Api(value="服务器监控接口", description="服务器监控接口") +public class SysServerRestController extends AbstractBaseController { + + @Autowired + private ISysServerService sysServerService; + + @RequestMapping(value = {"run"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="服务器运行状态(Content-Type为text/html)", notes="服务器运行状态(Content-Type为text/html)") + public String run() { + return "OK"; + } + + /** + * 服务器监控信息 + */ + @RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="服务器监控信息(Content-Type为text/html)", notes="服务器监控信息(Content-Type为text/html)") + @ApiImplicitParam(name = "id", value = "服务器监控id", required = false, dataType = "String",paramType="query") + public Result getRequestParam(@RequestParam(required=false) String id) { + return get(id); + } + + @RequestMapping(value = {"get/json"},method ={RequestMethod.POST}) + @ApiOperation(value="服务器监控信息(Content-Type为application/json)", notes="服务器监控信息(Content-Type为application/json)") + @ApiImplicitParam(name = "id", value = "服务器监控id", required = false, dataType = "String",paramType="body") + public Result getRequestBody(@RequestBody(required=false) String id) { + return get(id); + } + + private Result get(String id) { + SysServer entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysServerService.getCache(id); + //entity = sysServerService.get(id); + } + if (entity == null){ + entity = new SysServer(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(entity); + return result; + } + + /** + * 服务器监控列表(不包含页信息) + */ + //RequiresPermissions("sys:sysServer:findList") + @RequestMapping(value = {"findList"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="服务器监控列表(不包含页信息)(Content-Type为text/html)", notes="服务器监控列表(不包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="query") + public Result findListRequestParam(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + return findList( sysServer,model); + } + + @RequestMapping(value = {"findList/json"},method ={RequestMethod.POST}) + @ApiOperation(value="服务器监控列表(不包含页信息)(Content-Type为application/json)", notes="服务器监控列表(不包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="body") + public Result findListRequestBody(@RequestBody SysServer sysServer, Model model) { + return findList( sysServer,model); + } + + private Result findList(SysServer sysServer, Model model) { + List list = sysServerService.findListCache(sysServer); + //List list = sysServerService.findList(sysServer); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(list); + return result; + } + + /** + * 服务器监控列表(包含页信息) + */ + //RequiresPermissions("sys:sysServer:list") + @RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="服务器监控列表(包含页信息)(Content-Type为text/html)", notes="服务器监控列表(包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="query") + public Result listRequestParam(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + return list(sysServer,model); + } + + @RequestMapping(value = {"list/json"},method ={RequestMethod.POST}) + @ApiOperation(value="服务器监控列表(包含页信息)(Content-Type为application/json)", notes="服务器监控列表(包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="body") + public Result listRequestBody(@RequestBody SysServer sysServer, Model model) { + return list(sysServer,model); + } + + private Result list(SysServer sysServer, Model model) { + Page page = sysServerService.findPageCache(new Page(sysServer.getPageNo(),sysServer.getPageSize(),sysServer.getOrderBy()), sysServer); + //Page page = sysServerService.findPage(new Page(sysServer.getPageNo(),sysServer.getPageSize(),sysServer.getOrderBy()), sysServer); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + /** + * 服务器监控获取列表第一条记录 + */ + //RequiresPermissions("sys:sysServer:listFrist") + @RequestMapping(value = {"listFrist"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="服务器监控获取列表第一条记录(Content-Type为text/html)", notes="服务器监控获取列表第一条记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="query") + public Result listFristRequestParam(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + return listFrist(sysServer,model); + } + + @RequestMapping(value = {"listFrist/json"},method ={RequestMethod.POST}) + @ApiOperation(value="服务器监控获取列表第一条记录(Content-Type为application/json)", notes="服务器监控获取列表第一条记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="body") + public Result listFristRequestBody(@RequestBody SysServer sysServer, Model model) { + return listFrist(sysServer,model); + } + + private Result listFrist(SysServer sysServer, Model model) { + Page page = sysServerService.findPageCache(new Page(sysServer.getPageNo(),sysServer.getPageSize(),sysServer.getOrderBy()), sysServer); + //Page page = sysServerService.findPage(new Page(sysServer.getPageNo(),sysServer.getPageSize(),sysServer.getOrderBy()), sysServer); + Result result = ResultFactory.getSuccessResult(); + if(page.getList().size()>0){ + result.setResultObject(page.getList().get(0)); + }else{ + result=ResultFactory.getErrorResult("没有记录!"); + } + return result; + } + + /** + * 保存服务器监控 + */ + //RequiresPermissions(value={"sys:sysServer:add","sys:sysServer:edit"},logical=Logical.OR) + @RequestMapping(value = "save",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="保存服务器监控(Content-Type为text/html)", notes="保存服务器监控(Content-Type为text/html)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="query") + public Result saveRequestParam(SysServer sysServer, Model model, RedirectAttributes redirectAttributes) { + return save(sysServer,model,redirectAttributes); + } + + @RequestMapping(value = "save/json",method ={RequestMethod.POST}) + @ApiOperation(value="保存服务器监控(Content-Type为application/json)", notes="保存服务器监控(Content-Type为application/json)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="body") + public Result saveRequestBody(@RequestBody SysServer sysServer, Model model, RedirectAttributes redirectAttributes) { + return save(sysServer,model,redirectAttributes); + } + + private Result save(SysServer sysServer, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysServer)){ + Result result = ResultFactory.getErrorResult("数据验证失败"); + } + sysServerService.save(sysServer); + Result result = ResultFactory.getSuccessResult("保存服务器监控成功"); + return result; + } + + /** + * 删除服务器监控 + */ + //RequiresPermissions("sys:sysServer:del") + @RequestMapping(value = "delete",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="删除服务器监控(Content-Type为text/html)", notes="删除服务器监控(Content-Type为text/html)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="query") + public Result deleteRequestParam(SysServer sysServer, RedirectAttributes redirectAttributes) { + return delete(sysServer,redirectAttributes); + } + + @RequestMapping(value = "delete/json",method ={RequestMethod.POST}) + @ApiOperation(value="删除服务器监控(Content-Type为application/json)", notes="删除服务器监控(Content-Type为application/json)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="body") + public Result deleteRequestBody(@RequestBody SysServer sysServer, RedirectAttributes redirectAttributes) { + return delete(sysServer,redirectAttributes); + } + + private Result delete(SysServer sysServer, RedirectAttributes redirectAttributes) { + sysServerService.delete(sysServer); + Result result = ResultFactory.getSuccessResult("删除服务器监控成功"); + return result; + } + + /** + * 删除服务器监控(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑删除服务器监控(Content-Type为text/html)", notes="逻辑删除服务器监控(Content-Type为text/html)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="query") + public Result deleteByLogicRequestParam(SysServer sysServer, RedirectAttributes redirectAttributes) { + return deleteByLogic(sysServer,redirectAttributes); + } + + /** + * 删除服务器监控(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑删除服务器监控(Content-Type为application/json)", notes="逻辑删除服务器监控(Content-Type为application/json)") + @ApiImplicitParam(name = "sysServer", value = "服务器监控", dataType = "SysServer",paramType="body") + public Result deleteByLogicRequestBody(@RequestBody SysServer sysServer, RedirectAttributes redirectAttributes) { + return deleteByLogic(sysServer,redirectAttributes); + } + + private Result deleteByLogic(SysServer sysServer, RedirectAttributes redirectAttributes) { + sysServerService.deleteByLogic(sysServer); + Result result = ResultFactory.getSuccessResult("删除服务器监控成功"); + return result; + } + + /** + * 批量删除服务器监控 + */ + //RequiresPermissions("sys:sysServer:del") + @RequestMapping(value = "deleteAll",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="批量删除服务器监控(Content-Type为text/html)", notes="批量删除服务器监控(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "服务器监控ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllRequestParam(String ids, RedirectAttributes redirectAttributes) { + return deleteAll(ids,redirectAttributes); + } + + @RequestMapping(value = "deleteAll/json",method ={RequestMethod.POST}) + @ApiOperation(value="批量删除服务器监控(Content-Type为application/json)", notes="批量删除服务器监控(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "服务器监控ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) { + return deleteAll(ids,redirectAttributes); + } + + private Result deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysServerService.delete(sysServerService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除服务器监控成功"); + return result; + } + + /** + * 批量删除服务器监控(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑批量删除服务器监控(Content-Type为text/html)", notes="逻辑批量删除服务器监控(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "服务器监控ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllByLogicRequestParam(String ids, RedirectAttributes redirectAttributes) { + return deleteAllByLogic(ids,redirectAttributes); + } + + /** + * 批量删除服务器监控(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑批量删除服务器监控(Content-Type为application/json)", notes="逻辑批量删除服务器监控(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "服务器监控ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllByLogicRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) { + return deleteAllByLogic(ids,redirectAttributes); + } + + private Result deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysServerService.deleteByLogic(sysServerService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除服务器监控成功"); + return result; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/service/ISysServerService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/service/ISysServerService.java new file mode 100644 index 0000000..50975f5 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/service/ISysServerService.java @@ -0,0 +1,8 @@ +package com.jeespring.modules.server.service; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.common.persistence.InterfaceBaseService; +import com.jeespring.modules.server.entity.SysServer; + +public interface ISysServerService extends InterfaceBaseService { +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/service/SysServerService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/service/SysServerService.java new file mode 100644 index 0000000..a8c432f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/service/SysServerService.java @@ -0,0 +1,191 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.server.service; + +import java.util.List; + +//import org.springframework.stereotype.Service; +import org.apache.ibatis.annotations.Param; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.server.entity.SysServer; +import com.jeespring.modules.server.dao.SysServerDao; +import com.alibaba.fastjson.JSON; +import com.jeespring.common.redis.RedisUtils; +import com.alibaba.dubbo.config.annotation.Service; + +/** + * 服务器监控Service + * @author JeeSpring + * @version 2018-08-20 + */ + +//启用dubbo服务器时,要去掉下面注解 +//com.alibaba.dubbo.config.annotation.Service(interfaceClass = ISysServerService.class,version = "1.0.0", timeout = 60000) +@org.springframework.stereotype.Service +@Transactional(readOnly = true) +public class SysServerService extends AbstractBaseService implements ISysServerService{ + + /** + * redis caches + */ + @Autowired + private RedisUtils redisUtils; + + @Override + public SysServer get(String id) { + //获取数据库数据 + SysServer sysServer=super.get(id); + return sysServer; + } + + @Override + public SysServer getCache(String id) { + //获取缓存数据 + SysServer sysServer=(SysServer)redisUtils.get(RedisUtils.getIdKey(SysServerService.class.getName(),id)); + if( sysServer!=null) { + return sysServer; + } + //获取数据库数据 + sysServer=super.get(id); + //设置缓存数据 + redisUtils.set(RedisUtils.getIdKey(SysServerService.class.getName(),id),sysServer); + return sysServer; + } + + @Override + public List total(SysServer sysServer) { + //获取数据库数据 + List sysServerList=super.total(sysServer); + return sysServerList; + } + + @Override + public List totalCache(SysServer sysServer) { + //获取缓存数据 + String totalKey = RedisUtils.getTotalKey(SysServerService.class.getName(),JSON.toJSONString(sysServer)); + List sysServerList=(List)redisUtils.get(totalKey); + if(sysServerList!=null) { + return sysServerList; + } + //获取数据库数据 + sysServerList=super.total(sysServer); + //设置缓存数据 + redisUtils.set(totalKey,sysServerList); + return sysServerList; + } + + @Override + public List findList(SysServer sysServer) { + //获取数据库数据 + List sysServerList=super.findList(sysServer); + //设置缓存数据 + return sysServerList; + } + + @Override + public List findListCache(SysServer sysServer) { + //获取缓存数据 + String findListKey = RedisUtils.getFindListKey(SysServerService.class.getName(),JSON.toJSONString(sysServer)); + List sysServerList=(List)redisUtils.get(findListKey); + if(sysServerList!=null) { + return sysServerList; + } + //获取数据库数据 + sysServerList=super.findList(sysServer); + //设置缓存数据 + redisUtils.set(findListKey,sysServerList); + return sysServerList; + } + + public SysServer findListFirst(SysServer sysServer) {; + //获取数据库数据 + List sysServerList=super.findList(sysServer); + if(sysServerList.size()>0) { + sysServer = sysServerList.get(0); + } + return sysServer; + } + + public SysServer findListFirstCache(SysServer sysServer) { + //获取缓存数据 + String findListFirstKey = RedisUtils.getFindListFirstKey(SysServerService.class.getName(),JSON.toJSONString(sysServer)); + SysServer sysServerRedis=(SysServer)redisUtils.get(findListFirstKey); + if(sysServerRedis!=null) { + return sysServerRedis; + } + //获取数据库数据 + List sysServerList=super.findList(sysServer); + if(sysServerList.size()>0) { + sysServer = sysServerList.get(0); + } else { + sysServer = new SysServer(); + } + //设置缓存数据 + redisUtils.set(findListFirstKey,sysServer); + return sysServer; + } + + @Override + public Page findPage(Page page, SysServer sysServer) { + //获取数据库数据 + Page pageReuslt=super.findPage(page, sysServer); + return pageReuslt; + } + + @Override + public Page findPageCache(Page page, SysServer sysServer) { + //获取缓存数据 + String findPageKey = RedisUtils.getFindPageKey(SysServerService.class.getName(),JSON.toJSONString(page)+JSON.toJSONString(sysServer)); + Page pageReuslt=(Page)redisUtils.get(findPageKey); + if(pageReuslt!=null) { + return pageReuslt; + } + //获取数据库数据 + pageReuslt=super.findPage(page, sysServer); + //设置缓存数据 + redisUtils.set(findPageKey,pageReuslt); + return pageReuslt; + } + + @Override + @Transactional(readOnly = false) + public void save(SysServer sysServer) { + //保存数据库记录 + super.save(sysServer); + //设置清除缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysServerService.class.getName(),sysServer.getId())); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysServerService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysServerService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void delete(SysServer sysServer) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysServerService.class.getName(),sysServer.getId())); + //删除数据库记录 + super.delete(sysServer); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysServerService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysServerService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void deleteByLogic(SysServer sysServer) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysServerService.class.getName(),sysServer.getId())); + //逻辑删除数据库记录 + super.deleteByLogic(sysServer); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysServerService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysServerService.class.getName())); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/web/SysServerController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/web/SysServerController.java new file mode 100644 index 0000000..49a8824 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/server/web/SysServerController.java @@ -0,0 +1,315 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.server.web; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.server.service.ISysServerService; +import com.jeespring.modules.sys.service.SysConfigService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.server.entity.SysServer; +import com.jeespring.modules.server.service.SysServerService; +import com.alibaba.dubbo.config.annotation.Reference; +/** + * 服务器监控Controller + * @author JeeSpring + * @version 2018-08-20 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/sysServer") +public class SysServerController extends AbstractBaseController { + + //调用dubbo服务器是,要去掉下面注解 + //@Reference(version = "1.0.0") + @Autowired + private ISysServerService sysServerService; + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute + public SysServer get(@RequestParam(required=false) String id) { + SysServer entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysServerService.getCache(id); + //entity = sysServerService.get(id); + } + if (entity == null){ + entity = new SysServer(); + } + return entity; + } + + /** + * 服务器监控统计页面 + */ + @RequiresPermissions("sys:sysServer:total") + @RequestMapping(value = {"total"}) + public String totalView(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + total(sysServer,request,response,model); + return "modules/sys/sysServerTotal"; + } + private void total(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + if(StringUtils.isEmpty(sysServer.getTotalType())){ + sysServer.setTotalType("%Y-%m-%d"); + } + //X轴的数据 + List xAxisData= new ArrayList(); + //Y轴的数据 + Map> yAxisData = new HashMap>(); + List countList = new ArrayList(); + List sumList = new ArrayList(); + if(sysServer.getOrderBy()==""){ + sysServer.setOrderBy("totalDate"); + } + List list = sysServerService.totalCache(sysServer); + //List list = sysServerService.total(sysServer); + model.addAttribute("list", list); + for(SysServer sysServerItem:list){ + //x轴数据 + xAxisData.add( sysServerItem.getTotalDate()); + countList.add(Double.valueOf(sysServerItem.getTotalCount())); + } + yAxisData.put("数量", countList); + request.setAttribute("xAxisData", xAxisData); + request.setAttribute("yAxisData", yAxisData); + model.addAttribute("sumTotalCount", list.stream().mapToInt(SysServer::getTotalCount).sum()); + + //饼图数据 + Map orientData= new HashMap(); + for(SysServer sysServerItem:list){ + orientData.put(sysServerItem.getTotalDate(), sysServerItem.getTotalCount()); + } + model.addAttribute("orientData", orientData); + } + @RequiresPermissions("sys:sysServer:total") + @RequestMapping(value = {"totalMap"}) + public String totalMap(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + if(StringUtils.isEmpty(sysServer.getTotalType())){ + sysServer.setTotalType("%Y-%m-%d"); + } + List list = sysServerService.totalCache(sysServer); + //List list = sysServerService.total(sysServer); + model.addAttribute("sumTotalCount", list.stream().mapToInt(SysServer::getTotalCount).sum()); + model.addAttribute("list", list); + return "modules/sys/sysServerTotalMap"; + } + + /** + * 服务器监控列表页面 + */ + @RequiresPermissions("sys:sysServer:list") + @RequestMapping(value = {"list", ""}) + public String list(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysServerService.findPageCache(new Page(request, response), sysServer); + //Page page = sysServerService.findPage(new Page(request, response), sysServer); + model.addAttribute("page", page); + sysServer.setOrderBy("totalDate"); + total(sysServer,request,response,model); + return "modules/sys/sysServerList"; + } + + /** + * 服务器监控列表页面 + */ + @RequiresPermissions("sys:sysServer:list") + @RequestMapping(value = {"listVue"}) + public String listVue(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysServerService.findPageCache(new Page(request, response), sysServer); + //Page page = sysServerService.findPage(new Page(request, response), sysServer); + model.addAttribute("page", page); + return "modules/sys/sysServerListVue"; + } + + /** + * 服务器监控列表页面 + */ + //RequiresPermissions("sys:sysServer:select") + @RequestMapping(value = {"select"}) + public String select(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysServerService.findPageCache(new Page(request, response), sysServer); + //Page page = sysServerService.findPage(new Page(request, response), sysServer); + model.addAttribute("page", page); + return "modules/sys/sysServerSelect"; + } + + /** + * 查看,增加,编辑服务器监控表单页面 + */ + @RequiresPermissions(value={"sys:sysServer:view","sys:sysServer:add","sys:sysServer:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(SysServer sysServer, Model model, HttpServletRequest request, HttpServletResponse response) { + model.addAttribute("action", request.getParameter("action")); + model.addAttribute("sysServer", sysServer); + if(request.getParameter("ViewFormType")!=null && "FormTwo".equals(request.getParameter("ViewFormType"))) { + return "modules/sys/sysServerFormTwo"; + } + return "modules/sys/sysServerForm"; + } + + /** + * 保存服务器监控 + */ + @RequiresPermissions(value={"sys:sysServer:add","sys:sysServer:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(SysServer sysServer, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysServer/?repage"; + } + if (!beanValidator(model, sysServer)){ + return form(sysServer, model,request,response); + } + sysServerService.save(sysServer); + addMessage(redirectAttributes, "保存服务器监控成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysServer/?repage"; + } + + /** + * 删除服务器监控 + */ + @RequiresPermissions("sys:sysServer:del") + @RequestMapping(value = "delete") + public String delete(SysServer sysServer, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysServer/?repage"; + } + sysServerService.delete(sysServer); + addMessage(redirectAttributes, "删除服务器监控成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysServer/?repage"; + } + + /** + * 删除服务器监控(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequiresPermissions(value={"sys:sysServer:del","sys:sysServer:delByLogic"},logical=Logical.OR) + @RequestMapping(value = "deleteByLogic") + public String deleteByLogic(SysServer sysServer, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysServer/?repage"; + } + sysServerService.deleteByLogic(sysServer); + addMessage(redirectAttributes, "逻辑删除服务器监控成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysServer/?repage"; + } + + /** + * 批量删除服务器监控 + */ + @RequiresPermissions("sys:sysServer:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysServer/?repage"; + } + String[] idArray = ids.split(","); + for(String id : idArray){ + sysServerService.delete(sysServerService.get(id)); + } + addMessage(redirectAttributes, "删除服务器监控成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysServer/?repage"; + } + + /** + * 批量删除服务器监控(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequiresPermissions(value={"sys:sysServer:del","sys:sysServer:delByLogic"},logical=Logical.OR) + @RequestMapping(value = "deleteAllByLogic") + public String deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysServer/?repage"; + } + String[] idArray = ids.split(","); + for(String id : idArray){ + sysServerService.deleteByLogic(sysServerService.get(id)); + } + addMessage(redirectAttributes, "删除服务器监控成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysServer/?repage"; + } + + /** + * 导出excel文件 + */ + @RequiresPermissions("sys:sysServer:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(SysServer sysServer, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "服务器监控"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = sysServerService.findPage(new Page(request, response, -1), sysServer); + new ExportExcel("服务器监控", SysServer.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出服务器监控记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysServer/?repage"; + } + + /** + * 导入Excel数据 + + */ + @RequiresPermissions("sys:sysServer:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + try { + int successNum = 0; + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(SysServer.class); + for (SysServer sysServer : list){ + sysServerService.save(sysServer); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条服务器监控记录"); + } catch (Exception e) { + addMessage(redirectAttributes, "导入服务器监控失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysServer/?repage"; + } + + /** + * 下载导入服务器监控数据模板 + */ + @RequiresPermissions("sys:sysServer:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "服务器监控数据导入模板.xlsx"; + List list = Lists.newArrayList(); + new ExportExcel("服务器监控数据", SysServer.class, 1).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysServer/?repage"; + } + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/shopping/shopping.txt b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/shopping/shopping.txt new file mode 100644 index 0000000..e69de29 diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/AreaDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/AreaDao.java new file mode 100644 index 0000000..24fa5ce --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/AreaDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import com.jeespring.common.persistence.TreeDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.sys.entity.Area; + +/** + * 区域DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Mapper +public interface AreaDao extends TreeDao { + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/DictDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/DictDao.java new file mode 100644 index 0000000..8ae558d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/DictDao.java @@ -0,0 +1,22 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import java.util.List; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.sys.entity.Dict; + +/** + * 字典DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Mapper +public interface DictDao extends InterfaceBaseDao { + + List findTypeList(Dict dict); + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/LogDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/LogDao.java new file mode 100644 index 0000000..0427a6f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/LogDao.java @@ -0,0 +1,20 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import org.apache.ibatis.annotations.Mapper; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.modules.sys.entity.Log; + +/** + * 日志DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Mapper +public interface LogDao extends InterfaceBaseDao { + + void empty(); +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/MenuDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/MenuDao.java new file mode 100644 index 0000000..613d25e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/MenuDao.java @@ -0,0 +1,28 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import java.util.List; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.modules.sys.entity.Menu; +import org.apache.ibatis.annotations.Mapper; + +/** + * 菜单DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Mapper +public interface MenuDao extends InterfaceBaseDao { + + List findByParentIdsLike(Menu menu); + + List findByUserId(Menu menu); + + int updateParentIds(Menu menu); + + int updateSort(Menu menu); + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OfficeDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OfficeDao.java new file mode 100644 index 0000000..8453d89 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OfficeDao.java @@ -0,0 +1,19 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import com.jeespring.common.persistence.TreeDao; +import com.jeespring.modules.sys.entity.Office; +import org.apache.ibatis.annotations.Mapper; + +/** + * 机构DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Mapper +public interface OfficeDao extends TreeDao { + + Office getByCode(String code); +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OnlineSessionDAO.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OnlineSessionDAO.java new file mode 100644 index 0000000..3ebf070 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OnlineSessionDAO.java @@ -0,0 +1,89 @@ +package com.jeespring.modules.sys.dao; + +import com.jeespring.modules.monitor.entity.OnlineSession; +import com.jeespring.modules.sys.entity.SysUserOnline; +import com.jeespring.modules.sys.service.SysUserOnlineService; +import org.apache.shiro.session.Session; +import org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Repository; +import org.springframework.stereotype.Service; + +import java.io.Serializable; +import java.util.Date; + +/** + * 针对自定义的ShiroSession的db操作 + * + * @author JeeSpring + */ +@Service +public class OnlineSessionDAO extends EnterpriseCacheSessionDAO +{ + /** + * 同步session到数据库的周期 单位为毫秒(默认1分钟) + */ + @Value("${shiro.session.dbSyncPeriod}") + private int dbSyncPeriod=1; + + /** + * 上次同步数据库的时间戳 + */ + private static final String LAST_SYNC_DB_TIMESTAMP = OnlineSessionDAO.class.getName() + "LAST_SYNC_DB_TIMESTAMP"; + + @Autowired + private SysUserOnlineService sysUserOnlineService; + + @Autowired + private OnlineSessionFactory onlineSessionFactory; + + public OnlineSessionDAO() + { + super(); + } + + public OnlineSessionDAO(long expireTime) + { + super(); + } + + /** + * 根据会话ID获取会话 + * + * @param sessionId 会话ID + * @return ShiroSession + */ + @Override + protected Session doReadSession(Serializable sessionId) + { + SysUserOnline sysUserOnline=new SysUserOnline(); + if(sysUserOnlineService==null ){ + sysUserOnline.setId(String.valueOf(sessionId)); + }else{ + sysUserOnline = sysUserOnlineService.get(String.valueOf(sessionId)); + } + if (sysUserOnline == null) + { + return null; + } + return onlineSessionFactory.createSession(sysUserOnline); + } + /** + * 当会话过期/停止(如用户退出时)属性等会调用 + */ + @Override + protected void doDelete(Session session) + { + OnlineSession onlineSession = (OnlineSession) session; + if (null == onlineSession) + { + return; + } + onlineSession.setStatus(OnlineSession.OnlineStatus.off_line); + SysUserOnline sysUserOnline=new SysUserOnline(); + sysUserOnline.setId(String.valueOf(onlineSession.getId())); + sysUserOnlineService.delete(sysUserOnline); + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OnlineSessionFactory.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OnlineSessionFactory.java new file mode 100644 index 0000000..da0c8c4 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/OnlineSessionFactory.java @@ -0,0 +1,58 @@ +package com.jeespring.modules.sys.dao; + +import com.jeespring.modules.monitor.entity.OnlineSession; +import com.jeespring.modules.sys.entity.SysUserOnline; +import eu.bitwalker.useragentutils.UserAgent; +import org.apache.shiro.session.Session; +import org.apache.shiro.session.mgt.SessionContext; +import org.apache.shiro.session.mgt.SessionFactory; +import org.apache.shiro.web.session.mgt.WebSessionContext; +import org.springframework.stereotype.Component; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.ServletUtils; +import com.jeespring.common.utils.IpUtils; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; + +/** + * 自定义sessionFactory会话 + * + * @author JeeSpring + */ +@Service +public class OnlineSessionFactory implements SessionFactory +{ + public Session createSession(SysUserOnline userOnline) + { + OnlineSession onlineSession = userOnline.getSession(); + if (StringUtils.isNotNull(onlineSession) && onlineSession.getId() == null) + { + onlineSession.setId(userOnline.getId()); + } + return userOnline.getSession(); + } + + @Override + public Session createSession(SessionContext initData) + { + OnlineSession session = new OnlineSession(); + if (initData != null && initData instanceof WebSessionContext) + { + WebSessionContext sessionContext = (WebSessionContext) initData; + HttpServletRequest request = (HttpServletRequest) sessionContext.getServletRequest(); + if (request != null) + { + UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent")); + // 获取客户端操作系统 + String os = userAgent.getOperatingSystem().getName(); + // 获取客户端浏览器 + String browser = userAgent.getBrowser().getName(); + session.setHost(IpUtils.getIpAddr(request)); + session.setBrowser(browser); + session.setOs(os); + } + } + return session; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/RoleDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/RoleDao.java new file mode 100644 index 0000000..cf548f2 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/RoleDao.java @@ -0,0 +1,41 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import org.apache.ibatis.annotations.Mapper; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.modules.sys.entity.Role; + +/** + * 角色DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2013-12-05 + */ +@Mapper +public interface RoleDao extends InterfaceBaseDao { + + Role getByName(Role role); + + Role getByEnname(Role role); + + /** + * 维护角色与菜单权限关系 + * @param role + * @return + */ + int deleteRoleMenu(Role role); + + int insertRoleMenu(Role role); + + /** + * 维护角色与公司部门关系 + * @param role + * @return + */ + int deleteRoleOffice(Role role); + + int insertRoleOffice(Role role); + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysConfigDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysConfigDao.java new file mode 100644 index 0000000..f6eeee3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysConfigDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.sys.entity.SysConfig; + +/** + * 系统配置DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2017-11-17 + */ +@Mapper +public interface SysConfigDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysConfigTreeDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysConfigTreeDao.java new file mode 100644 index 0000000..fb34ed2 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysConfigTreeDao.java @@ -0,0 +1,19 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import com.jeespring.common.persistence.TreeDao; +import com.jeespring.common.persistence.annotation.MyBatisDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.sys.entity.SysConfigTree; + +/** + * 系统配置DAO接口 + * @author JeeSpring + * @version 2018-08-22 + */ +@Mapper +public interface SysConfigTreeDao extends TreeDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysDictTreeDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysDictTreeDao.java new file mode 100644 index 0000000..019a34c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysDictTreeDao.java @@ -0,0 +1,19 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import com.jeespring.common.persistence.TreeDao; +import com.jeespring.common.persistence.annotation.MyBatisDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.sys.entity.SysDictTree; + +/** + * 数据字典DAO接口 + * @author JeeSpring + * @version 2018-08-22 + */ +@Mapper +public interface SysDictTreeDao extends TreeDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysUserOnlineDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysUserOnlineDao.java new file mode 100644 index 0000000..339c082 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SysUserOnlineDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.sys.entity.SysUserOnline; + +/** + * 在线用户记录DAO接口 + * @author JeeSpring + * @version 2018-08-16 + */ +@Mapper +public interface SysUserOnlineDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SystemConfigDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SystemConfigDao.java new file mode 100644 index 0000000..74ebbd3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/SystemConfigDao.java @@ -0,0 +1,18 @@ +/** + * Copyright © 2015-2020 JeeSpring All rights reserved. + */ +package com.jeespring.modules.sys.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.modules.sys.entity.SystemConfig; +import org.apache.ibatis.annotations.Mapper; + +/** + * 系统配置DAO接口 + * @author liugf + * @version 2016-02-07 + */ +@Mapper +public interface SystemConfigDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/UserDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/UserDao.java new file mode 100644 index 0000000..354246b --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/dao/UserDao.java @@ -0,0 +1,112 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.dao; + +import java.util.List; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import com.jeespring.modules.sys.entity.User; + +/** + * 用户DAO接口 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Mapper +public interface UserDao extends InterfaceBaseDao { + + /** + * 根据登录名称查询用户 + * @param loginName + * @return + */ + User getByLoginName(User user); + + /** + * 通过OfficeId获取用户列表,仅返回用户id和name(树查询用户时用) + * @param user + * @return + */ + List findUserByOfficeId(User user); + + /** + * 查询全部用户数目 + * @return + */ + long findAllCount(User user); + + /** + * 更新用户密码 + * @param user + * @return + */ + int updatePasswordById(User user); + + /** + * 更新登录信息,如:登录IP、登录时间 + * @param user + * @return + */ + int updateLoginInfo(User user); + + /** + * 删除用户角色关联数据 + * @param user + * @return + */ + int deleteUserRole(User user); + + /** + * 插入用户角色关联数据 + * @param user + * @return + */ + int insertUserRole(User user); + + /** + * 更新用户信息 + * @param user + * @return + */ + int updateUserInfo(User user); + + /** + * 插入好友 + */ + int insertFriend(@Param("id") String id, @Param("userId") String userId, @Param("friendId") String friendId); + + /** + * 查找好友 + */ + User findFriend(@Param("userId") String userId, @Param("friendId") String friendId); + /** + * 删除好友 + */ + void deleteFriend(@Param("userId") String userId, @Param("friendId") String friendId); + + /** + * + * 获取我的好友列表 + * + */ + List findFriends(User currentUser); + + /** + * + * 查询用户-->用来添加到常用联系人 + * + */ + List searchUsers(User user); + + /** + * + */ + + List findListByOffice(User user); + + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Area.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Area.java new file mode 100644 index 0000000..70d071d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Area.java @@ -0,0 +1,98 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import org.hibernate.validator.constraints.Length; + +import com.jeespring.common.persistence.TreeEntity; + +/** + * 区域Entity + * @author 黄炳桂 516821420@qq.com + * @version 2013-05-15 + */ +public class Area extends TreeEntity { + + private static final long serialVersionUID = 1L; +// private Area parent; // 父级编号 +// private String parentIds; // 所有父级编号 + private String code; // 区域编码 +// private String name; // 区域名称 +// private Integer sort; // 排序 + private String type; // 区域类型(1:国家;2:省份、直辖市;3:地市;4:区县) + + public Area(){ + super(); + this.sort = 30; + } + + public Area(String id){ + super(id); + } + +// @JsonBackReference +// @NotNull + @Override + public Area getParent() { + return parent; + } + + @Override + public void setParent(Area parent) { + this.parent = parent; + } +// +// @Length(min=1, max=2000) +// public String getParentIds() { +// return parentIds; +// } +// +// public void setParentIds(String parentIds) { +// this.parentIds = parentIds; +// } +// +// @Length(min=1, max=100) +// public String getName() { +// return name; +// } +// +// public void setName(String name) { +// this.name = name; +// } +// +// public Integer getSort() { +// return sort; +// } +// +// public void setSort(Integer sort) { +// this.sort = sort; +// } + + @Length(min=1, max=1) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Length(min=0, max=100) + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } +// +// public String getParentId() { +// return parent != null && parent.getId() != null ? parent.getId() : "0"; +// } + + @Override + public String toString() { + return name; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Dict.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Dict.java new file mode 100644 index 0000000..af46201 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Dict.java @@ -0,0 +1,111 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import javax.validation.constraints.NotNull; +import javax.xml.bind.annotation.XmlAttribute; + +import org.hibernate.validator.constraints.Length; + +import com.jeespring.common.persistence.AbstractBaseEntity; + +/** + * 字典Entity + * @author 黄炳桂 516821420@qq.com + * @version 2013-05-15 + */ +public class Dict extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String value; // 数据值 + private String label; // 标签名 + private String type; // 类型 + private String description;// 描述 + private Integer sort; // 排序 + private String parentId;//父Id + private String picture;//图片 + + public Dict() { + super(); + } + + public Dict(String id){ + super(id); + } + + public Dict(String value, String label){ + this.value = value; + this.label = label; + } + + @XmlAttribute + @Length(min=1, max=100) + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @XmlAttribute + @Length(min=1, max=100) + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @Length(min=1, max=100) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @XmlAttribute + @Length(min=0, max=100) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @NotNull + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + @Length(min=1, max=100) + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public String getPicture() { + return picture; + } + + public void setPicture(String picture) { + this.picture = picture; + } + + @Override + public String toString() { + return label; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Log.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Log.java new file mode 100644 index 0000000..70656f7 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Log.java @@ -0,0 +1,148 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import java.util.Date; +import java.util.Map; + +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.AbstractBaseEntity; + +/** + * 日志Entity + * @author 黄炳桂 516821420@qq.com + * @version 2014-8-19 + */ +public class Log extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String type; // 日志类型(1:接入日志;2:错误日志) + private String title; // 日志标题 + private String remoteAddr; // 操作用户的IP地址 + private String requestUri; // 操作的URI + private String method; // 操作的方式 + private String params; // 操作提交的数据 + private String userAgent; // 操作用户代理信息 + private String exception; // 异常信息 + + private Date beginDate; // 开始日期 + private Date endDate; // 结束日期 + + // 日志类型(1:接入日志;2:错误日志) + public static final String TYPE_ACCESS = "1"; + public static final String TYPE_EXCEPTION = "2"; + + public Log(){ + super(); + } + + public Log(String id){ + super(id); + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getRemoteAddr() { + return remoteAddr; + } + + public void setRemoteAddr(String remoteAddr) { + this.remoteAddr = remoteAddr; + } + + public String getUserAgent() { + return userAgent; + } + + public void setUserAgent(String userAgent) { + this.userAgent = userAgent; + } + + public String getRequestUri() { + return requestUri; + } + + public void setRequestUri(String requestUri) { + this.requestUri = requestUri; + } + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + + public String getException() { + return exception; + } + + public void setException(String exception) { + this.exception = exception; + } + + public Date getBeginDate() { + return beginDate; + } + + public void setBeginDate(Date beginDate) { + this.beginDate = beginDate; + } + + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + /** + * 设置请求参数 + * @param paramMap + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void setParams(Map paramMap){ + if (paramMap == null){ + return; + } + StringBuilder params = new StringBuilder(); + for (Map.Entry param : ((Map)paramMap).entrySet()){ + params.append(("".equals(params.toString()) ? "" : "&") + param.getKey() + "="); + String paramValue = (param.getValue() != null && param.getValue().length > 0 ? param.getValue()[0] : ""); + params.append(StringUtils.abbr(StringUtils.endsWithIgnoreCase(param.getKey(), "password") ? "" : paramValue, 100)); + } + this.params = params.toString(); + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Menu.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Menu.java new file mode 100644 index 0000000..56be0eb --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Menu.java @@ -0,0 +1,210 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import java.util.List; + +import javax.validation.constraints.NotNull; + +import org.hibernate.validator.constraints.Length; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 菜单Entity + * @author 黄炳桂 516821420@qq.com + * @version 2013-05-15 + */ +public class Menu extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private Menu parent; // 父级菜单 + private String parentIds; // 所有父级编号 + private List children; // 父级菜单 + private String name; // 名称 + private String href; // 链接 + private String target; // 目标( mainFrame、_blank、_self、_parent、_top) + private String icon; // 图标 + private Integer sort; // 排序 + private String isShow; // 是否在菜单中显示(1:显示;0:不显示) + private String permission; // 权限标识 + + private String userId; + + public Menu(){ + super(); + this.sort = 30; + this.isShow = "1"; + } + + public Menu(String id){ + super(id); + } + + @JsonBackReference + @NotNull + public Menu getParent() { + return parent; + } + + public void setParent(Menu parent) { + this.parent = parent; + } + + @Length(min=1, max=2000) + public String getParentIds() { + if(parentIds==null) { + parentIds = "0,"; + } + return parentIds; + } + + public void setParentIds(String parentIds) { + this.parentIds = parentIds; + } + + @Length(min=1, max=100) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Length(min=0, max=2000) + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } + + @Length(min=0, max=20) + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + @Length(min=0, max=100) + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + @NotNull + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + @Length(min=1, max=1) + public String getIsShow() { + return isShow; + } + + public void setIsShow(String isShow) { + this.isShow = isShow; + } + + @Length(min=0, max=200) + public String getPermission() { + return permission; + } + + public void setPermission(String permission) { + this.permission = permission; + } + + public String getParentId() { + return parent != null && parent.getId() != null ? parent.getId() : "0"; + } + + @JsonIgnore + public boolean hasChildren(){ + if(children == null || children.size() == 0){ + return false; + } + if(children.toString().contains("查看")) { + return false; + } + for(Menu child:children){ + if("1".equals(child.getIsShow())){ + return true; + } + } + return false; + } + @JsonIgnore + public boolean hasPermisson(){ + List menuList = UserUtils.getMenuList(); + for(Menu menu:menuList){ + if(menu.getId().equals(this.getId())) { + return true; + } + } + return false; + } + + @JsonIgnore + public static void sortList(List list, List sourcelist, String parentId, boolean cascade){ + for (int i=0; i children) { + this.children = children; + } + + public List getChildren() { + return children; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Office.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Office.java new file mode 100644 index 0000000..8b3a9ff --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Office.java @@ -0,0 +1,219 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import java.util.List; + +import javax.validation.constraints.NotNull; + +import org.hibernate.validator.constraints.Length; + +import com.jeespring.common.persistence.TreeEntity; + +/** + * 机构Entity + * @author 黄炳桂 516821420@qq.com + * @version 2013-05-15 + */ +public class Office extends TreeEntity { + + private static final long serialVersionUID = 1L; +// private Office parent; // 父级编号 +// private String parentIds; // 所有父级编号 + private Area area; // 归属区域 + private String code; // 机构编码 +// private String name; // 机构名称 +// private Integer sort; // 排序 + private String type; // 机构类型(1:公司;2:部门;3:小组) + private String grade; // 机构等级(1:一级;2:二级;3:三级;4:四级) + private String address; // 联系地址 + private String zipCode; // 邮政编码 + private String master; // 负责人 + private String phone; // 电话 + private String fax; // 传真 + private String email; // 邮箱 + private String useable;//是否可用 + private User primaryPerson;//主负责人 + private User deputyPerson;//副负责人 + private List childDeptList;//快速添加子部门 + + public Office(){ + super(); +// this.sort = 30; + this.type = "2"; + } + + public Office(String id){ + super(id); + } + + public List getChildDeptList() { + return childDeptList; + } + + public void setChildDeptList(List childDeptList) { + this.childDeptList = childDeptList; + } + + public String getUseable() { + return useable; + } + + public void setUseable(String useable) { + this.useable = useable; + } + + public User getPrimaryPerson() { + return primaryPerson; + } + + public void setPrimaryPerson(User primaryPerson) { + this.primaryPerson = primaryPerson; + } + + public User getDeputyPerson() { + return deputyPerson; + } + + public void setDeputyPerson(User deputyPerson) { + this.deputyPerson = deputyPerson; + } + +// @JsonBackReference +// @NotNull + @Override + public Office getParent() { + return parent; + } + + @Override + public void setParent(Office parent) { + this.parent = parent; + } +// +// @Length(min=1, max=2000) +// public String getParentIds() { +// return parentIds; +// } +// +// public void setParentIds(String parentIds) { +// this.parentIds = parentIds; +// } + + @NotNull + public Area getArea() { + return area; + } + + public void setArea(Area area) { + this.area = area; + } +// +// @Length(min=1, max=100) +// public String getName() { +// return name; +// } +// +// public void setName(String name) { +// this.name = name; +// } +// +// public Integer getSort() { +// return sort; +// } +// +// public void setSort(Integer sort) { +// this.sort = sort; +// } + + @Length(min=1, max=1) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Length(min=1, max=1) + public String getGrade() { + return grade; + } + + public void setGrade(String grade) { + this.grade = grade; + } + + @Length(min=0, max=255) + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + @Length(min=0, max=100) + public String getZipCode() { + return zipCode; + } + + public void setZipCode(String zipCode) { + this.zipCode = zipCode; + } + + @Length(min=0, max=100) + public String getMaster() { + return master; + } + + public void setMaster(String master) { + this.master = master; + } + + @Length(min=0, max=200) + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @Length(min=0, max=200) + public String getFax() { + return fax; + } + + public void setFax(String fax) { + this.fax = fax; + } + + @Length(min=0, max=200) + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Length(min=0, max=100) + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + +// public String getParentId() { +// return parent != null && parent.getId() != null ? parent.getId() : "0"; +// } + + @Override + public String toString() { + return name; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Role.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Role.java new file mode 100644 index 0000000..3c0c2c0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/Role.java @@ -0,0 +1,270 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.hibernate.validator.constraints.Length; + +import com.google.common.collect.Lists; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.AbstractBaseEntity; + +/** + * 角色Entity + * @author 黄炳桂 516821420@qq.com + * @version 2013-12-05 + */ +public class Role extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private Office office; // 归属机构 + private String name; // 角色名称 + private String enname; // 英文名称 + private String roleType;// 权限类型 + private String dataScope;// 数据范围 + + private String oldName; // 原角色名称 + private String oldEnname; // 原英文名称 + private String sysData; //是否是系统数据 + private String useable; //是否是可用 + + private User user; // 根据用户ID查询角色列表 + +// private List userList = Lists.newArrayList(); // 拥有用户列表 + private List menuList = Lists.newArrayList(); // 拥有菜单列表 + private List officeList = Lists.newArrayList(); // 按明细设置数据范围 + + // 数据范围(1:所有数据;2:所在公司及以下数据;3:所在公司数据;4:所在部门及以下数据;5:所在部门数据;8:仅本人数据;9:按明细设置) + public static final String DATA_SCOPE_ALL = "1"; + public static final String DATA_SCOPE_COMPANY_AND_CHILD = "2"; + public static final String DATA_SCOPE_COMPANY = "3"; + public static final String DATA_SCOPE_OFFICE_AND_CHILD = "4"; + public static final String DATA_SCOPE_OFFICE = "5"; + public static final String DATA_SCOPE_SELF = "8"; + public static final String DATA_SCOPE_CUSTOM = "9"; + + public Role() { + super(); + this.dataScope = DATA_SCOPE_SELF; + this.useable=Global.YES; + } + + public Role(String id){ + super(id); + } + + public Role(User user) { + this(); + this.user = user; + } + + public String getUseable() { + return useable; + } + + public void setUseable(String useable) { + this.useable = useable; + } + + public String getSysData() { + return sysData; + } + + public void setSysData(String sysData) { + this.sysData = sysData; + } + + public Office getOffice() { + return office; + } + + public void setOffice(Office office) { + this.office = office; + } + + @Length(min=1, max=100) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Length(min=1, max=100) + public String getEnname() { + return enname; + } + + public void setEnname(String enname) { + this.enname = enname; + } + + @Length(min=1, max=100) + public String getRoleType() { + return roleType; + } + + public void setRoleType(String roleType) { + this.roleType = roleType; + } + + public String getDataScope() { + return dataScope; + } + + public void setDataScope(String dataScope) { + this.dataScope = dataScope; + } + + public String getOldName() { + return oldName; + } + + public void setOldName(String oldName) { + this.oldName = oldName; + } + + public String getOldEnname() { + return oldEnname; + } + + public void setOldEnname(String oldEnname) { + this.oldEnname = oldEnname; + } + +// public List getUserList() { +// return userList; +// } +// +// public void setUserList(List userList) { +// this.userList = userList; +// } +// +// public List getUserIdList() { +// List nameIdList = Lists.newArrayList(); +// for (User user : userList) { +// nameIdList.add(user.getId()); +// } +// return nameIdList; +// } +// +// public String getUserIds() { +// return StringUtils.join(getUserIdList(), ","); +// } + + public List getMenuList() { + return menuList; + } + + public void setMenuList(List menuList) { + this.menuList = menuList; + } + + public List getMenuIdList() { + List menuIdList = Lists.newArrayList(); + for (Menu menu : menuList) { + menuIdList.add(menu.getId()); + } + return menuIdList; + } + + public void setMenuIdList(List menuIdList) { + menuList = Lists.newArrayList(); + for (String menuId : menuIdList) { + Menu menu = new Menu(); + menu.setId(menuId); + menuList.add(menu); + } + } + + public String getMenuIds() { + return StringUtils.join(getMenuIdList(), ","); + } + + public void setMenuIds(String menuIds) { + menuList = Lists.newArrayList(); + if (menuIds != null){ + String[] ids = StringUtils.split(menuIds, ","); + setMenuIdList(Lists.newArrayList(ids)); + } + } + + public List getOfficeList() { + return officeList; + } + + public void setOfficeList(List officeList) { + this.officeList = officeList; + } + + public List getOfficeIdList() { + List officeIdList = Lists.newArrayList(); + for (Office office : officeList) { + officeIdList.add(office.getId()); + } + return officeIdList; + } + + public void setOfficeIdList(List officeIdList) { + officeList = Lists.newArrayList(); + for (String officeId : officeIdList) { + Office office = new Office(); + office.setId(officeId); + officeList.add(office); + } + } + + public String getOfficeIds() { + return StringUtils.join(getOfficeIdList(), ","); + } + + public void setOfficeIds(String officeIds) { + officeList = Lists.newArrayList(); + if (officeIds != null){ + String[] ids = StringUtils.split(officeIds, ","); + setOfficeIdList(Lists.newArrayList(ids)); + } + } + + /** + * 获取权限字符串列表 + */ + public List getPermissions() { + List permissions = Lists.newArrayList(); + for (Menu menu : menuList) { + if (menu.getPermission()!=null && !"".equals(menu.getPermission())){ + permissions.add(menu.getPermission()); + } + } + return permissions; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + +// public boolean isAdmin(){ +// return isAdmin(this.id); +// } +// +// public static boolean isAdmin(String id){ +// return id != null && "1".equals(id); +// } + +// @Transient +// public String getMenuNames() { +// List menuNameList = Lists.newArrayList(); +// for (Menu menu : menuList) { +// menuNameList.add(menu.getName()); +// } +// return StringUtils.join(menuNameList, ","); +// } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysConfig.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysConfig.java new file mode 100644 index 0000000..45db207 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysConfig.java @@ -0,0 +1,89 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; + +/** + * 系统配置Entity + * @author 黄炳桂 516821420@qq.com + * @version 2017-11-17 + */ +public class SysConfig extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String type; // 类型 + private String value; // 数据值 + private String label; // 标签名 + private String description; // 描述 + private Long sort; // 排序(升序) + private String picture; //图片 + + public SysConfig() { + super(); + } + + public SysConfig(String id){ + super(id); + } + + @Length(min=1, max=100, message="类型长度必须介于 1 和 100 之间") + @ExcelField(title="类型", align=2, sort=1) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Length(min=1, max=100, message="数据值长度必须介于 1 和 100 之间") + @ExcelField(title="数据值", align=2, sort=2) + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Length(min=1, max=100, message="标签名长度必须介于 1 和 100 之间") + @ExcelField(title="标签名", align=2, sort=3) + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @Length(min=1, max=4000, message="描述长度必须介于 1 和 2000 之间") + @ExcelField(title="描述", align=2, sort=4) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @NotNull(message="排序(升序)不能为空") + @ExcelField(title="排序(升序)", align=2, sort=5) + public Long getSort() { + return sort; + } + + public String getPicture() {return picture;} + + public void setPicture(String picture) {this.picture = picture;} + + public void setSort(Long sort) { + this.sort = sort; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysConfigTree.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysConfigTree.java new file mode 100644 index 0000000..21d347c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysConfigTree.java @@ -0,0 +1,145 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonBackReference; +import java.util.Date; + +import com.jeespring.common.persistence.TreeEntity; + +/** + * 系统配置Entity + * @author JeeSpring + * @version 2018-08-22 + */ +public class SysConfigTree extends TreeEntity { + + private static final long serialVersionUID = 1L; + private String type; // 类型 + private String value; // 数据值 + private String label; // 标签名 + private String description; // 描述 + //private Long sort; // 排序(升序) + private SysConfigTree parent; // 父级编号 + private String parentIds; // 所有父级编号 + private String picture; // 图片 + private Date beginCreateDate; // 开始 创建时间 + private Date endCreateDate; // 结束 创建时间 + private Date beginUpdateDate; // 开始 更新时间 + private Date endUpdateDate; // 结束 更新时间 + + public SysConfigTree() { + super(); + } + + public SysConfigTree(String id){ + super(id); + } + + @Length(min=1, max=100, message="类型长度必须介于 1 和 100 之间") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Length(min=1, max=100, message="数据值长度必须介于 1 和 100 之间") + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Length(min=1, max=100, message="标签名长度必须介于 1 和 100 之间") + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @Length(min=1, max=4000, message="描述长度必须介于 1 和 4000 之间") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + //@JsonBackReference + @Override + public SysConfigTree getParent() { + return parent; + } + + @Override + public void setParent(SysConfigTree parent) { + this.parent = parent; + } + + @Override + @Length(min=0, max=2000, message="所有父级编号长度必须介于 0 和 2000 之间") + public String getParentIds() { + return parentIds; + } + + @Override + public void setParentIds(String parentIds) { + this.parentIds = parentIds; + } + + @Length(min=0, max=255, message="图片长度必须介于 0 和 255 之间") + public String getPicture() { + return picture; + } + + public void setPicture(String picture) { + this.picture = picture; + } + + public Date getBeginCreateDate() { + return beginCreateDate; + } + + public void setBeginCreateDate(Date beginCreateDate) { + this.beginCreateDate = beginCreateDate; + } + + public Date getEndCreateDate() { + return endCreateDate; + } + + public void setEndCreateDate(Date endCreateDate) { + this.endCreateDate = endCreateDate; + } + + public Date getBeginUpdateDate() { + return beginUpdateDate; + } + + public void setBeginUpdateDate(Date beginUpdateDate) { + this.beginUpdateDate = beginUpdateDate; + } + + public Date getEndUpdateDate() { + return endUpdateDate; + } + + public void setEndUpdateDate(Date endUpdateDate) { + this.endUpdateDate = endUpdateDate; + } + + @Override + public String getParentId() { + return parent != null && parent.getId() != null ? parent.getId() : "0"; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysDictTree.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysDictTree.java new file mode 100644 index 0000000..f8f299d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysDictTree.java @@ -0,0 +1,154 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonBackReference; +import java.util.Date; + +import com.jeespring.common.persistence.TreeEntity; + +/** + * 数据字典Entity + * @author JeeSpring + * @version 2018-08-22 + */ +public class SysDictTree extends TreeEntity { + + private static final long serialVersionUID = 1L; + private String value; // 数据值 + private String label; // 标签名 + private String type; // 类型 + private String description; // 描述 + //private Long sort; // 排序(升序) + private SysDictTree parent; // 父级编号 + private String parentIds; // 所有父级编号 + private String picture; // 图片 + private Date beginCreateDate; // 开始 创建时间 + private Date endCreateDate; // 结束 创建时间 + private Date beginUpdateDate; // 开始 更新时间 + private Date endUpdateDate; // 结束 更新时间 + + public SysDictTree() { + super(); + } + + public SysDictTree(String id){ + super(id); + } + + @Length(min=1, max=100, message="数据值长度必须介于 1 和 100 之间") + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Length(min=1, max=100, message="标签名长度必须介于 1 和 100 之间") + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + @Length(min=1, max=100, message="类型长度必须介于 1 和 100 之间") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Length(min=1, max=100, message="描述长度必须介于 1 和 100 之间") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + //@NotNull(message="排序(升序)不能为空") + //public Long getSort() { + //return sort; + //} + + //public void setSort(Long sort) { + //this.sort = sort; + //} + + @Override + @JsonBackReference + public SysDictTree getParent() { + return parent; + } + + @Override + public void setParent(SysDictTree parent) { + this.parent = parent; + } + + @Override + @Length(min=0, max=2000, message="所有父级编号长度必须介于 0 和 2000 之间") + public String getParentIds() { + return parentIds; + } + + @Override + public void setParentIds(String parentIds) { + this.parentIds = parentIds; + } + + @Length(min=0, max=255, message="图片长度必须介于 0 和 255 之间") + public String getPicture() { + return picture; + } + + public void setPicture(String picture) { + this.picture = picture; + } + + public Date getBeginCreateDate() { + return beginCreateDate; + } + + public void setBeginCreateDate(Date beginCreateDate) { + this.beginCreateDate = beginCreateDate; + } + + public Date getEndCreateDate() { + return endCreateDate; + } + + public void setEndCreateDate(Date endCreateDate) { + this.endCreateDate = endCreateDate; + } + + public Date getBeginUpdateDate() { + return beginUpdateDate; + } + + public void setBeginUpdateDate(Date beginUpdateDate) { + this.beginUpdateDate = beginUpdateDate; + } + + public Date getEndUpdateDate() { + return endUpdateDate; + } + + public void setEndUpdateDate(Date endUpdateDate) { + this.endUpdateDate = endUpdateDate; + } + + @Override + public String getParentId() { + return parent != null && parent.getId() != null ? parent.getId() : "0"; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysUserOnline.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysUserOnline.java new file mode 100644 index 0000000..0fcf358 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SysUserOnline.java @@ -0,0 +1,246 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import com.jeespring.common.utils.AddressUtils; +import com.jeespring.modules.monitor.entity.OnlineSession; +import org.hibernate.validator.constraints.Length; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; + +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; +import com.jeespring.modules.sys.utils.DictUtils; + +/** + * 在线用户记录Entity + * @author JeeSpring + * @version 2018-08-16 + */ +public class SysUserOnline extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String loginName; // 登录账号 + private String deptName; // 部门名称 + private String ipaddr; // 登录IP地址 + private String loginLocation; // 登录地点 + private String browser; // 浏览器类型 + private String os; // 操作系统 + private String status; // 在线状态on_line在线off_line离线 + private String statusLabel; // 在线状态on_line在线off_line离线Label + private String statusPicture; // 在线状态on_line在线off_line离线Picture + private java.util.Date startTimestsamp; // session创建时间 + private java.util.Date lastAccessTime; // session最后访问时间 + private Integer expireTime; // 超时时间,单位为分钟 + private java.util.Date beginStartTimestsamp; // 开始 session创建时间 + private java.util.Date endStartTimestsamp; // 结束 session创建时间 + private java.util.Date beginLastAccessTime; // 开始 session最后访问时间 + private java.util.Date endLastAccessTime; // 结束 session最后访问时间 + private java.util.Date beginCreateDate; // 开始 创建时间 + private java.util.Date endCreateDate; // 结束 创建时间 + private OnlineSession session; /** 备份的当前用户会话 */ + + public SysUserOnline() { + super(); + } + + public SysUserOnline(String id){ + super(id); + } + + @Length(min=0, max=50, message="登录账号长度必须介于 0 和 50 之间") + @ExcelField(title="登录账号", align=2, sort=1) + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + + @Length(min=0, max=50, message="部门名称长度必须介于 0 和 50 之间") + @ExcelField(title="部门名称", align=2, sort=2) + public String getDeptName() { + return deptName; + } + + public void setDeptName(String deptName) { + this.deptName = deptName; + } + + + @Length(min=0, max=50, message="登录IP地址长度必须介于 0 和 50 之间") + @ExcelField(title="登录IP地址", align=2, sort=3) + public String getIpaddr() { + return ipaddr; + } + + public void setIpaddr(String ipaddr) { + this.ipaddr = ipaddr; + } + + + @Length(min=0, max=255, message="登录地点长度必须介于 0 和 255 之间") + @ExcelField(title="登录地点", align=2, sort=4) + public String getLoginLocation() { + return loginLocation; + } + + public void setLoginLocation(String loginLocation) { + this.loginLocation = loginLocation; + } + + + @Length(min=0, max=50, message="浏览器类型长度必须介于 0 和 50 之间") + @ExcelField(title="浏览器类型", align=2, sort=5) + public String getBrowser() { + return browser; + } + + public void setBrowser(String browser) { + this.browser = browser; + } + + + @Length(min=0, max=50, message="操作系统长度必须介于 0 和 50 之间") + @ExcelField(title="操作系统", align=2, sort=6) + public String getOs() { + return os; + } + + public void setOs(String os) { + this.os = os; + } + + + @Length(min=0, max=10, message="在线状态on_line在线off_line离线长度必须介于 0 和 10 之间") + @ExcelField(title="在线状态on_line在线off_line离线", dictType="on_line_status", align=2, sort=7) + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + + public String getStatusLabel() { + return DictUtils.getDictLabel(status,"on_line_status",""); + } + public String getStatusPicture() { + return DictUtils.getDictPicture(status,"on_line_status",""); + } + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ExcelField(title="session创建时间", align=2, sort=8) + public Date getStartTimestsamp() { + return startTimestsamp; + } + + public void setStartTimestsamp(Date startTimestsamp) { + this.startTimestsamp = startTimestsamp; + } + + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ExcelField(title="session最后访问时间", align=2, sort=9) + public Date getLastAccessTime() { + return lastAccessTime; + } + + public void setLastAccessTime(Date lastAccessTime) { + this.lastAccessTime = lastAccessTime; + } + + + @ExcelField(title="超时时间,单位为分钟", align=2, sort=10) + public Integer getExpireTime() { + return expireTime; + } + + public void setExpireTime(Integer expireTime) { + this.expireTime = expireTime; + } + + + public Date getBeginStartTimestsamp() { + return beginStartTimestsamp; + } + + public void setBeginStartTimestsamp(Date beginStartTimestsamp) { + this.beginStartTimestsamp = beginStartTimestsamp; + } + + public Date getEndStartTimestsamp() { + return endStartTimestsamp; + } + + public void setEndStartTimestsamp(Date endStartTimestsamp) { + this.endStartTimestsamp = endStartTimestsamp; + } + + public Date getBeginLastAccessTime() { + return beginLastAccessTime; + } + + public void setBeginLastAccessTime(Date beginLastAccessTime) { + this.beginLastAccessTime = beginLastAccessTime; + } + + public Date getEndLastAccessTime() { + return endLastAccessTime; + } + + public void setEndLastAccessTime(Date endLastAccessTime) { + this.endLastAccessTime = endLastAccessTime; + } + + public Date getBeginCreateDate() { + return beginCreateDate; + } + + public void setBeginCreateDate(Date beginCreateDate) { + this.beginCreateDate = beginCreateDate; + } + + public Date getEndCreateDate() { + return endCreateDate; + } + + public void setEndCreateDate(Date endCreateDate) { + this.endCreateDate = endCreateDate; + } + + + public OnlineSession getSession() { + return session; + } + + public void setSession(OnlineSession session) { + this.session = session; + } + + /** + * 设置session对象 + */ + public static final SysUserOnline fromOnlineSession(OnlineSession session) + { + SysUserOnline online = new SysUserOnline(); + online.setId(String.valueOf(session.getId())); + online.setDeptName(session.getDeptName()); + online.setLoginName(session.getLoginName()); + online.setStartTimestsamp(session.getStartTimestamp()); + online.setLastAccessTime(session.getLastAccessTime()); + online.setExpireTime((int)session.getTimeout()); + online.setIpaddr(session.getHost()); + online.setLoginLocation(AddressUtils.getRealAddressByIP(session.getHost())); + online.setBrowser(session.getBrowser()); + online.setOs(session.getOs()); + online.setStatus(session.getStatus().toString()); + online.setSession(session); + return online; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SystemConfig.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SystemConfig.java new file mode 100644 index 0000000..940f5a7 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/SystemConfig.java @@ -0,0 +1,102 @@ +/** + * Copyright © 2015-2020 JeeSpring All rights reserved. + */ +package com.jeespring.modules.sys.entity; + +import org.hibernate.validator.constraints.Length; + +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; + +/** + * 系统配置Entity + * @author liugf + * @version 2016-02-07 + */ +public class SystemConfig extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String smtp; // 邮箱服务器地址 + private String port; // 邮箱服务器端口 + private String mailName; // 系统邮箱地址 + private String mailPassword; // 系统邮箱密码 + private String smsName; // 短信用户名 + private String smsPassword; // 短信密码 + private boolean test = false; + public SystemConfig() { + super(); + } + + public SystemConfig(String id){ + super(id); + } + + @Length(min=0, max=64, message="邮箱服务器地址长度必须介于 0 和 64 之间") + @ExcelField(title="邮箱服务器地址", align=2, sort=1) + public String getSmtp() { + return smtp; + } + + public void setSmtp(String smtp) { + this.smtp = smtp; + } + + @Length(min=0, max=64, message="邮箱服务器端口长度必须介于 0 和 64 之间") + @ExcelField(title="邮箱服务器端口", align=2, sort=2) + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + @Length(min=0, max=64, message="系统邮箱地址长度必须介于 0 和 64 之间") + @ExcelField(title="系统邮箱地址", align=2, sort=3) + public String getMailName() { + return mailName; + } + + public void setMailName(String mailName) { + this.mailName = mailName; + } + + @Length(min=0, max=64, message="系统邮箱密码长度必须介于 0 和 64 之间") + @ExcelField(title="系统邮箱密码", align=2, sort=4) + public String getMailPassword() { + return mailPassword; + } + + public void setMailPassword(String mailPassword) { + this.mailPassword = mailPassword; + } + + @Length(min=0, max=64, message="短信用户名长度必须介于 0 和 64 之间") + @ExcelField(title="短信用户名", align=2, sort=5) + public String getSmsName() { + return smsName; + } + + public void setSmsName(String smsName) { + this.smsName = smsName; + } + + @Length(min=0, max=64, message="短信密码长度必须介于 0 和 64 之间") + @ExcelField(title="短信密码", align=2, sort=6) + public String getSmsPassword() { + return smsPassword; + } + + public void setSmsPassword(String smsPassword) { + this.smsPassword = smsPassword; + } + + public void setTest(boolean test) { + this.test = test; + } + + public boolean isTest() { + return test; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/User.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/User.java new file mode 100644 index 0000000..3d4f7ce --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/User.java @@ -0,0 +1,349 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.entity; + +import java.util.Date; +import java.util.List; + +import javax.validation.constraints.NotNull; + +import org.hibernate.validator.constraints.Email; +import org.hibernate.validator.constraints.Length; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.google.common.collect.Lists; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.Collections3; +import com.jeespring.common.utils.excel.annotation.ExcelField; +import com.jeespring.common.utils.excel.fieldtype.RoleListType; +import com.jeespring.common.persistence.AbstractBaseEntity; + +/** + * 用户Entity + * @author 黄炳桂 516821420@qq.com + * @version 2013-12-05 + */ +public class User extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private Office company; // 归属公司 + private Office office; // 归属部门 + private String loginName;// 登录名 + private String password;// 密码 + private String no; // 工号 + private String name; // 姓名 + private String email; // 邮箱 + private String phone; // 电话 + private String mobile; // 手机 + private String userType;// 用户类型 + private String loginIp; // 最后登陆IP + private Date loginDate; // 最后登陆日期 + private String loginFlag; // 是否允许登陆 + private String photo; // 头像 + private String qrCode; //二维码 + private String oldLoginName;// 原登录名 + private String newPassword; // 新密码 + private String oldLoginIp; // 上次登陆IP + private Date oldLoginDate; // 上次登陆日期 + private Role role; // 根据角色查询用户条件 + private List roleList = Lists.newArrayList(); // 拥有角色列表 + private String oauthId; //小程序唯一标识 + private String oauthSecret; //小程序秘钥 + + public User() { + super(); + this.loginFlag = Global.YES; + } + + public User(String id){ + super(id); + } + + public User(String id, String loginName){ + super(id); + this.loginName = loginName; + } + + public User(Role role){ + super(); + this.role = role; + } + + public String getPhoto() { + return photo; + } + + public void setPhoto(String photo) { + this.photo = photo; + } + + public String getLoginFlag() { + return loginFlag; + } + + public void setLoginFlag(String loginFlag) { + this.loginFlag = loginFlag; + } + + //SupCol(isUnique="true", isHide="true") + @Override + @ExcelField(title="ID", type=1, align=2, sort=1) + public String getId() { + return id; + } + + @JsonIgnore + @NotNull(message="归属公司不能为空") + @ExcelField(title="归属公司", align=2, sort=20) + public Office getCompany() { + return company; + } + + public void setCompany(Office company) { + this.company = company; + } + + @JsonIgnore + @NotNull(message="归属部门不能为空") + @ExcelField(title="归属部门", align=2, sort=25) + public Office getOffice() { + return office; + } + + public void setOffice(Office office) { + this.office = office; + } + + @Length(min=1, max=100, message="登录名长度必须介于 1 和 100 之间") + @ExcelField(title="登录名", align=2, sort=30) + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + @JsonIgnore + @Length(min=1, max=100, message="密码长度必须介于 1 和 100 之间") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Length(min=1, max=100, message="姓名长度必须介于 1 和 100 之间") + @ExcelField(title="姓名", align=2, sort=40) + public String getName() { + return name; + } + + @Length(min=1, max=100, message="工号长度必须介于 1 和 100 之间") + @ExcelField(title="工号", align=2, sort=45) + public String getNo() { + return no; + } + + public void setNo(String no) { + this.no = no; + } + + public void setName(String name) { + this.name = name; + } + + @Email(message="邮箱格式不正确") + @Length(min=0, max=200, message="邮箱长度必须介于 1 和 200 之间") + @ExcelField(title="邮箱", align=1, sort=50) + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Length(min=0, max=200, message="电话长度必须介于 1 和 200 之间") + @ExcelField(title="电话", align=2, sort=60) + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @Length(min=0, max=200, message="手机长度必须介于 1 和 200 之间") + @ExcelField(title="手机", align=2, sort=70) + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + @Override + @ExcelField(title="备注", align=1, sort=900) + public String getRemarks() { + return remarks; + } + + @Length(min=0, max=100, message="用户类型长度必须介于 1 和 100 之间") + @ExcelField(title="用户类型", align=2, sort=80, dictType="sys_user_type") + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + @Override + @ExcelField(title="创建时间", type=0, align=1, sort=90) + public Date getCreateDate() { + return createDate; + } + + @ExcelField(title="最后登录IP", type=1, align=1, sort=100) + public String getLoginIp() { + return loginIp; + } + + public void setLoginIp(String loginIp) { + this.loginIp = loginIp; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ExcelField(title="最后登录日期", type=1, align=1, sort=110) + public Date getLoginDate() { + return loginDate; + } + + public void setLoginDate(Date loginDate) { + this.loginDate = loginDate; + } + + public String getOldLoginName() { + return oldLoginName; + } + + public void setOldLoginName(String oldLoginName) { + this.oldLoginName = oldLoginName; + } + + public String getNewPassword() { + return newPassword; + } + + public void setNewPassword(String newPassword) { + this.newPassword = newPassword; + } + + public String getOldLoginIp() { + if (oldLoginIp == null){ + return loginIp; + } + return oldLoginIp; + } + + public void setOldLoginIp(String oldLoginIp) { + this.oldLoginIp = oldLoginIp; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + public Date getOldLoginDate() { + if (oldLoginDate == null){ + return loginDate; + } + return oldLoginDate; + } + + public void setOldLoginDate(Date oldLoginDate) { + this.oldLoginDate = oldLoginDate; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + + @JsonIgnore + @ExcelField(title="拥有角色", align=1, sort=800, fieldType=RoleListType.class) + public List getRoleList() { + return roleList; + } + + public void setRoleList(List roleList) { + this.roleList = roleList; + } + + @JsonIgnore + public List getRoleIdList() { + List roleIdList = Lists.newArrayList(); + for (Role role : roleList) { + roleIdList.add(role.getId()); + } + return roleIdList; + } + + public void setRoleIdList(List roleIdList) { + roleList = Lists.newArrayList(); + for (String roleId : roleIdList) { + Role role = new Role(); + role.setId(roleId); + roleList.add(role); + } + } + + /** + * 用户拥有的角色名称字符串, 多个角色名称用','分隔. + */ + public String getRoleNames() { + return Collections3.extractToString(roleList, "name", ","); + } + + public boolean isAdmin(){ + return isAdmin(this.id); + } + + public static boolean isAdmin(String id){ + return id != null && "1".equals(id); + } + + @Override + public String toString() { + return id; + } + + public void setQrCode(String qrCode) { + this.qrCode = qrCode; + } + + public String getQrCode() { + return qrCode; + } + + public String getOauthId() { + return oauthId; + } + + public void setOauthId(String oauthId) { + this.oauthId = oauthId; + } + + public String getOauthSecret() { + return oauthSecret; + } + + public void setOauthSecret(String oauthSecret) { + this.oauthSecret = oauthSecret; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/UserRealm.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/UserRealm.java new file mode 100644 index 0000000..0d9772e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/entity/UserRealm.java @@ -0,0 +1,98 @@ +package com.jeespring.modules.sys.entity; + +import com.jeespring.common.security.ShiroUtils; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.*; +import org.apache.shiro.authz.AuthorizationInfo; +import org.apache.shiro.authz.SimpleAuthorizationInfo; +import org.apache.shiro.realm.AuthorizingRealm; +import org.apache.shiro.subject.PrincipalCollection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * 自定义Realm 处理登录 权限 + * + * @author JeeSpring + */ +public class UserRealm extends AuthorizingRealm +{ + private static final Logger log = LoggerFactory.getLogger(UserRealm.class); + + /** + * 授权 + */ + @Override + protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) + { + Long userId = ShiroUtils.getUserId(); + SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); + // 角色加入AuthorizationInfo认证对象 + //info.setRoles(roleService.selectRoleKeys(userId)); + // 权限加入AuthorizationInfo认证对象 + //info.setStringPermissions(menuService.selectPermsByUserId(userId)); + return info; + } + + /** + * 登录认证 /admin/login + */ + @Override + protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException + { + UsernamePasswordToken upToken = (UsernamePasswordToken) token; + String username = upToken.getUsername(); + String password = ""; + if (upToken.getPassword() != null) + { + password = new String(upToken.getPassword()); + } + + User user = null; + try + { + //user = loginService.login(username, password); + } + /*catch (CaptchaException e) + { + throw new AuthenticationException(e.getMessage(), e); + } + catch (UserNotExistsException e) + { + throw new UnknownAccountException(e.getMessage(), e); + } + catch (UserPasswordNotMatchException e) + { + throw new IncorrectCredentialsException(e.getMessage(), e); + } + catch (UserPasswordRetryLimitExceedException e) + { + throw new ExcessiveAttemptsException(e.getMessage(), e); + } + catch (UserBlockedException e) + { + throw new LockedAccountException(e.getMessage(), e); + } + catch (RoleBlockedException e) + { + throw new LockedAccountException(e.getMessage(), e); + }*/ + catch (Exception e) + { + log.info("对用户[" + username + "]进行登录验证..验证未通过{}", e.getMessage()); + throw new AuthenticationException(e.getMessage(), e); + } + SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, password, getName()); + return info; + } + + /** + * 清理缓存权限 + */ + public void clearCachedAuthorizationInfo() + { + this.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals()); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/InterceptorLogEntity.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/InterceptorLogEntity.java new file mode 100644 index 0000000..6ebeeff --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/InterceptorLogEntity.java @@ -0,0 +1,44 @@ +package com.jeespring.modules.sys.interceptor; + +import com.jeespring.modules.sys.entity.Log; + +/** + * Created by + * Created on 2017/1/15 20:51 + * JeeSpring + */ +public class InterceptorLogEntity { + private Log log; + private Object handler; + private Exception ex; + + public InterceptorLogEntity(Log log, Object handler, Exception ex) { + this.log = log; + this.handler = handler; + this.ex = ex; + } + + public Log getLog() { + return log; + } + + public void setLog(Log log) { + this.log = log; + } + + public Object getHandler() { + return handler; + } + + public void setHandler(Object handler) { + this.handler = handler; + } + + public Exception getEx() { + return ex; + } + + public void setEx(Exception ex) { + this.ex = ex; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/LogInterceptor.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/LogInterceptor.java new file mode 100644 index 0000000..1c7e38f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/LogInterceptor.java @@ -0,0 +1,54 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.modules.sys.interceptor; + +import com.jeespring.common.service.AbstractService; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.modules.sys.utils.LogUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.NamedThreadLocal; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 日志拦截器 + * + * @author 黄炳桂 516821420@qq.com + * @version 2014-8-19 + */ +@Component("controllerLogInterceptor") +public class LogInterceptor extends AbstractService implements HandlerInterceptor { + + private Logger logger = LoggerFactory.getLogger("controller-log"); + private static final ThreadLocal startTimeThreadLocal =new NamedThreadLocal("ThreadLocal StartTime"); + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, + Object handler) throws Exception { + startTimeThreadLocal.set(System.currentTimeMillis()); + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) throws Exception { + } + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, + Object handler, Exception ex) throws Exception { + if(!"/error".equals(request.getRequestURI())) { + logger.info("URI: {},耗时:{} ", request.getRequestURI() + "-" + request.getMethod() + , DateUtils.formatDateTime(System.currentTimeMillis() - startTimeThreadLocal.get())); + } + //删除线程变量中的数据,防止内存泄漏 + startTimeThreadLocal.remove(); + // 保存日志 + LogUtils.saveLog(request, handler, ex, null); + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/LogThread.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/LogThread.java new file mode 100644 index 0000000..fa7d9ce --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/LogThread.java @@ -0,0 +1,140 @@ +package com.jeespring.modules.sys.interceptor; + +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.LinkedBlockingQueue; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.CacheUtils; +import com.jeespring.common.utils.Exceptions; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.sys.dao.LogDao; +import com.jeespring.modules.sys.dao.MenuDao; +import com.jeespring.modules.sys.entity.Log; +import com.jeespring.modules.sys.entity.Menu; + +/** + * Created by + * Created on 2017/1/15 20:55 + * JeeSpring + */ +@Component +public class LogThread extends Thread { + + public static LinkedBlockingQueue interceptorLogQueue = new LinkedBlockingQueue<>(); + private static final String CACHE_MENU_NAME_PATH_MAP = "menuNamePathMap"; + private static Logger logger = LoggerFactory.getLogger(LogThread.class); + @Autowired + private LogDao logDao; + @Autowired + private MenuDao menuDao; + + @Override + public void run() { + logger.info("start the InterceptorLog thread"); + while (true) { + try { + InterceptorLogEntity entiry = interceptorLogQueue.take(); + Log log = entiry.getLog(); + Exception ex = entiry.getEx(); + Object handler = entiry.getHandler(); + // 获取日志标题 + if (StringUtils.isBlank(log.getTitle())) { + String permission = ""; + if (handler instanceof HandlerMethod) { + Method m = ((HandlerMethod) handler).getMethod(); + RequiresPermissions rp = m.getAnnotation(RequiresPermissions.class); + permission = (rp != null ? StringUtils.join(rp.value(), ",") : ""); + } + log.setTitle(getMenuNamePath(log.getRequestUri(), permission)); + if(StringUtils.isBlank(log.getTitle())){ + log.setTitle(log.getRequestUri()); + } + } + // 如果有异常,设置异常信息 + //log.setException(Exceptions.getStackTraceAsString(ex)); + if(ex!=null) { + log.setException(ex.getMessage()); + } + // 如果无标题并无异常日志,则不保存信息 + if (StringUtils.isBlank(log.getTitle()) && StringUtils.isBlank(log.getException())) { + continue; + } + log.setId(UUID.randomUUID().toString()); + if(log.getParams()!=null && log.getParams().length()>=500) { + log.setParams(log.getParams().substring(0, 200)); + } + logDao.insert(log); + } catch (Exception e) { + e.printStackTrace(System.out); + } + } + } + + /** + * 获取菜单名称路径(如:系统设置-机构用户-用户管理-编辑) + */ + private String getMenuNamePath(String requestUri, String permission) { + String href = StringUtils.substringAfter(requestUri, Global.getAdminPath()); + @SuppressWarnings("unchecked") + Map menuMap = (Map) CacheUtils.get(CACHE_MENU_NAME_PATH_MAP); + if (menuMap == null) { + menuMap = Maps.newHashMap(); + List menuList = menuDao.findAllList(new Menu()); + for (Menu menu : menuList) { + // 获取菜单名称路径(如:系统设置-机构用户-用户管理-编辑) + String namePath = ""; + if (menu.getParentIds() != null) { + List namePathList = Lists.newArrayList(); + for (String id : StringUtils.split(menu.getParentIds(), ",")) { + if (Menu.getRootId().equals(id)) { + continue; // 过滤跟节点 + } + for (Menu m : menuList) { + if (m.getId().equals(id)) { + namePathList.add(m.getName()); + break; + } + } + } + namePathList.add(menu.getName()); + namePath = StringUtils.join(namePathList, "-"); + } + // 设置菜单名称路径 + if (StringUtils.isNotBlank(menu.getHref())) { + menuMap.put(menu.getHref(), namePath); + } else if (StringUtils.isNotBlank(menu.getPermission())) { + for (String p : StringUtils.split(menu.getPermission())) { + menuMap.put(p, namePath); + } + } + + } + CacheUtils.put(CACHE_MENU_NAME_PATH_MAP, menuMap); + } + String menuNamePath = menuMap.get(href); + if (menuNamePath == null) { + for (String p : StringUtils.split(permission)) { + menuNamePath = menuMap.get(p); + if (StringUtils.isNotBlank(menuNamePath)) { + break; + } + } + if (menuNamePath == null) { + return ""; + } + } + return menuNamePath; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/MobileInterceptor.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/MobileInterceptor.java new file mode 100644 index 0000000..019228b --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/MobileInterceptor.java @@ -0,0 +1,44 @@ +/** + * Copyright © 2015-2020 JeeSpring All rights reserved. + */ +package com.jeespring.modules.sys.interceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import com.jeespring.common.service.AbstractService; + +/** + * 手机端视图拦截器 + * @author jeespring + * @version 2014-9-1 + */ +public class MobileInterceptor extends AbstractService implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, + Object handler) throws Exception { + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) throws Exception { +// if (modelAndView != null){//手机端没有开发,默认打开PC端界面。如果你自己开发app端界面,请取消该注释。 +// // 如果是手机或平板访问的话,则跳转到手机视图页面。 +// if(UserAgentUtils.isMobileOrTablet(request) && !StringUtils.startsWithIgnoreCase(modelAndView.getViewName(), "redirect:")){ +// modelAndView.setViewName("mobile/" + modelAndView.getViewName()); +// } +// } + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, + Object handler, Exception ex) throws Exception { + + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/WebInterceptorConfigurer.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/WebInterceptorConfigurer.java new file mode 100644 index 0000000..3a05fb7 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/interceptor/WebInterceptorConfigurer.java @@ -0,0 +1,107 @@ +package com.jeespring.modules.sys.interceptor; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.support.http.StatViewServlet; +import com.alibaba.druid.support.http.WebStatFilter; +import com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator; +import com.alibaba.druid.support.spring.stat.DruidStatInterceptor; +import com.jeespring.modules.sys.web.UserController; +import org.springframework.aop.Advisor; +import org.springframework.aop.support.DefaultPointcutAdvisor; +import org.springframework.aop.support.JdkRegexpMethodPointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; +import org.springframework.util.ResourceUtils; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +/** + * Created by + * Created on 2017/1/15 20:21 + * JeeSpring + */ +@Component +public class WebInterceptorConfigurer extends WebMvcConfigurerAdapter{ + @Autowired + private LogInterceptor logInterceptor; + @Autowired + private LogThread logThread; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(logInterceptor).addPathPatterns("/**"); + super.addInterceptors(registry); + logThread.start(); + } + + /** + * druidServlet注册 + */ + @Bean + public ServletRegistrationBean druidServletRegistration() { + ServletRegistrationBean registration = new ServletRegistrationBean(new StatViewServlet()); + registration.addUrlMappings("/druid/*"); + return registration; + } + + /** + * druid监控 配置URI拦截策略 + */ + @Bean + public FilterRegistrationBean druidStatFilter() { + FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter()); + //添加过滤规则. + filterRegistrationBean.addUrlPatterns("/*"); + //添加不需要忽略的格式信息. + filterRegistrationBean.addInitParameter( + "exclusions", "/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid,/druid/*"); + //用于session监控页面的用户名显示 需要登录后主动将username注入到session里 + filterRegistrationBean.addInitParameter("principalSessionName", "username"); + return filterRegistrationBean; + } + + /** + * druid数据库连接池监控 + */ + @Bean + public DruidStatInterceptor druidStatInterceptor() { + return new DruidStatInterceptor(); + } + + @Bean + public JdkRegexpMethodPointcut druidStatPointcut() { + JdkRegexpMethodPointcut druidStatPointcut = new JdkRegexpMethodPointcut(); + String patterns = "com.jeespring.modules.*.service.*"; + //可以set多个 + druidStatPointcut.setPatterns(patterns); + return druidStatPointcut; + } + + /** + * druid数据库连接池监控 + */ + @Bean + public BeanTypeAutoProxyCreator beanTypeAutoProxyCreator() { + BeanTypeAutoProxyCreator beanTypeAutoProxyCreator = new BeanTypeAutoProxyCreator(); + beanTypeAutoProxyCreator.setTargetBeanType(DruidDataSource.class); + beanTypeAutoProxyCreator.setInterceptorNames("druidStatInterceptor"); + return beanTypeAutoProxyCreator; + } + + /** + * druid 为druidStatPointcut添加拦截 + * + * @return + */ + @Bean + public Advisor druidStatAdvisor() { + return new DefaultPointcutAdvisor(druidStatPointcut(), druidStatInterceptor()); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/DictRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/DictRestController.java new file mode 100644 index 0000000..636ec0d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/DictRestController.java @@ -0,0 +1,81 @@ +package com.jeespring.modules.sys.rest; + +import com.jeespring.common.web.AbstractBaseController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.entity.Dict; +import com.jeespring.modules.sys.service.DictService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; + +@RestController +@RequestMapping(value={"/rest/sys/dict"}) +@Api(value="dict数据字典云接口", description="dict数据字典云接口") +public class DictRestController extends AbstractBaseController { + + @Autowired + private DictService dictService; + + @RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="数据字典获取信息(Content-Type为text/html)", notes="数据字典获取信息(Content-Type为text/html)") + @ApiImplicitParam(name = "id", value = "数据字典id", required = false, dataType = "String",paramType="query") + public Result get(@RequestParam(required=false) String id) { + Dict dict=null; + if (StringUtils.isNotBlank(id)){ + dict=dictService.get(id); + }else{ + dict=new Dict(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(dict); + return result; + + } + @RequestMapping(value = {"get/json"},method ={RequestMethod.POST}) + @ApiOperation(value="数据字典获取信息(Content-Type为application/json)", notes="数据字典获取信息(Content-Type为application/json)") + @ApiImplicitParam(name = "id", value = "数据字典id", required = false, dataType = "String",paramType="body") + public Result getJson(@RequestBody(required=false) String id) { + Dict dict=null; + if (StringUtils.isNotBlank(id)){ + dict=dictService.get(id); + }else{ + dict=new Dict(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(dict); + return result; + } + + //RequiresPermissions("sys:dict:list") + @RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="数据字典获取列表(Content-Type为text/html)", notes="数据字典获取列表(Content-Type为text/html)") + @ApiImplicitParam(name = "dict", value = "数据字典", dataType = "Dict",paramType="query") + public Result list(Dict dict, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = dictService.findPage(new Page(request, response), dict); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + @RequestMapping(value = {"list/json"},method ={RequestMethod.POST}) + @ApiOperation(value="数据字典获取列表(Content-Type为application/json)", notes="数据字典获取列表(Content-Type为application/json)") + @ApiImplicitParam(name = "dict", value = "数据字典", dataType = "Dict",paramType="body") + public Result listJson(@RequestBody Dict dict, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = dictService.findPage(new Page(request, response), dict); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/SysConfigRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/SysConfigRestController.java new file mode 100644 index 0000000..5afb205 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/SysConfigRestController.java @@ -0,0 +1,291 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.rest; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.sys.service.SysConfigService; +import org.springframework.web.bind.annotation.RestController; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +/** + * 系统配置Controller + * @author 黄炳桂 516821420@qq.com + * @version 2017-11-17 + */ +@RestController +@RequestMapping(value = "/rest/sys/sysConfig") +@Api(value="SysConfig系统配置接口", description="SysConfig系统配置接口") +public class SysConfigRestController extends AbstractBaseController { + + @Autowired + private SysConfigService sysConfigService; + + /** + * 系统配置信息 + */ + @RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="系统配置信息(Content-Type为text/html)", notes="系统配置信息(Content-Type为text/html)") + @ApiImplicitParam(name = "id", value = "系统配置id", required = false, dataType = "String",paramType="query") + public Result get(@RequestParam(required=false) String id) { + SysConfig entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysConfigService.get(id); + } + if (entity == null){ + entity = new SysConfig(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(entity); + return result; + } + + @RequestMapping(value = {"get/json"},method ={RequestMethod.POST}) + @ApiOperation(value="系统配置信息(Content-Type为application/json)", notes="系统配置信息(Content-Type为application/json)") + @ApiImplicitParam(name = "id", value = "系统配置id", required = false, dataType = "String",paramType="body") + public Result getJson(@RequestBody(required=false) String id) { + SysConfig entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysConfigService.get(id); + } + if (entity == null){ + entity = new SysConfig(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(entity); + return result; + } + + /** + * 系统配置列表(不包含页信息) + */ + //RequiresPermissions("sys:sysConfig:findList") + @RequestMapping(value = {"findList"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="系统配置列表(不包含页信息)(Content-Type为text/html)", notes="系统配置列表(不包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query") + public Result findList(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + List list = sysConfigService.findList(sysConfig); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(list); + return result; + } + + @RequestMapping(value = {"findList/json"},method ={RequestMethod.POST}) + @ApiOperation(value="系统配置列表(不包含页信息)(Content-Type为application/json)", notes="系统配置列表(不包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body") + public Result findListJson(@RequestBody SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + List list = sysConfigService.findList(sysConfig); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(list); + return result; + } + + /** + * 系统配置列表(包含页信息) + */ + //RequiresPermissions("sys:sysConfig:list") + @RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="系统配置列表(包含页信息)(Content-Type为text/html)", notes="系统配置列表(包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query") + public Result list(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysConfigService.findPage(new Page(request, response), sysConfig); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + @RequestMapping(value = {"list/json"},method ={RequestMethod.POST}) + @ApiOperation(value="系统配置列表(包含页信息)(Content-Type为application/json)", notes="系统配置列表(包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body") + public Result listJson(@RequestBody SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysConfigService.findPage(new Page(sysConfig.getPageNo(),sysConfig.getPageSize(),sysConfig.getOrderBy()), sysConfig); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + /** + * 系统配置获取列表第一条记录 + */ + //RequiresPermissions("sys:sysConfig:listFrist") + @RequestMapping(value = {"listFrist"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="系统配置获取列表第一条记录(Content-Type为text/html)", notes="系统配置获取列表第一条记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query") + public Result listFrist(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysConfigService.findPage(new Page(request, response), sysConfig); + Result result = ResultFactory.getSuccessResult(); + if(page.getList().size()>0){ + result.setResultObject(page.getList().get(0)); + }else{ + result=ResultFactory.getErrorResult("没有记录!"); + } + return result; + } + + @RequestMapping(value = {"listFrist/json"},method ={RequestMethod.POST}) + @ApiOperation(value="系统配置获取列表第一条记录(Content-Type为application/json)", notes="系统配置获取列表第一条记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body") + public Result listFristJson(@RequestBody SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysConfigService.findPage(new Page(sysConfig.getPageNo(),sysConfig.getPageSize(),sysConfig.getOrderBy()), sysConfig); + Result result = ResultFactory.getSuccessResult(); + if(page.getList().size()>0){ + result.setResultObject(page.getList().get(0)); + }else{ + result=ResultFactory.getErrorResult("没有记录!"); + } + return result; + } + + /** + * 保存系统配置 + */ + //RequiresPermissions(value={"sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR) + @RequestMapping(value = "save",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="保存系统配置(Content-Type为text/html)", notes="保存系统配置(Content-Type为text/html)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query") + public Result save(SysConfig sysConfig, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysConfig)){ + Result result = ResultFactory.getErrorResult("数据验证失败"); + } + sysConfigService.save(sysConfig); + Result result = ResultFactory.getSuccessResult("保存系统配置成功"); + return result; + } + + @RequestMapping(value = "save/json",method ={RequestMethod.POST}) + @ApiOperation(value="保存系统配置(Content-Type为application/json)", notes="保存系统配置(Content-Type为application/json)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body") + public Result saveJson(@RequestBody SysConfig sysConfig, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysConfig)){ + Result result = ResultFactory.getErrorResult("数据验证失败"); + } + sysConfigService.save(sysConfig); + Result result = ResultFactory.getSuccessResult("保存系统配置成功"); + return result; + } + + /** + * 删除系统配置 + */ + //RequiresPermissions("sys:sysConfig:del") + @RequestMapping(value = "delete",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="删除系统配置(Content-Type为text/html)", notes="删除系统配置(Content-Type为text/html)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query") + public Result delete(SysConfig sysConfig, RedirectAttributes redirectAttributes) { + sysConfigService.delete(sysConfig); + Result result = ResultFactory.getSuccessResult("删除系统配置成功"); + return result; + } + + /** + * 删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑删除系统配置(Content-Type为text/html)", notes="逻辑删除系统配置(Content-Type为text/html)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="query") + public Result deleteByLogic(SysConfig sysConfig, RedirectAttributes redirectAttributes) { + sysConfigService.deleteByLogic(sysConfig); + Result result = ResultFactory.getSuccessResult("删除系统配置成功"); + return result; + } + + @RequestMapping(value = "delete/json",method ={RequestMethod.POST}) + @ApiOperation(value="删除系统配置(Content-Type为application/json)", notes="删除系统配置(Content-Type为application/json)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body") + public Result deleteJson(@RequestBody SysConfig sysConfig, RedirectAttributes redirectAttributes) { + sysConfigService.delete(sysConfig); + Result result = ResultFactory.getSuccessResult("删除系统配置成功"); + return result; + } + + /** + * 删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑删除系统配置(Content-Type为application/json)", notes="逻辑删除系统配置(Content-Type为application/json)") + @ApiImplicitParam(name = "sysConfig", value = "系统配置", dataType = "SysConfig",paramType="body") + public Result deleteByLogicJson(@RequestBody SysConfig sysConfig, RedirectAttributes redirectAttributes) { + sysConfigService.deleteByLogic(sysConfig); + Result result = ResultFactory.getSuccessResult("删除系统配置成功"); + return result; + } + + /** + * 批量删除系统配置 + */ + //RequiresPermissions("sys:sysConfig:del") + @RequestMapping(value = "deleteAll",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="批量删除系统配置(Content-Type为text/html)", notes="批量删除系统配置(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "系统配置ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysConfigService.delete(sysConfigService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除系统配置成功"); + return result; + } + + /** + * 批量删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑批量删除系统配置(Content-Type为text/html)", notes="逻辑批量删除系统配置(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "系统配置ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysConfigService.deleteByLogic(sysConfigService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除系统配置成功"); + return result; + } + + @RequestMapping(value = "deleteAll/json",method ={RequestMethod.POST}) + @ApiOperation(value="批量删除系统配置(Content-Type为application/json)", notes="批量删除系统配置(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "系统配置ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllJson(@RequestBody String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysConfigService.delete(sysConfigService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除系统配置成功"); + return result; + } + + /** + * 批量删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑批量删除系统配置(Content-Type为application/json)", notes="逻辑批量删除系统配置(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "系统配置ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllByLogicJson(@RequestBody String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysConfigService.deleteByLogic(sysConfigService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除系统配置成功"); + return result; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/SysUserOnlineRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/SysUserOnlineRestController.java new file mode 100644 index 0000000..591443d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/rest/SysUserOnlineRestController.java @@ -0,0 +1,301 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.rest; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.sys.entity.SysUserOnline; +import com.jeespring.modules.sys.service.SysUserOnlineService; +import org.springframework.web.bind.annotation.RestController; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +/** + * 在线用户记录Controller + * @author JeeSpring + * @version 2018-08-16 + */ +@RestController +@RequestMapping(value = "/rest/sys/sysUserOnline") +@Api(value="在线用户记录接口", description="在线用户记录接口") +public class SysUserOnlineRestController extends AbstractBaseController { + + @Autowired + private SysUserOnlineService sysUserOnlineService; + + /** + * 在线用户记录信息 + */ + @RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="在线用户记录信息(Content-Type为text/html)", notes="在线用户记录信息(Content-Type为text/html)") + @ApiImplicitParam(name = "id", value = "在线用户记录id", required = false, dataType = "String",paramType="query") + public Result getRequestParam(@RequestParam(required=false) String id) { + return get(id); + } + + @RequestMapping(value = {"get/json"},method ={RequestMethod.POST}) + @ApiOperation(value="在线用户记录信息(Content-Type为application/json)", notes="在线用户记录信息(Content-Type为application/json)") + @ApiImplicitParam(name = "id", value = "在线用户记录id", required = false, dataType = "String",paramType="body") + public Result getRequestBody(@RequestBody(required=false) String id) { + return get(id); + } + + private Result get(String id) { + SysUserOnline entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysUserOnlineService.getCache(id); + //entity = sysUserOnlineService.get(id); + } + if (entity == null){ + entity = new SysUserOnline(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(entity); + return result; + } + + /** + * 在线用户记录列表(不包含页信息) + */ + //RequiresPermissions("sys:sysUserOnline:findList") + @RequestMapping(value = {"findList"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="在线用户记录列表(不包含页信息)(Content-Type为text/html)", notes="在线用户记录列表(不包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query") + public Result findListRequestParam(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + return findList( sysUserOnline,model); + } + + @RequestMapping(value = {"findList/json"},method ={RequestMethod.POST}) + @ApiOperation(value="在线用户记录列表(不包含页信息)(Content-Type为application/json)", notes="在线用户记录列表(不包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body") + public Result findListRequestBody(@RequestBody SysUserOnline sysUserOnline, Model model) { + return findList( sysUserOnline,model); + } + + private Result findList(SysUserOnline sysUserOnline, Model model) { + List list = sysUserOnlineService.findListCache(sysUserOnline); + //List list = sysUserOnlineService.findList(sysUserOnline); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(list); + return result; + } + + /** + * 在线用户记录列表(包含页信息) + */ + //RequiresPermissions("sys:sysUserOnline:list") + @RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="在线用户记录列表(包含页信息)(Content-Type为text/html)", notes="在线用户记录列表(包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query") + public Result listRequestParam(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + return list(sysUserOnline,model); + } + + @RequestMapping(value = {"list/json"},method ={RequestMethod.POST}) + @ApiOperation(value="在线用户记录列表(包含页信息)(Content-Type为application/json)", notes="在线用户记录列表(包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body") + public Result listRequestBody(@RequestBody SysUserOnline sysUserOnline, Model model) { + return list(sysUserOnline,model); + } + + private Result list(SysUserOnline sysUserOnline, Model model) { + Page page = sysUserOnlineService.findPageCache(new Page(sysUserOnline.getPageNo(),sysUserOnline.getPageSize(),sysUserOnline.getOrderBy()), sysUserOnline); + //Page page = sysUserOnlineService.findPage(new Page(sysUserOnline.getPageNo(),sysUserOnline.getPageSize(),sysUserOnline.getOrderBy()), sysUserOnline); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + /** + * 在线用户记录获取列表第一条记录 + */ + //RequiresPermissions("sys:sysUserOnline:listFrist") + @RequestMapping(value = {"listFrist"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="在线用户记录获取列表第一条记录(Content-Type为text/html)", notes="在线用户记录获取列表第一条记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query") + public Result listFristRequestParam(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + return listFrist(sysUserOnline,model); + } + + @RequestMapping(value = {"listFrist/json"},method ={RequestMethod.POST}) + @ApiOperation(value="在线用户记录获取列表第一条记录(Content-Type为application/json)", notes="在线用户记录获取列表第一条记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body") + public Result listFristRequestBody(@RequestBody SysUserOnline sysUserOnline, Model model) { + return listFrist(sysUserOnline,model); + } + + private Result listFrist(SysUserOnline sysUserOnline, Model model) { + Page page = sysUserOnlineService.findPageCache(new Page(sysUserOnline.getPageNo(),sysUserOnline.getPageSize(),sysUserOnline.getOrderBy()), sysUserOnline); + //Page page = sysUserOnlineService.findPage(new Page(sysUserOnline.getPageNo(),sysUserOnline.getPageSize(),sysUserOnline.getOrderBy()), sysUserOnline); + Result result = ResultFactory.getSuccessResult(); + if(page.getList().size()>0){ + result.setResultObject(page.getList().get(0)); + }else{ + result=ResultFactory.getErrorResult("没有记录!"); + } + return result; + } + + /** + * 保存在线用户记录 + */ + //RequiresPermissions(value={"sys:sysUserOnline:add","sys:sysUserOnline:edit"},logical=Logical.OR) + @RequestMapping(value = "save",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="保存在线用户记录(Content-Type为text/html)", notes="保存在线用户记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query") + public Result saveRequestParam(SysUserOnline sysUserOnline, Model model, RedirectAttributes redirectAttributes) { + return save(sysUserOnline,model,redirectAttributes); + } + + @RequestMapping(value = "save/json",method ={RequestMethod.POST}) + @ApiOperation(value="保存在线用户记录(Content-Type为application/json)", notes="保存在线用户记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body") + public Result saveRequestBody(@RequestBody SysUserOnline sysUserOnline, Model model, RedirectAttributes redirectAttributes) { + return save(sysUserOnline,model,redirectAttributes); + } + + private Result save(SysUserOnline sysUserOnline, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysUserOnline)){ + Result result = ResultFactory.getErrorResult("数据验证失败"); + } + sysUserOnlineService.save(sysUserOnline); + Result result = ResultFactory.getSuccessResult("保存在线用户记录成功"); + return result; + } + + /** + * 删除在线用户记录 + */ + //RequiresPermissions("sys:sysUserOnline:del") + @RequestMapping(value = "delete",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="删除在线用户记录(Content-Type为text/html)", notes="删除在线用户记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query") + public Result deleteRequestParam(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) { + return delete(sysUserOnline,redirectAttributes); + } + + @RequestMapping(value = "delete/json",method ={RequestMethod.POST}) + @ApiOperation(value="删除在线用户记录(Content-Type为application/json)", notes="删除在线用户记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body") + public Result deleteRequestBody(@RequestBody SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) { + return delete(sysUserOnline,redirectAttributes); + } + + private Result delete(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) { + sysUserOnlineService.delete(sysUserOnline); + Result result = ResultFactory.getSuccessResult("删除在线用户记录成功"); + return result; + } + + /** + * 删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑删除在线用户记录(Content-Type为text/html)", notes="逻辑删除在线用户记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="query") + public Result deleteByLogicRequestParam(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) { + return deleteByLogic(sysUserOnline,redirectAttributes); + } + + /** + * 删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑删除在线用户记录(Content-Type为application/json)", notes="逻辑删除在线用户记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserOnline", value = "在线用户记录", dataType = "SysUserOnline",paramType="body") + public Result deleteByLogicRequestBody(@RequestBody SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) { + return deleteByLogic(sysUserOnline,redirectAttributes); + } + + private Result deleteByLogic(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) { + sysUserOnlineService.deleteByLogic(sysUserOnline); + Result result = ResultFactory.getSuccessResult("删除在线用户记录成功"); + return result; + } + + /** + * 批量删除在线用户记录 + */ + //RequiresPermissions("sys:sysUserOnline:del") + @RequestMapping(value = "deleteAll",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="批量删除在线用户记录(Content-Type为text/html)", notes="批量删除在线用户记录(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "在线用户记录ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllRequestParam(String ids, RedirectAttributes redirectAttributes) { + return deleteAll(ids,redirectAttributes); + } + + @RequestMapping(value = "deleteAll/json",method ={RequestMethod.POST}) + @ApiOperation(value="批量删除在线用户记录(Content-Type为application/json)", notes="批量删除在线用户记录(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "在线用户记录ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) { + return deleteAll(ids,redirectAttributes); + } + + private Result deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserOnlineService.delete(sysUserOnlineService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除在线用户记录成功"); + return result; + } + + /** + * 批量删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑批量删除在线用户记录(Content-Type为text/html)", notes="逻辑批量删除在线用户记录(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "在线用户记录ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllByLogicRequestParam(String ids, RedirectAttributes redirectAttributes) { + return deleteAllByLogic(ids,redirectAttributes); + } + + /** + * 批量删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑批量删除在线用户记录(Content-Type为application/json)", notes="逻辑批量删除在线用户记录(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "在线用户记录ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllByLogicRequestBody(@RequestBody String ids, RedirectAttributes redirectAttributes) { + return deleteAllByLogic(ids,redirectAttributes); + } + + private Result deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserOnlineService.deleteByLogic(sysUserOnlineService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除在线用户记录成功"); + return result; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/FormAuthenticationFilter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/FormAuthenticationFilter.java new file mode 100644 index 0000000..9330867 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/FormAuthenticationFilter.java @@ -0,0 +1,111 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.modules.sys.security; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; + +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.authc.IncorrectCredentialsException; +import org.apache.shiro.authc.UnknownAccountException; +import org.apache.shiro.web.util.WebUtils; +import org.springframework.stereotype.Service; + +import com.jeespring.common.utils.StringUtils; + +/** + * 表单验证(包含验证码)过滤类 + * @author 黄炳桂 516821420@qq.com + * @version 2014-5-19 + */ +@Service +public class FormAuthenticationFilter extends org.apache.shiro.web.filter.authc.FormAuthenticationFilter { + + public static final String DEFAULT_CAPTCHA_PARAM = "validateCode"; + public static final String DEFAULT_MOBILE_PARAM = "mobileLogin"; + public static final String DEFAULT_MESSAGE_PARAM = "message"; + + private String captchaParam = DEFAULT_CAPTCHA_PARAM; + private String mobileLoginParam = DEFAULT_MOBILE_PARAM; + private String messageParam = DEFAULT_MESSAGE_PARAM; + + @Override + protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) { + String username = getUsername(request); + String password = getPassword(request); + if (password==null){ + password = ""; + } + boolean rememberMe = isRememberMe(request); + String host = StringUtils.getRemoteAddr((HttpServletRequest)request); + String captcha = getCaptcha(request); + boolean mobile = isMobileLogin(request); + return new UsernamePasswordToken(username, password.toCharArray(), rememberMe, host, captcha, mobile); + } + + public String getCaptchaParam() { + return captchaParam; + } + + protected String getCaptcha(ServletRequest request) { + return WebUtils.getCleanParam(request, getCaptchaParam()); + } + + public String getMobileLoginParam() { + return mobileLoginParam; + } + + protected boolean isMobileLogin(ServletRequest request) { + return WebUtils.isTrue(request, getMobileLoginParam()); + } + + public String getMessageParam() { + return messageParam; + } + + /** + * 登录成功之后跳转URL + */ + @Override + public String getSuccessUrl() { + return super.getSuccessUrl(); + } + + @Override + protected void issueSuccessRedirect(ServletRequest request, + ServletResponse response) throws Exception { +// Principal p = UserUtils.getPrincipal(); +// if (p != null && !p.isMobileLogin()){ + WebUtils.issueRedirect(request, response, getSuccessUrl(), null, true); +// }else{ +// super.issueSuccessRedirect(request, response); +// } + } + + /** + * 登录失败调用事件 + */ + @Override + protected boolean onLoginFailure(AuthenticationToken token, + AuthenticationException e, ServletRequest request, ServletResponse response) { + String className = e.getClass().getName(), message = ""; + if (IncorrectCredentialsException.class.getName().equals(className) + || UnknownAccountException.class.getName().equals(className)){ + message = "用户或密码错误, 请重试."; + } + else if (e.getMessage() != null && StringUtils.startsWith(e.getMessage(), "msg:")){ + message = StringUtils.replace(e.getMessage(), "msg:", ""); + } + else{ + message = "系统出现点问题,请稍后再试!"; + e.printStackTrace(); // 输出到控制台 + } + request.setAttribute(getFailureKeyAttribute(), className); + request.setAttribute(getMessageParam(), message); + return true; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/SystemAuthorizingRealm.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/SystemAuthorizingRealm.java new file mode 100644 index 0000000..4884c09 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/SystemAuthorizingRealm.java @@ -0,0 +1,268 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.modules.sys.security; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.AuthenticationInfo; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.authc.SimpleAuthenticationInfo; +import org.apache.shiro.authc.credential.HashedCredentialsMatcher; +import org.apache.shiro.authz.AuthorizationInfo; +import org.apache.shiro.authz.Permission; +import org.apache.shiro.authz.SimpleAuthorizationInfo; +import org.apache.shiro.realm.AuthorizingRealm; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.PrincipalCollection; +import org.apache.shiro.util.ByteSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import com.jeespring.common.config.Global; +import com.jeespring.common.servlet.ValidateCodeServlet; +import com.jeespring.common.utils.Encodes; +import com.jeespring.common.utils.SpringContextHolder; +import com.jeespring.common.web.Servlets; +import com.jeespring.modules.sys.entity.Menu; +import com.jeespring.modules.sys.entity.Role; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SystemService; +import com.jeespring.modules.sys.utils.LogUtils; +import com.jeespring.modules.sys.utils.UserUtils; +import com.jeespring.modules.sys.web.LoginController; + +/** + * 系统安全认证实现类 + * @author 黄炳桂 516821420@qq.com + * @version 2014-7-5 + */ +@Service +//@DependsOn({"userDao","roleDao","menuDao"}) +public class SystemAuthorizingRealm extends AuthorizingRealm { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + private SystemService systemService; + + /** + * 认证回调函数, 登录时调用 + */ + @Override + protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) { + UsernamePasswordToken token = (UsernamePasswordToken) authcToken; + + int activeSessionSize = getSystemService().getSessionDao().getActiveSessions(false).size(); + if (logger.isDebugEnabled()){ + logger.debug("login submit, active session size: {}, username: {}", activeSessionSize, token.getUsername()); + } + + // 校验登录验证码 + if (LoginController.isValidateCodeLogin(token.getUsername(), false, false)){ + Session session = UserUtils.getSession(); + String code = (String)session.getAttribute(ValidateCodeServlet.VALIDATE_CODE); + if (token.getCaptcha() == null || !token.getCaptcha().toUpperCase().equals(code)){ + //throw new AuthenticationException("msg:验证码错误, 请重试."); + } + } + + // 校验用户名密码 + User user = getSystemService().getUserByLoginName(token.getUsername()); + if (user != null) { + if (Global.NO.equals(user.getLoginFlag())){ + throw new AuthenticationException("msg:该帐号已禁止登录."); + } + byte[] salt = Encodes.decodeHex(user.getPassword().substring(0,16)); + return new SimpleAuthenticationInfo(new Principal(user, token.isMobileLogin()), + user.getPassword().substring(16), ByteSource.Util.bytes(salt), getName()); + } else { + return null; + } + } + + /** + * 授权查询回调函数, 进行鉴权但缓存中无用户的授权信息时调用 + */ + @Override + protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { + Principal principal = (Principal) getAvailablePrincipal(principals); + User user = getSystemService().getUserByLoginName(principal.getLoginName()); + if (user != null) { + SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(); + List list = UserUtils.getMenuList(); + for (Menu menu : list){ + if (StringUtils.isNotBlank(menu.getPermission())){ + // 添加基于Permission的权限信息 + for (String permission : StringUtils.split(menu.getPermission(),",")){ + info.addStringPermission(permission); + } + } + } + // 添加用户权限 + info.addStringPermission("user"); + // 添加用户角色信息 + for (Role role : user.getRoleList()){ + info.addRole(role.getEnname()); + } + // 更新登录IP和时间 + getSystemService().updateUserLoginInfo(user); + // 记录登录日志 + LogUtils.saveLog(Servlets.getRequest(), "系统登录"); + return info; + } else { + return null; + } + } + + @Override + protected void checkPermission(Permission permission, AuthorizationInfo info) { + authorizationValidate(permission); + super.checkPermission(permission, info); + } + + @Override + protected boolean[] isPermitted(List permissions, AuthorizationInfo info) { + if (permissions != null && !permissions.isEmpty()) { + for (Permission permission : permissions) { + authorizationValidate(permission); + } + } + return super.isPermitted(permissions, info); + } + + @Override + public boolean isPermitted(PrincipalCollection principals, Permission permission) { + authorizationValidate(permission); + return super.isPermitted(principals, permission); + } + + @Override + protected boolean isPermittedAll(Collection permissions, AuthorizationInfo info) { + if (permissions != null && !permissions.isEmpty()) { + for (Permission permission : permissions) { + authorizationValidate(permission); + } + } + return super.isPermittedAll(permissions, info); + } + + /** + * 授权验证方法 + * @param permission + */ + private void authorizationValidate(Permission permission){ + // 模块授权预留接口 + } + + /** + * 设定密码校验的Hash算法与迭代次数 + */ + @PostConstruct + public void initCredentialsMatcher() { + HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(SystemService.HASH_ALGORITHM); + matcher.setHashIterations(SystemService.HASH_INTERATIONS); + setCredentialsMatcher(matcher); + } + +// /** +// * 清空用户关联权限认证,待下次使用时重新加载 +// */ +// public void clearCachedAuthorizationInfo(Principal principal) { +// SimplePrincipalCollection principals = new SimplePrincipalCollection(principal, getName()); +// clearCachedAuthorizationInfo(principals); +// } + + /** + * 清空所有关联认证 + * @Deprecated 不需要清空,授权缓存保存到session中 + */ + @Deprecated + public void clearAllCachedAuthorizationInfo() { +// Cache cache = getAuthorizationCache(); +// if (cache != null) { +// for (Object key : cache.keys()) { +// cache.remove(key); +// } +// } + } + + /** + * 获取系统业务对象 + */ + public SystemService getSystemService() { + if (systemService == null){ + systemService = SpringContextHolder.getBean(SystemService.class); + } + return systemService; + } + + /** + * 授权用户信息 + */ + public static class Principal implements Serializable { + + private static final long serialVersionUID = 1L; + + private String id; // 编号 + private String loginName; // 登录名 + private String name; // 姓名 + private boolean mobileLogin; // 是否手机登录 + +// private Map cacheMap; + + public Principal(User user, boolean mobileLogin) { + this.id = user.getId(); + this.loginName = user.getLoginName(); + this.name = user.getName(); + this.mobileLogin = mobileLogin; + } + + public String getId() { + return id; + } + + public String getLoginName() { + return loginName; + } + + public String getName() { + return name; + } + + public boolean isMobileLogin() { + return mobileLogin; + } + +// @JsonIgnore +// public Map getCacheMap() { +// if (cacheMap==null){ +// cacheMap = new HashMap(); +// } +// return cacheMap; +// } + + /** + * 获取SESSIONID + */ + public String getSessionid() { + try{ + return (String) UserUtils.getSession().getId(); + }catch (Exception e) { + return ""; + } + } + + @Override + public String toString() { + return id; + } + + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/UsernamePasswordToken.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/UsernamePasswordToken.java new file mode 100644 index 0000000..4b66d31 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/security/UsernamePasswordToken.java @@ -0,0 +1,41 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.modules.sys.security; + +/** + * 用户和密码(包含验证码)令牌类 + * @author 黄炳桂 516821420@qq.com + * @version 2013-5-19 + */ +public class UsernamePasswordToken extends org.apache.shiro.authc.UsernamePasswordToken { + + private static final long serialVersionUID = 1L; + + private String captcha; + private boolean mobileLogin; + + public UsernamePasswordToken() { + super(); + } + + public UsernamePasswordToken(String username, char[] password, + boolean rememberMe, String host, String captcha, boolean mobileLogin) { + super(username, password, rememberMe, host); + this.captcha = captcha; + this.mobileLogin = mobileLogin; + } + + public String getCaptcha() { + return captcha; + } + + public void setCaptcha(String captcha) { + this.captcha = captcha; + } + + public boolean isMobileLogin() { + return mobileLogin; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/AreaService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/AreaService.java new file mode 100644 index 0000000..98c3ae4 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/AreaService.java @@ -0,0 +1,43 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.service.TreeService; +import com.jeespring.modules.sys.dao.AreaDao; +import com.jeespring.modules.sys.entity.Area; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 区域Service + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Service +@Transactional(readOnly = true) +public class AreaService extends TreeService { + + public List findAll(){ + return UserUtils.getAreaList(); + } + + @Override + @Transactional(readOnly = false) + public void save(Area area) { + super.save(area); + UserUtils.removeCache(UserUtils.CACHE_AREA_LIST); + } + + @Override + @Transactional(readOnly = false) + public void delete(Area area) { + super.delete(area); + UserUtils.removeCache(UserUtils.CACHE_AREA_LIST); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/DictService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/DictService.java new file mode 100644 index 0000000..fb91fd2 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/DictService.java @@ -0,0 +1,48 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.utils.CacheUtils; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.sys.dao.DictDao; +import com.jeespring.modules.sys.entity.Dict; +import com.jeespring.modules.sys.utils.DictUtils; + +/** + * 字典Service + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Service +@Transactional(readOnly = true) +public class DictService extends AbstractBaseService { + + /** + * 查询字段类型列表 + * @return + */ + public List findTypeList(){ + return dao.findTypeList(new Dict()); + } + + @Override + @Transactional(readOnly = false) + public void save(Dict dict) { + super.save(dict); + CacheUtils.remove(DictUtils.CACHE_DICT_MAP); + } + + @Override + @Transactional(readOnly = false) + public void delete(Dict dict) { + super.delete(dict); + CacheUtils.remove(DictUtils.CACHE_DICT_MAP); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/LogService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/LogService.java new file mode 100644 index 0000000..8bd6e35 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/LogService.java @@ -0,0 +1,53 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.modules.sys.dao.LogDao; +import com.jeespring.modules.sys.entity.Log; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.common.utils.DateUtils; + +/** + * 日志Service + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Service +@Transactional(readOnly = true) +public class LogService extends AbstractBaseService { + + @Autowired + private LogDao logDao; + + @Override + public Page findPage(Page page, Log log) { + + // 设置默认时间范围,默认当前月 + if (log.getBeginDate() == null){ + log.setBeginDate(DateUtils.setDays(DateUtils.parseDate(DateUtils.getDate()), 1)); + } + if (log.getEndDate() == null){ + log.setEndDate(DateUtils.addMonths(log.getBeginDate(), 1)); + } + + return super.findPage(page, log); + + } + + /** + * 删除全部数据 + * @param entity + */ + @Transactional(readOnly = false) + public void empty(){ + + logDao.empty(); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/OfficeService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/OfficeService.java new file mode 100644 index 0000000..674d81e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/OfficeService.java @@ -0,0 +1,64 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.service.TreeService; +import com.jeespring.modules.sys.dao.OfficeDao; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 机构Service + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Service +@Transactional(readOnly = true) +public class OfficeService extends TreeService { + + public List findAll(){ + return UserUtils.getOfficeList(); + } + + public List findList(Boolean isAll){ + if (isAll != null && isAll){ + return UserUtils.getOfficeAllList(); + }else{ + return UserUtils.getOfficeList(); + } + } + + @Override + @Transactional(readOnly = true) + public List findList(Office office){ + office.setParentIds(office.getParentIds()+"%"); + return dao.findByParentIdsLike(office); + } + + @Transactional(readOnly = true) + public Office getByCode(String code){ + return dao.getByCode(code); + } + + + @Override + @Transactional(readOnly = false) + public void save(Office office) { + super.save(office); + UserUtils.removeCache(UserUtils.CACHE_OFFICE_LIST); + } + + @Override + @Transactional(readOnly = false) + public void delete(Office office) { + super.delete(office); + UserUtils.removeCache(UserUtils.CACHE_OFFICE_LIST); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysConfigService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysConfigService.java new file mode 100644 index 0000000..19b52ee --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysConfigService.java @@ -0,0 +1,171 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import java.util.List; + +import com.jeespring.common.config.Global; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.sys.dao.SysConfigDao; +import com.alibaba.fastjson.JSON; +import com.jeespring.common.redis.RedisUtils; + +/** + * 系统配置Service + * @author 黄炳桂 516821420@qq.com + * @version 2017-11-17 + */ +@Service +@Transactional(readOnly = true) +public class SysConfigService extends AbstractBaseService { + + /** + * redis caches + */ + @Autowired + private RedisUtils redisUtils; + + @Override + public SysConfig get(String id) { + //获取缓存数据 + SysConfig sysConfig=(SysConfig)redisUtils.get(RedisUtils.getIdKey(SysConfigService.class.getName(),id)); + if( sysConfig!=null) { + return sysConfig; + } + //获取数据库数据 + sysConfig=super.get(id); + //设置缓存数据 + redisUtils.set(RedisUtils.getIdKey(SysConfigService.class.getName(),id),sysConfig); + return sysConfig; + } + + public SysConfig findListFirst(SysConfig sysConfig) {; + //获取数据库数据 + List sysConfigList=super.findList(sysConfig); + if(sysConfigList.size()>0) { + sysConfig = sysConfigList.get(0); + } + return sysConfig; + } + + public SysConfig findListFirstCache(SysConfig sysConfig) { + //获取缓存数据 + String findListFirstKey = RedisUtils.getFindListFirstKey(SysConfigService.class.getName(),JSON.toJSONString(sysConfig)); + SysConfig sysConfigRedis=(SysConfig)redisUtils.get(findListFirstKey); + if(sysConfigRedis!=null) { + return sysConfigRedis; + } + //获取数据库数据 + List tfTicketList=super.findList(sysConfig); + if(tfTicketList.size()>0) { + sysConfig = tfTicketList.get(0); + } else { + sysConfig = new SysConfig(); + } + //设置缓存数据 + redisUtils.set(findListFirstKey,sysConfig); + return sysConfig; + } + + @Override + public List findList(SysConfig sysConfig) { + //获取缓存数据 + String findListKey = RedisUtils.getFindListKey(SysConfigService.class.getName(),JSON.toJSONString(sysConfig)); + List sysConfigList=(List)redisUtils.get(findListKey); + if(sysConfigList!=null) { + return sysConfigList; + } + //获取数据库数据 + sysConfigList=super.findList(sysConfig); + //设置缓存数据 + redisUtils.set(findListKey,sysConfigList); + return sysConfigList; + } + + @Override + public Page findPage(Page page, SysConfig sysConfig) { + //获取缓存数据 + String findPageKey = RedisUtils.getFindPageKey(SysConfigService.class.getName(),JSON.toJSONString(page)+JSON.toJSONString(sysConfig)); + Page pageReuslt=(Page)redisUtils.get(findPageKey); + if(pageReuslt!=null) { + return pageReuslt; + } + //获取数据库数据 + pageReuslt=super.findPage(page, sysConfig); + //设置缓存数据 + redisUtils.set(findPageKey,pageReuslt); + return pageReuslt; + } + + @Override + @Transactional(readOnly = false) + public void save(SysConfig sysConfig) { + //保存数据库记录 + super.save(sysConfig); + //设置清除缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysConfigService.class.getName(),sysConfig.getId())); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysConfigService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysConfigService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void delete(SysConfig sysConfig) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysConfigService.class.getName(),sysConfig.getId())); + //删除数据库记录 + super.delete(sysConfig); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysConfigService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysConfigService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void deleteByLogic(SysConfig sysConfig) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysConfigService.class.getName(),sysConfig.getId())); + //逻辑删除数据库记录 + super.deleteByLogic(sysConfig); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysConfigService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysConfigService.class.getName())); + } + + /** + * 是否是演示模式,演示模式下不能修改用户、角色、密码、菜单、授权 + */ + public Boolean isDemoMode() { + SysConfig sysConfig=new SysConfig(); + sysConfig.setType("demoMode"); + sysConfig=this.findListFirstCache(sysConfig); + if("true".equals(sysConfig.getValue()) && Global.isDemoMode()) { + return true; + } + return false; + } + + public String isDemoModeDescription() { + SysConfig sysConfig=new SysConfig(); + sysConfig.setType("demoMode"); + sysConfig=this.findListFirstCache(sysConfig); + if(sysConfig==null) { + return Global.isDemoModeDescription(); + } + return sysConfig.getDescription(); + } + public String systemMode(){ + if(this.isDemoMode()) { + return "演示版"; + } + return "正式版"; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysConfigTreeService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysConfigTreeService.java new file mode 100644 index 0000000..acd598d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysConfigTreeService.java @@ -0,0 +1,50 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.service.TreeService; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.sys.entity.SysConfigTree; +import com.jeespring.modules.sys.dao.SysConfigTreeDao; + +/** + * 系统配置Service + * @author JeeSpring + * @version 2018-08-22 + */ +@Service +@Transactional(readOnly = true) +public class SysConfigTreeService extends TreeService { + + @Override + public SysConfigTree get(String id) { + return super.get(id); + } + + @Override + public List findList(SysConfigTree sysConfig) { + if (StringUtils.isNotBlank(sysConfig.getParentIds())){ + sysConfig.setParentIds(","+sysConfig.getParentIds()+","); + } + return super.findList(sysConfig); + } + + @Override + @Transactional(readOnly = false) + public void save(SysConfigTree sysConfig) { + super.save(sysConfig); + } + + @Override + @Transactional(readOnly = false) + public void delete(SysConfigTree sysConfig) { + super.delete(sysConfig); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysDictTreeService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysDictTreeService.java new file mode 100644 index 0000000..5292540 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysDictTreeService.java @@ -0,0 +1,50 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.service.TreeService; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.sys.entity.SysDictTree; +import com.jeespring.modules.sys.dao.SysDictTreeDao; + +/** + * 数据字典Service + * @author JeeSpring + * @version 2018-08-22 + */ +@Service +@Transactional(readOnly = true) +public class SysDictTreeService extends TreeService { + + @Override + public SysDictTree get(String id) { + return super.get(id); + } + + @Override + public List findList(SysDictTree sysDict) { + if (StringUtils.isNotBlank(sysDict.getParentIds())){ + sysDict.setParentIds(","+sysDict.getParentIds()+","); + } + return super.findList(sysDict); + } + + @Override + @Transactional(readOnly = false) + public void save(SysDictTree sysDict) { + super.save(sysDict); + } + + @Override + @Transactional(readOnly = false) + public void delete(SysDictTree sysDict) { + super.delete(sysDict); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysUserOnlineService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysUserOnlineService.java new file mode 100644 index 0000000..0626c6e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SysUserOnlineService.java @@ -0,0 +1,271 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import java.util.Date; +import java.util.List; + +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.monitor.entity.OnlineSession; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.utils.UserUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.sys.entity.SysUserOnline; +import com.jeespring.modules.sys.dao.SysUserOnlineDao; +import com.alibaba.fastjson.JSON; +import com.jeespring.common.redis.RedisUtils; +import com.jeespring.common.security.MD5Tools; + +/** + * 在线用户记录Service + * @author JeeSpring + * @version 2018-08-16 + */ +@Service +@Transactional(readOnly = true) +public class SysUserOnlineService extends AbstractBaseService { + + /** + * redis caches + */ + @Autowired + private RedisUtils redisUtils; + + @Value("${spring.redis.run}") + String redisRun; + /** + * 同步session到数据库的周期 单位为毫秒(默认1分钟) + */ + @Value("${shiro.session.dbSyncPeriod}") + private int dbSyncPeriod=1; + /** + * 上次同步数据库的时间戳 + */ + private static final String LAST_SYNC_DB_TIMESTAMP = SysUserOnlineService.class.getName() + "LAST_SYNC_DB_TIMESTAMP"; + + @Override + public SysUserOnline get(String id) { + //获取数据库数据 + SysUserOnline sysUserOnline=super.get(id); + return sysUserOnline; + } + + public SysUserOnline getCache(String id) { + //获取缓存数据 + SysUserOnline sysUserOnline=(SysUserOnline)redisUtils.get(RedisUtils.getIdKey(SysUserOnlineService.class.getName(),id)); + if( sysUserOnline!=null) { + return sysUserOnline; + } + //获取数据库数据 + sysUserOnline=super.get(id); + //设置缓存数据 + redisUtils.set(RedisUtils.getIdKey(SysUserOnlineService.class.getName(),id),sysUserOnline); + return sysUserOnline; + } + + @Override + public List total(SysUserOnline sysUserOnline) { + //获取数据库数据 + List sysUserOnlineList=super.total(sysUserOnline); + return sysUserOnlineList; + } + + public List totalCache(SysUserOnline sysUserOnline) { + //获取缓存数据 + String totalKey = RedisUtils.getTotalKey(SysUserOnlineService.class.getName(),JSON.toJSONString(sysUserOnline)); + List sysUserOnlineList=(List)redisUtils.get(totalKey); + if(sysUserOnlineList!=null) { + return sysUserOnlineList; + } + //获取数据库数据 + sysUserOnlineList=super.total(sysUserOnline); + //设置缓存数据 + redisUtils.set(totalKey,sysUserOnlineList); + return sysUserOnlineList; + } + + @Override + public List findList(SysUserOnline sysUserOnline) { + //获取数据库数据 + List sysUserOnlineList=super.findList(sysUserOnline); + //设置缓存数据 + return sysUserOnlineList; + } + + public List findListCache(SysUserOnline sysUserOnline) { + //获取缓存数据 + String findListKey = RedisUtils.getFindListKey(SysUserOnlineService.class.getName(),JSON.toJSONString(sysUserOnline)); + List sysUserOnlineList=(List)redisUtils.get(findListKey); + if(sysUserOnlineList!=null) { + return sysUserOnlineList; + } + //获取数据库数据 + sysUserOnlineList=super.findList(sysUserOnline); + //设置缓存数据 + redisUtils.set(findListKey,sysUserOnlineList); + return sysUserOnlineList; + } + + public SysUserOnline findListFirst(SysUserOnline sysUserOnline) {; + //获取数据库数据 + List sysUserOnlineList=super.findList(sysUserOnline); + if(sysUserOnlineList.size()>0) { + sysUserOnline = sysUserOnlineList.get(0); + } + return sysUserOnline; + } + + public SysUserOnline findListFirstCache(SysUserOnline sysUserOnline) { + //获取缓存数据 + String findListFirstKey = RedisUtils.getFindListFirstKey(SysUserOnlineService.class.getName(),JSON.toJSONString(sysUserOnline)); + SysUserOnline sysUserOnlineRedis=(SysUserOnline)redisUtils.get(findListFirstKey); + if(sysUserOnlineRedis!=null) { + return sysUserOnlineRedis; + } + //获取数据库数据 + List sysUserOnlineList=super.findList(sysUserOnline); + if(sysUserOnlineList.size()>0) { + sysUserOnline = sysUserOnlineList.get(0); + } else { + sysUserOnline = new SysUserOnline(); + } + //设置缓存数据 + redisUtils.set(findListFirstKey,sysUserOnline); + return sysUserOnline; + } + + @Override + public Page findPage(Page page, SysUserOnline sysUserOnline) { + //获取数据库数据 + Page pageReuslt=super.findPage(page, sysUserOnline); + return pageReuslt; + } + + @Transactional(readOnly = false) + public Page findPageCache(Page page, SysUserOnline sysUserOnline) { + //获取缓存数据 + String findPageKey = RedisUtils.getFindPageKey(SysUserOnlineService.class.getName(),JSON.toJSONString(page)+JSON.toJSONString(sysUserOnline)); + Page pageReuslt=(Page)redisUtils.get(findPageKey); + if(pageReuslt!=null) { + return pageReuslt; + } + //获取数据库数据 + pageReuslt=super.findPage(page, sysUserOnline); + + for (SysUserOnline item: pageReuslt.getList()) { + if("true".equals(redisRun)){ + try{ + if(!redisUtils.exists(RedisUtils.SHIRO_REDIS+":"+item.getId())){ + item.setStatus(OnlineSession.OnlineStatus.off_line.toString()); + super.save(item); + } + }catch (Exception e){} + } + } + //设置缓存数据 + redisUtils.set(findPageKey,pageReuslt); + return pageReuslt; + } + + @Override + @Transactional(readOnly = false) + public void save(SysUserOnline sysUserOnline) { + //保存数据库记录 + super.save(sysUserOnline); + //设置清除缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysUserOnlineService.class.getName(),sysUserOnline.getId())); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysUserOnlineService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysUserOnlineService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void delete(SysUserOnline sysUserOnline) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysUserOnlineService.class.getName(),sysUserOnline.getId())); + //删除数据库记录 + super.delete(sysUserOnline); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysUserOnlineService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysUserOnlineService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void deleteByLogic(SysUserOnline sysUserOnline) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysUserOnlineService.class.getName(),sysUserOnline.getId())); + //逻辑删除数据库记录 + super.deleteByLogic(sysUserOnline); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysUserOnlineService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysUserOnlineService.class.getName())); + } + + /** + * 更新会话;如更新会话最后访问时间/停止会话/设置超时时间/设置移除属性等会调用 + */ + @Transactional(readOnly = false) + public void syncToDb(OnlineSession onlineSession) + { + Date lastSyncTimestamp = (Date) onlineSession.getAttribute(LAST_SYNC_DB_TIMESTAMP); + if (lastSyncTimestamp != null) + { + boolean needSync = true; + long deltaTime = onlineSession.getLastAccessTime().getTime() - lastSyncTimestamp.getTime(); + if (deltaTime < dbSyncPeriod * 60 * 1000) + { + // 时间差不足 无需同步 + needSync = false; + } + boolean isGuest = onlineSession.getUserId() == null || onlineSession.getUserId() == ""; + + // session 数据变更了 同步 + if (isGuest == false && onlineSession.isAttributeChanged()) + { + needSync = true; + } + + if (needSync == false) + { + return; + } + } + onlineSession.setAttribute(LAST_SYNC_DB_TIMESTAMP, onlineSession.getLastAccessTime()); + // 更新完后 重置标识 + if (onlineSession.isAttributeChanged()) + { + onlineSession.resetAttributeChanged(); + } + try{ + SysUserOnline sysUserOnline=SysUserOnline.fromOnlineSession(onlineSession); + SysUserOnline sysUserOnlineDb=this.get(sysUserOnline.getId()); + if(sysUserOnlineDb==null){ + sysUserOnline.setIsNewRecord(true); + }else{ + sysUserOnline.setStartTimestsamp(sysUserOnlineDb.getStartTimestsamp()); + } + if(StringUtils.isEmpty(sysUserOnline.getDeptName())){ + User user=UserUtils.getByLoginName(sysUserOnline.getLoginName()); + if(user.getCompany()!=null && user.getOffice()!=null) { + sysUserOnline.setDeptName(user.getCompany().getName() + "-" + user.getOffice().getName()); + } else if(user.getCompany()!=null) { + sysUserOnline.setDeptName(user.getCompany().getName()); + } else if(user.getOffice()!=null) { + sysUserOnline.setDeptName(user.getOffice().getName()); + } + } + this.save(sysUserOnline); + } catch (Exception e){ + //System.out.println(e.getMessage()); + } + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SystemConfigService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SystemConfigService.java new file mode 100644 index 0000000..b608a19 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SystemConfigService.java @@ -0,0 +1,52 @@ +/** + * Copyright © 2015-2020 JeeSpring All rights reserved. + */ +package com.jeespring.modules.sys.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.sys.entity.SystemConfig; +import com.jeespring.modules.sys.dao.SystemConfigDao; + +/** + * 系统配置Service + * @author liugf + * @version 2016-02-07 + */ +@Service +@Transactional(readOnly = true) +public class SystemConfigService extends AbstractBaseService { + + @Override + public SystemConfig get(String id) { + return super.get(id); + } + + @Override + public List findList(SystemConfig systemConfig) { + return super.findList(systemConfig); + } + + @Override + public Page findPage(Page page, SystemConfig systemConfig) { + return super.findPage(page, systemConfig); + } + + @Override + @Transactional(readOnly = false) + public void save(SystemConfig systemConfig) { + super.save(systemConfig); + } + + @Override + @Transactional(readOnly = false) + public void delete(SystemConfig systemConfig) { + super.delete(systemConfig); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SystemService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SystemService.java new file mode 100644 index 0000000..6a1bc1d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/service/SystemService.java @@ -0,0 +1,399 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.service; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import org.apache.shiro.session.Session; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.CacheUtils; +import com.jeespring.common.utils.Encodes; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.security.Digests; +import com.jeespring.common.security.shiro.session.SessionDAO; +import com.jeespring.common.service.AbstractService; +import com.jeespring.common.service.ServiceException; +import com.jeespring.modules.sys.dao.MenuDao; +import com.jeespring.modules.sys.dao.RoleDao; +import com.jeespring.modules.sys.dao.UserDao; +import com.jeespring.modules.sys.entity.Menu; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.Role; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.security.SystemAuthorizingRealm; +import com.jeespring.modules.sys.utils.LogUtils; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 系统管理,安全相关实体的管理类,包括用户、角色、菜单. + * @author 黄炳桂 516821420@qq.com + * @version 2013-12-05 + */ +@org.springframework.stereotype.Service +@Transactional(readOnly = true) +public class SystemService extends AbstractService implements InitializingBean { + + public static final String HASH_ALGORITHM = "SHA-1"; + public static final int HASH_INTERATIONS = 1024; + public static final int SALT_SIZE = 8; + + @Autowired + private UserDao userDao; + @Autowired + private RoleDao roleDao; + @Autowired + private MenuDao menuDao; + @Autowired + private SessionDAO sessionDao; + @Autowired + private SystemAuthorizingRealm systemRealm; + + public SessionDAO getSessionDao() { + return sessionDao; + } + + //-- User Service --// + + /** + * 获取用户 + * @param id + * @return + */ + public User getUser(String id) { + return UserUtils.get(id); + } + + /** + * 根据登录名获取用户 + * @param loginName + * @return + */ + public User getUserByLoginName(String loginName) { + return UserUtils.getByLoginName(loginName); + } + + public Page findUser(Page page, User user) { + // 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL) + user.getSqlMap().put("dsf", dataScopeFilter(user.getCurrentUser(), "o", "a")); + // 设置分页参数 + user.setPage(page); + // 执行分页查询 + page.setList(userDao.findList(user)); + return page; + } + + /** + * 无分页查询人员列表 + * @param user + * @return + */ + public List findUser(User user){ + // 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL) + user.getSqlMap().put("dsf", dataScopeFilter(user.getCurrentUser(), "o", "a")); + List list = userDao.findList(user); + return list; + } + + /** + * 通过部门ID获取用户列表,仅返回用户id和name(树查询用户时用) + * @param user + * @return + */ + @SuppressWarnings("unchecked") + public List findUserByOfficeId(String officeId) { + List list = (List)CacheUtils.get(UserUtils.USER_CACHE, UserUtils.USER_CACHE_LIST_BY_OFFICE_ID_ + officeId); + if (list == null){ + User user = new User(); + user.setOffice(new Office(officeId)); + list = userDao.findUserByOfficeId(user); + CacheUtils.put(UserUtils.USER_CACHE, UserUtils.USER_CACHE_LIST_BY_OFFICE_ID_ + officeId, list); + } + return list; + } + + @Transactional(readOnly = false) + public void saveUser(User user) { + if (StringUtils.isBlank(user.getId())){ + user.preInsert(); + userDao.insert(user); + }else{ + // 清除原用户机构用户缓存 + User oldUser = userDao.get(user.getId()); + if (oldUser.getOffice() != null && oldUser.getOffice().getId() != null){ + CacheUtils.remove(UserUtils.USER_CACHE, UserUtils.USER_CACHE_LIST_BY_OFFICE_ID_ + oldUser.getOffice().getId()); + } + // 更新用户数据 + user.preUpdate(); + userDao.update(user); + } + if (StringUtils.isNotBlank(user.getId())){ + // 更新用户与角色关联 + userDao.deleteUserRole(user); + if (user.getRoleList() != null && user.getRoleList().size() > 0){ + userDao.insertUserRole(user); + }else{ + throw new ServiceException(user.getLoginName() + "没有设置角色!"); + } + // 清除用户缓存 + UserUtils.clearCache(user); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + } + } + + @Transactional(readOnly = false) + public void updateUserInfo(User user) { + user.preUpdate(); + userDao.updateUserInfo(user); + // 清除用户缓存 + UserUtils.clearCache(user); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + } + + @Transactional(readOnly = false) + public void deleteUser(User user) { + userDao.delete(user); + // 清除用户缓存 + UserUtils.clearCache(user); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + } + + @Transactional(readOnly = false) + public void updatePasswordById(String id, String loginName, String newPassword) { + User user = new User(id); + user.setPassword(entryptPassword(newPassword)); + userDao.updatePasswordById(user); + // 清除用户缓存 + user.setLoginName(loginName); + UserUtils.clearCache(user); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + } + + @Transactional(readOnly = false) + public void updateUserLoginInfo(User user) { + // 保存上次登录信息 + user.setOldLoginIp(user.getLoginIp()); + user.setOldLoginDate(user.getLoginDate()); + // 更新本次登录信息 + user.setLoginIp(UserUtils.getSession().getHost()); + user.setLoginDate(new Date()); + userDao.updateLoginInfo(user); + } + + /** + * 生成安全的密码,生成随机的16位salt并经过1024次 sha-1 hash + */ + public static String entryptPassword(String plainPassword) { + byte[] salt = Digests.generateSalt(SALT_SIZE); + byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS); + return Encodes.encodeHex(salt)+Encodes.encodeHex(hashPassword); + } + + /** + * 验证密码 + * @param plainPassword 明文密码 + * @param password 密文密码 + * @return 验证成功返回true + */ + public static boolean validatePassword(String plainPassword, String password) { + byte[] salt = Encodes.decodeHex(password.substring(0,16)); + byte[] hashPassword = Digests.sha1(plainPassword.getBytes(), salt, HASH_INTERATIONS); + return password.equals(Encodes.encodeHex(salt)+Encodes.encodeHex(hashPassword)); + } + + /** + * 获得活动会话 + * @return + */ + public Collection getActiveSessions(){ + return sessionDao.getActiveSessions(false); + } + + //-- Role Service --// + + public Role getRole(String id) { + return roleDao.get(id); + } + + public Role getRoleByName(String name) { + Role r = new Role(); + r.setName(name); + return roleDao.getByName(r); + } + + public Role getRoleByEnname(String enname) { + Role r = new Role(); + r.setEnname(enname); + return roleDao.getByEnname(r); + } + + public List findRole(Role role){ + return roleDao.findList(role); + } + + public List findAllRole(){ + return UserUtils.getRoleList(); + } + + @Transactional(readOnly = false) + public void saveRole(Role role) { + if (StringUtils.isBlank(role.getId())){ + role.preInsert(); + roleDao.insert(role); + }else{ + role.preUpdate(); + roleDao.update(role); + } + // 更新角色与菜单关联 + roleDao.deleteRoleMenu(role); + if (role.getMenuList().size() > 0){ + roleDao.insertRoleMenu(role); + } + // 更新角色与部门关联 + roleDao.deleteRoleOffice(role); + if (role.getOfficeList().size() > 0){ + roleDao.insertRoleOffice(role); + } + // 清除用户角色缓存 + UserUtils.removeCache(UserUtils.CACHE_ROLE_LIST); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + } + + @Transactional(readOnly = false) + public void deleteRole(Role role) { + roleDao.delete(role); + // 清除用户角色缓存 + UserUtils.removeCache(UserUtils.CACHE_ROLE_LIST); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + } + + @Transactional(readOnly = false) + public Boolean outUserInRole(Role role, User user) { + List roles = user.getRoleList(); + for (Role e : roles){ + if (e.getId().equals(role.getId())){ + roles.remove(e); + saveUser(user); + return true; + } + } + return false; + } + + @Transactional(readOnly = false) + public User assignUserToRole(Role role, User user) { + if (user == null){ + return null; + } + List roleIds = user.getRoleIdList(); + if (roleIds.contains(role.getId())) { + return null; + } + user.getRoleList().add(role); + saveUser(user); + return user; + } + + //-- Menu Service --// + + public Menu getMenu(String id) { + return menuDao.get(id); + } + + public List findAllMenu(){ + return UserUtils.getMenuList(); + } + + @Transactional(readOnly = false) + public void saveMenu(Menu menu) { + + // 获取父节点实体 + menu.setParent(this.getMenu(menu.getParent().getId())); + + // 获取修改前的parentIds,用于更新子节点的parentIds + String oldParentIds = menu.getParentIds(); + + // 设置新的父节点串 + menu.setParentIds(menu.getParent().getParentIds()+menu.getParent().getId()+","); + + // 保存或更新实体 + if (StringUtils.isBlank(menu.getId())){ + menu.preInsert(); + menuDao.insert(menu); + }else{ + menu.preUpdate(); + menuDao.update(menu); + } + + // 更新子节点 parentIds + Menu m = new Menu(); + m.setParentIds("%,"+menu.getId()+",%"); + List list = menuDao.findByParentIdsLike(m); + for (Menu e : list){ + e.setParentIds(e.getParentIds().replace(oldParentIds, menu.getParentIds())); + menuDao.updateParentIds(e); + } + // 清除用户菜单缓存 + UserUtils.removeCache(UserUtils.CACHE_MENU_LIST); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + // 清除日志相关缓存 + CacheUtils.remove(LogUtils.CACHE_MENU_NAME_PATH_MAP); + } + + @Transactional(readOnly = false) + public void updateMenuSort(Menu menu) { + menuDao.updateSort(menu); + // 清除用户菜单缓存 + UserUtils.removeCache(UserUtils.CACHE_MENU_LIST); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + // 清除日志相关缓存 + CacheUtils.remove(LogUtils.CACHE_MENU_NAME_PATH_MAP); + } + + @Transactional(readOnly = false) + public void deleteMenu(Menu menu) { + menuDao.delete(menu); + // 清除用户菜单缓存 + UserUtils.removeCache(UserUtils.CACHE_MENU_LIST); +// // 清除权限缓存 +// systemRealm.clearAllCachedAuthorizationInfo(); + // 清除日志相关缓存 + CacheUtils.remove(LogUtils.CACHE_MENU_NAME_PATH_MAP); + } + + /** + * 获取Key加载信息 + */ + public static boolean printKeyLoadMessage(){ + StringBuilder sb = new StringBuilder(); + sb.append("\r\n======================================================================\r\n"); + sb.append("\r\n 欢迎使用 "+Global.getConfig("productName")+" - Powered By http://www.jeespring.org\r\n"); + sb.append("\r\n======================================================================\r\n"); + System.out.println(sb.toString()); + return true; + } + + @Override + public void afterPropertiesSet() throws Exception { + // TODO Auto-generated method stub + + } + + + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/DictUtils.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/DictUtils.java new file mode 100644 index 0000000..aec3f47 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/DictUtils.java @@ -0,0 +1,152 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.modules.sys.utils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import io.swagger.models.auth.In; +import org.apache.commons.lang3.StringUtils; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.mapper.JsonMapper; +import com.jeespring.common.utils.CacheUtils; +import com.jeespring.common.utils.SpringContextHolder; +import com.jeespring.modules.sys.dao.DictDao; +import com.jeespring.modules.sys.entity.Dict; + +/** + * 字典工具类 + * @author 黄炳桂 516821420@qq.com + * @version 2013-5-29 + */ +public class DictUtils { + + private static DictDao dictDao = SpringContextHolder.getBean(DictDao.class); + + public static final String CACHE_DICT_MAP = "dictMap"; + + public static String getDictLabel(String value, String type, String defaultValue){ + if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(value)){ + for (Dict dict : getDictList(type)){ + if (type.equals(dict.getType()) && value.equals(dict.getValue())){ + return dict.getLabel(); + } + } + } + return defaultValue; + } + + public static String getDictLabel(Long value, String type, String defaultValue){ + if(value==null) { + return ""; + } + return getDictLabel(value.toString(),type,defaultValue); + } + + public static String getDictLabel(Integer value, String type, String defaultValue){ + if(value==null) { + return ""; + } + return getDictLabel(value.toString(),type,defaultValue); + } + + public static String getDictPicture(String value, String type, String defaultValue){ + if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(value)){ + for (Dict dict : getDictList(type)){ + if (type.equals(dict.getType()) && value.equals(dict.getValue())){ + return dict.getPicture(); + } + } + } + return defaultValue; + } + + public static String getDictPicture(Long value, String type, String defaultValue){ + if(value==null) { + return ""; + } + return getDictPicture(value.toString(),type,defaultValue); + } + + public static String getDictPicture(Integer value, String type, String defaultValue){ + if(value==null) { + return ""; + } + return getDictPicture(value.toString(),type,defaultValue); + } + + public static String getDictLabels(String values, String type, String defaultValue){ + if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(values)){ + List valueList = Lists.newArrayList(); + for (String value : StringUtils.split(values, ",")){ + valueList.add(getDictLabel(value, type, defaultValue)); + } + return StringUtils.join(valueList, ","); + } + return defaultValue; + } + + public static String getDictValue(String label, String type, String defaultLabel){ + if (StringUtils.isNotBlank(type) && StringUtils.isNotBlank(label)){ + for (Dict dict : getDictList(type)){ + if (type.equals(dict.getType()) && label.equals(dict.getLabel())){ + return dict.getValue(); + } + } + } + return defaultLabel; + } + + public static List getDictList(String type){ + @SuppressWarnings("unchecked") + Map> dictMap = (Map>)CacheUtils.get(CACHE_DICT_MAP); + if (dictMap==null){ + dictMap = Maps.newHashMap(); + for (Dict dict : dictDao.findAllList(new Dict())){ + List dictList = dictMap.get(dict.getType()); + if (dictList != null){ + dictList.add(dict); + }else{ + dictMap.put(dict.getType(), Lists.newArrayList(dict)); + } + } + CacheUtils.put(CACHE_DICT_MAP, dictMap); + } + List dictList = dictMap.get(type); + if (dictList == null){ + dictList = Lists.newArrayList(); + } + //if(dictList!=null && dictList.size()!=0 && "".equals(dictList.get(dictList.size()-1).getValue())){ + // dictList.remove(dictList.size()-1); + //} + return dictList; + } + + //增加全部项 + public static List getDictListAddAll(String type){ + List dictListResult=new ArrayList(); + List dictList =getDictList(type); + dictListResult.addAll(dictList); + //if(dictList!=null && "".equals(dictList.get(dictList.size()-1).getValue())){ + // return dictList; + //} + Dict dict=new Dict(); + dict.setValue(""); + dict.setLabel("全部"); + dictListResult.add(dict); + return dictListResult; + } + /** + * 返回字典列表(JSON) + * @param type + * @return + */ + public static String getDictListJson(String type){ + return JsonMapper.toJsonString(getDictList(type)); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/LogUtils.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/LogUtils.java new file mode 100644 index 0000000..c411956 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/utils/LogUtils.java @@ -0,0 +1,88 @@ +/** + * Copyright © 2012-2016 jeespring All rights reserved. + */ +package com.jeespring.modules.sys.utils; + +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.sys.entity.Log; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.interceptor.InterceptorLogEntity; +import com.jeespring.modules.sys.interceptor.LogThread; + +import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; +import java.util.Date; +import java.util.Map; + +/** + * 字典工具类 + * + * @author 黄炳桂 516821420@qq.com + * @version 2014-11-7 + */ +public class LogUtils { + + public static final String CACHE_MENU_NAME_PATH_MAP = "menuNamePathMap"; + + /** + * 保存日志 + */ + public static void saveLog(HttpServletRequest request, String title) { + saveLog(request, null, null, title); + } + + /** + * 保存日志 + */ + public static void saveLog(HttpServletRequest request, Object handler, Exception ex, String title) { + User user = UserUtils.getUser(); + if (user != null && user.getId() != null) { + Log log = new Log(); + log.setTitle(title); + log.setType(ex == null ? Log.TYPE_ACCESS : Log.TYPE_EXCEPTION); + log.setRemoteAddr(StringUtils.getRemoteAddr(request)); + log.setUserAgent(request.getHeader("user-agent")); + log.setRequestUri(request.getRequestURI()); + log.setParams(getParameterString(request)); + log.setMethod(request.getMethod()); + log.setCreateBy(user); + log.setUpdateBy(user); + log.setUpdateDate(new Date()); + log.setCreateDate(new Date()); + // 异步保存日志 + try { + InterceptorLogEntity entiry = new InterceptorLogEntity(log, handler, ex); + LogThread.interceptorLogQueue.put(entiry); + } catch (Exception e) { + e.printStackTrace(System.out); + } + } + } + public static String getParameterString(HttpServletRequest request){ + if(request.getQueryString()!=null){ + if(request.getQueryString().length()>0){ + return request.getQueryString(); + } + } + Map map = request.getParameterMap(); + java.util.Enumeration enumx = request.getParameterNames(); + String result=""; + while(enumx.hasMoreElements()){ + String paramName=(String)enumx.nextElement(); + String[] values=request.getParameterValues(paramName); + for(int i=0;iJeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.utils; + +import java.io.IOException; +import java.util.Date; +import java.util.List; + +import com.jeespring.common.sms.SMSUtils; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.UnavailableSecurityManagerException; +import org.apache.shiro.session.InvalidSessionException; +import org.apache.shiro.session.Session; +import org.apache.shiro.subject.Subject; + +import com.jeespring.common.utils.CacheUtils; +import com.jeespring.common.utils.SpringContextHolder; +import com.jeespring.common.service.AbstractService; +import com.jeespring.modules.sys.dao.AreaDao; +import com.jeespring.modules.sys.dao.MenuDao; +import com.jeespring.modules.sys.dao.OfficeDao; +import com.jeespring.modules.sys.dao.RoleDao; +import com.jeespring.modules.sys.dao.UserDao; +import com.jeespring.modules.sys.entity.Area; +import com.jeespring.modules.sys.entity.Menu; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.Role; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.security.SystemAuthorizingRealm.Principal; + +/** + * 用户工具类 + * @author 黄炳桂 516821420@qq.com + * @version 2013-12-05 + */ +public class UserUtils { + + private static UserDao userDao = SpringContextHolder.getBean(UserDao.class); + private static RoleDao roleDao = SpringContextHolder.getBean(RoleDao.class); + private static MenuDao menuDao = SpringContextHolder.getBean(MenuDao.class); + private static AreaDao areaDao = SpringContextHolder.getBean(AreaDao.class); + private static OfficeDao officeDao = SpringContextHolder.getBean(OfficeDao.class); + + public static final String USER_CACHE = "userCache"; + public static final String USER_CACHE_ID_ = "id_"; + public static final String USER_CACHE_LOGIN_NAME_ = "ln"; + public static final String USER_CACHE_LIST_BY_OFFICE_ID_ = "oid_"; + + public static final String CACHE_ROLE_LIST = "roleList"; + public static final String CACHE_MENU_LIST = "menuList"; + public static final String CACHE_AREA_LIST = "areaList"; + public static final String CACHE_OFFICE_LIST = "officeList"; + public static final String CACHE_OFFICE_ALL_LIST = "officeAllList"; + + /** + * 根据ID获取用户 + * @param id + * @return 取不到返回null + */ + public static User get(String id){ + User user = (User)CacheUtils.get(USER_CACHE, USER_CACHE_ID_ + id); + if (user == null){ + user = userDao.get(id); + if (user == null){ + return null; + } + user.setRoleList(roleDao.findList(new Role(user))); + CacheUtils.put(USER_CACHE, USER_CACHE_ID_ + user.getId(), user); + CacheUtils.put(USER_CACHE, USER_CACHE_LOGIN_NAME_ + user.getLoginName(), user); + } + return user; + } + + /** + * 根据登录名获取用户 + * @param loginName + * @return 取不到返回null + */ + public static User getByLoginName(String loginName){ + User user = (User)CacheUtils.get(USER_CACHE, USER_CACHE_LOGIN_NAME_ + loginName); + if (user == null){ + user = userDao.getByLoginName(new User(null, loginName)); + if (user == null){ + return null; + } + user.setRoleList(roleDao.findList(new Role(user))); + CacheUtils.put(USER_CACHE, USER_CACHE_ID_ + user.getId(), user); + CacheUtils.put(USER_CACHE, USER_CACHE_LOGIN_NAME_ + user.getLoginName(), user); + } + return user; + } + + /** + * 清除当前用户缓存 + */ + public static void clearCache(){ + removeCache(CACHE_ROLE_LIST); + removeCache(CACHE_MENU_LIST); + removeCache(CACHE_AREA_LIST); + removeCache(CACHE_OFFICE_LIST); + removeCache(CACHE_OFFICE_ALL_LIST); + UserUtils.clearCache(getUser()); + } + + /** + * 清除指定用户缓存 + * @param user + */ + public static void clearCache(User user){ + CacheUtils.remove(USER_CACHE, USER_CACHE_ID_ + user.getId()); + CacheUtils.remove(USER_CACHE, USER_CACHE_LOGIN_NAME_ + user.getLoginName()); + CacheUtils.remove(USER_CACHE, USER_CACHE_LOGIN_NAME_ + user.getOldLoginName()); + if (user.getOffice() != null && user.getOffice().getId() != null){ + CacheUtils.remove(USER_CACHE, USER_CACHE_LIST_BY_OFFICE_ID_ + user.getOffice().getId()); + } + } + + /** + * 获取当前用户 + * @return 取不到返回 new User() + */ + public static User getUser(){ + Principal principal = getPrincipal(); + if (principal!=null){ + User user = get(principal.getId()); + if (user != null){ + return user; + } + return new User(); + } + // 如果没有登录,则返回实例化空的User对象。 + return new User(); + } + + /** + * 获取当前用户角色列表 + * @return + */ + public static List getRoleList(){ + @SuppressWarnings("unchecked") + List roleList = (List)getCache(CACHE_ROLE_LIST); + if (roleList == null){ + User user = getUser(); + if (user.isAdmin()){ + roleList = roleDao.findAllList(new Role()); + }else{ + Role role = new Role(); + role.getSqlMap().put("dsf", AbstractService.dataScopeFilter(user.getCurrentUser(), "o", "u")); + roleList = roleDao.findList(role); + } + putCache(CACHE_ROLE_LIST, roleList); + } + return roleList; + } + + /** + * 获取当前用户授权菜单 + * @return + */ + public static List getMenuList(){ + @SuppressWarnings("unchecked") + List menuList = (List)getCache(CACHE_MENU_LIST); + if (menuList == null){ + User user = getUser(); + if (user.isAdmin()){ + menuList = menuDao.findAllList(new Menu()); + }else{ + Menu m = new Menu(); + m.setUserId(user.getId()); + menuList = menuDao.findByUserId(m); + } + putCache(CACHE_MENU_LIST, menuList); + } + return menuList; + } + + /** + * 获取当前用户授权菜单 + * @return + */ + public static Menu getTopMenu(){ + @SuppressWarnings("unchecked") + Menu topMenu = menuDao.findUniqueByProperty("parent_id", "'0'"); + return topMenu; + } + /** + * 获取当前用户授权的区域 + * @return + */ + public static List getAreaList(){ + @SuppressWarnings("unchecked") + List areaList = (List)getCache(CACHE_AREA_LIST); + if (areaList == null){ + areaList = areaDao.findAllList(new Area()); + putCache(CACHE_AREA_LIST, areaList); + } + return areaList; + } + + /** + * 获取当前用户有权限访问的部门 + * @return + */ + public static List getOfficeList(){ + @SuppressWarnings("unchecked") + List officeList = (List)getCache(CACHE_OFFICE_LIST); + if (officeList == null){ + User user = getUser(); + if (user.isAdmin()){ + officeList = officeDao.findAllList(new Office()); + }else{ + Office office = new Office(); + office.getSqlMap().put("dsf", AbstractService.dataScopeFilter(user, "a", "")); + officeList = officeDao.findList(office); + } + putCache(CACHE_OFFICE_LIST, officeList); + } + return officeList; + } + + /** + * 获取当前用户有权限访问的部门 + * @return + */ + public static List getOfficeAllList(){ + @SuppressWarnings("unchecked") + List officeList = (List)getCache(CACHE_OFFICE_ALL_LIST); + if (officeList == null){ + officeList = officeDao.findAllList(new Office()); + } + return officeList; + } + + /** + * 获取授权主要对象 + */ + public static Subject getSubject(){ + return SecurityUtils.getSubject(); + } + + /** + * 获取当前登录者对象 + */ + public static Principal getPrincipal(){ + try{ + Subject subject = SecurityUtils.getSubject(); + Principal principal = (Principal)subject.getPrincipal(); + if (principal != null){ + return principal; + } +// subject.logout(); + }catch (UnavailableSecurityManagerException e) { + + }catch (InvalidSessionException e){ + + } + return null; + } + + public static Session getSession(){ + try{ + Subject subject = SecurityUtils.getSubject(); + Session session = subject.getSession(false); + if (session == null){ + session = subject.getSession(); + } + if (session != null){ + return session; + } +// subject.logout(); + }catch (InvalidSessionException e){ + + } + return null; + } + + // ============== User Cache ============== + + public static Object getCache(String key) { + return getCache(key, null); + } + + public static Object getCache(String key, Object defaultValue) { +// Object obj = getCacheMap().get(key); + Object obj = getSession().getAttribute(key); + return obj==null?defaultValue:obj; + } + + public static void putCache(String key, Object value) { +// getCacheMap().put(key, value); + getSession().setAttribute(key, value); + } + + public static void removeCache(String key) { +// getCacheMap().remove(key); + getSession().removeAttribute(key); + } + + public static String getTime(Date date){ + StringBuffer time = new StringBuffer(); + Date date2 = new Date(); + long temp = date2.getTime() - date.getTime(); + long days = temp / 1000 / 3600/24; //相差小时数 + if(days>0){ + time.append(days+"天"); + } + long temp1 = temp % (1000 * 3600*24); + long hours = temp1 / 1000 / 3600; //相差小时数 + if(days>0 || hours>0){ + time.append(hours+"小时"); + } + long temp2 = temp1 % (1000 * 3600); + long mins = temp2 / 1000 / 60; //相差分钟数 + time.append(mins + "分钟"); + return time.toString(); + } +// public static Map getCacheMap(){ +// Principal principal = getPrincipal(); +// if(principal!=null){ +// return principal.getCacheMap(); +// } +// return new HashMap(); +// } +//发送注册码 +public static String sendRandomCode(String uid, String pwd, String tel, String randomCode) throws IOException { + //发送内容 + String content = "您的验证码是:"+randomCode+",有效期30分钟,请在有效期内使用。"; + try{ + return SMSUtils.send(uid, pwd, tel, content); + }catch (Exception e){ + return ""; + } +} + + //注册用户重置密码 + public static String sendPass(String uid, String pwd, String tel, String password) throws IOException { + //发送内容 + String content = "您的新密码是:"+password+",请登录系统,重新设置密码。"; + try{ + return SMSUtils.send(uid, pwd, tel, content); + }catch (Exception e){ + return ""; + } + } + + /** + * 导出Excel调用,根据姓名转换为ID + */ + public static User getByUserName(String name){ + User u = new User(); + u.setName(name); + List list = userDao.findList(u); + if(list.size()>0){ + return list.get(0); + }else{ + return new User(); + } + } + /** + * 导出Excel使用,根据名字转换为id + */ + public static Office getByOfficeName(String name){ + Office o = new Office(); + o.setName(name); + List list = officeDao.findList(o); + if(list.size()>0){ + return list.get(0); + }else{ + return new Office(); + } + } + /** + * 导出Excel使用,根据名字转换为id + */ + public static Area getByAreaName(String name){ + Area a = new Area(); + a.setName(name); + List list = areaDao.findList(a); + if(list.size()>0){ + return list.get(0); + }else{ + return new Area(); + } + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/AreaController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/AreaController.java new file mode 100644 index 0000000..5abadb0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/AreaController.java @@ -0,0 +1,135 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.Area; +import com.jeespring.modules.sys.service.AreaService; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 区域Controller + * @author 黄炳桂 516821420@qq.com + * @version 2013-5-15 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/area") +public class AreaController extends AbstractBaseController { + + @Autowired + private AreaService areaService; + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute("area") + public Area get(@RequestParam(required=false) String id) { + if (StringUtils.isNotBlank(id)){ + return areaService.get(id); + }else{ + return new Area(); + } + } + + //RequiresPermissions("sys:area:list") + @RequestMapping(value = {"list", ""}) + public String list(Area area, Model model) { + model.addAttribute("list", areaService.findAll()); + return "modules/sys/areaList"; + } + + //RequiresPermissions(value={"sys:area:view","sys:area:add","sys:area:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(Area area, Model model) { + if (area.getParent()==null||area.getParent().getId()==null){ + area.setParent(UserUtils.getUser().getOffice().getArea()); + }else{ + area.setParent(areaService.get(area.getParent().getId())); + } + +// // 自动获取排序号 +// if (StringUtils.isBlank(area.getId())){ +// int size = 0; +// List list = areaService.findAll(); +// for (int i=0; i 0 ? size : 1), 4, "0")); +// } + model.addAttribute("area", area); + return "modules/sys/areaForm"; + } + + //RequiresPermissions(value={"sys:area:add","sys:area:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(Area area, Model model, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/area"; + } + if (!beanValidator(model, area)){ + return form(area, model); + } + areaService.save(area); + addMessage(redirectAttributes, "保存区域'" + area.getName() + "'成功"); + return "redirect:" + adminPath + "/sys/area/"; + } + + //RequiresPermissions("sys:area:del") + @RequestMapping(value = "delete") + public String delete(Area area, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/area"; + } +// if (Area.isRoot(id)){ +// addMessage(redirectAttributes, "删除区域失败, 不允许删除顶级区域或编号为空"); +// }else{ + areaService.delete(area); + addMessage(redirectAttributes, "删除区域成功"); +// } + return "redirect:" + adminPath + "/sys/area/"; + } + + //RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "treeData") + public List> treeData(@RequestParam(required=false) String extId, HttpServletResponse response) { + List> mapList = Lists.newArrayList(); + List list = areaService.findAll(); + for (int i=0; i map = Maps.newHashMap(); + map.put("id", e.getId()); + map.put("pId", e.getParentId()); + map.put("name", e.getName()); + mapList.add(map); + } + } + return mapList; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/DictController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/DictController.java new file mode 100644 index 0000000..95b4579 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/DictController.java @@ -0,0 +1,147 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.Dict; +import com.jeespring.modules.sys.service.DictService; + +/** + * 字典Controller + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/dict") +public class DictController extends AbstractBaseController { + + @Autowired + private DictService dictService; + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute + public Dict get(@RequestParam(required=false) String id) { + if (StringUtils.isNotBlank(id)){ + return dictService.get(id); + }else{ + return new Dict(); + } + } + + //RequiresPermissions("sys:dict:list") + @RequestMapping(value = {"list", ""}) + public String list(Dict dict, HttpServletRequest request, HttpServletResponse response, Model model) { + List typeList = dictService.findTypeList(); + model.addAttribute("typeList", typeList); + Page page = dictService.findPage(new Page(request, response), dict); + model.addAttribute("page", page); + return "modules/sys/dictList"; + } + + //RequiresPermissions(value={"sys:dict:view","sys:dict:add","sys:dict:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(Dict dict, Model model) { + model.addAttribute("dict", dict); + return "modules/sys/dictForm"; + } + + //RequiresPermissions(value={"sys:dict:add","sys:dict:edit"},logical=Logical.OR) + @RequestMapping(value = "save")//@Valid + public String save(Dict dict, Model model, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/dict/?repage&type="+dict.getType(); + } + if (!beanValidator(model, dict)){ + return form(dict, model); + } + dictService.save(dict); + addMessage(redirectAttributes, "保存字典'" + dict.getLabel() + "'成功"); + return "redirect:" + adminPath + "/sys/dict/?repage&type="+dict.getType(); + } + + //RequiresPermissions("sys:dict:del") + @RequestMapping(value = "delete") + public String delete(Dict dict, Model model, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes,sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/dict/?repage"; + } + dictService.delete(dict); + model.addAttribute("dict", dict); + addMessage(redirectAttributes, "删除字典成功"); + return "redirect:" + adminPath + "/sys/dict/?repage&type="+dict.getType(); + } + + + /** + * 批量删除角色 + */ + //RequiresPermissions("sys:role:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/dict/?repage"; + } + String[] idArray = ids.split(","); + for(String id : idArray){ + Dict dict = dictService.get(id); + dictService.delete(dict); + } + addMessage(redirectAttributes, "删除字典成功"); + return "redirect:" + adminPath + "/sys/dict/?repage"; + } + + + //RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "treeData") + public List> treeData(@RequestParam(required=false) String type, HttpServletResponse response) { + List> mapList = Lists.newArrayList(); + Dict dict = new Dict(); + dict.setType(type); + List list = dictService.findList(dict); + for (int i=0; i map = Maps.newHashMap(); + map.put("id", e.getId()); + map.put("pId", e.getParentId()); + map.put("name", StringUtils.replace(e.getLabel(), " ", "")); + mapList.add(map); + } + return mapList; + } + + @ResponseBody + @RequestMapping(value = "listData") + public List listData(@RequestParam(required=false) String type) { + Dict dict = new Dict(); + dict.setType(type); + return dictService.findList(dict); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/IndexConteoller.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/IndexConteoller.java new file mode 100644 index 0000000..e306092 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/IndexConteoller.java @@ -0,0 +1,28 @@ +package com.jeespring.modules.sys.web; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * 主页 + * Created by zhao.weiwei + * create on 2017/1/11 15:15 + * the email is zhao.weiwei@jyall.com. + */ +@Controller +public class IndexConteoller { + @Value("${adminPath:/a}") + private String adminpath; + @RequestMapping(value = "/", method = RequestMethod.GET) + public String index() { + return "redirect:" + adminpath + "/login"; + } + + + @RequestMapping(value = "/2", method = RequestMethod.GET) + public String index2() { + return "index2"; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/LogController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/LogController.java new file mode 100644 index 0000000..99dc0d6 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/LogController.java @@ -0,0 +1,66 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.Log; +import com.jeespring.modules.sys.service.LogService; + +/** + * 日志Controller + * @author 黄炳桂 516821420@qq.com + * @version 2013-6-2 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/log") +public class LogController extends AbstractBaseController { + + @Autowired + private LogService logService; + + //RequiresPermissions("sys:log:list") + @RequestMapping(value = {"list", ""}) + public String list(Log log, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = logService.findPage(new Page(request, response), log); + model.addAttribute("page", page); + return "modules/sys/logList"; + } + + + /** + * 批量删除 + */ + //RequiresPermissions("sys:log:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + logService.delete(logService.get(id)); + } + addMessage(redirectAttributes, "删除日志成功"); + return "redirect:"+Global.getAdminPath()+"/sys/log/?repage"; + } + + /** + * 批量删除 + */ + //RequiresPermissions("sys:log:del") + @RequestMapping(value = "empty") + public String empty(RedirectAttributes redirectAttributes) { + logService.empty(); + addMessage(redirectAttributes, "清空日志成功"); + return "redirect:"+Global.getAdminPath()+"/sys/log/?repage"; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/LoginController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/LoginController.java new file mode 100644 index 0000000..2868c52 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/LoginController.java @@ -0,0 +1,435 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.oa.entity.OaNotify; +import com.jeespring.modules.oa.service.OaNotifyService; +import com.jeespring.modules.sys.entity.Dict; +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.sys.service.DictService; +import com.jeespring.modules.sys.service.SysConfigService; +import com.jeespring.modules.sys.service.SysUserOnlineService; +import org.apache.shiro.authz.UnauthorizedException; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.web.util.SavedRequest; +import org.apache.shiro.web.util.WebUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.servlet.ValidateCodeServlet; +import com.jeespring.common.utils.CacheUtils; +import com.jeespring.common.utils.CookieUtils; +import com.jeespring.common.utils.IdGen; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.json.AjaxJson; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.security.shiro.session.SessionDAO; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.security.FormAuthenticationFilter; +import com.jeespring.modules.sys.security.SystemAuthorizingRealm.Principal; +import com.jeespring.modules.sys.utils.UserUtils; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +/** + * 登录Controller + * @author 黄炳桂 516821420@qq.com + * @version 2013-5-31 + */ +@Controller +public class LoginController extends AbstractBaseController { + + @Autowired + private SessionDAO sessionDAO; + + @Autowired + private OaNotifyService oaNotifyService; + + @Autowired + private SysConfigService sysConfigService; + + @Autowired + private DictService dictService; + + /** + * 管理登录 + * @throws IOException + */ + @RequestMapping(value = "${adminPath}/login", method = RequestMethod.GET) + public String login(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException { + Principal principal = UserUtils.getPrincipal(); + + // 默认页签模式 + String tabmode = CookieUtils.getCookie(request, "tabmode"); + if (tabmode == null){ + CookieUtils.setCookie(response, "tabmode", "1"); + } + + if (logger.isDebugEnabled()){ + logger.debug("login, active session size: {}", sessionDAO.getActiveSessions(false).size()); + } + + // 如果已登录,再次访问主页,则退出原账号。 + if (Global.TRUE.equals(Global.getConfig("notAllowRefreshIndex"))){ + CookieUtils.setCookie(response, "LOGINED", "false"); + } + + // 如果已经登录,则跳转到管理首页 + if(principal != null && !principal.isMobileLogin()){ + return "redirect:" + adminPath; + } + + + SavedRequest savedRequest = WebUtils.getSavedRequest(request);//获取跳转到login之前的URL + // 如果是手机没有登录跳转到到login,则返回JSON字符串 + if(savedRequest != null){ + String queryStr = savedRequest.getQueryString(); + if( queryStr!=null &&( queryStr.contains("__ajax") || queryStr.contains("mobileLogin"))){ + AjaxJson j = new AjaxJson(); + j.setSuccess(false); + j.setErrorCode("0"); + j.setMsg("没有登录!"); + return renderString(response, j); + } + } + SysConfig sysConfig = new SysConfig(); + sysConfig.setType("loginImgUrl"); + List loginImgUrlSysConfig= sysConfigService.findList(sysConfig); + String loginImgUrl=""; + if(loginImgUrlSysConfig.size()>0){ + Random rand = new Random(); + loginImgUrl=loginImgUrlSysConfig.get(rand.nextInt(loginImgUrlSysConfig.size())).getPicture(); + } + + SysConfig validateCodeSysConfig = new SysConfig(); + validateCodeSysConfig.setType("validateCode"); + validateCodeSysConfig= sysConfigService.findListFirstCache(validateCodeSysConfig); + SysConfig versionSysConfig = new SysConfig(); + versionSysConfig.setType("version"); + versionSysConfig= sysConfigService.findListFirstCache(versionSysConfig); + model.addAttribute("loginImgUrl",loginImgUrl); + model.addAttribute("systemMode", sysConfigService.systemMode()); + model.addAttribute("validateCode",validateCodeSysConfig.getValue()); + model.addAttribute("version",versionSysConfig.getValue()); + //return "modules/sys/sysLogin"; + return "base/login"; + } + + @RequestMapping(value = "${adminPath}/register", method = RequestMethod.GET) + public String register(HttpServletRequest request, HttpServletResponse response, Model model, RedirectAttributes redirectAttributes) throws IOException { + Principal principal = UserUtils.getPrincipal(); + + // 默认页签模式 + String tabmode = CookieUtils.getCookie(request, "tabmode"); + if (tabmode == null){ + CookieUtils.setCookie(response, "tabmode", "1"); + } + + if (logger.isDebugEnabled()){ + logger.debug("login, active session size: {}", sessionDAO.getActiveSessions(false).size()); + } + + // 如果已登录,再次访问主页,则退出原账号。 + if (Global.TRUE.equals(Global.getConfig("notAllowRefreshIndex"))){ + CookieUtils.setCookie(response, "LOGINED", "false"); + } + + // 如果已经登录,则跳转到管理首页 + if(principal != null && !principal.isMobileLogin()){ + return "redirect:" + adminPath; + } + + + SavedRequest savedRequest = WebUtils.getSavedRequest(request);//获取跳转到login之前的URL + // 如果是手机没有登录跳转到到login,则返回JSON字符串 + if(savedRequest != null){ + String queryStr = savedRequest.getQueryString(); + if( queryStr!=null &&( queryStr.contains("__ajax") || queryStr.contains("mobileLogin"))){ + AjaxJson j = new AjaxJson(); + j.setSuccess(false); + j.setErrorCode("0"); + j.setMsg("没有登录!"); + return renderString(response, j); + } + } + + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/login"; + } + + //return "modules/sys/sysRegister"; + return "base/register"; + } + + /** + * 登录失败,真正登录的POST请求由Filter完成 + */ + @RequestMapping(value = "${adminPath}/login", method = RequestMethod.POST) + public String loginFail(HttpServletRequest request, HttpServletResponse response, Model model) { + Principal principal = UserUtils.getPrincipal(); + + // 如果已经登录,则跳转到管理首页 + if(principal != null){ + return "redirect:" + adminPath; + } + + String username = WebUtils.getCleanParam(request, FormAuthenticationFilter.DEFAULT_USERNAME_PARAM); + boolean rememberMe = WebUtils.isTrue(request, FormAuthenticationFilter.DEFAULT_REMEMBER_ME_PARAM); + boolean mobile = WebUtils.isTrue(request, FormAuthenticationFilter.DEFAULT_MOBILE_PARAM); + String exception = (String)request.getAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME); + String message = (String)request.getAttribute(FormAuthenticationFilter.DEFAULT_MESSAGE_PARAM); + + if (StringUtils.isBlank(message) || StringUtils.equals(message, "null")){ + message = "用户或密码错误, 请重试."; + } + + model.addAttribute(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM, username); + model.addAttribute(FormAuthenticationFilter.DEFAULT_REMEMBER_ME_PARAM, rememberMe); + model.addAttribute(FormAuthenticationFilter.DEFAULT_MOBILE_PARAM, mobile); + model.addAttribute(FormAuthenticationFilter.DEFAULT_ERROR_KEY_ATTRIBUTE_NAME, exception); + model.addAttribute(FormAuthenticationFilter.DEFAULT_MESSAGE_PARAM, message); + + if (logger.isDebugEnabled()){ + logger.debug("login fail, active session size: {}, message: {}, exception: {}", + sessionDAO.getActiveSessions(false).size(), message, exception); + } + + // 非授权异常,登录失败,验证码加1。 + if (!UnauthorizedException.class.getName().equals(exception)){ + model.addAttribute("isValidateCodeLogin", isValidateCodeLogin(username, true, false)); + } + + // 验证失败清空验证码 + request.getSession().setAttribute(ValidateCodeServlet.VALIDATE_CODE, IdGen.uuid()); + model.addAttribute("systemMode", sysConfigService.systemMode()); + + return "base/login"; + } + + /** + * 管理登录 + * @throws IOException + */ + @RequestMapping(value = "${adminPath}/logout", method = RequestMethod.GET) + public String logout(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException { + Principal principal = UserUtils.getPrincipal(); + // 如果已经登录,则跳转到管理首页 + if(principal != null){ + UserUtils.getSubject().logout(); + + } + // 如果是手机客户端退出跳转到login,则返回JSON字符串 + String ajax = request.getParameter("__ajax"); + if( ajax!=null){ + model.addAttribute("success", "1"); + model.addAttribute("msg", "退出成功"); + return renderString(response, model); + } + return "redirect:" + adminPath+"/login"; + } + + /** + * 登录成功,进入管理首页 + */ + @RequiresPermissions("user") + @RequestMapping(value = "${adminPath}") + public String index(HttpServletRequest request, HttpServletResponse response, Model model,RedirectAttributes redirectAttributes) { + Principal principal = UserUtils.getPrincipal(); + // 登录成功后,验证码计算器清零 + isValidateCodeLogin(principal.getLoginName(), false, true); + + if (logger.isDebugEnabled()){ + logger.debug("show index, active session size: {}", sessionDAO.getActiveSessions(false).size()); + } + + // 如果已登录,再次访问主页,则退出原账号。 + if (Global.TRUE.equals(Global.getConfig("notAllowRefreshIndex"))){ + String logined = CookieUtils.getCookie(request, "LOGINED"); + if (StringUtils.isBlank(logined) || "false".equals(logined)){ + CookieUtils.setCookie(response, "LOGINED", "true"); + }else if (StringUtils.equals(logined, "true")){ + UserUtils.getSubject().logout(); + return "redirect:" + adminPath + "/login"; + } + } + + SysConfig sysConfig = new SysConfig(); + sysConfig.setType("IMEnable"); + SysConfig IMEnableSysConfig= sysConfigService.findListFirstCache(sysConfig); + sysConfig.setType("tabmode"); + SysConfig tabmodeSysConfig= sysConfigService.findListFirstCache(sysConfig); + sysConfig.setType("skinSetttings"); + SysConfig skinSetttingsSysConfig= sysConfigService.findListFirstCache(sysConfig); + sysConfig.setType("version"); + SysConfig versionSysConfig= sysConfigService.findListFirstCache(sysConfig); + model.addAttribute("IMEnable", IMEnableSysConfig.getValue()); + model.addAttribute("tabmode", tabmodeSysConfig.getValue()); + model.addAttribute("skinSetttings", skinSetttingsSysConfig.getValue()); + model.addAttribute("systemMode", sysConfigService.systemMode()); + model.addAttribute("version", versionSysConfig.getValue()); + // 如果是手机登录,则返回JSON字符串 + if (principal.isMobileLogin()){ + if (request.getParameter("login") != null){ + return renderString(response, principal); + } + if (request.getParameter("index") != null){ + return "modules/sys/sysIndex"; + } + return "redirect:" + adminPath + "/login"; + } + +// // 登录成功后,获取上次登录的当前站点ID +// UserUtils.putCache("siteId", StringUtils.toLong(CookieUtils.getCookie(request, "siteId"))); + +// System.out.println("==========================a"); +// try { +// byte[] bytes = com.jeespring.common.utils.FileUtils.readFileToByteArray( +// com.jeespring.common.utils.FileUtils.getFile("c:\\sxt.dmp")); +// UserUtils.getSession().setAttribute("kkk", bytes); +// UserUtils.getSession().setAttribute("kkk2", bytes); +// } catch (Exception e) { +// e.printStackTrace(); +// } +//// for (int i=0; i<1000000; i++){ +//// //UserUtils.getSession().setAttribute("a", "a"); +//// request.getSession().setAttribute("aaa", "aa"); +//// } +// System.out.println("==========================b"); + // + // + + //return "modules/sys/sysIndex"; + return "base/index"; + } + + /** + * 获取主题方案 + */ + @RequestMapping(value = "/theme/{theme}") + public String getThemeInCookie(@PathVariable String theme, HttpServletRequest request, HttpServletResponse response){ + if (StringUtils.isNotBlank(theme)){ + CookieUtils.setCookie(response, "theme", theme); + }else{ + theme = CookieUtils.getCookie(request, "theme"); + } + return "redirect:"+request.getParameter("url"); + } + + /** + * 是否是验证码登录 + * @param useruame 用户名 + * @param isFail 计数加1 + * @param clean 计数清零 + * @return + */ + @SuppressWarnings("unchecked") + public static boolean isValidateCodeLogin(String useruame, boolean isFail, boolean clean){ + Map loginFailMap = (Map)CacheUtils.get("loginFailMap"); + if (loginFailMap==null){ + loginFailMap = Maps.newHashMap(); + CacheUtils.put("loginFailMap", loginFailMap); + } + Integer loginFailNum = loginFailMap.get(useruame); + if (loginFailNum==null){ + loginFailNum = 0; + } + if (isFail){ + loginFailNum++; + loginFailMap.put(useruame, loginFailNum); + } + if (clean){ + loginFailMap.remove(useruame); + } + return loginFailNum >= 3; + } + + + /** + * 首页 + * @throws IOException + */ + @RequestMapping(value = "${adminPath}/home") + public String home(HttpServletRequest request, HttpServletResponse response, Model model,RedirectAttributes redirectAttributes) throws IOException { + SysConfig sysConfig = new SysConfig(); //new一个新的xxx对象 + sysConfig.setType("homePageAboveInfomation");//传值 + List indexSysConfig= sysConfigService.findList(sysConfig);//查询系统配置项 + sysConfig.setType("homePageTechnical");//传值 + SysConfig homePageTechnicalSysConfig= sysConfigService.findListFirstCache(sysConfig);//查询系统配置项 + sysConfig.setType("homePageAuthorization");//传值 + SysConfig homePageAuthorizationSysConfig= sysConfigService.findListFirstCache(sysConfig);//查询系统配置项 + sysConfig.setType("homePageContactInfo");//传值 + SysConfig homePageContactInfoSysConfig= sysConfigService.findListFirstCache(sysConfig);//查询系统配置项 + sysConfig.setType("homePageInfomation");//传值 + SysConfig homePageInfomationSysConfig= sysConfigService.findListFirstCache(sysConfig);//查询系统配置项 + sysConfig.setType("version");//传值 + SysConfig versionSysConfig= sysConfigService.findListFirstCache(sysConfig);//查询系统配置项 + model.addAttribute("homePageTechnical",homePageTechnicalSysConfig.getDescription().toString()); + model.addAttribute("homePageAuthorization",homePageAuthorizationSysConfig.getDescription().toString()); + model.addAttribute("homePageContactInfo",homePageContactInfoSysConfig.getDescription().toString()); + model.addAttribute("homePageInfomation",homePageInfomationSysConfig.getDescription().toString()); + model.addAttribute("version",versionSysConfig.getValue()); + + if(indexSysConfig.size() == 0 ) { + indexSysConfig.add(new SysConfig()); + } + + OaNotify oaNotify = new OaNotify(); + Dict dict = new Dict(); + dict.setValue("1"); //传一个数据值 + //dict.setLabel("会议通知"); //传一个标签名 + List getDict =dictService.findList(dict);//按传的值查数据字典 + if(getDict != null){ + if(getDict.size() > 0){ + oaNotify.setType(getDict.get(0).getValue()); + } + } + Page pageOaNotify = oaNotifyService.find(new Page(request, response), oaNotify); + model.addAttribute("pageOaNotify",pageOaNotify); + + dict = new Dict(); + oaNotify = new OaNotify(); + dict.setValue("4"); + //dict.setLabel("升级日志"); + List getDictLog =dictService.findList(dict); + if(getDictLog != null){ + if(getDictLog.size() > 0){ + oaNotify.setType(getDictLog.get(0).getValue()); + } + } + Page pageOaNotifyLog = oaNotifyService.find(new Page(request, response), oaNotify); + model.addAttribute("pageOaNotifyLog",pageOaNotifyLog); + + dict = new Dict(); + oaNotify = new OaNotify(); + dict.setValue("5"); + //dict.setLabel("技术支持"); + List getDictTechnology =dictService.findList(dict); + if(getDictTechnology != null){ + if(getDictTechnology.size() > 0){ + oaNotify.setType(getDictTechnology.get(0).getValue()); + } + } + Page pageOaNotifyTechnology = oaNotifyService.find(new Page(request, response), oaNotify); + model.addAttribute("pageOaNotifyTechnology",pageOaNotifyTechnology); + + model.addAttribute("indexSysConfig",indexSysConfig.get(0)); + //return "modules/sys/sysHome"; + return "base/home"; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/MenuController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/MenuController.java new file mode 100644 index 0000000..38ce41c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/MenuController.java @@ -0,0 +1,206 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.Menu; +import com.jeespring.modules.sys.service.SystemService; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 菜单Controller + * @author 黄炳桂 516821420@qq.com + * @version 2013-3-23 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/menu") +public class MenuController extends AbstractBaseController { + + @Autowired + private SystemService systemService; + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute("menu") + public Menu get(@RequestParam(required=false) String id) { + if (StringUtils.isNotBlank(id)){ + return systemService.getMenu(id); + }else{ + return new Menu(); + } + } + + //RequiresPermissions("sys:menu:list") + @RequestMapping(value = {"list", ""}) + public String list(Model model, RedirectAttributes redirectAttributes) { + List list = Lists.newArrayList(); + List sourcelist = systemService.findAllMenu(); + //if(sysConfigService.isDemoMode()){ + // model.addAttribute("list", list); + // model.addAttribute("message", sysConfigService.isDemoModeDescription()); + // return "modules/sys/menuList"; + //}else{ + Menu.sortList(list, sourcelist, Menu.getRootId(), true); + //} + model.addAttribute("list", list); + return "modules/sys/menuList"; + } + + //RequiresPermissions(value={"sys:menu:view","sys:menu:add","sys:menu:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(Menu menu, Model model) { + if (menu.getParent()==null||menu.getParent().getId()==null){ + menu.setParent(new Menu(Menu.getRootId())); + } + menu.setParent(systemService.getMenu(menu.getParent().getId())); + // 获取排序号,最末节点排序号+30 + if (StringUtils.isBlank(menu.getId())){ + List list = Lists.newArrayList(); + List sourcelist = systemService.findAllMenu(); + Menu.sortList(list, sourcelist, menu.getParentId(), false); + if (list.size() > 0){ + menu.setSort(list.get(list.size()-1).getSort() + 30); + } + } + model.addAttribute("menu", menu); + return "modules/sys/menuForm"; + } + + //RequiresPermissions(value={"sys:menu:add","sys:menu:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(Menu menu, Model model, RedirectAttributes redirectAttributes) { + if(!UserUtils.getUser().isAdmin()){ + addMessage(redirectAttributes, "越权操作,只有超级管理员才能添加或修改数据!"); + return "redirect:" + adminPath + "/sys/role/?repage"; + } + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/menu/"; + } + if (!beanValidator(model, menu)){ + return form(menu, model); + } + systemService.saveMenu(menu); + addMessage(redirectAttributes, "保存菜单'" + menu.getName() + "'成功"); + return "redirect:" + adminPath + "/sys/menu/"; + } + + //RequiresPermissions("sys:menu:del") + @RequestMapping(value = "delete") + public String delete(Menu menu, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/menu/"; + } +// if (Menu.isRoot(id)){ +// addMessage(redirectAttributes, "删除菜单失败, 不允许删除顶级菜单或编号为空"); +// }else{ + systemService.deleteMenu(menu); + addMessage(redirectAttributes, "删除菜单成功"); +// } + return "redirect:" + adminPath + "/sys/menu/"; + } + + //RequiresPermissions("sys:menu:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes,sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/menu/"; + } +// if (Menu.isRoot(id)){ +// addMessage(redirectAttributes, "删除菜单失败, 不允许删除顶级菜单或编号为空"); +// }else{ + String[] idArray = ids.split(","); + for(String id : idArray){ + Menu menu = systemService.getMenu(id); + if(menu != null){ + systemService.deleteMenu(systemService.getMenu(id)); + } + } + + addMessage(redirectAttributes, "删除菜单成功"); +// } + return "redirect:" + adminPath + "/sys/menu/"; + } + //RequiresPermissions("user") + @RequestMapping(value = "tree") + public String tree() { + return "modules/sys/menuTree"; + } + + //RequiresPermissions("user") + @RequestMapping(value = "treeselect") + public String treeselect(String parentId, Model model) { + model.addAttribute("parentId", parentId); + return "modules/sys/menuTreeselect"; + } + + /** + * 批量修改菜单排序 + */ + //RequiresPermissions("sys:menu:updateSort") + @RequestMapping(value = "updateSort") + public String updateSort(String[] ids, Integer[] sorts, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/menu/"; + } + for (int i = 0; i < ids.length; i++) { + Menu menu = new Menu(ids[i]); + menu.setSort(sorts[i]); + systemService.updateMenuSort(menu); + } + addMessage(redirectAttributes, "保存菜单排序成功!"); + return "redirect:" + adminPath + "/sys/menu/"; + } + + /** + * isShowHide是否显示隐藏菜单 + * @param extId + * @param isShowHidden + * @param response + * @return + */ + //RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "treeData") + public List> treeData(@RequestParam(required=false) String extId,@RequestParam(required=false) String isShowHide, HttpServletResponse response) { + List> mapList = Lists.newArrayList(); + List list = systemService.findAllMenu(); + for (int i=0; i map = Maps.newHashMap(); + map.put("id", e.getId()); + map.put("pId", e.getParentId()); + map.put("name", e.getName()); + mapList.add(map); + } + } + return mapList; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/OfficeController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/OfficeController.java new file mode 100644 index 0000000..c9b8a4c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/OfficeController.java @@ -0,0 +1,182 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.OfficeService; +import com.jeespring.modules.sys.utils.DictUtils; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 机构Controller + * @author 黄炳桂 516821420@qq.com + * @version 2013-5-15 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/office") +public class OfficeController extends AbstractBaseController { + + @Autowired + private OfficeService officeService; + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute("office") + public Office get(@RequestParam(required=false) String id) { + if (StringUtils.isNotBlank(id)){ + return officeService.get(id); + }else{ + return new Office(); + } + } + + //RequiresPermissions("sys:office:index") + @RequestMapping(value = {"","index"}) + public String index(Office office, Model model) { +// model.addAttribute("list", officeService.findAll()); + return "modules/sys/officeIndex"; + } + + //RequiresPermissions("sys:office:index") + @RequestMapping(value = {"list"}) + public String list(Office office, Model model) { + if(office==null || office.getParentIds() == null){ + model.addAttribute("list", officeService.findList(false)); + }else{ + model.addAttribute("list", officeService.findList(office)); + } + return "modules/sys/officeList"; + } + + //RequiresPermissions(value={"sys:office:view","sys:office:add","sys:office:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(Office office, Model model) { + User user = UserUtils.getUser(); + if (office.getParent()==null || office.getParent().getId()==null){ + office.setParent(user.getOffice()); + } + office.setParent(officeService.get(office.getParent().getId())); + if (office.getArea()==null){ + office.setArea(user.getOffice().getArea()); + } + // 自动获取排序号 + if (StringUtils.isBlank(office.getId())&&office.getParent()!=null){ + int size = 0; + List list = officeService.findAll(); + for (int i=0; i 0 ? size+1 : 1), 3, "0")); + } + model.addAttribute("office", office); + return "modules/sys/officeForm"; + } + + //RequiresPermissions(value={"sys:office:add","sys:office:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(Office office, Model model, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/office/"; + } + if (!beanValidator(model, office)){ + return form(office, model); + } + officeService.save(office); + + if(office.getChildDeptList()!=null){ + Office childOffice = null; + for(String id : office.getChildDeptList()){ + childOffice = new Office(); + childOffice.setName(DictUtils.getDictLabel(id, "sys_office_common", "未知")); + childOffice.setParent(office); + childOffice.setArea(office.getArea()); + childOffice.setType("2"); + childOffice.setGrade(String.valueOf(Integer.valueOf(office.getGrade())+1)); + childOffice.setUseable(Global.YES); + officeService.save(childOffice); + } + } + + addMessage(redirectAttributes, "保存机构'" + office.getName() + "'成功"); + String id = "0".equals(office.getParentId()) ? "" : office.getParentId(); + return "redirect:" + adminPath + "/sys/office/list?id="+id+"&parentIds="+office.getParentIds(); + } + + //RequiresPermissions("sys:office:del") + @RequestMapping(value = "delete") + public String delete(Office office, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/office/list"; + } +// if (Office.isRoot(id)){ +// addMessage(redirectAttributes, "删除机构失败, 不允许删除顶级机构或编号空"); +// }else{ + officeService.delete(office); + addMessage(redirectAttributes, "删除机构成功"); +// } + return "redirect:" + adminPath + "/sys/office/list?id="+office.getParentId()+"&parentIds="+office.getParentIds(); + } + + /** + * 获取机构JSON数据。 + * @param extId 排除的ID + * @param type 类型(1:公司;2:部门/小组/其它:3:用户) + * @param grade 显示级别 + * @param response + * @return + */ + //RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "treeData") + public List> treeData(@RequestParam(required=false) String extId, @RequestParam(required=false) String type, + @RequestParam(required=false) Long grade, @RequestParam(required=false) Boolean isAll, HttpServletResponse response) { + List> mapList = Lists.newArrayList(); + List list = officeService.findList(isAll); + for (int i=0; i map = Maps.newHashMap(); + map.put("id", e.getId()); + map.put("pId", e.getParentId()); + map.put("pIds", e.getParentIds()); + map.put("name", e.getName()); + if (type != null && "3".equals(type)){ + map.put("isParent", true); + } + mapList.add(map); + } + } + return mapList; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/RegisterController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/RegisterController.java new file mode 100644 index 0000000..c5b0051 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/RegisterController.java @@ -0,0 +1,241 @@ +package com.jeespring.modules.sys.web; + + +import java.io.IOException; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.config.Global; +import com.jeespring.common.json.AjaxJson; +import com.jeespring.common.utils.FileUtils; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.dao.UserDao; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.Role; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.OfficeService; +import com.jeespring.modules.sys.service.SystemService; +import com.jeespring.modules.sys.utils.UserUtils; + + +/** + * 用户Controller + * @author 黄炳桂 516821420@qq.com + * @version 2013-8-29 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/register") +public class RegisterController extends AbstractBaseController { + + @Autowired + private SystemService systemService; + + @Autowired + private OfficeService officeService; + + @Autowired + private UserDao userDao; + + @ModelAttribute + public User get(@RequestParam(required=false) String id) { + if (StringUtils.isNotBlank(id)){ + return systemService.getUser(id); + }else{ + return new User(); + } + } + + + + @RequestMapping(value = {"index",""}) + public String register(User user, Model model) { + //return "modules/sys/register"; + //return "redirect:" + adminPath + "/login"; + //return "redirect:" + adminPath + "/register"; + model.addAttribute("user", user); + return "modules/sys/sysRegister"; + } + + + @RequestMapping(value = "registerUser") + public String registerUser( HttpServletRequest request,HttpServletResponse response, boolean mobileLogin, String randomCode, String roleName, User user, Model model, RedirectAttributes redirectAttributes) { + + + //验证手机号是否已经注册 + + if(userDao.findUniqueByProperty("mobile", user.getMobile()) != null){ + // 如果是手机登录,则返回JSON字符串 + if (mobileLogin){ + AjaxJson j = new AjaxJson(); + j.setSuccess(false); + j.setErrorCode("1"); + j.setMsg("手机号已经被使用!"); + return renderString(response, j.getJsonStr()); + }else{ + addMessage(redirectAttributes, "手机号已经被使用!"); + model.addAttribute("message", "手机号已经被使用!"); + return register(user, model); + } + } + + //验证用户是否已经注册 + + if(userDao.findUniqueByProperty("login_name", user.getLoginName()) != null){ + // 如果是手机登录,则返回JSON字符串 + if (mobileLogin){ + AjaxJson j = new AjaxJson(); + j.setSuccess(false); + j.setErrorCode("2"); + j.setMsg("用户名已经被注册!"); + return renderString(response, j.getJsonStr()); + }else{ + addMessage(redirectAttributes, "用户名已经被注册!"); + model.addAttribute("message", "用户名已经被注册!"); + return register(user, model); + } + } + + //验证短信内容 + /*if(!randomCode.equals(request.getSession().getServletContext().getAttribute(user.getMobile()))){ + // 如果是手机登录,则返回JSON字符串 + if (mobileLogin){ + AjaxJson j = new AjaxJson(); + j.setSuccess(false); + j.setErrorCode("3"); + j.setMsg("手机验证码不正确!"); + return renderString(response, j.getJsonStr()); + }else{ + addMessage(model, "手机验证码不正确!"); + return register(user, model); + } + }*/ + + + // 修正引用赋值问题,不知道为何,Company和Office引用的一个实例地址,修改了一个,另外一个跟着修改。 + Role role = systemService.getRoleByEnname(roleName); + String officeCode = "1000"; + if("patient".equals(roleName)){ + officeCode = "1001"; + } + Office office = officeService.getByCode(officeCode); + // 密码MD5加密 + user.setPassword(SystemService.entryptPassword(user.getPassword())); + if (systemService.getUserByLoginName(user.getLoginName()) != null){ + addMessage(redirectAttributes, "注册用户'" + user.getLoginName() + "'失败,用户名已存在"); + model.addAttribute("message", "注册用户'" + user.getLoginName() + "'失败,用户名已存在"); + return register(user, model); + } + // 角色数据有效性验证,过滤不在授权内的角色 + List roleList = Lists.newArrayList(); + roleList.add(role); + user.setRoleList(roleList); + //保存机构 + user.setCompany(office); + user.setOffice(office); + //生成用户二维码,使用登录名 + String realPath = Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + + user.getId() + "/qrcode/"; + FileUtils.createDirectory(realPath); + String name= user.getId()+".png"; //encoderImgId此处二维码的图片名 + String filePath = realPath + name; //存放路径 + //TwoDimensionCode.encoderQRCode(user.getLoginName(), filePath, "png");//执行生成二维码 + user.setQrCode(request.getContextPath()+Global.USERFILES_BASE_URL + + user.getId() + "/qrcode/"+name); + // 保存用户信息 + systemService.saveUser(user); + // 清除当前用户缓存 + if (user.getLoginName().equals(UserUtils.getUser().getLoginName())){ + UserUtils.clearCache(); + //UserUtils.getCacheMap().clear(); + } + request.getSession().getServletContext().removeAttribute(user.getMobile());//清除验证码 + + // 如果是手机登录,则返回JSON字符串 + if (mobileLogin){ + AjaxJson j = new AjaxJson(); + j.setSuccess(true); + j.setMsg("注册用户'" + user.getLoginName() + "'成功"); + return renderString(response, j); + } + + + addMessage(redirectAttributes, "注册用户'" + user.getLoginName() + "'成功"); + return "redirect:" + adminPath + "/login"; + } + + + /** + * 获取验证码 + * @param request + * @param response + * @param mobile + * @param model + * @param redirectAttributes + * @return + */ + @RequestMapping(value = "getRegisterCode") + @ResponseBody + public AjaxJson getRegisterCode(HttpServletRequest request,HttpServletResponse response, String mobile, + Model model, RedirectAttributes redirectAttributes) { + AjaxJson j = new AjaxJson(); + + //验证手机号是否已经注册 + if(userDao.findUniqueByProperty("mobile", mobile) != null){ + + j.setSuccess(false); + j.setErrorCode("1"); + j.setMsg("手机号已经被使用!"); + return j; + } + + String randomCode = String.valueOf((int) (Math.random() * 9000 + 1000)); + try { + String result =UserUtils.sendRandomCode(mobile, randomCode, mobile, randomCode); + if (!"100".equals(result)) { + j.setSuccess(false); + j.setErrorCode("2"); + j.setMsg("短信发送失败,错误代码:"+result+",请联系管理员。"); + }else{ + j.setSuccess(true); + j.setErrorCode("-1"); + j.setMsg("短信发送成功!"); + request.getSession().getServletContext().setAttribute(mobile, randomCode); + } + } catch (IOException e) { + j.setSuccess(false); + j.setErrorCode("3"); + j.setMsg("因未知原因导致短信发送失败,请联系管理员。"); + } + return j; + } + + + /** + * web端ajax验证手机验证码是否正确 + */ + @ResponseBody + @RequestMapping(value = "validateMobileCode") + public boolean validateMobileCode(HttpServletRequest request, + String mobile, String randomCode) { + if (randomCode.equals(request.getSession().getServletContext().getAttribute(mobile))) { + return true; + } else { + return false; + } + } + + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/RoleController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/RoleController.java new file mode 100644 index 0000000..d51595a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/RoleController.java @@ -0,0 +1,320 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.utils.Collections3; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.Role; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.OfficeService; +import com.jeespring.modules.sys.service.SystemService; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 角色Controller + * @author 黄炳桂 516821420@qq.com + * @version 2013-12-05 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/role") +public class RoleController extends AbstractBaseController { + + @Autowired + private SystemService systemService; + + @Autowired + private OfficeService officeService; + @Autowired + private SysConfigService sysConfigService; + + + @ModelAttribute("role") + public Role get(@RequestParam(required=false) String id) { + if (StringUtils.isNotBlank(id)){ + return systemService.getRole(id); + }else{ + return new Role(); + } + } + + //RequiresPermissions("sys:role:list") + @RequestMapping(value = {"list", ""}) + public String list(Role role, Model model) { + List list = systemService.findRole(role); + model.addAttribute("list", list); + return "modules/sys/roleList"; + } + + //RequiresPermissions(value={"sys:role:view","sys:role:add","sys:role:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(Role role, Model model) { + if (role.getOffice()==null){ + role.setOffice(UserUtils.getUser().getOffice()); + } + model.addAttribute("role", role); + model.addAttribute("menuList", systemService.findAllMenu()); + model.addAttribute("officeList", officeService.findAll()); + return "modules/sys/roleForm"; + } + + //RequiresPermissions("sys:role:auth") + @RequestMapping(value = "auth") + public String auth(Role role, Model model) { + if (role.getOffice()==null){ + role.setOffice(UserUtils.getUser().getOffice()); + } + model.addAttribute("role", role); + model.addAttribute("menuList", systemService.findAllMenu()); + model.addAttribute("officeList", officeService.findAll()); + return "modules/sys/roleAuth"; + } + + //RequiresPermissions(value={"sys:role:assign","sys:role:auth","sys:role:add","sys:role:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(Role role, Model model, RedirectAttributes redirectAttributes) { + if(!UserUtils.getUser().isAdmin()&&role.getSysData().equals(Global.YES)){ + addMessage(redirectAttributes, "越权操作,只有超级管理员才能修改此数据!"); + return "redirect:" + adminPath + "/sys/role/?repage"; + } + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes,sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/role/?repage"; + } + if (!beanValidator(model, role)){ + return list(role, model); + } + if (!"true".equals(checkName(role.getOldName(), role.getName()))){ + addMessage(model, "保存角色'" + role.getName() + "'失败, 角色名已存在"); + return list(role, model); + } + if (!"true".equals(checkEnname(role.getOldEnname(), role.getEnname()))){ + addMessage(model, "保存角色'" + role.getName() + "'失败, 英文名已存在"); + return list(role, model); + } + systemService.saveRole(role); + addMessage(redirectAttributes, "保存角色'" + role.getName() + "'成功"); + return "redirect:" + adminPath + "/sys/role/?repage"; + } + + //RequiresPermissions("sys:role:del") + @RequestMapping(value = "delete") + public String delete(Role role, RedirectAttributes redirectAttributes) { + if(!UserUtils.getUser().isAdmin() && role.getSysData().equals(Global.YES)){ + addMessage(redirectAttributes, "越权操作,只有超级管理员才能修改此数据!"); + return "redirect:" + adminPath + "/sys/role/?repage"; + } + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/role/?repage"; + } +// if (Role.isAdmin(id)){ +// addMessage(redirectAttributes, "删除角色失败, 不允许内置角色或编号空"); +//// }else if (UserUtils.getUser().getRoleIdList().contains(id)){ +//// addMessage(redirectAttributes, "删除角色失败, 不能删除当前用户所在角色"); +// }else{ + systemService.deleteRole(role); + addMessage(redirectAttributes, "删除角色成功"); +// } + return "redirect:" + adminPath + "/sys/role/?repage"; + } + + /** + * 批量删除角色 + */ + //RequiresPermissions("sys:role:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes,sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/role/?repage"; + } + String[] idArray = ids.split(","); + StringBuffer msg = new StringBuffer(); + for(String id : idArray){ + Role role = systemService.getRole(id); + if(!UserUtils.getUser().isAdmin() && role.getSysData().equals(Global.YES)){ + msg.append( "越权操作,只有超级管理员才能修改["+role.getName()+"]数据!
    "); + }else{ + systemService.deleteRole(role); + msg.append( "删除角色["+role.getName()+"]成功
    "); + + } + } + addMessage(redirectAttributes, msg.toString()); + return "redirect:" + adminPath + "/sys/role/?repage"; + } + + /** + * 角色分配页面 + * @param role + * @param model + * @return + */ + //RequiresPermissions("sys:role:assign") + @RequestMapping(value = "assign") + public String assign(Role role, Model model) { + List userList = systemService.findUser(new User(new Role(role.getId()))); + model.addAttribute("userList", userList); + return "modules/sys/roleAssign"; + } + + /** + * 角色分配 -- 打开角色分配对话框 + * @param role + * @param model + * @return + */ + //RequiresPermissions("sys:role:assign") + @RequestMapping(value = "usertorole") + public String selectUserToRole(Role role, Model model) { + List userList = systemService.findUser(new User(new Role(role.getId()))); + model.addAttribute("role", role); + model.addAttribute("userList", userList); + model.addAttribute("selectIds", Collections3.extractToString(userList, "name", ",")); + model.addAttribute("officeList", officeService.findAll()); + return "modules/sys/selectUserToRole"; + } + + /** + * 角色分配 -- 根据部门编号获取用户列表 + * @param officeId + * @param response + * @return + */ + //RequiresPermissions("sys:role:assign") + @ResponseBody + @RequestMapping(value = "users") + public List> users(String officeId, HttpServletResponse response) { + List> mapList = Lists.newArrayList(); + User user = new User(); + user.setOffice(new Office(officeId)); + Page page = systemService.findUser(new Page(1, -1), user); + for (User e : page.getList()) { + Map map = Maps.newHashMap(); + map.put("id", e.getId()); + map.put("pId", 0); + map.put("name", e.getName()); + mapList.add(map); + } + return mapList; + } + + /** + * 角色分配 -- 从角色中移除用户 + * @param userId + * @param roleId + * @param redirectAttributes + * @return + */ + //RequiresPermissions("sys:role:assign") + @RequestMapping(value = "outrole") + public String outrole(String userId, String roleId, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/role/assign?id="+roleId; + } + Role role = systemService.getRole(roleId); + User user = systemService.getUser(userId); + if (UserUtils.getUser().getId().equals(userId)) { + addMessage(redirectAttributes, "无法从角色【" + role.getName() + "】中移除用户【" + user.getName() + "】自己!"); + }else { + if (user.getRoleList().size() <= 1){ + addMessage(redirectAttributes, "用户【" + user.getName() + "】从角色【" + role.getName() + "】中移除失败!这已经是该用户的唯一角色,不能移除。"); + }else{ + Boolean flag = systemService.outUserInRole(role, user); + if (!flag) { + addMessage(redirectAttributes, "用户【" + user.getName() + "】从角色【" + role.getName() + "】中移除失败!"); + }else { + addMessage(redirectAttributes, "用户【" + user.getName() + "】从角色【" + role.getName() + "】中移除成功!"); + } + } + } + return "redirect:" + adminPath + "/sys/role/assign?id="+role.getId(); + } + + /** + * 角色分配 + * @param role + * @param idsArr + * @param redirectAttributes + * @return + */ + //RequiresPermissions("sys:role:assign") + @RequestMapping(value = "assignrole") + public String assignRole(Role role, String[] idsArr, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/role/assign?id="+role.getId(); + } + StringBuilder msg = new StringBuilder(); + int newNum = 0; + for (int i = 0; i < idsArr.length; i++) { + User user = systemService.assignUserToRole(role, systemService.getUser(idsArr[i])); + if (null != user) { + msg.append("
    新增用户【" + user.getName() + "】到角色【" + role.getName() + "】!"); + newNum++; + } + } + addMessage(redirectAttributes, "已成功分配 "+newNum+" 个用户"+msg); + return "redirect:" + adminPath + "/sys/role/assign?id="+role.getId(); + } + + /** + * 验证角色名是否有效 + * @param oldName + * @param name + * @return + */ + //RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "checkName") + public String checkName(String oldName, String name) { + if (name!=null && name.equals(oldName)) { + return "true"; + } else if (name!=null && systemService.getRoleByName(name) == null) { + return "true"; + } + return "false"; + } + + /** + * 验证角色英文名是否有效 + * @param oldName + * @param name + * @return + */ + //RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "checkEnname") + public String checkEnname(String oldEnname, String enname) { + if (enname!=null && enname.equals(oldEnname)) { + return "true"; + } else if (enname!=null && systemService.getRoleByEnname(enname) == null) { + return "true"; + } + return "false"; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysConfigController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysConfigController.java new file mode 100644 index 0000000..90174bf --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysConfigController.java @@ -0,0 +1,232 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.sys.service.SysConfigService; +/** + * 系统配置Controller + * @author 黄炳桂 516821420@qq.com + * @version 2017-11-17 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/sysConfig") +public class SysConfigController extends AbstractBaseController { + + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute + public SysConfig get(@RequestParam(required=false) String id) { + SysConfig entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysConfigService.get(id); + } + if (entity == null){ + entity = new SysConfig(); + } + return entity; + } + + /** + * 系统配置列表页面 + */ + //RequiresPermissions("sys:sysConfig:list") + @RequestMapping(value = {"list", ""}) + public String list(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysConfigService.findPage(new Page(request, response), sysConfig); + model.addAttribute("page", page); + return "modules/sys/sysConfigList"; + } + + /** + * 系统配置列表页面 + */ + //RequiresPermissions("sys:sysConfig:select") + @RequestMapping(value = {"select"}) + public String select(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysConfigService.findPage(new Page(request, response), sysConfig); + model.addAttribute("page", page); + return "modules/sys/sysConfigSelect"; + } + + /** + * 查看,增加,编辑系统配置表单页面 + */ + //RequiresPermissions(value={"sys:sysConfig:view","sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(SysConfig sysConfig, Model model) { + model.addAttribute("sysConfig", sysConfig); + return "modules/sys/sysConfigForm"; + } + + /** + * 保存系统配置 + */ + //RequiresPermissions(value={"sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(SysConfig sysConfig, Model model, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfig/?repage"; + } + + if (!beanValidator(model, sysConfig)){ + return form(sysConfig, model); + } + sysConfigService.save(sysConfig); + addMessage(redirectAttributes, "保存系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysConfig/?repage"; + } + + /** + * 删除系统配置 + */ + //RequiresPermissions("sys:sysConfig:del") + @RequestMapping(value = "delete") + public String delete(SysConfig sysConfig, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfig/?repage"; + } + + sysConfigService.delete(sysConfig); + addMessage(redirectAttributes, "删除系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysConfig/?repage"; + } + + /** + * 删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + //RequiresPermissions("sys:sysConfig:delByLogic") + @RequestMapping(value = "deleteByLogic") + public String deleteByLogic(SysConfig sysConfig, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfig/?repage"; + } + + sysConfigService.deleteByLogic(sysConfig); + addMessage(redirectAttributes, "逻辑删除系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysConfig/?repage"; + } + + /** + * 批量删除系统配置 + */ + //RequiresPermissions("sys:sysConfig:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfig/?repage"; + } + + String[] idArray = ids.split(","); + for(String id : idArray){ + sysConfigService.delete(sysConfigService.get(id)); + } + addMessage(redirectAttributes, "删除系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysConfig/?repage"; + } + + /** + * 批量删除系统配置(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + //RequiresPermissions("sys:sysConfig:delByLogic") + @RequestMapping(value = "deleteAllByLogic") + public String deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfig/?repage"; + } + + String[] idArray = ids.split(","); + for(String id : idArray){ + sysConfigService.deleteByLogic(sysConfigService.get(id)); + } + addMessage(redirectAttributes, "删除系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysConfig/?repage"; + } + + /** + * 导出excel文件 + */ + //RequiresPermissions("sys:sysConfig:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(SysConfig sysConfig, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "系统配置"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = sysConfigService.findPage(new Page(request, response, -1), sysConfig); + new ExportExcel("系统配置", SysConfig.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出系统配置记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysConfig/?repage"; + } + + /** + * 导入Excel数据 + + */ + //RequiresPermissions("sys:sysConfig:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + try { + int successNum = 0; + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(SysConfig.class); + for (SysConfig sysConfig : list){ + sysConfigService.save(sysConfig); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条系统配置记录"); + } catch (Exception e) { + addMessage(redirectAttributes, "导入系统配置失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysConfig/?repage"; + } + + /** + * 下载导入系统配置数据模板 + */ + //RequiresPermissions("sys:sysConfig:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "系统配置数据导入模板.xlsx"; + List list = Lists.newArrayList(); + new ExportExcel("系统配置数据", SysConfig.class, 1).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysConfig/?repage"; + } + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysConfigTreeController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysConfigTreeController.java new file mode 100644 index 0000000..1571b53 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysConfigTreeController.java @@ -0,0 +1,158 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.sys.entity.SysConfigTree; +import com.jeespring.modules.sys.service.SysConfigTreeService; + +/** + * 系统配置Controller + * @author JeeSpring + * @version 2018-08-22 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/sysConfigTree") +public class SysConfigTreeController extends AbstractBaseController { + @Autowired + private SysConfigService sysConfigService; + + @Autowired + private SysConfigTreeService sysConfigTreeService; + + @ModelAttribute + public SysConfigTree get(@RequestParam(required=false) String id) { + SysConfigTree entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysConfigTreeService.get(id); + } + if (entity == null){ + entity = new SysConfigTree(); + } + return entity; + } + + /** + * 系统配置列表页面 + */ + //@RequiresPermissions("sys:sysConfig:list") + @RequestMapping(value = {"list", ""}) + public String list(SysConfigTree sysConfig, HttpServletRequest request, HttpServletResponse response, Model model) { + List list = sysConfigTreeService.findList(sysConfig); + for(SysConfigTree item:list){ + if(item.getDescription()==null) { + item.setDescription(""); + } + if(item.getDescription().length()>20) { + item.setDescription(item.getDescription().substring(0, 20)); + } + } + model.addAttribute("list", list); + return "modules/sys/sysConfigTreeList"; + } + + /** + * 查看,增加,编辑系统配置表单页面 + */ + //@RequiresPermissions(value={"sys:sysConfig:view","sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(SysConfigTree sysConfig, Model model) { + if (sysConfig.getParent()!=null && StringUtils.isNotBlank(sysConfig.getParent().getId())){ + sysConfig.setParent(sysConfigTreeService.get(sysConfig.getParent().getId())); + // 获取排序号,最末节点排序号+30 + if (StringUtils.isBlank(sysConfig.getId())){ + SysConfigTree sysConfigChild = new SysConfigTree(); + sysConfigChild.setParent(new SysConfigTree(sysConfig.getParent().getId())); + List list = sysConfigTreeService.findList(sysConfig); + if (list.size() > 0){ + sysConfig.setSort(list.get(list.size()-1).getSort()); + if (sysConfig.getSort() != null){ + sysConfig.setSort(sysConfig.getSort() + 30); + } + } + } + } + if (sysConfig.getSort() == null){ + sysConfig.setSort(30); + } + model.addAttribute("sysConfig", sysConfig); + return "modules/sys/sysConfigTreeForm"; + } + + /** + * 保存系统配置 + */ + //@RequiresPermissions(value={"sys:sysConfig:add","sys:sysConfig:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(SysConfigTree sysConfig, Model model, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfigTree/?repage"; + } + if (!beanValidator(model, sysConfig)){ + return form(sysConfig, model); + } + sysConfigTreeService.save(sysConfig); + addMessage(redirectAttributes, "保存系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysConfigTree/?repage"; + } + + /** + * 删除系统配置 + */ + //@RequiresPermissions("sys:sysConfig:del") + @RequestMapping(value = "delete") + public String delete(SysConfigTree sysConfig, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfigTree/?repage"; + } + + sysConfigTreeService.delete(sysConfig); + addMessage(redirectAttributes, "删除系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysConfigTree/?repage"; + } + + //@RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "treeData") + public List> treeData(@RequestParam(required=false) String extId, HttpServletResponse response) { + List> mapList = Lists.newArrayList(); + List list = sysConfigTreeService.findList(new SysConfigTree()); + for (int i=0; i map = Maps.newHashMap(); + map.put("id", e.getId()); + map.put("pId", e.getParentId()); + map.put("name", e.getName()); + mapList.add(map); + } + } + return mapList; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysDictTreeController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysDictTreeController.java new file mode 100644 index 0000000..4dab416 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysDictTreeController.java @@ -0,0 +1,150 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.jeespring.modules.sys.service.SysConfigService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.config.Global; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.sys.entity.SysDictTree; +import com.jeespring.modules.sys.service.SysDictTreeService; + +/** + * 数据字典Controller + * @author JeeSpring + * @version 2018-08-22 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/sysDictTree") +public class SysDictTreeController extends AbstractBaseController { + @Autowired + private SysConfigService sysConfigService; + @Autowired + private SysDictTreeService sysDictTreeService; + + @ModelAttribute + public SysDictTree get(@RequestParam(required=false) String id) { + SysDictTree entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysDictTreeService.get(id); + } + if (entity == null){ + entity = new SysDictTree(); + } + return entity; + } + + /** + * 数据字典列表页面 + */ + //@RequiresPermissions("sys:sysDict:list") + @RequestMapping(value = {"list", ""}) + public String list(SysDictTree sysDict, HttpServletRequest request, HttpServletResponse response, Model model) { + List list = sysDictTreeService.findList(sysDict); + model.addAttribute("list", list); + return "modules/sys/sysDictTreeList"; + } + + /** + * 查看,增加,编辑数据字典表单页面 + */ + //@RequiresPermissions(value={"sys:sysDict:view","sys:sysDict:add","sys:sysDict:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(SysDictTree sysDict, Model model) { + if (sysDict.getParent()!=null && StringUtils.isNotBlank(sysDict.getParent().getId())){ + sysDict.setParent(sysDictTreeService.get(sysDict.getParent().getId())); + // 获取排序号,最末节点排序号+30 + if (StringUtils.isBlank(sysDict.getId())){ + SysDictTree sysDictChild = new SysDictTree(); + sysDictChild.setParent(new SysDictTree(sysDict.getParent().getId())); + List list = sysDictTreeService.findList(sysDict); + if (list.size() > 0){ + sysDict.setSort(list.get(list.size()-1).getSort()); + if (sysDict.getSort() != null){ + sysDict.setSort(sysDict.getSort() + 30); + } + } + } + } + if (sysDict.getSort() == null){ + sysDict.setSort(30); + } + model.addAttribute("sysDict", sysDict); + return "modules/sys/sysDictTreeForm"; + } + + /** + * 保存数据字典 + */ + //@RequiresPermissions(value={"sys:sysDict:add","sys:sysDict:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(SysDictTree sysDict, Model model, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfigTree/?repage"; + } + + if (!beanValidator(model, sysDict)){ + return form(sysDict, model); + } + sysDictTreeService.save(sysDict); + addMessage(redirectAttributes, "保存数据字典成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysDictTree/?repage"; + } + + /** + * 删除数据字典 + */ + //@RequiresPermissions("sys:sysDict:del") + @RequestMapping(value = "delete") + public String delete(SysDictTree sysDict, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/sysConfigTree/?repage"; + } + + sysDictTreeService.delete(sysDict); + addMessage(redirectAttributes, "删除数据字典成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysDictTree/?repage"; + } + + //@RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "treeData") + public List> treeData(@RequestParam(required=false) String extId, HttpServletResponse response) { + List> mapList = Lists.newArrayList(); + List list = sysDictTreeService.findList(new SysDictTree()); + for (int i=0; i map = Maps.newHashMap(); + map.put("id", e.getId()); + map.put("pId", e.getParentId()); + map.put("name", e.getName()); + mapList.add(map); + } + } + return mapList; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysUserOnlineController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysUserOnlineController.java new file mode 100644 index 0000000..689a821 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SysUserOnlineController.java @@ -0,0 +1,288 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.sys.entity.SysUserOnline; +import com.jeespring.modules.sys.service.SysUserOnlineService; +/** + * 在线用户记录Controller + * @author JeeSpring + * @version 2018-08-16 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/sysUserOnline") +public class SysUserOnlineController extends AbstractBaseController { + + @Autowired + private SysUserOnlineService sysUserOnlineService; + + @ModelAttribute + public SysUserOnline get(@RequestParam(required=false) String id) { + SysUserOnline entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysUserOnlineService.getCache(id); + //entity = sysUserOnlineService.get(id); + } + if (entity == null){ + entity = new SysUserOnline(); + } + return entity; + } + + /** + * 在线用户记录统计页面 + */ + @RequiresPermissions("sys:sysUserOnline:total") + @RequestMapping(value = {"total"}) + public String totalView(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + total(sysUserOnline,request,response,model); + return "modules/sys/sysUserOnlineTotal"; + } + private void total(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + if(StringUtils.isEmpty(sysUserOnline.getTotalType())){ + sysUserOnline.setTotalType("%Y-%m-%d"); + } + //X轴的数据 + List xAxisData= new ArrayList(); + //Y轴的数据 + Map> yAxisData = new HashMap>(); + List countList = new ArrayList(); + List sumList = new ArrayList(); + if( sysUserOnline.getOrderBy()==""){ + sysUserOnline.setOrderBy("totalDate"); + } + List list = sysUserOnlineService.totalCache(sysUserOnline); + //List list = sysUserOnlineService.total(sysUserOnline); + model.addAttribute("list", list); + for(SysUserOnline sysUserOnlineItem:list){ + //x轴数据 + xAxisData.add( sysUserOnlineItem.getTotalDate()); + countList.add(Double.valueOf(sysUserOnlineItem.getTotalCount())); + } + yAxisData.put("数量", countList); + request.setAttribute("xAxisData", xAxisData); + request.setAttribute("yAxisData", yAxisData); + model.addAttribute("sumTotalCount", list.stream().mapToInt(SysUserOnline::getTotalCount).sum()); + + //饼图数据 + Map orientData= new HashMap(); + for(SysUserOnline sysUserOnlineItem:list){ + orientData.put(sysUserOnlineItem.getTotalDate(), sysUserOnlineItem.getTotalCount()); + } + model.addAttribute("orientData", orientData); + } + @RequiresPermissions("sys:sysUserOnline:total") + @RequestMapping(value = {"totalMap"}) + public String totalMap(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + if(StringUtils.isEmpty(sysUserOnline.getTotalType())){ + sysUserOnline.setTotalType("%Y-%m-%d"); + } + List list = sysUserOnlineService.totalCache(sysUserOnline); + //List list = sysUserOnlineService.total(sysUserOnline); + model.addAttribute("sumTotalCount", list.stream().mapToInt(SysUserOnline::getTotalCount).sum()); + model.addAttribute("list", list); + return "modules/sys/sysUserOnlineTotalMap"; + } + + /** + * 在线用户记录列表页面 + */ + @RequiresPermissions("sys:sysUserOnline:list") + @RequestMapping(value = {"list", ""}) + public String list(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserOnlineService.findPageCache(new Page(request, response), sysUserOnline); + //Page page = sysUserOnlineService.findPage(new Page(request, response), sysUserOnline); + model.addAttribute("page", page); + sysUserOnline.setOrderBy("totalDate"); + total(sysUserOnline,request,response,model); + return "modules/sys/sysUserOnlineList"; + } + + /** + * 在线用户记录列表页面 + */ + @RequiresPermissions("sys:sysUserOnline:list") + @RequestMapping(value = {"listVue"}) + public String listVue(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserOnlineService.findPageCache(new Page(request, response), sysUserOnline); + //Page page = sysUserOnlineService.findPage(new Page(request, response), sysUserOnline); + model.addAttribute("page", page); + return "modules/sys/sysUserOnlineListVue"; + } + + /** + * 在线用户记录列表页面 + */ + //RequiresPermissions("sys:sysUserOnline:select") + @RequestMapping(value = {"select"}) + public String select(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserOnlineService.findPageCache(new Page(request, response), sysUserOnline); + //Page page = sysUserOnlineService.findPage(new Page(request, response), sysUserOnline); + model.addAttribute("page", page); + return "modules/sys/sysUserOnlineSelect"; + } + + /** + * 查看,增加,编辑在线用户记录表单页面 + */ + @RequiresPermissions(value={"sys:sysUserOnline:view","sys:sysUserOnline:add","sys:sysUserOnline:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(SysUserOnline sysUserOnline, Model model, HttpServletRequest request, HttpServletResponse response) { + model.addAttribute("action", request.getParameter("action")); + model.addAttribute("sysUserOnline", sysUserOnline); + if(request.getParameter("ViewFormType")!=null && "FormTwo".equals(request.getParameter("ViewFormType"))) { + return "modules/sys/sysUserOnlineFormTwo"; + } + return "modules/sys/sysUserOnlineForm"; + } + + /** + * 保存在线用户记录 + */ + @RequiresPermissions(value={"sys:sysUserOnline:add","sys:sysUserOnline:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(SysUserOnline sysUserOnline, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) { + if (!beanValidator(model, sysUserOnline)){ + return form(sysUserOnline, model,request,response); + } + sysUserOnlineService.save(sysUserOnline); + addMessage(redirectAttributes, "保存在线用户记录成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysUserOnline/?repage"; + } + + /** + * 删除在线用户记录 + */ + @RequiresPermissions("sys:sysUserOnline:del") + @RequestMapping(value = "delete") + public String delete(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) { + sysUserOnlineService.delete(sysUserOnline); + addMessage(redirectAttributes, "删除在线用户记录成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysUserOnline/?repage"; + } + + /** + * 删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequiresPermissions(value={"sys:sysUserOnline:del","sys:sysUserOnline:delByLogic"},logical=Logical.OR) + @RequestMapping(value = "deleteByLogic") + public String deleteByLogic(SysUserOnline sysUserOnline, RedirectAttributes redirectAttributes) { + sysUserOnlineService.deleteByLogic(sysUserOnline); + addMessage(redirectAttributes, "逻辑删除在线用户记录成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysUserOnline/?repage"; + } + + /** + * 批量删除在线用户记录 + */ + @RequiresPermissions("sys:sysUserOnline:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserOnlineService.delete(sysUserOnlineService.get(id)); + } + addMessage(redirectAttributes, "删除在线用户记录成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysUserOnline/?repage"; + } + + /** + * 批量删除在线用户记录(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequiresPermissions(value={"sys:sysUserOnline:del","sys:sysUserOnline:delByLogic"},logical=Logical.OR) + @RequestMapping(value = "deleteAllByLogic") + public String deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserOnlineService.deleteByLogic(sysUserOnlineService.get(id)); + } + addMessage(redirectAttributes, "删除在线用户记录成功"); + return "redirect:"+Global.getAdminPath()+"/sys/sysUserOnline/?repage"; + } + + /** + * 导出excel文件 + */ + @RequiresPermissions("sys:sysUserOnline:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(SysUserOnline sysUserOnline, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "在线用户记录"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = sysUserOnlineService.findPage(new Page(request, response, -1), sysUserOnline); + new ExportExcel("在线用户记录", SysUserOnline.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出在线用户记录记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysUserOnline/?repage"; + } + + /** + * 导入Excel数据 + + */ + @RequiresPermissions("sys:sysUserOnline:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + try { + int successNum = 0; + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(SysUserOnline.class); + for (SysUserOnline sysUserOnline : list){ + sysUserOnlineService.save(sysUserOnline); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条在线用户记录记录"); + } catch (Exception e) { + addMessage(redirectAttributes, "导入在线用户记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysUserOnline/?repage"; + } + + /** + * 下载导入在线用户记录数据模板 + */ + @RequiresPermissions("sys:sysUserOnline:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "在线用户记录数据导入模板.xlsx"; + List list = Lists.newArrayList(); + new ExportExcel("在线用户记录数据", SysUserOnline.class, 1).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/sysUserOnline/?repage"; + } + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SystemConfigController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SystemConfigController.java new file mode 100644 index 0000000..193bcd1 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/SystemConfigController.java @@ -0,0 +1,175 @@ +/** + * Copyright © 2015-2020 JeeSpring All rights reserved. + */ +package com.jeespring.modules.sys.web; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.config.Global; +import com.jeespring.common.json.AjaxJson; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.utils.MyBeanUtils; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.SystemConfig; +import com.jeespring.modules.sys.service.SystemConfigService; + +/** + * 系统配置Controller + * @author liugf + * @version 2016-02-07 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/systemConfig") +public class SystemConfigController extends AbstractBaseController { + + @Autowired + private SystemConfigService systemConfigService; + + @ModelAttribute + public SystemConfig get(@RequestParam(required=false) String id) { + SystemConfig entity = null; + if (StringUtils.isNotBlank(id)){ + entity = systemConfigService.get(id); + } + if (entity == null){ + entity = new SystemConfig(); + } + return entity; + } + + /** + * 系统配置列表页面 + */ + @RequiresPermissions("sys:systemConfig:index") + @RequestMapping(value = {"index", ""}) + public String index(HttpServletRequest request, HttpServletResponse response, Model model) { + SystemConfig systemConfig = systemConfigService.get("1"); + model.addAttribute("systemConfig", systemConfig); + return "modules/sys/systemConfig"; + } + + + /** + * 保存系统配置 + */ + @ResponseBody + @RequestMapping(value = "save") + public AjaxJson save(SystemConfig systemConfig, Model model, RedirectAttributes redirectAttributes) { + AjaxJson j = new AjaxJson(); + String message = "保存系统配置成功"; + SystemConfig t = systemConfigService.get("1"); + try { + systemConfig.setId("1"); + MyBeanUtils.copyBeanNotNull2Bean(systemConfig, t); + systemConfigService.save(t); + } catch (Exception e) { + e.printStackTrace(); + j.setSuccess(false); + message = "保存系统配置失败"; + } + j.setMsg(message); + return j; + } + + /** + * 删除系统配置 + */ + @RequiresPermissions("sys:systemConfig:del") + @RequestMapping(value = "delete") + public String delete(SystemConfig systemConfig, RedirectAttributes redirectAttributes) { + systemConfigService.delete(systemConfig); + addMessage(redirectAttributes, "删除系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/systemConfig/?repage"; + } + + /** + * 批量删除系统配置 + */ + @RequiresPermissions("sys:systemConfig:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + systemConfigService.delete(systemConfigService.get(id)); + } + addMessage(redirectAttributes, "删除系统配置成功"); + return "redirect:"+Global.getAdminPath()+"/sys/systemConfig/?repage"; + } + + /** + * 导出excel文件 + */ + @RequiresPermissions("sys:systemConfig:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(SystemConfig systemConfig, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "系统配置"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = systemConfigService.findPage(new Page(request, response, -1), systemConfig); + new ExportExcel("系统配置", SystemConfig.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出系统配置记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/systemConfig/?repage"; + } + + /** + * 导入Excel数据 + + */ + @RequiresPermissions("sys:systemConfig:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + try { + int successNum = 0; + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(SystemConfig.class); + for (SystemConfig systemConfig : list){ + systemConfigService.save(systemConfig); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条系统配置记录"); + } catch (Exception e) { + addMessage(redirectAttributes, "导入系统配置失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/systemConfig/?repage"; + } + + /** + * 下载导入系统配置数据模板 + */ + @RequiresPermissions("sys:systemConfig:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "系统配置数据导入模板.xlsx"; + List list = Lists.newArrayList(); + new ExportExcel("系统配置数据", SystemConfig.class, 1).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/sys/systemConfig/?repage"; + } + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/TagController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/TagController.java new file mode 100644 index 0000000..616dc3f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/TagController.java @@ -0,0 +1,49 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; + +import com.jeespring.common.web.AbstractBaseController; + +/** + * 标签Controller + * * * * @author 黄炳桂 516821420@qq.com + * @version 2013-3-23 + */ +@Controller +@RequestMapping(value = "${adminPath}/tag") +public class TagController extends AbstractBaseController { + + /** + * 树结构选择标签(treeselect.tag) + */ + @RequiresPermissions("user") + @RequestMapping(value = "treeselect") + public String treeselect(HttpServletRequest request, Model model) { + model.addAttribute("url", request.getParameter("url")); // 树结构数据URL + model.addAttribute("extId", request.getParameter("extId")); // 排除的编号ID + model.addAttribute("checked", request.getParameter("checked")); // 是否可复选 + model.addAttribute("selectIds", request.getParameter("selectIds")); // 指定默认选中的ID + model.addAttribute("isAll", request.getParameter("isAll")); // 是否读取全部数据,不进行权限过滤 + model.addAttribute("module", request.getParameter("module")); // 过滤栏目模型(仅针对CMS的Category树) + return "modules/sys/tagTreeselect"; + } + + /** + * 图标选择标签(iconselect.tag) + */ + @RequiresPermissions("user") + @RequestMapping(value = "iconselect") + public String iconselect(HttpServletRequest request, Model model) { + model.addAttribute("value", request.getParameter("value")); + return "modules/sys/tagIconselect"; + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/UserController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/UserController.java new file mode 100644 index 0000000..c7a243d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/sys/web/UserController.java @@ -0,0 +1,606 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.sys.web; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.ConstraintViolationException; + +import com.jeespring.common.sms.SMSUtils; +import com.jeespring.modules.sys.service.SysConfigService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jeespring.common.validator.BeanValidators; +import com.jeespring.common.config.Global; +import com.jeespring.common.json.AjaxJson; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.utils.FileUtils; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.dao.UserDao; +import com.jeespring.modules.sys.entity.Office; +import com.jeespring.modules.sys.entity.Role; +import com.jeespring.modules.sys.entity.User; +import com.jeespring.modules.sys.service.SystemService; +import com.jeespring.modules.sys.utils.UserUtils; + +/** + * 用户Controller + * @author 黄炳桂 516821420@qq.com + * @version 2013-8-29 + */ +@Controller +@RequestMapping(value = "${adminPath}/sys/user") +public class UserController extends AbstractBaseController { + + @Autowired + private SystemService systemService; + @Autowired + private UserDao userDao; + @Autowired + private SysConfigService sysConfigService; + + @ModelAttribute + public User get(@RequestParam(required=false) String id) { + if (StringUtils.isNotBlank(id)){ + return systemService.getUser(id); + }else{ + return new User(); + } + } + + //RequiresPermissions("sys:user:index") + @RequestMapping(value = {"index"}) + public String index(User user, Model model) { + return "modules/sys/userIndex"; + } + + //RequiresPermissions("sys:user:index") + @RequestMapping(value = {"list", ""}) + public String list(User user, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = systemService.findUser(new Page(request, response), user); + model.addAttribute("page", page); + return "modules/sys/userList"; + } + + @RequestMapping(value = {"listjson"}) + @ResponseBody + public Page listjson(User user, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = systemService.findUser(new Page(request, response), user); + return page; + } + + + @RequiresPermissions(value={"sys:user:view","sys:user:add","sys:user:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(User user, Model model) { + if (user.getCompany()==null || user.getCompany().getId()==null){ + user.setCompany(UserUtils.getUser().getCompany()); + } + if (user.getOffice()==null || user.getOffice().getId()==null){ + user.setOffice(UserUtils.getUser().getOffice()); + } + model.addAttribute("user", user); + model.addAttribute("allRoles", systemService.findAllRole()); + return "modules/sys/userForm"; + } + + @RequiresPermissions(value={"sys:user:add","sys:user:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(User user, HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + // 修正引用赋值问题,不知道为何,Company和Office引用的一个实例地址,修改了一个,另外一个跟着修改。 + user.setCompany(new Office(request.getParameter("company.id"))); + user.setOffice(new Office(request.getParameter("office.id"))); + // 如果新密码为空,则不更换密码 + if (StringUtils.isNotBlank(user.getNewPassword())) { + user.setPassword(SystemService.entryptPassword(user.getNewPassword())); + } + if (!beanValidator(model, user)){ + return form(user, model); + } + if (!"true".equals(checkLoginName(user.getOldLoginName(), user.getLoginName()))){ + addMessage(model, "保存用户'" + user.getLoginName() + "'失败,登录名已存在"); + return form(user, model); + } + // 角色数据有效性验证,过滤不在授权内的角色 + List roleList = Lists.newArrayList(); + List roleIdList = user.getRoleIdList(); + for (Role r : systemService.findAllRole()){ + if (roleIdList.contains(r.getId())){ + roleList.add(r); + } + } + user.setRoleList(roleList); + //生成用户二维码,使用登录名 + String realPath = Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + + user.getId() + "/qrcode/"; + FileUtils.createDirectory(realPath); + String name= user.getId()+".png"; //encoderImgId此处二维码的图片名 + String filePath = realPath + name; //存放路径 + //TwoDimensionCode.encoderQRCode(user.getLoginName(), filePath, "png");//执行生成二维码 + user.setQrCode(request.getContextPath()+Global.USERFILES_BASE_URL + + user.getId() + "/qrcode/"+name); + // 保存用户信息 + systemService.saveUser(user); + // 清除当前用户缓存 + if (user.getLoginName().equals(UserUtils.getUser().getLoginName())){ + UserUtils.clearCache(); + //UserUtils.getCacheMap().clear(); + } + addMessage(redirectAttributes, "保存用户'" + user.getLoginName() + "'成功"); + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + + @RequiresPermissions("sys:user:del") + @RequestMapping(value = "delete") + public String delete(User user, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + if (UserUtils.getUser().getId().equals(user.getId())){ + addMessage(redirectAttributes, "删除用户失败, 不允许删除当前用户"); + }else if (User.isAdmin(user.getId())){ + addMessage(redirectAttributes, "删除用户失败, 不允许删除超级管理员用户"); + }else{ + systemService.deleteUser(user); + addMessage(redirectAttributes, "删除用户成功"); + } + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + + /** + * 批量删除用户 + */ + @RequiresPermissions("sys:user:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + User user = systemService.getUser(id); + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + if (UserUtils.getUser().getId().equals(user.getId())){ + addMessage(redirectAttributes, "删除用户失败, 不允许删除当前用户"); + }else if (User.isAdmin(user.getId())){ + addMessage(redirectAttributes, "删除用户失败, 不允许删除超级管理员用户"); + }else{ + systemService.deleteUser(user); + addMessage(redirectAttributes, "删除用户成功"); + } + } + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + + /** + * 导出用户数据 + * @param user + * @param request + * @param response + * @param redirectAttributes + * @return + */ + @RequiresPermissions("sys:user:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(User user, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "用户数据"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = systemService.findUser(new Page(request, response, -1), user); + new ExportExcel("用户数据", User.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出用户失败!失败信息:"+e.getMessage()); + } + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + + /** + * 导入用户数据 + * @param file + * @param redirectAttributes + * @return + */ + @RequiresPermissions("sys:user:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + if(sysConfigService.isDemoMode()){ + addMessage(redirectAttributes, sysConfigService.isDemoModeDescription()); + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + try { + int successNum = 0; + int failureNum = 0; + StringBuilder failureMsg = new StringBuilder(); + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(User.class); + for (User user : list){ + try{ + if ("true".equals(checkLoginName("", user.getLoginName()))){ + user.setPassword(SystemService.entryptPassword("123456")); + BeanValidators.validateWithException(validator, user); + systemService.saveUser(user); + successNum++; + }else{ + failureMsg.append("
    登录名 "+user.getLoginName()+" 已存在; "); + failureNum++; + } + }catch(ConstraintViolationException ex){ + failureMsg.append("
    登录名 "+user.getLoginName()+" 导入失败:"); + List messageList = BeanValidators.extractPropertyAndMessageAsList(ex, ": "); + for (String message : messageList){ + failureMsg.append(message+"; "); + failureNum++; + } + }catch (Exception ex) { + failureMsg.append("
    登录名 "+user.getLoginName()+" 导入失败:"+ex.getMessage()); + } + } + if (failureNum>0){ + failureMsg.insert(0, ",失败 "+failureNum+" 条用户,导入信息如下:"); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条用户"+failureMsg); + } catch (Exception e) { + addMessage(redirectAttributes, "导入用户失败!失败信息:"+e.getMessage()); + } + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + + /** + * 下载导入用户数据模板 + * @param response + * @param redirectAttributes + * @return + */ + @RequiresPermissions("sys:user:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "用户数据导入模板.xlsx"; + List list = Lists.newArrayList(); list.add(UserUtils.getUser()); + new ExportExcel("用户数据", User.class, 2).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:" + adminPath + "/sys/user/list?repage"; + } + + /** + * 验证登录名是否有效 + * @param oldLoginName + * @param loginName + * @return + */ + @ResponseBody + @RequiresPermissions(value={"sys:user:add","sys:user:edit"},logical=Logical.OR) + @RequestMapping(value = "checkLoginName") + public String checkLoginName(String oldLoginName, String loginName) { + if (loginName !=null && loginName.equals(oldLoginName)) { + return "true"; + } else if (loginName !=null && systemService.getUserByLoginName(loginName) == null) { + return "true"; + } + return "false"; + } + + /** + * 用户信息显示 + * @param user + * @param model + * @return + */ + @RequiresPermissions("user") + @RequestMapping(value = "info") + public String info(HttpServletResponse response, Model model) { + User currentUser = UserUtils.getUser(); + model.addAttribute("user", currentUser); + model.addAttribute("Global", new Global()); + return "modules/sys/userInfo"; + } + + /** + * 用户信息显示编辑保存 + * @param user + * @param model + * @return + */ + @RequiresPermissions("user") + @RequestMapping(value = "infoEdit") + public String infoEdit(User user, boolean __ajax, HttpServletResponse response, Model model) { + User currentUser = UserUtils.getUser(); + if (StringUtils.isNotBlank(user.getName())){ + if(sysConfigService.isDemoMode()){ + model.addAttribute("message", sysConfigService.isDemoModeDescription()); + return "modules/sys/userInfo"; + } + if(user.getName() !=null ) { + currentUser.setName(user.getName()); + } + if(user.getEmail() !=null ) { + currentUser.setEmail(user.getEmail()); + } + if(user.getPhone() !=null ) { + currentUser.setPhone(user.getPhone()); + } + if(user.getMobile() !=null ) { + currentUser.setMobile(user.getMobile()); + } + if(user.getRemarks() !=null ) { + currentUser.setRemarks(user.getRemarks()); + } +// if(user.getPhoto() !=null ) +// currentUser.setPhoto(user.getPhoto()); + systemService.updateUserInfo(currentUser); + if(__ajax){//手机访问 + AjaxJson j = new AjaxJson(); + j.setSuccess(true); + j.setMsg("修改个人资料成功!"); + return renderString(response, j); + } + model.addAttribute("user", currentUser); + model.addAttribute("Global", new Global()); + model.addAttribute("message", "保存用户信息成功"); + return "modules/sys/userInfo"; + } + model.addAttribute("user", currentUser); + model.addAttribute("Global", new Global()); + return "modules/sys/userInfoEdit"; + } + + + /** + * 用户头像显示编辑保存 + * @param user + * @param model + * @return + */ + @RequiresPermissions("user") + @RequestMapping(value = "imageEdit") + public String imageEdit(User user, boolean __ajax, HttpServletResponse response, Model model) { + User currentUser = UserUtils.getUser(); + if (StringUtils.isNotBlank(user.getName())){ + if(sysConfigService.isDemoMode()){ + model.addAttribute("message", sysConfigService.isDemoModeDescription()); + return "modules/sys/userInfo"; + } + if(user.getPhoto() !=null ) { + currentUser.setPhoto(user.getPhoto()); + } + systemService.updateUserInfo(currentUser); + if(__ajax){//手机访问 + AjaxJson j = new AjaxJson(); + j.setSuccess(true); + j.setMsg("修改个人头像成功!"); + return renderString(response, j); + } + model.addAttribute("message", "保存用户信息成功"); + return "modules/sys/userInfo"; + } + model.addAttribute("user", currentUser); + model.addAttribute("Global", new Global()); + return "modules/sys/userImageEdit"; + } + /** + * 用户头像显示编辑保存 + * @param user + * @param model + * @return + * @throws IOException + * @throws IllegalStateException + */ + @RequiresPermissions("user") + @RequestMapping(value = "imageUpload") + public String imageUpload( HttpServletRequest request, HttpServletResponse response,MultipartFile file) throws IllegalStateException, IOException { + User currentUser = UserUtils.getUser(); + + // 判断文件是否为空 + if (!file.isEmpty()) { + // 文件保存路径 + String realPath = Global.USERFILES_BASE_URL + + UserUtils.getPrincipal() + "/images/" ; + // 转存文件 + FileUtils.createDirectory(Global.getUserfilesBaseDir()+realPath); + File files=new File( Global.getUserfilesBaseDir() +realPath + file.getOriginalFilename()); + /*file.transferTo(files); */ + FileUtils.copyInputStreamToFile(file.getInputStream(), files); + currentUser.setPhoto(request.getContextPath()+realPath + file.getOriginalFilename()); + systemService.updateUserInfo(currentUser); + } + + return "modules/sys/userImageEdit"; + } + + /** + * 返回用户信息 + * @return + */ + @RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "infoData") + public AjaxJson infoData() { + AjaxJson j = new AjaxJson(); + j.setSuccess(true); + j.setErrorCode("-1"); + j.setMsg("获取个人信息成功!"); + j.put("data", UserUtils.getUser()); + return j; + } + + + + /** + * 修改个人用户密码 + * @param oldPassword + * @param newPassword + * @param model + * @return + */ + @RequiresPermissions("user") + @RequestMapping(value = "modifyPwd") + public String modifyPwd(String oldPassword, String newPassword, Model model) { + User user = UserUtils.getUser(); + if (StringUtils.isNotBlank(oldPassword) && StringUtils.isNotBlank(newPassword)){ + if(sysConfigService.isDemoMode()){ + model.addAttribute("message", sysConfigService.isDemoModeDescription()); + return "modules/sys/userInfo"; + } + if (SystemService.validatePassword(oldPassword, user.getPassword())){ + systemService.updatePasswordById(user.getId(), user.getLoginName(), newPassword); + model.addAttribute("message", "修改密码成功"); + }else{ + model.addAttribute("message", "修改密码失败,旧密码错误"); + } + return "modules/sys/userInfo"; + } + model.addAttribute("user", user); + return "modules/sys/userModifyPwd"; + } + + @RequiresPermissions("user") + @ResponseBody + @RequestMapping(value = "treeData") + public List> treeData(@RequestParam(required=false) String officeId, HttpServletResponse response) { + List> mapList = Lists.newArrayList(); + List list = systemService.findUserByOfficeId(officeId); + for (int i=0; i map = Maps.newHashMap(); + map.put("id", "u_"+e.getId()); + map.put("pId", officeId); + map.put("name", StringUtils.replace(e.getName(), " ", "")); + mapList.add(map); + } + return mapList; + } + + /** + * web端ajax验证用户名是否可用 + * @param loginName + * @param response + * @return + */ + @ResponseBody + @RequestMapping(value = "validateLoginName") + public boolean validateLoginName(String loginName, HttpServletResponse response) { + + User user = userDao.findUniqueByProperty("login_name", loginName); + if(user == null){ + return true; + }else{ + return false; + } + + } + + /** + * web端ajax验证手机号是否可以注册(数据库中不存在) + */ + @ResponseBody + @RequestMapping(value = "validateMobile") + public boolean validateMobile(String mobile, HttpServletResponse response, Model model) { + User user = userDao.findUniqueByProperty("mobile", mobile); + if(user == null){ + return true; + }else{ + return false; + } + } + + /** + * web端ajax验证手机号是否已经注册(数据库中已存在) + */ + @ResponseBody + @RequestMapping(value = "validateMobileExist") + public boolean validateMobileExist(String mobile, HttpServletResponse response, Model model) { + User user = userDao.findUniqueByProperty("mobile", mobile); + if(user != null){ + return true; + }else{ + return false; + } + } + + @ResponseBody + @RequestMapping(value = "resetPassword") + public AjaxJson resetPassword(String mobile, HttpServletResponse response, Model model) { + AjaxJson j = new AjaxJson(); + if(userDao.findUniqueByProperty("mobile", mobile) == null){ + j.setSuccess(false); + j.setMsg("手机号不存在!"); + j.setErrorCode("1"); + return j; + } + User user = userDao.findUniqueByProperty("mobile", mobile); + String newPassword = String.valueOf((int) (Math.random() * 900000 + 100000)); + try { + //SystemConfig config = systemConfigService.get("1");//获取短信配置的用户名和密码 + //UserUtils.sendPass(config.getSmsName(), config.getSmsPassword(), mobile, newPassword); + String result = SMSUtils.sendPass(mobile, newPassword); + if (!"100".equals(result)) { + j.setSuccess(false); + j.setErrorCode("2"); + j.setMsg("短信发送失败,密码重置失败,错误代码:"+result+",请联系管理员。"); + }else{ + j.setSuccess(true); + j.setErrorCode("-1"); + j.setMsg("短信发送成功,密码重置成功!"); + systemService.updatePasswordById(user.getId(), user.getLoginName(), newPassword); + } + } catch (IOException e) { + j.setSuccess(false); + j.setErrorCode("3"); + j.setMsg("因未知原因导致短信发送失败,请联系管理员。"); + } + return j; + } + +// @InitBinder +// public void initBinder(WebDataBinder b) { +// b.registerCustomEditor(List.class, "roleList", new PropertyEditorSupport(){ +// @Autowired +// private SystemService systemService; +// @Override +// public void setAsText(String text) throws IllegalArgumentException { +// String[] ids = StringUtils.split(text, ","); +// List roles = new ArrayList(); +// for (String id : ids) { +// Role role = systemService.getRole(Long.valueOf(id)); +// roles.add(role); +// } +// setValue(roles); +// } +// @Override +// public String getAsText() { +// return Collections3.extractToString((List) getValue(), "id", ","); +// } +// }); +// } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/dao/SysUserCenterDao.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/dao/SysUserCenterDao.java new file mode 100644 index 0000000..6ae08a0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/dao/SysUserCenterDao.java @@ -0,0 +1,18 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.usercenter.dao; + +import com.jeespring.common.persistence.InterfaceBaseDao; +import org.apache.ibatis.annotations.Mapper; +import com.jeespring.modules.usercenter.entity.SysUserCenter; + +/** + * 用户中心DAO接口 + * @author 黄炳桂 + * @version 2017-12-12 + */ +@Mapper +public interface SysUserCenterDao extends InterfaceBaseDao { + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/entity/SysUserCenter.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/entity/SysUserCenter.java new file mode 100644 index 0000000..14bd95e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/entity/SysUserCenter.java @@ -0,0 +1,145 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.usercenter.entity; + +import com.jeespring.common.persistence.AbstractBaseEntity; +import com.jeespring.common.utils.excel.annotation.ExcelField; +import org.hibernate.validator.constraints.Length; + +import java.util.Date; + +/** + * 用户中心Entity + * @author 黄炳桂 + * @version 2017-12-12 + */ +public class SysUserCenter extends AbstractBaseEntity { + + private static final long serialVersionUID = 1L; + private String userId; // 用户编号 + private String userName; // 用户名称 + private String userPhone; // 用户手机号 + private String lat; // 纬度 + private String lng; // 经度 + private String city; // 城市 + private String address; // 地址 + private Date beginCreateDate; // 开始 创建时间 + private Date endCreateDate; // 结束 创建时间 + private Date beginUpdateDate; // 开始 更新时间 + private Date endUpdateDate; // 结束 更新时间 + private String ip;//ip地址 + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public SysUserCenter() { + super(); + } + + public SysUserCenter(String id){ + super(id); + } + + @ExcelField(title="用户编号", align=2, sort=1) + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + @Length(min=0, max=64, message="用户名称长度必须介于 0 和 64 之间") + @ExcelField(title="用户名称", align=2, sort=2) + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + @Length(min=0, max=64, message="用户手机号长度必须介于 0 和 64 之间") + @ExcelField(title="用户手机号", align=2, sort=3) + public String getUserPhone() { + return userPhone; + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + @Length(min=0, max=30, message="纬度长度必须介于 0 和 30 之间") + @ExcelField(title="纬度", align=2, sort=4) + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + @Length(min=0, max=30, message="经度长度必须介于 0 和 30 之间") + @ExcelField(title="经度", align=2, sort=5) + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public Date getBeginCreateDate() { + return beginCreateDate; + } + + public void setBeginCreateDate(Date beginCreateDate) { + this.beginCreateDate = beginCreateDate; + } + + public Date getEndCreateDate() { + return endCreateDate; + } + + public void setEndCreateDate(Date endCreateDate) { + this.endCreateDate = endCreateDate; + } + + public Date getBeginUpdateDate() { + return beginUpdateDate; + } + + public void setBeginUpdateDate(Date beginUpdateDate) { + this.beginUpdateDate = beginUpdateDate; + } + + public Date getEndUpdateDate() { + return endUpdateDate; + } + + public void setEndUpdateDate(Date endUpdateDate) { + this.endUpdateDate = endUpdateDate; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/rest/SysUserCenterRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/rest/SysUserCenterRestController.java new file mode 100644 index 0000000..147fa3f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/rest/SysUserCenterRestController.java @@ -0,0 +1,291 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.usercenter.rest; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.modules.usercenter.entity.SysUserCenter; +import com.jeespring.modules.usercenter.service.SysUserCenterService; +import org.springframework.web.bind.annotation.RestController; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +/** + * 用户中心Controller + * @author 黄炳桂 + * @version 2017-12-12 + */ +@RestController +@RequestMapping(value = "/rest/usercenter/sysUserCenter") +@Api(value="用户中心接口", description="用户中心接口") +public class SysUserCenterRestController extends AbstractBaseController { + + @Autowired + private SysUserCenterService sysUserCenterService; + + /** + * 用户中心信息 + */ + @RequestMapping(value = {"get"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="用户中心信息(Content-Type为text/html)", notes="用户中心信息(Content-Type为text/html)") + @ApiImplicitParam(name = "id", value = "用户中心id", required = false, dataType = "String",paramType="query") + public Result get(@RequestParam(required=false) String id) { + SysUserCenter entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysUserCenterService.get(id); + } + if (entity == null){ + entity = new SysUserCenter(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(entity); + return result; + } + + @RequestMapping(value = {"get/json"},method ={RequestMethod.POST}) + @ApiOperation(value="用户中心信息(Content-Type为application/json)", notes="用户中心信息(Content-Type为application/json)") + @ApiImplicitParam(name = "id", value = "用户中心id", required = false, dataType = "String",paramType="body") + public Result getJson(@RequestBody(required=false) String id) { + SysUserCenter entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysUserCenterService.get(id); + } + if (entity == null){ + entity = new SysUserCenter(); + } + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(entity); + return result; + } + + /** + * 用户中心列表(不包含页信息) + */ + //RequiresPermissions("usercenter:sysUserCenter:findList") + @RequestMapping(value = {"findList"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="用户中心列表(不包含页信息)(Content-Type为text/html)", notes="用户中心列表(不包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="query") + public Result findList(SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, Model model) { + List list = sysUserCenterService.findList(sysUserCenter); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(list); + return result; + } + + @RequestMapping(value = {"findList/json"},method ={RequestMethod.POST}) + @ApiOperation(value="用户中心列表(不包含页信息)(Content-Type为application/json)", notes="用户中心列表(不包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="body") + public Result findListJson(@RequestBody SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, Model model) { + List list = sysUserCenterService.findList(sysUserCenter); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(list); + return result; + } + + /** + * 用户中心列表(包含页信息) + */ + //RequiresPermissions("usercenter:sysUserCenter:list") + @RequestMapping(value = {"list"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="用户中心列表(包含页信息)(Content-Type为text/html)", notes="用户中心列表(包含页信息)(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="query") + public Result list(SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserCenterService.findPage(new Page(request, response), sysUserCenter); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + @RequestMapping(value = {"list/json"},method ={RequestMethod.POST}) + @ApiOperation(value="用户中心列表(包含页信息)(Content-Type为application/json)", notes="用户中心列表(包含页信息)(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="body") + public Result listJson(@RequestBody SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserCenterService.findPage(new Page(sysUserCenter.getPageNo(),sysUserCenter.getPageSize(),sysUserCenter.getOrderBy()), sysUserCenter); + Result result = ResultFactory.getSuccessResult(); + result.setResultObject(page); + return result; + } + + /** + * 用户中心获取列表第一条记录 + */ + //RequiresPermissions("usercenter:sysUserCenter:listFrist") + @RequestMapping(value = {"listFrist"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="用户中心获取列表第一条记录(Content-Type为text/html)", notes="用户中心获取列表第一条记录(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="query") + public Result listFrist(SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserCenterService.findPage(new Page(request, response), sysUserCenter); + Result result = ResultFactory.getSuccessResult(); + if(page.getList().size()>0){ + result.setResultObject(page.getList().get(0)); + }else{ + result=ResultFactory.getErrorResult("没有记录!"); + } + return result; + } + + @RequestMapping(value = {"listFrist/json"},method ={RequestMethod.POST}) + @ApiOperation(value="用户中心获取列表第一条记录(Content-Type为application/json)", notes="用户中心获取列表第一条记录(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="body") + public Result listFristJson(@RequestBody SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserCenterService.findPage(new Page(sysUserCenter.getPageNo(),sysUserCenter.getPageSize(),sysUserCenter.getOrderBy()), sysUserCenter); + Result result = ResultFactory.getSuccessResult(); + if(page.getList().size()>0){ + result.setResultObject(page.getList().get(0)); + }else{ + result=ResultFactory.getErrorResult("没有记录!"); + } + return result; + } + + /** + * 保存用户中心 + */ + //RequiresPermissions(value={"usercenter:sysUserCenter:add","usercenter:sysUserCenter:edit"},logical=Logical.OR) + @RequestMapping(value = "save",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="保存用户中心(Content-Type为text/html)", notes="保存用户中心(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="query") + public Result save(SysUserCenter sysUserCenter, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysUserCenter)){ + Result result = ResultFactory.getErrorResult("数据验证失败"); + } + sysUserCenterService.save(sysUserCenter); + Result result = ResultFactory.getSuccessResult("保存用户中心成功"); + return result; + } + + @RequestMapping(value = "save/json",method ={RequestMethod.POST}) + @ApiOperation(value="保存用户中心(Content-Type为application/json)", notes="保存用户中心(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="body") + public Result saveJson(@RequestBody SysUserCenter sysUserCenter, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysUserCenter)){ + Result result = ResultFactory.getErrorResult("数据验证失败"); + } + sysUserCenterService.save(sysUserCenter); + Result result = ResultFactory.getSuccessResult("保存用户中心成功"); + return result; + } + + /** + * 删除用户中心 + */ + //RequiresPermissions("usercenter:sysUserCenter:del") + @RequestMapping(value = "delete",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="删除用户中心(Content-Type为text/html)", notes="删除用户中心(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="query") + public Result delete(SysUserCenter sysUserCenter, RedirectAttributes redirectAttributes) { + sysUserCenterService.delete(sysUserCenter); + Result result = ResultFactory.getSuccessResult("删除用户中心成功"); + return result; + } + + /** + * 删除用户中心(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑删除用户中心(Content-Type为text/html)", notes="逻辑删除用户中心(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="query") + public Result deleteByLogic(SysUserCenter sysUserCenter, RedirectAttributes redirectAttributes) { + sysUserCenterService.deleteByLogic(sysUserCenter); + Result result = ResultFactory.getSuccessResult("删除用户中心成功"); + return result; + } + + @RequestMapping(value = "delete/json",method ={RequestMethod.POST}) + @ApiOperation(value="删除用户中心(Content-Type为application/json)", notes="删除用户中心(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="body") + public Result deleteJson(@RequestBody SysUserCenter sysUserCenter, RedirectAttributes redirectAttributes) { + sysUserCenterService.delete(sysUserCenter); + Result result = ResultFactory.getSuccessResult("删除用户中心成功"); + return result; + } + + /** + * 删除用户中心(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑删除用户中心(Content-Type为application/json)", notes="逻辑删除用户中心(Content-Type为application/json)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="body") + public Result deleteByLogicJson(@RequestBody SysUserCenter sysUserCenter, RedirectAttributes redirectAttributes) { + sysUserCenterService.deleteByLogic(sysUserCenter); + Result result = ResultFactory.getSuccessResult("删除用户中心成功"); + return result; + } + + /** + * 批量删除用户中心 + */ + //RequiresPermissions("usercenter:sysUserCenter:del") + @RequestMapping(value = "deleteAll",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="批量删除用户中心(Content-Type为text/html)", notes="批量删除用户中心(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "用户中心ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserCenterService.delete(sysUserCenterService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除用户中心成功"); + return result; + } + + /** + * 批量删除用户中心(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic",method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="逻辑批量删除用户中心(Content-Type为text/html)", notes="逻辑批量删除用户中心(Content-Type为text/html)") + @ApiImplicitParam(name = "ids", value = "用户中心ids,用,隔开", required = false, dataType = "String",paramType="query") + public Result deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserCenterService.deleteByLogic(sysUserCenterService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除用户中心成功"); + return result; + } + + @RequestMapping(value = "deleteAll/json",method ={RequestMethod.POST}) + @ApiOperation(value="批量删除用户中心(Content-Type为application/json)", notes="批量删除用户中心(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "用户中心ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllJson(@RequestBody String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserCenterService.delete(sysUserCenterService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除用户中心成功"); + return result; + } + + /** + * 批量删除用户中心(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + @RequestMapping(value = "deleteAllByLogic/json",method ={RequestMethod.POST}) + @ApiOperation(value="逻辑批量删除用户中心(Content-Type为application/json)", notes="逻辑批量删除用户中心(Content-Type为application/json)") + @ApiImplicitParam(name = "ids", value = "用户中心ids,用,隔开", required = false, dataType = "String",paramType="body") + public Result deleteAllByLogicJson(@RequestBody String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserCenterService.deleteByLogic(sysUserCenterService.get(id)); + } + Result result = ResultFactory.getSuccessResult("删除用户中心成功"); + return result; + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/service/ISysUserCenterService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/service/ISysUserCenterService.java new file mode 100644 index 0000000..c506782 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/service/ISysUserCenterService.java @@ -0,0 +1,7 @@ +package com.jeespring.modules.usercenter.service; + +import com.jeespring.common.persistence.InterfaceBaseService; +import com.jeespring.modules.usercenter.entity.SysUserCenter; + +public interface ISysUserCenterService extends InterfaceBaseService { +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/service/SysUserCenterService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/service/SysUserCenterService.java new file mode 100644 index 0000000..7c3e915 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/service/SysUserCenterService.java @@ -0,0 +1,134 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.usercenter.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.beans.factory.annotation.Autowired; + +import com.jeespring.common.persistence.Page; +import com.jeespring.common.service.AbstractBaseService; +import com.jeespring.modules.usercenter.entity.SysUserCenter; +import com.jeespring.modules.usercenter.dao.SysUserCenterDao; +import com.alibaba.fastjson.JSON; +import com.jeespring.common.redis.RedisUtils; + +/** + * 用户中心Service + * @author 黄炳桂 + * @version 2017-12-12 + */ +@Service +@Transactional(readOnly = true) +public class SysUserCenterService extends AbstractBaseService implements ISysUserCenterService { + + /** + * redis caches + */ + @Autowired + private RedisUtils redisUtils; + + @Override + public SysUserCenter get(String id) { + //获取缓存数据 + SysUserCenter sysUserCenter=(SysUserCenter)redisUtils.get(RedisUtils.getIdKey(SysUserCenterService.class.getName(),id)); + if( sysUserCenter!=null) { + return sysUserCenter; + } + //获取数据库数据 + sysUserCenter=super.get(id); + //设置缓存数据 + redisUtils.set(RedisUtils.getIdKey(SysUserCenterService.class.getName(),id),sysUserCenter); + return sysUserCenter; + } + + @Override + public SysUserCenter getCache(String id) { + return null; + } + + @Override + public List totalCache(SysUserCenter entity) { + return null; + } + + @Override + public List findList(SysUserCenter sysUserCenter) { + //获取缓存数据 + String findListKey = RedisUtils.getFindListKey(SysUserCenterService.class.getName(),JSON.toJSONString(sysUserCenter)); + List sysUserCenterList=(List)redisUtils.get(findListKey); + if(sysUserCenterList!=null) { + return sysUserCenterList; + } + //获取数据库数据 + sysUserCenterList=super.findList(sysUserCenter); + //设置缓存数据 + redisUtils.set(findListKey,sysUserCenterList); + return sysUserCenterList; + } + + @Override + public List findListCache(SysUserCenter entity) { + return null; + } + + @Override + public Page findPage(Page page, SysUserCenter sysUserCenter) { + //获取缓存数据 + String findPageKey = RedisUtils.getFindPageKey(SysUserCenterService.class.getName(),JSON.toJSONString(page)+JSON.toJSONString(sysUserCenter)); + Page pageReuslt=(Page)redisUtils.get(findPageKey); + if(pageReuslt!=null) { + return pageReuslt; + } + //获取数据库数据 + pageReuslt=super.findPage(page, sysUserCenter); + //设置缓存数据 + redisUtils.set(findPageKey,pageReuslt); + return pageReuslt; + } + + @Override + public Page findPageCache(Page page, SysUserCenter entity) { + return null; + } + + @Override + @Transactional(readOnly = false) + public void save(SysUserCenter sysUserCenter) { + //保存数据库记录 + super.save(sysUserCenter); + //设置清除缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysUserCenterService.class.getName(),sysUserCenter.getId())); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysUserCenterService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysUserCenterService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void delete(SysUserCenter sysUserCenter) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysUserCenterService.class.getName(),sysUserCenter.getId())); + //删除数据库记录 + super.delete(sysUserCenter); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysUserCenterService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysUserCenterService.class.getName())); + } + + @Override + @Transactional(readOnly = false) + public void deleteByLogic(SysUserCenter sysUserCenter) { + //清除记录缓存数据 + redisUtils.remove(RedisUtils.getIdKey(SysUserCenterService.class.getName(),sysUserCenter.getId())); + //逻辑删除数据库记录 + super.deleteByLogic(sysUserCenter); + //清除列表和页面缓存数据 + redisUtils.removePattern(RedisUtils.getFindListKeyPattern(SysUserCenterService.class.getName())); + redisUtils.removePattern(RedisUtils.getFinPageKeyPattern(SysUserCenterService.class.getName())); + } + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/web/SysUserCenterController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/web/SysUserCenterController.java new file mode 100644 index 0000000..75760c0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/usercenter/web/SysUserCenterController.java @@ -0,0 +1,207 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.usercenter.web; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import com.google.common.collect.Lists; +import com.jeespring.common.utils.DateUtils; +import com.jeespring.common.config.Global; +import com.jeespring.common.persistence.Page; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.utils.StringUtils; +import com.jeespring.common.utils.excel.ExportExcel; +import com.jeespring.common.utils.excel.ImportExcel; +import com.jeespring.modules.usercenter.entity.SysUserCenter; +import com.jeespring.modules.usercenter.service.SysUserCenterService; +/** + * 用户中心Controller + * @author 黄炳桂 + * @version 2017-12-12 + */ +@Controller +@RequestMapping(value = "${adminPath}/usercenter/sysUserCenter") +public class SysUserCenterController extends AbstractBaseController { + + @Autowired + private SysUserCenterService sysUserCenterService; + + @ModelAttribute + public SysUserCenter get(@RequestParam(required=false) String id) { + SysUserCenter entity = null; + if (StringUtils.isNotBlank(id)){ + entity = sysUserCenterService.get(id); + } + if (entity == null){ + entity = new SysUserCenter(); + } + return entity; + } + + /** + * 用户中心列表页面 + */ + //RequiresPermissions("usercenter:sysUserCenter:list") + @RequestMapping(value = {"list", ""}) + public String list(SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserCenterService.findPage(new Page(request, response), sysUserCenter); + model.addAttribute("page", page); + return "modules/usercenter/sysUserCenterList"; + } + + /** + * 用户中心列表页面 + */ + //RequiresPermissions("usercenter:sysUserCenter:select") + @RequestMapping(value = {"select"}) + public String select(SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, Model model) { + Page page = sysUserCenterService.findPage(new Page(request, response), sysUserCenter); + model.addAttribute("page", page); + return "modules/usercenter/sysUserCenterSelect"; + } + + /** + * 查看,增加,编辑用户中心表单页面 + */ + //RequiresPermissions(value={"usercenter:sysUserCenter:view","usercenter:sysUserCenter:add","usercenter:sysUserCenter:edit"},logical=Logical.OR) + @RequestMapping(value = "form") + public String form(SysUserCenter sysUserCenter, Model model) { + model.addAttribute("sysUserCenter", sysUserCenter); + return "modules/usercenter/sysUserCenterForm"; + } + + /** + * 保存用户中心 + */ + //RequiresPermissions(value={"usercenter:sysUserCenter:add","usercenter:sysUserCenter:edit"},logical=Logical.OR) + @RequestMapping(value = "save") + public String save(SysUserCenter sysUserCenter, Model model, RedirectAttributes redirectAttributes) { + if (!beanValidator(model, sysUserCenter)){ + return form(sysUserCenter, model); + } + sysUserCenterService.save(sysUserCenter); + addMessage(redirectAttributes, "保存用户中心成功"); + return "redirect:"+Global.getAdminPath()+"/usercenter/sysUserCenter/?repage"; + } + + /** + * 删除用户中心 + */ + //RequiresPermissions("usercenter:sysUserCenter:del") + @RequestMapping(value = "delete") + public String delete(SysUserCenter sysUserCenter, RedirectAttributes redirectAttributes) { + sysUserCenterService.delete(sysUserCenter); + addMessage(redirectAttributes, "删除用户中心成功"); + return "redirect:"+Global.getAdminPath()+"/usercenter/sysUserCenter/?repage"; + } + + /** + * 删除用户中心(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + //RequiresPermissions("usercenter:sysUserCenter:delByLogic") + @RequestMapping(value = "deleteByLogic") + public String deleteByLogic(SysUserCenter sysUserCenter, RedirectAttributes redirectAttributes) { + sysUserCenterService.deleteByLogic(sysUserCenter); + addMessage(redirectAttributes, "逻辑删除用户中心成功"); + return "redirect:"+Global.getAdminPath()+"/usercenter/sysUserCenter/?repage"; + } + + /** + * 批量删除用户中心 + */ + //RequiresPermissions("usercenter:sysUserCenter:del") + @RequestMapping(value = "deleteAll") + public String deleteAll(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserCenterService.delete(sysUserCenterService.get(id)); + } + addMessage(redirectAttributes, "删除用户中心成功"); + return "redirect:"+Global.getAdminPath()+"/usercenter/sysUserCenter/?repage"; + } + + /** + * 批量删除用户中心(逻辑删除,更新del_flag字段为1,在表包含字段del_flag时,可以调用此方法,将数据隐藏) + */ + //RequiresPermissions("usercenter:sysUserCenter:delByLogic") + @RequestMapping(value = "deleteAllByLogic") + public String deleteAllByLogic(String ids, RedirectAttributes redirectAttributes) { + String[] idArray = ids.split(","); + for(String id : idArray){ + sysUserCenterService.deleteByLogic(sysUserCenterService.get(id)); + } + addMessage(redirectAttributes, "删除用户中心成功"); + return "redirect:"+Global.getAdminPath()+"/usercenter/sysUserCenter/?repage"; + } + + /** + * 导出excel文件 + */ + //RequiresPermissions("usercenter:sysUserCenter:export") + @RequestMapping(value = "export", method=RequestMethod.POST) + public String exportFile(SysUserCenter sysUserCenter, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "用户中心"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx"; + Page page = sysUserCenterService.findPage(new Page(request, response, -1), sysUserCenter); + new ExportExcel("用户中心", SysUserCenter.class).setDataList(page.getList()).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导出用户中心记录失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/usercenter/sysUserCenter/?repage"; + } + + /** + * 导入Excel数据 + + */ + //RequiresPermissions("usercenter:sysUserCenter:import") + @RequestMapping(value = "import", method=RequestMethod.POST) + public String importFile(MultipartFile file, RedirectAttributes redirectAttributes) { + try { + int successNum = 0; + ImportExcel ei = new ImportExcel(file, 1, 0); + List list = ei.getDataList(SysUserCenter.class); + for (SysUserCenter sysUserCenter : list){ + sysUserCenterService.save(sysUserCenter); + } + addMessage(redirectAttributes, "已成功导入 "+successNum+" 条用户中心记录"); + } catch (Exception e) { + addMessage(redirectAttributes, "导入用户中心失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/usercenter/sysUserCenter/?repage"; + } + + /** + * 下载导入用户中心数据模板 + */ + //RequiresPermissions("usercenter:sysUserCenter:import") + @RequestMapping(value = "import/template") + public String importFileTemplate(HttpServletResponse response, RedirectAttributes redirectAttributes) { + try { + String fileName = "用户中心数据导入模板.xlsx"; + List list = Lists.newArrayList(); + new ExportExcel("用户中心数据", SysUserCenter.class, 1).setDataList(list).write(response, fileName).dispose(); + return null; + } catch (Exception e) { + addMessage(redirectAttributes, "导入模板下载失败!失败信息:"+e.getMessage()); + } + return "redirect:"+Global.getAdminPath()+"/usercenter/sysUserCenter/?repage"; + } + + +} \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/EmailRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/EmailRestController.java new file mode 100644 index 0000000..52dcf6c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/EmailRestController.java @@ -0,0 +1,125 @@ +/** + * * Copyright © 2015-2020 JeeSpring All rights reserved.. + */ +package com.jeespring.modules.utils; + +import com.jeespring.common.utils.SendMailUtil; +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.sys.service.SysConfigService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 邮箱Controller + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@RestController +@RequestMapping(value = "rest/sys/email") +@Api(value="email邮件云接口", description="email邮件云接口") +public class EmailRestController extends AbstractBaseController { + @Autowired + private SysConfigService sysConfigService; + + @RequestMapping(value = {"sendMailException"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="发送邮件(Content-Type为text/html)", notes="发送邮件(Content-Type为text/html)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "subject", value = "邮件主题", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "message", value = "邮件内容", required = false, dataType = "String",paramType="query") + }) + public void sendMailException(@RequestParam(required=false) String subject, @RequestParam(required=false) String message) { + //SendMailUtil.sendCommonMail("1638077616@qq.com","jeespring",message); + SysConfig entity = new SysConfig(); + entity.setType("toExceptionMailAddr"); + List sysConfigList=sysConfigService.findList(entity); + if(sysConfigList.size()>=0){ + SendMailUtil.sendCommonMail(sysConfigList.get(0).getValue(),"(异常邮件)"+subject,message); + } + } + + @RequestMapping(value = {"sendMailException/json"},method ={RequestMethod.POST}) + @ApiOperation(value="发送邮件(Content-Type为application/json)", notes="发送邮件(application/json)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "subject", value = "邮件主题", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "message", value = "邮件内容", required = false, dataType = "String",paramType="body") + }) + public void sendMailExceptionJson(@RequestBody(required=false) String subject, @RequestBody(required=false) String message) { + //SendMailUtil.sendCommonMail("1638077616@qq.com","jeespring",message); + SysConfig entity = new SysConfig(); + entity.setType("toExceptionMailAddr"); + List sysConfigList=sysConfigService.findList(entity); + if(sysConfigList.size()>=0){ + SendMailUtil.sendCommonMail(sysConfigList.get(0).getValue(),"(异常邮件)"+subject,message); + } + } + + @RequestMapping(value = {"sendMail"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="发送邮件(Content-Type为text/html)", notes="发送邮件(Content-Type为text/html)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "toMailAddr", value = "接收邮箱", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "subject", value = "邮件主题", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "message", value = "邮件内容", required = false, dataType = "String",paramType="query") + }) + public void sendMail(@RequestParam(required=false) String toMailAddr, @RequestParam(required=false) String subject, @RequestParam(required=false) String message) { + //SendMailUtil.sendCommonMail("1638077616@qq.com","jeespring",message); + SendMailUtil.sendCommonMail(toMailAddr,subject,message); + } + + @RequestMapping(value = {"sendMail/json"},method ={RequestMethod.POST}) + @ApiOperation(value="发送邮件(Content-Type为application/json)", notes="发送邮件(application/json)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "toMailAddr", value = "接收邮箱", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "subject", value = "邮件主题", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "message", value = "邮件内容", required = false, dataType = "String",paramType="body") + }) + public void sendMailJson(@RequestBody(required=false) String toMailAddr, @RequestBody(required=false) String subject, @RequestBody(required=false) String message) { + //SendMailUtil.sendCommonMail("1638077616@qq.com","jeespring",message); + SendMailUtil.sendCommonMail(toMailAddr,subject,message); + } + + @RequestMapping(value = {"sendMailFromTo"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="发送邮件(Content-Type为text/html)", notes="发送邮件(Content-Type为text/html)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "fromMailAddr", value = "发送邮箱", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "fromMailName", value = "发送邮箱名称", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "fromMailUsername", value = "发送邮箱用户名", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "fromMailPassword", value = "发送邮箱密码", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "toMailAddr", value = "接收邮箱", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "subject", value = "邮件主题", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "message", value = "邮件内容", required = false, dataType = "String",paramType="query") + }) + public void sendMailFromTo(@RequestParam(required=false) String fromMailAddr,@RequestParam(required=false) String fromMailName, + @RequestParam(required=false) String fromMailUsername,@RequestParam(required=false) String fromMailPassword, + @RequestParam(required=false) String toMailAddr, @RequestParam(required=false) String subject, + @RequestParam(required=false) String message) { + //SendMailUtil.sendCommonMail("516821420@qq.com","jeespring","516821420@qq.com","lzxfcmfbrtmdcbcg","1638077616@qq.com","jeespring",message); + SendMailUtil.sendCommonMailFromTo(fromMailAddr,fromMailName,fromMailUsername,fromMailPassword,toMailAddr,subject,message); + } + + @RequestMapping(value = {"sendMailFromTo/json"},method ={RequestMethod.POST}) + @ApiOperation(value="发送邮件(Content-Type为application/json)", notes="发送邮件(Content-Type为application/json)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "fromMailAddr", value = "发送邮箱", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "fromMailName", value = "发送邮箱名称", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "fromMailUsername", value = "发送邮箱用户名", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "fromMailPassword", value = "发送邮箱密码", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "toMailAddr", value = "接收邮箱", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "subject", value = "邮件主题", required = false, dataType = "String",paramType="body"), + @ApiImplicitParam(name = "message", value = "邮件内容", required = false, dataType = "String",paramType="body") + }) + public void sendMailFromToJson(@RequestBody(required=false) String fromMailAddr,@RequestBody(required=false) String fromMailName, + @RequestBody(required=false) String fromMailUsername,@RequestBody(required=false) String fromMailPassword, + @RequestBody(required=false) String toMailAddr, @RequestBody(required=false) String subject, + @RequestBody(required=false) String message) { + //SendMailUtil.sendCommonMail("516821420@qq.com","jeespring","516821420@qq.com","lzxfcmfbrtmdcbcg","1638077616@qq.com","jeespring",message); + SendMailUtil.sendCommonMailFromTo(fromMailAddr,fromMailName,fromMailUsername,fromMailPassword,toMailAddr,subject,message); + } + +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/rest/MapApiRestController.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/rest/MapApiRestController.java new file mode 100644 index 0000000..ff051f2 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/rest/MapApiRestController.java @@ -0,0 +1,138 @@ +package com.jeespring.modules.utils.rest; + +import com.jeespring.common.web.AbstractBaseController; +import com.jeespring.common.web.Result; +import com.jeespring.modules.usercenter.entity.SysUserCenter; +import com.jeespring.modules.usercenter.service.SysUserCenterService; +import com.jeespring.modules.utils.service.MapApiService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * MapAPI百度地图RestController + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@RestController +@RequestMapping(value = "rest/utils/mapapi") +@Api(value="MapAPI百度地图", description="MapAPI百度地图") +public class MapApiRestController extends AbstractBaseController { + + @Autowired + private MapApiService mapApiService; + + + @Autowired + private SysUserCenterService sysUserCenterService; + + @RequestMapping(value = {"getLocation"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="获取地址经纬度(Content-Type为text/html)", notes="获取地址经纬度(Content-Type为text/html)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ak", value = "百度授权码", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "output", value = "输出格式(json/xml)", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "address", value = "地址", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "city", value = "城市", required = false, dataType = "String",paramType="query") + }) + public Result getLocation(@RequestParam(required=false) String ak, @RequestParam(required=false) String output, @RequestParam(required=false) String address, @RequestParam(required=false) String city) { + return mapApiService.getLocation(ak,output,address,city); + } + + @RequestMapping(value = {"getMap"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="获取地图(Content-Type为text/html)", notes="获取地图(Content-Type为text/html)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "lat", value = "经度", required = false, dataType = "String",paramType="query"), + @ApiImplicitParam(name = "lng", value = "纬度", required = false, dataType = "String",paramType="query"), + }) + public ModelAndView getMap(@RequestParam(required=false) String lat, @RequestParam(required=false) String lng, HttpServletRequest request, HttpServletResponse response, Model model){ + if(lat=="" || lat == null) { + lng = "113.24712"; + } + if(lng=="" || lng == null) { + lat = "23.098878"; + } + model.addAttribute("lat", lat); + model.addAttribute("lng", lng); + ModelAndView mv = new ModelAndView("modules/utils/map"); + Map map = new HashMap(); + map.put("lat", lat); + map.put("lng", lng); + mv.addAllObjects(map); + return mv; + } + + @RequestMapping(value = {"getMapUserCenter"},method ={RequestMethod.POST,RequestMethod.GET}) + @ApiOperation(value="获取用户中心地图(Content-Type为text/html)", notes="获取用户中心地图(Content-Type为text/html)") + @ApiImplicitParam(name = "sysUserCenter", value = "用户中心", dataType = "SysUserCenter",paramType="query") + public ModelAndView getMapUserCenter(SysUserCenter sysUserCenter,HttpServletRequest request, HttpServletResponse response, Model model){ + try { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat formatDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date=new Date(); + if(sysUserCenter.getBeginCreateDate()==null || sysUserCenter.getEndCreateDate()==null){ + sysUserCenter.setBeginCreateDate(formatDateTime.parse(format.format(date)+" 00:00:00")); + sysUserCenter.setEndCreateDate(formatDateTime.parse(format.format(date)+" 23:59:59")); + }else{ + sysUserCenter.setBeginCreateDate(formatDateTime.parse(format.format(sysUserCenter.getBeginCreateDate())+" 00:00:00")); + sysUserCenter.setEndCreateDate(formatDateTime.parse(format.format(sysUserCenter.getEndCreateDate())+" 23:59:59")); + } + }catch (Exception e){} + List sysUserCenterList=sysUserCenterService.findList(sysUserCenter); + for (SysUserCenter item:sysUserCenterList) { + if(item.getUserName()==null) { + continue; + } + if(item.getUserPhone()==null) { + item.setUserPhone(""); + } + if(item.getUserName().indexOf("\"")>0) { + item.setUserName(item.getUserName().replaceAll("\"", "")); + } + if(item.getLat()==null || item.getAddress()==null) { + item.setLat("0"); + item.setLng("0"); + item.setAddress("-"); + item.setCity("-"); + } + if(item.getLat().indexOf(".")<=0 || item.getAddress().length()<=6) { + continue; + } + if(item.getLat().substring(item.getLat().indexOf(".")).length()<=10 && item.getAddress().length()>6){ + Result result=mapApiService.getLocation("","",item.getAddress(),item.getCity()); + if("0".equals(result.getResultCoe().toString())){ + int index=result.getResultObject().toString().indexOf("|"); + int size=result.getResultObject().toString().length(); + if(index>0){ + item.setLng(result.getResultObject().toString().substring(0,index)); + item.setLat(result.getResultObject().toString().substring(index+1)); + String lat=String.valueOf(Double.valueOf(item.getLat()) +(Math.random()*9+1)*0.00001*5); + String lng=String.valueOf(Double.valueOf(item.getLng()) +(Math.random()*9+1)*0.00001*5); + item.setLng(lng); + item.setLat(lat); + } + sysUserCenterService.save(item); + } + } + } + ModelAndView mv = new ModelAndView("modules/utils/mapUserCenter"); + Map map = new HashMap(); + map.put("sysUserCenterList", sysUserCenterList); + map.put("count", sysUserCenterList.size()); + map.put("sysUserCenter", sysUserCenter); + mv.addAllObjects(map); + return mv; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/service/EmailService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/service/EmailService.java new file mode 100644 index 0000000..cfb78f7 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/service/EmailService.java @@ -0,0 +1,32 @@ +package com.jeespring.modules.utils.service; + +import com.jeespring.common.utils.SendMailUtil; +import com.jeespring.modules.sys.entity.SysConfig; +import com.jeespring.modules.sys.service.SysConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * 发邮件服务 + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Service +public class EmailService { + @Autowired + private SysConfigService sysConfigService; + + public void sendMailException(@RequestParam(required=false) String subject, @RequestParam(required=false) String message) { + SysConfig entity = new SysConfig(); + entity.setType("toExceptionMailAddr"); + List sysConfigList=sysConfigService.findList(entity); + entity.setType("ExceptionMailRun"); + entity=sysConfigService.findListFirstCache(entity); + if(sysConfigList.size()>0 && "true".equals(entity.getValue())){ + SendMailUtil.sendCommonMail(sysConfigList.get(0).getValue(),"(异常邮件)"+subject,message); + } + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/service/MapApiService.java b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/service/MapApiService.java new file mode 100644 index 0000000..fb7b202 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/com/jeespring/modules/utils/service/MapApiService.java @@ -0,0 +1,49 @@ +package com.jeespring.modules.utils.service; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.jeespring.common.utils.HttpRequest; +import com.jeespring.common.web.Result; +import com.jeespring.common.web.ResultFactory; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * MapAPI百度地图Service + * @author 黄炳桂 516821420@qq.com + * @version 2014-05-16 + */ +@Service +public class MapApiService { + + //获取地址经纬度 + public Result getLocation(@RequestParam(required=false) String ak, @RequestParam(required=false) String output, @RequestParam(required=false) String address, @RequestParam(required=false) String city) { + if(ak=="" || ak==null) { + ak = "2ae1130ce176b453fb29e59a69b18407"; + } + if(output=="" || output==null) { + output = "json"; + } + if(address=="" || address==null) { + address = "广州"; + } + if(city=="" || city==null) { + city = "广州"; + } + String url="http://api.map.baidu.com/geocoder/v2/?ak="+ak+"&callback=renderOption&output="+output+"&address="+address+"&city="+city; + Result result; + try{ + JSONObject jsonObject = JSON.parseObject(HttpRequest.sendGet(url,"").replace("renderOption&&renderOption(","").replace(")","")); + JSONObject resultObject = jsonObject.getJSONObject("result"); + JSONObject location = resultObject.getJSONObject("location"); + String lat = location.getString("lat"); + String lng = location.getString("lng"); + result = ResultFactory.getSuccessResult(); + result.setResultObject(lng+"|"+lat); + }catch (Exception e){ + result = ResultFactory.getErrorResult("MapAPI获取失败!"); + } + return result; + } +} diff --git a/JeeSpringCloud/jeespring-framework/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java b/JeeSpringCloud/jeespring-framework/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java new file mode 100644 index 0000000..ebc7043 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/java/org/activiti/editor/language/json/converter/BpmnJsonConverter.java @@ -0,0 +1,1051 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.activiti.editor.language.json.converter; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import math.geom2d.Point2D; + +import math.geom2d.conic.Circle2D; + +import math.geom2d.curve.AbstractContinuousCurve2D; + +import math.geom2d.line.Line2D; + +import math.geom2d.polygon.Polyline2D; + +import org.activiti.bpmn.model.Activity; +import org.activiti.bpmn.model.Artifact; +import org.activiti.bpmn.model.BaseElement; +import org.activiti.bpmn.model.BoundaryEvent; +import org.activiti.bpmn.model.BpmnModel; +import org.activiti.bpmn.model.Event; +import org.activiti.bpmn.model.EventDefinition; +import org.activiti.bpmn.model.ExtensionElement; +import org.activiti.bpmn.model.FlowElement; +import org.activiti.bpmn.model.FlowElementsContainer; +import org.activiti.bpmn.model.FlowNode; +import org.activiti.bpmn.model.Gateway; +import org.activiti.bpmn.model.GraphicInfo; +import org.activiti.bpmn.model.Lane; +import org.activiti.bpmn.model.Message; +import org.activiti.bpmn.model.MessageEventDefinition; +import org.activiti.bpmn.model.MessageFlow; +import org.activiti.bpmn.model.Pool; +import org.activiti.bpmn.model.Process; +import org.activiti.bpmn.model.SequenceFlow; +import org.activiti.bpmn.model.Signal; +import org.activiti.bpmn.model.SignalEventDefinition; +import org.activiti.bpmn.model.SubProcess; +import org.activiti.bpmn.model.ValuedDataObject; + +import org.activiti.editor.constants.EditorJsonConstants; +import org.activiti.editor.constants.StencilConstants; +import org.activiti.editor.language.json.converter.util.JsonConverterUtil; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Tijs Rademakers + * @modify xuhuisheng 解决modeler发布的流程图,sequenceFlow不显示的问题 + */ +public class BpmnJsonConverter implements EditorJsonConstants, StencilConstants, ActivityProcessor { + + protected static final Logger LOGGER = LoggerFactory.getLogger(BpmnJsonConverter.class); + protected static Map, Class> convertersToJsonMap = new HashMap, Class>(); + protected static Map> convertersToBpmnMap = new HashMap>(); + public static final String MODELER_NAMESPACE = "http://activiti.com/modeler"; + protected static final DateFormat defaultFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + protected static final DateFormat entFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + + static { + // start and end events + StartEventJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + EndEventJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + + // connectors + SequenceFlowJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + MessageFlowJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + AssociationJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + + // task types + BusinessRuleTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + MailTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + ManualTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + ReceiveTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + ScriptTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + ServiceTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + UserTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + CallActivityJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + CamelTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + MuleTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + SendTaskJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + + // gateways + ExclusiveGatewayJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + InclusiveGatewayJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + ParallelGatewayJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + EventGatewayJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + + // scope constructs + SubProcessJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + EventSubProcessJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + + // catch events + CatchEventJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + + // throw events + ThrowEventJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + + // boundary events + BoundaryEventJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + + // artifacts + TextAnnotationJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + DataStoreJsonConverter.fillTypes(convertersToBpmnMap, convertersToJsonMap); + } + + private static final List DI_CIRCLES = new ArrayList(); + private static final List DI_RECTANGLES = new ArrayList(); + private static final List DI_GATEWAY = new ArrayList(); + + static { + DI_CIRCLES.add(STENCIL_EVENT_START_ERROR); + DI_CIRCLES.add(STENCIL_EVENT_START_MESSAGE); + DI_CIRCLES.add(STENCIL_EVENT_START_NONE); + DI_CIRCLES.add(STENCIL_EVENT_START_TIMER); + DI_CIRCLES.add(STENCIL_EVENT_START_SIGNAL); + + DI_CIRCLES.add(STENCIL_EVENT_BOUNDARY_ERROR); + DI_CIRCLES.add(STENCIL_EVENT_BOUNDARY_SIGNAL); + DI_CIRCLES.add(STENCIL_EVENT_BOUNDARY_TIMER); + DI_CIRCLES.add(STENCIL_EVENT_BOUNDARY_MESSAGE); + DI_CIRCLES.add(STENCIL_EVENT_BOUNDARY_CANCEL); + DI_CIRCLES.add(STENCIL_EVENT_BOUNDARY_COMPENSATION); + + DI_CIRCLES.add(STENCIL_EVENT_CATCH_MESSAGE); + DI_CIRCLES.add(STENCIL_EVENT_CATCH_SIGNAL); + DI_CIRCLES.add(STENCIL_EVENT_CATCH_TIMER); + + DI_CIRCLES.add(STENCIL_EVENT_THROW_NONE); + DI_CIRCLES.add(STENCIL_EVENT_THROW_SIGNAL); + + DI_CIRCLES.add(STENCIL_EVENT_END_NONE); + DI_CIRCLES.add(STENCIL_EVENT_END_ERROR); + DI_CIRCLES.add(STENCIL_EVENT_END_CANCEL); + DI_CIRCLES.add(STENCIL_EVENT_END_TERMINATE); + + DI_RECTANGLES.add(STENCIL_CALL_ACTIVITY); + DI_RECTANGLES.add(STENCIL_SUB_PROCESS); + DI_RECTANGLES.add(STENCIL_EVENT_SUB_PROCESS); + DI_RECTANGLES.add(STENCIL_TASK_BUSINESS_RULE); + DI_RECTANGLES.add(STENCIL_TASK_MAIL); + DI_RECTANGLES.add(STENCIL_TASK_MANUAL); + DI_RECTANGLES.add(STENCIL_TASK_RECEIVE); + DI_RECTANGLES.add(STENCIL_TASK_SCRIPT); + DI_RECTANGLES.add(STENCIL_TASK_SEND); + DI_RECTANGLES.add(STENCIL_TASK_SERVICE); + DI_RECTANGLES.add(STENCIL_TASK_USER); + DI_RECTANGLES.add(STENCIL_TASK_CAMEL); + DI_RECTANGLES.add(STENCIL_TASK_MULE); + DI_RECTANGLES.add(STENCIL_TEXT_ANNOTATION); + + DI_GATEWAY.add(STENCIL_GATEWAY_EVENT); + DI_GATEWAY.add(STENCIL_GATEWAY_EXCLUSIVE); + DI_GATEWAY.add(STENCIL_GATEWAY_INCLUSIVE); + DI_GATEWAY.add(STENCIL_GATEWAY_PARALLEL); + } + + protected ObjectMapper objectMapper = new ObjectMapper(); + + public ObjectNode convertToJson(BpmnModel model) { + ObjectNode modelNode = objectMapper.createObjectNode(); + double maxX = 0.0; + double maxY = 0.0; + + for (GraphicInfo flowInfo : model.getLocationMap().values()) { + if ((flowInfo.getX() + flowInfo.getWidth()) > maxX) { + maxX = flowInfo.getX() + flowInfo.getWidth(); + } + + if ((flowInfo.getY() + flowInfo.getHeight()) > maxY) { + maxY = flowInfo.getY() + flowInfo.getHeight(); + } + } + + maxX += 50; + maxY += 50; + + if (maxX < 1485) { + maxX = 1485; + } + + if (maxY < 700) { + maxY = 700; + } + + modelNode.put("bounds", BpmnJsonConverterUtil.createBoundsNode(maxX, maxY, 0, 0)); + modelNode.put("resourceId", "canvas"); + + ObjectNode stencilNode = objectMapper.createObjectNode(); + stencilNode.put("id", "BPMNDiagram"); + modelNode.put("stencil", stencilNode); + + ObjectNode stencilsetNode = objectMapper.createObjectNode(); + stencilsetNode.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#"); + stencilsetNode.put("url", "../editor/stencilsets/bpmn2.0/bpmn2.0.json"); + modelNode.put("stencilset", stencilsetNode); + + ArrayNode shapesArrayNode = objectMapper.createArrayNode(); + + Process mainProcess = null; + + if (model.getPools().size() > 0) { + mainProcess = model.getProcess(model.getPools().get(0).getId()); + } else { + mainProcess = model.getMainProcess(); + } + + ObjectNode propertiesNode = objectMapper.createObjectNode(); + + if (StringUtils.isNotEmpty(mainProcess.getId())) { + propertiesNode.put(PROPERTY_PROCESS_ID, mainProcess.getId()); + } + + if (StringUtils.isNotEmpty(mainProcess.getName())) { + propertiesNode.put(PROPERTY_NAME, mainProcess.getName()); + } + + if (StringUtils.isNotEmpty(mainProcess.getDocumentation())) { + propertiesNode.put(PROPERTY_DOCUMENTATION, mainProcess.getDocumentation()); + } + + if (mainProcess.isExecutable() == false) { + propertiesNode.put(PROPERTY_PROCESS_EXECUTABLE, "No"); + } + + if (StringUtils.isNoneEmpty(model.getTargetNamespace())) { + propertiesNode.put(PROPERTY_PROCESS_NAMESPACE, model.getTargetNamespace()); + } + + BpmnJsonConverterUtil.convertMessagesToJson(model.getMessages(), propertiesNode); + + BpmnJsonConverterUtil.convertListenersToJson(mainProcess.getExecutionListeners(), true, propertiesNode); + BpmnJsonConverterUtil.convertEventListenersToJson(mainProcess.getEventListeners(), propertiesNode); + BpmnJsonConverterUtil.convertSignalDefinitionsToJson(model, propertiesNode); + BpmnJsonConverterUtil.convertMessagesToJson(model, propertiesNode); + + if (CollectionUtils.isNotEmpty(mainProcess.getDataObjects())) { + BpmnJsonConverterUtil.convertDataPropertiesToJson(mainProcess.getDataObjects(), propertiesNode); + } + + modelNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode); + + boolean poolHasDI = false; + + if (model.getPools().size() > 0) { + for (Pool pool : model.getPools()) { + GraphicInfo graphicInfo = model.getGraphicInfo(pool.getId()); + + if (graphicInfo != null) { + poolHasDI = true; + + break; + } + } + } + + if ((model.getPools().size() > 0) && poolHasDI) { + for (Pool pool : model.getPools()) { + GraphicInfo graphicInfo = model.getGraphicInfo(pool.getId()); + + if (graphicInfo == null) { + continue; + } + + ObjectNode poolNode = BpmnJsonConverterUtil.createChildShape(pool.getId(), STENCIL_POOL, graphicInfo.getX() + graphicInfo.getWidth(), + graphicInfo.getY() + graphicInfo.getHeight(), graphicInfo.getX(), graphicInfo.getY()); + shapesArrayNode.add(poolNode); + + ObjectNode poolPropertiesNode = objectMapper.createObjectNode(); + poolPropertiesNode.put(PROPERTY_OVERRIDE_ID, pool.getId()); + poolPropertiesNode.put(PROPERTY_PROCESS_ID, pool.getProcessRef()); + + if (pool.isExecutable() == false) { + poolPropertiesNode.put(PROPERTY_PROCESS_EXECUTABLE, PROPERTY_VALUE_NO); + } + + if (StringUtils.isNotEmpty(pool.getName())) { + poolPropertiesNode.put(PROPERTY_NAME, pool.getName()); + } + + poolNode.put(EDITOR_SHAPE_PROPERTIES, poolPropertiesNode); + + ArrayNode laneShapesArrayNode = objectMapper.createArrayNode(); + poolNode.put(EDITOR_CHILD_SHAPES, laneShapesArrayNode); + + ArrayNode outgoingArrayNode = objectMapper.createArrayNode(); + poolNode.put("outgoing", outgoingArrayNode); + + Process process = model.getProcess(pool.getId()); + + if (process != null) { + Map laneMap = new HashMap(); + + for (Lane lane : process.getLanes()) { + GraphicInfo laneGraphicInfo = model.getGraphicInfo(lane.getId()); + + if (laneGraphicInfo == null) { + continue; + } + + ObjectNode laneNode = BpmnJsonConverterUtil.createChildShape(lane.getId(), STENCIL_LANE, laneGraphicInfo.getX() + + laneGraphicInfo.getWidth(), laneGraphicInfo.getY() + laneGraphicInfo.getHeight(), laneGraphicInfo.getX(), + laneGraphicInfo.getY()); + laneShapesArrayNode.add(laneNode); + + ObjectNode lanePropertiesNode = objectMapper.createObjectNode(); + lanePropertiesNode.put(PROPERTY_OVERRIDE_ID, lane.getId()); + + if (StringUtils.isNotEmpty(lane.getName())) { + lanePropertiesNode.put(PROPERTY_NAME, lane.getName()); + } + + laneNode.put(EDITOR_SHAPE_PROPERTIES, lanePropertiesNode); + + ArrayNode elementShapesArrayNode = objectMapper.createArrayNode(); + laneNode.put(EDITOR_CHILD_SHAPES, elementShapesArrayNode); + laneNode.put("outgoing", objectMapper.createArrayNode()); + + laneMap.put(lane.getId(), elementShapesArrayNode); + } + + for (FlowElement flowElement : process.getFlowElements()) { + Lane laneForElement = null; + GraphicInfo laneGraphicInfo = null; + + FlowElement lookForElement = null; + + if (flowElement instanceof SequenceFlow) { + SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + lookForElement = model.getFlowElement(sequenceFlow.getSourceRef()); + } else { + lookForElement = flowElement; + } + + for (Lane lane : process.getLanes()) { + if (lane.getFlowReferences().contains(lookForElement.getId())) { + laneGraphicInfo = model.getGraphicInfo(lane.getId()); + + if (laneGraphicInfo != null) { + laneForElement = lane; + } + + break; + } + } + + if (flowElement instanceof SequenceFlow || (laneForElement != null)) { + processFlowElement(flowElement, process, model, laneMap.get(laneForElement.getId()), laneGraphicInfo.getX(), + laneGraphicInfo.getY()); + } + } + + processArtifacts(process, model, shapesArrayNode, 0.0, 0.0); + } + + for (MessageFlow messageFlow : model.getMessageFlows().values()) { + if (messageFlow.getSourceRef().equals(pool.getId())) { + outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(messageFlow.getId())); + } + } + } + + processMessageFlows(model, shapesArrayNode); + } else { + processFlowElements(model.getMainProcess(), model, shapesArrayNode, 0.0, 0.0); + processMessageFlows(model, shapesArrayNode); + } + + modelNode.put(EDITOR_CHILD_SHAPES, shapesArrayNode); + + return modelNode; + } + + public void processFlowElements(FlowElementsContainer container, BpmnModel model, ArrayNode shapesArrayNode, double subProcessX, + double subProcessY) { + for (FlowElement flowElement : container.getFlowElements()) { + processFlowElement(flowElement, container, model, shapesArrayNode, subProcessX, subProcessY); + } + + processArtifacts(container, model, shapesArrayNode, subProcessX, subProcessY); + } + + protected void processFlowElement(FlowElement flowElement, FlowElementsContainer container, BpmnModel model, ArrayNode shapesArrayNode, + double containerX, double containerY) { + Class converter = convertersToJsonMap.get(flowElement.getClass()); + + if (converter != null) { + try { + converter.newInstance().convertToJson(flowElement, this, model, container, shapesArrayNode, containerX, containerY); + } catch (Exception e) { + LOGGER.error("Error converting {}", flowElement, e); + } + } + } + + protected void processArtifacts(FlowElementsContainer container, BpmnModel model, ArrayNode shapesArrayNode, double containerX, double containerY) { + for (Artifact artifact : container.getArtifacts()) { + Class converter = convertersToJsonMap.get(artifact.getClass()); + + if (converter != null) { + try { + converter.newInstance().convertToJson(artifact, this, model, container, shapesArrayNode, containerX, containerY); + } catch (Exception e) { + LOGGER.error("Error converting {}", artifact, e); + } + } + } + } + + protected void processMessageFlows(BpmnModel model, ArrayNode shapesArrayNode) { + for (MessageFlow messageFlow : model.getMessageFlows().values()) { + MessageFlowJsonConverter jsonConverter = new MessageFlowJsonConverter(); + jsonConverter.convertToJson(messageFlow, this, model, null, shapesArrayNode, 0.0, 0.0); + } + } + + public BpmnModel convertToBpmnModel(JsonNode modelNode) { + BpmnModel bpmnModel = new BpmnModel(); + + bpmnModel.setTargetNamespace("http://activiti.org/test"); + + Map shapeMap = new HashMap(); + Map sourceRefMap = new HashMap(); + Map edgeMap = new HashMap(); + Map> sourceAndTargetMap = new HashMap>(); + + readShapeDI(modelNode, 0, 0, shapeMap, sourceRefMap, bpmnModel); + filterAllEdges(modelNode, edgeMap, sourceAndTargetMap, shapeMap, sourceRefMap); + readEdgeDI(edgeMap, sourceAndTargetMap, bpmnModel); + + ArrayNode shapesArrayNode = (ArrayNode) modelNode.get(EDITOR_CHILD_SHAPES); + + if ((shapesArrayNode == null) || (shapesArrayNode.size() == 0)) { + return bpmnModel; + } + + boolean nonEmptyPoolFound = false; + Map elementInLaneMap = new HashMap(); + + // first create the pool structure + for (JsonNode shapeNode : shapesArrayNode) { + String stencilId = BpmnJsonConverterUtil.getStencilId(shapeNode); + + if (STENCIL_POOL.equals(stencilId)) { + Pool pool = new Pool(); + pool.setId(BpmnJsonConverterUtil.getElementId(shapeNode)); + pool.setName(JsonConverterUtil.getPropertyValueAsString(PROPERTY_NAME, shapeNode)); + pool.setProcessRef(JsonConverterUtil.getPropertyValueAsString(PROPERTY_PROCESS_ID, shapeNode)); + pool.setExecutable(JsonConverterUtil.getPropertyValueAsBoolean(PROPERTY_PROCESS_EXECUTABLE, shapeNode, true)); + bpmnModel.getPools().add(pool); + + Process process = new Process(); + process.setId(pool.getProcessRef()); + process.setName(pool.getName()); + process.setExecutable(pool.isExecutable()); + bpmnModel.addProcess(process); + + ArrayNode laneArrayNode = (ArrayNode) shapeNode.get(EDITOR_CHILD_SHAPES); + + for (JsonNode laneNode : laneArrayNode) { + // should be a lane, but just check to be certain + String laneStencilId = BpmnJsonConverterUtil.getStencilId(laneNode); + + if (STENCIL_LANE.equals(laneStencilId)) { + nonEmptyPoolFound = true; + + Lane lane = new Lane(); + lane.setId(BpmnJsonConverterUtil.getElementId(laneNode)); + lane.setName(JsonConverterUtil.getPropertyValueAsString(PROPERTY_NAME, laneNode)); + lane.setParentProcess(process); + process.getLanes().add(lane); + + processJsonElements(laneNode.get(EDITOR_CHILD_SHAPES), modelNode, lane, shapeMap, bpmnModel); + + if (CollectionUtils.isNotEmpty(lane.getFlowReferences())) { + for (String elementRef : lane.getFlowReferences()) { + elementInLaneMap.put(elementRef, lane); + } + } + } + } + } + } + + // Signal Definitions exist on the root level + JsonNode signalDefinitionNode = BpmnJsonConverterUtil.getProperty(PROPERTY_SIGNAL_DEFINITIONS, modelNode); + signalDefinitionNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(signalDefinitionNode); + signalDefinitionNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(signalDefinitionNode); // no idea why this needs to be done twice .. + + if (signalDefinitionNode != null) { + if (signalDefinitionNode instanceof ArrayNode) { + ArrayNode signalDefinitionArrayNode = (ArrayNode) signalDefinitionNode; + Iterator signalDefinitionIterator = signalDefinitionArrayNode.iterator(); + + while (signalDefinitionIterator.hasNext()) { + JsonNode signalDefinitionJsonNode = signalDefinitionIterator.next(); + String signalId = signalDefinitionJsonNode.get(PROPERTY_SIGNAL_DEFINITION_ID).asText(); + String signalName = signalDefinitionJsonNode.get(PROPERTY_SIGNAL_DEFINITION_NAME).asText(); + String signalScope = signalDefinitionJsonNode.get(PROPERTY_SIGNAL_DEFINITION_SCOPE).asText(); + + Signal signal = new Signal(); + signal.setId(signalId); + signal.setName(signalName); + signal.setScope((signalScope.toLowerCase().equals("processinstance")) ? Signal.SCOPE_PROCESS_INSTANCE : Signal.SCOPE_GLOBAL); + bpmnModel.addSignal(signal); + } + } + } + + if (nonEmptyPoolFound == false) { + Process process = new Process(); + bpmnModel.getProcesses().add(process); + process.setId(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_PROCESS_ID, modelNode)); + process.setName(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_NAME, modelNode)); + + String namespace = BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_PROCESS_NAMESPACE, modelNode); + + if (StringUtils.isNotEmpty(namespace)) { + bpmnModel.setTargetNamespace(namespace); + } + + process.setDocumentation(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_DOCUMENTATION, modelNode)); + + JsonNode processExecutableNode = JsonConverterUtil.getProperty(PROPERTY_PROCESS_EXECUTABLE, modelNode); + + if ((processExecutableNode != null) && StringUtils.isNotEmpty(processExecutableNode.asText())) { + process.setExecutable(JsonConverterUtil.getPropertyValueAsBoolean(PROPERTY_PROCESS_EXECUTABLE, modelNode)); + } + + BpmnJsonConverterUtil.convertJsonToMessages(modelNode, bpmnModel); + + BpmnJsonConverterUtil.convertJsonToListeners(modelNode, process); + + JsonNode eventListenersNode = BpmnJsonConverterUtil.getProperty(PROPERTY_EVENT_LISTENERS, modelNode); + + if (eventListenersNode != null) { + eventListenersNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(eventListenersNode); + BpmnJsonConverterUtil.parseEventListeners(eventListenersNode.get(PROPERTY_EVENTLISTENER_VALUE), process); + } + + JsonNode processDataPropertiesNode = modelNode.get(EDITOR_SHAPE_PROPERTIES).get(PROPERTY_DATA_PROPERTIES); + + if (processDataPropertiesNode != null) { + List dataObjects = BpmnJsonConverterUtil.convertJsonToDataProperties(processDataPropertiesNode, process); + process.setDataObjects(dataObjects); + process.getFlowElements().addAll(dataObjects); + } + + processJsonElements(shapesArrayNode, modelNode, process, shapeMap, bpmnModel); + } else { + // sequence flows are on root level so need additional parsing for pools + for (JsonNode shapeNode : shapesArrayNode) { + if (STENCIL_SEQUENCE_FLOW.equalsIgnoreCase(BpmnJsonConverterUtil.getStencilId(shapeNode)) + || STENCIL_ASSOCIATION.equalsIgnoreCase(BpmnJsonConverterUtil.getStencilId(shapeNode))) { + String sourceRef = BpmnJsonConverterUtil.lookForSourceRef(shapeNode.get(EDITOR_SHAPE_ID).asText(), + modelNode.get(EDITOR_CHILD_SHAPES)); + + if (sourceRef != null) { + Lane lane = elementInLaneMap.get(sourceRef); + SequenceFlowJsonConverter flowConverter = new SequenceFlowJsonConverter(); + + if (lane != null) { + flowConverter.convertToBpmnModel(shapeNode, modelNode, this, lane, shapeMap, bpmnModel); + } else { + flowConverter.convertToBpmnModel(shapeNode, modelNode, this, bpmnModel.getProcesses().get(0), shapeMap, bpmnModel); + } + } + } + } + } + + // sequence flows are now all on root level + Map subShapesMap = new HashMap(); + + for (Process process : bpmnModel.getProcesses()) { + for (FlowElement flowElement : process.findFlowElementsOfType(SubProcess.class)) { + SubProcess subProcess = (SubProcess) flowElement; + fillSubShapes(subShapesMap, subProcess); + } + + if (subShapesMap.size() > 0) { + List removeSubFlowsList = new ArrayList(); + + for (FlowElement flowElement : process.findFlowElementsOfType(SequenceFlow.class)) { + SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + + if (subShapesMap.containsKey(sequenceFlow.getSourceRef())) { + SubProcess subProcess = subShapesMap.get(sequenceFlow.getSourceRef()); + + if (subProcess.getFlowElement(sequenceFlow.getId()) == null) { + subProcess.addFlowElement(sequenceFlow); + removeSubFlowsList.add(sequenceFlow.getId()); + } + } + } + + for (String flowId : removeSubFlowsList) { + process.removeFlowElement(flowId); + } + } + } + + Map allFlowMap = new HashMap(); + List gatewayWithOrderList = new ArrayList(); + + // post handling of process elements + for (Process process : bpmnModel.getProcesses()) { + postProcessElements(process, process.getFlowElements(), edgeMap, bpmnModel, allFlowMap, gatewayWithOrderList); + } + + // sort the sequence flows + for (Gateway gateway : gatewayWithOrderList) { + List orderList = gateway.getExtensionElements().get("EDITOR_FLOW_ORDER"); + + if (CollectionUtils.isNotEmpty(orderList)) { + for (ExtensionElement orderElement : orderList) { + String flowValue = orderElement.getElementText(); + + if (StringUtils.isNotEmpty(flowValue)) { + if (allFlowMap.containsKey(flowValue)) { + FlowWithContainer flowWithContainer = allFlowMap.get(flowValue); + flowWithContainer.getFlowContainer().removeFlowElement(flowWithContainer.getSequenceFlow().getId()); + flowWithContainer.getFlowContainer().addFlowElement(flowWithContainer.getSequenceFlow()); + } + } + } + } + + gateway.getExtensionElements().remove("EDITOR_FLOW_ORDER"); + } + + return bpmnModel; + } + + public void processJsonElements(JsonNode shapesArrayNode, JsonNode modelNode, BaseElement parentElement, Map shapeMap, + BpmnModel bpmnModel) { + for (JsonNode shapeNode : shapesArrayNode) { + String stencilId = BpmnJsonConverterUtil.getStencilId(shapeNode); + Class converter = convertersToBpmnMap.get(stencilId); + + try { + BaseBpmnJsonConverter converterInstance = converter.newInstance(); + converterInstance.convertToBpmnModel(shapeNode, modelNode, this, parentElement, shapeMap, bpmnModel); + } catch (Exception e) { + LOGGER.error("Error converting {}", BpmnJsonConverterUtil.getStencilId(shapeNode), e); + } + } + } + + private void fillSubShapes(Map subShapesMap, SubProcess subProcess) { + for (FlowElement flowElement : subProcess.getFlowElements()) { + if (flowElement instanceof SubProcess) { + SubProcess childSubProcess = (SubProcess) flowElement; + subShapesMap.put(childSubProcess.getId(), subProcess); + fillSubShapes(subShapesMap, childSubProcess); + } else { + subShapesMap.put(flowElement.getId(), subProcess); + } + } + } + + private void postProcessElements(FlowElementsContainer parentContainer, Collection flowElementList, Map edgeMap, + BpmnModel bpmnModel, Map allFlowMap, List gatewayWithOrderList) { + for (FlowElement flowElement : flowElementList) { + if (flowElement instanceof Event) { + Event event = (Event) flowElement; + + if (CollectionUtils.isNotEmpty(event.getEventDefinitions())) { + EventDefinition eventDef = event.getEventDefinitions().get(0); + + if (eventDef instanceof SignalEventDefinition) { + SignalEventDefinition signalEventDef = (SignalEventDefinition) eventDef; + + if (StringUtils.isNotEmpty(signalEventDef.getSignalRef())) { + if (bpmnModel.getSignal(signalEventDef.getSignalRef()) == null) { + bpmnModel.addSignal(new Signal(signalEventDef.getSignalRef(), signalEventDef.getSignalRef())); + } + } + } else if (eventDef instanceof MessageEventDefinition) { + MessageEventDefinition messageEventDef = (MessageEventDefinition) eventDef; + + if (StringUtils.isNotEmpty(messageEventDef.getMessageRef())) { + if (bpmnModel.getMessage(messageEventDef.getMessageRef()) == null) { + bpmnModel.addMessage(new Message(messageEventDef.getMessageRef(), messageEventDef.getMessageRef(), null)); + } + } + } + } + } + + if (flowElement instanceof BoundaryEvent) { + BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement; + Activity activity = retrieveAttachedRefObject(boundaryEvent.getAttachedToRefId(), parentContainer.getFlowElements()); + + if (activity == null) { + LOGGER.warn("Boundary event " + boundaryEvent.getId() + " is not attached to any activity"); + } else { + boundaryEvent.setAttachedToRef(activity); + activity.getBoundaryEvents().add(boundaryEvent); + } + } else if (flowElement instanceof Gateway) { + if (flowElement.getExtensionElements().containsKey("EDITOR_FLOW_ORDER")) { + gatewayWithOrderList.add((Gateway) flowElement); + } + } else if (flowElement instanceof SubProcess) { + SubProcess subProcess = (SubProcess) flowElement; + postProcessElements(subProcess, subProcess.getFlowElements(), edgeMap, bpmnModel, allFlowMap, gatewayWithOrderList); + } else if (flowElement instanceof SequenceFlow) { + SequenceFlow sequenceFlow = (SequenceFlow) flowElement; + FlowElement sourceFlowElement = parentContainer.getFlowElement(sequenceFlow.getSourceRef()); + + if ((sourceFlowElement != null) && sourceFlowElement instanceof FlowNode) { + FlowWithContainer flowWithContainer = new FlowWithContainer(sequenceFlow, parentContainer); + + if ((sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID") != null) + && (sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID").size() > 0)) { + allFlowMap.put(sequenceFlow.getExtensionElements().get("EDITOR_RESOURCEID").get(0).getElementText(), flowWithContainer); + sequenceFlow.getExtensionElements().remove("EDITOR_RESOURCEID"); + } + + ((FlowNode) sourceFlowElement).getOutgoingFlows().add(sequenceFlow); + + JsonNode edgeNode = edgeMap.get(sequenceFlow.getId()); + + if (edgeNode != null) { + boolean isDefault = JsonConverterUtil.getPropertyValueAsBoolean("defaultflow", edgeNode); + + if (isDefault) { + if (sourceFlowElement instanceof Activity) { + ((Activity) sourceFlowElement).setDefaultFlow(sequenceFlow.getId()); + } else if (sourceFlowElement instanceof Gateway) { + ((Gateway) sourceFlowElement).setDefaultFlow(sequenceFlow.getId()); + } + } + } + } + + FlowElement targetFlowElement = parentContainer.getFlowElement(sequenceFlow.getTargetRef()); + + if ((targetFlowElement != null) && targetFlowElement instanceof FlowNode) { + ((FlowNode) targetFlowElement).getIncomingFlows().add(sequenceFlow); + } + } + } + } + + private Activity retrieveAttachedRefObject(String attachedToRefId, Collection flowElementList) { + Activity activity = null; + + if (StringUtils.isNotEmpty(attachedToRefId)) { + for (FlowElement flowElement : flowElementList) { + if (attachedToRefId.equals(flowElement.getId())) { + activity = (Activity) flowElement; + + break; + } else if (flowElement instanceof SubProcess) { + SubProcess subProcess = (SubProcess) flowElement; + Activity retrievedActivity = retrieveAttachedRefObject(attachedToRefId, subProcess.getFlowElements()); + + if (retrievedActivity != null) { + activity = retrievedActivity; + + break; + } + } + } + } + + return activity; + } + + private void readShapeDI(JsonNode objectNode, double parentX, double parentY, Map shapeMap, Map sourceRefMap, + BpmnModel bpmnModel) { + if (objectNode.get(EDITOR_CHILD_SHAPES) != null) { + for (JsonNode jsonChildNode : objectNode.get(EDITOR_CHILD_SHAPES)) { + String stencilId = BpmnJsonConverterUtil.getStencilId(jsonChildNode); + + if (STENCIL_SEQUENCE_FLOW.equals(stencilId) == false) { + GraphicInfo graphicInfo = new GraphicInfo(); + + JsonNode boundsNode = jsonChildNode.get(EDITOR_BOUNDS); + ObjectNode upperLeftNode = (ObjectNode) boundsNode.get(EDITOR_BOUNDS_UPPER_LEFT); + graphicInfo.setX(upperLeftNode.get(EDITOR_BOUNDS_X).asDouble() + parentX); + graphicInfo.setY(upperLeftNode.get(EDITOR_BOUNDS_Y).asDouble() + parentY); + + ObjectNode lowerRightNode = (ObjectNode) boundsNode.get(EDITOR_BOUNDS_LOWER_RIGHT); + graphicInfo.setWidth(lowerRightNode.get(EDITOR_BOUNDS_X).asDouble() - graphicInfo.getX() + parentX); + graphicInfo.setHeight(lowerRightNode.get(EDITOR_BOUNDS_Y).asDouble() - graphicInfo.getY() + parentY); + + String childShapeId = jsonChildNode.get(EDITOR_SHAPE_ID).asText(); + bpmnModel.addGraphicInfo(BpmnJsonConverterUtil.getElementId(jsonChildNode), graphicInfo); + + shapeMap.put(childShapeId, jsonChildNode); + + ArrayNode outgoingNode = (ArrayNode) jsonChildNode.get("outgoing"); + + if ((outgoingNode != null) && (outgoingNode.size() > 0)) { + for (JsonNode outgoingChildNode : outgoingNode) { + JsonNode resourceNode = outgoingChildNode.get(EDITOR_SHAPE_ID); + + if (resourceNode != null) { + sourceRefMap.put(resourceNode.asText(), jsonChildNode); + } + } + } + + readShapeDI(jsonChildNode, graphicInfo.getX(), graphicInfo.getY(), shapeMap, sourceRefMap, bpmnModel); + } + } + } + } + + private void filterAllEdges(JsonNode objectNode, Map edgeMap, Map> sourceAndTargetMap, + Map shapeMap, Map sourceRefMap) { + if (objectNode.get(EDITOR_CHILD_SHAPES) != null) { + for (JsonNode jsonChildNode : objectNode.get(EDITOR_CHILD_SHAPES)) { + ObjectNode childNode = (ObjectNode) jsonChildNode; + String stencilId = BpmnJsonConverterUtil.getStencilId(childNode); + + if (STENCIL_SUB_PROCESS.equals(stencilId)) { + filterAllEdges(childNode, edgeMap, sourceAndTargetMap, shapeMap, sourceRefMap); + } else if (STENCIL_SEQUENCE_FLOW.equals(stencilId) || STENCIL_ASSOCIATION.equals(stencilId)) { + String childEdgeId = BpmnJsonConverterUtil.getElementId(childNode); + JsonNode targetNode = childNode.get("target"); + + if ((targetNode != null) && (targetNode.isNull() == false)) { + String targetRefId = targetNode.get(EDITOR_SHAPE_ID).asText(); + List sourceAndTargetList = new ArrayList(); + sourceAndTargetList.add(sourceRefMap.get(childNode.get(EDITOR_SHAPE_ID).asText())); + sourceAndTargetList.add(shapeMap.get(targetRefId)); + sourceAndTargetMap.put(childEdgeId, sourceAndTargetList); + } + + edgeMap.put(childEdgeId, childNode); + } + } + } + } + + private void readEdgeDI(Map edgeMap, Map> sourceAndTargetMap, BpmnModel bpmnModel) { + for (String edgeId : edgeMap.keySet()) { + JsonNode edgeNode = edgeMap.get(edgeId); + List sourceAndTargetList = sourceAndTargetMap.get(edgeId); + + JsonNode sourceRefNode = null; + JsonNode targetRefNode = null; + + if ((sourceAndTargetList != null) && (sourceAndTargetList.size() > 1)) { + sourceRefNode = sourceAndTargetList.get(0); + targetRefNode = sourceAndTargetList.get(1); + } + + if (sourceRefNode == null) { + LOGGER.info("Skipping edge {} because source ref is null", edgeId); + + continue; + } + + if (targetRefNode == null) { + LOGGER.info("Skipping edge {} because target ref is null", edgeId); + + continue; + } + + JsonNode dockersNode = edgeNode.get(EDITOR_DOCKERS); + double sourceDockersX = dockersNode.get(0).get(EDITOR_BOUNDS_X).asDouble(); + double sourceDockersY = dockersNode.get(0).get(EDITOR_BOUNDS_Y).asDouble(); + + GraphicInfo sourceInfo = bpmnModel.getGraphicInfo(BpmnJsonConverterUtil.getElementId(sourceRefNode)); + GraphicInfo targetInfo = bpmnModel.getGraphicInfo(BpmnJsonConverterUtil.getElementId(targetRefNode)); + + double sourceRefLineX = sourceInfo.getX() + sourceDockersX; + double sourceRefLineY = sourceInfo.getY() + sourceDockersY; + + double nextPointInLineX; + double nextPointInLineY; + + nextPointInLineX = dockersNode.get(1).get(EDITOR_BOUNDS_X).asDouble(); + nextPointInLineY = dockersNode.get(1).get(EDITOR_BOUNDS_Y).asDouble(); + + if (dockersNode.size() == 2) { + nextPointInLineX += targetInfo.getX(); + nextPointInLineY += targetInfo.getY(); + } + + Line2D firstLine = new Line2D(sourceRefLineX, sourceRefLineY, nextPointInLineX, nextPointInLineY); + + String sourceRefStencilId = BpmnJsonConverterUtil.getStencilId(sourceRefNode); + String targetRefStencilId = BpmnJsonConverterUtil.getStencilId(targetRefNode); + + List graphicInfoList = new ArrayList(); + + AbstractContinuousCurve2D source2D = null; + + if (DI_CIRCLES.contains(sourceRefStencilId)) { + source2D = new Circle2D(sourceInfo.getX() + sourceDockersX, sourceInfo.getY() + sourceDockersY, sourceDockersX); + } else if (DI_RECTANGLES.contains(sourceRefStencilId)) { + source2D = createRectangle(sourceInfo); + } else if (DI_GATEWAY.contains(sourceRefStencilId)) { + source2D = createGateway(sourceInfo); + } + + if (source2D != null) { + Collection intersections = source2D.intersections(firstLine); + + if ((intersections != null) && (intersections.size() > 0)) { + Point2D intersection = intersections.iterator().next(); + graphicInfoList.add(createGraphicInfo(intersection.x(), intersection.y())); + } else { + graphicInfoList.add(createGraphicInfo(sourceRefLineX, sourceRefLineY)); + } + } + + Line2D lastLine = null; + + if (dockersNode.size() > 2) { + for (int i = 1; i < (dockersNode.size() - 1); i++) { + double x = dockersNode.get(i).get(EDITOR_BOUNDS_X).asDouble(); + double y = dockersNode.get(i).get(EDITOR_BOUNDS_Y).asDouble(); + graphicInfoList.add(createGraphicInfo(x, y)); + } + + double startLastLineX = dockersNode.get(dockersNode.size() - 2).get(EDITOR_BOUNDS_X).asDouble(); + double startLastLineY = dockersNode.get(dockersNode.size() - 2).get(EDITOR_BOUNDS_Y).asDouble(); + + double endLastLineX = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_X).asDouble(); + double endLastLineY = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_Y).asDouble(); + + endLastLineX += targetInfo.getX(); + endLastLineY += targetInfo.getY(); + + lastLine = new Line2D(startLastLineX, startLastLineY, endLastLineX, endLastLineY); + } else { + lastLine = firstLine; + } + + AbstractContinuousCurve2D target2D = null; + + if (DI_RECTANGLES.contains(targetRefStencilId)) { + target2D = createRectangle(targetInfo); + } else if (DI_CIRCLES.contains(targetRefStencilId)) { + double targetDockersX = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_X).asDouble(); + double targetDockersY = dockersNode.get(dockersNode.size() - 1).get(EDITOR_BOUNDS_Y).asDouble(); + + target2D = new Circle2D(targetInfo.getX() + targetDockersX, targetInfo.getY() + targetDockersY, targetDockersX); + } else if (DI_GATEWAY.contains(targetRefStencilId)) { + target2D = createGateway(targetInfo); + } + + if (target2D != null) { + Collection intersections = target2D.intersections(lastLine); + + if ((intersections != null) && (intersections.size() > 0)) { + Point2D intersection = intersections.iterator().next(); + graphicInfoList.add(createGraphicInfo(intersection.x(), intersection.y())); + } else { + graphicInfoList.add(createGraphicInfo(lastLine.getPoint2().x(), lastLine.getPoint2().y())); + } + } + + bpmnModel.addFlowGraphicInfoList(edgeId, graphicInfoList); + + // if sequence has a name, just add a label graphic info + if (!"".equals(edgeNode.get("properties").get("name"))) { + bpmnModel.addLabelGraphicInfo(edgeId, createGraphicInfo(graphicInfoList.get(0).getX(), graphicInfoList.get(0).getY())); + } + } + } + + private Polyline2D createRectangle(GraphicInfo graphicInfo) { + Polyline2D rectangle = new Polyline2D(new Point2D(graphicInfo.getX(), graphicInfo.getY()), new Point2D(graphicInfo.getX() + + graphicInfo.getWidth(), graphicInfo.getY()), new Point2D(graphicInfo.getX() + graphicInfo.getWidth(), graphicInfo.getY() + + graphicInfo.getHeight()), new Point2D(graphicInfo.getX(), graphicInfo.getY() + graphicInfo.getHeight()), new Point2D( + graphicInfo.getX(), graphicInfo.getY())); + + return rectangle; + } + + private Polyline2D createGateway(GraphicInfo graphicInfo) { + double middleX = graphicInfo.getX() + (graphicInfo.getWidth() / 2); + double middleY = graphicInfo.getY() + (graphicInfo.getHeight() / 2); + + Polyline2D gatewayRectangle = new Polyline2D(new Point2D(graphicInfo.getX(), middleY), new Point2D(middleX, graphicInfo.getY()), new Point2D( + graphicInfo.getX() + graphicInfo.getWidth(), middleY), new Point2D(middleX, graphicInfo.getY() + graphicInfo.getHeight()), + new Point2D(graphicInfo.getX(), middleY)); + + return gatewayRectangle; + } + + private GraphicInfo createGraphicInfo(double x, double y) { + GraphicInfo graphicInfo = new GraphicInfo(); + graphicInfo.setX(x); + graphicInfo.setY(y); + + return graphicInfo; + } + + class FlowWithContainer { + protected SequenceFlow sequenceFlow; + protected FlowElementsContainer flowContainer; + + public FlowWithContainer(SequenceFlow sequenceFlow, FlowElementsContainer flowContainer) { + this.sequenceFlow = sequenceFlow; + this.flowContainer = flowContainer; + } + + public SequenceFlow getSequenceFlow() { + return sequenceFlow; + } + + public void setSequenceFlow(SequenceFlow sequenceFlow) { + this.sequenceFlow = sequenceFlow; + } + + public FlowElementsContainer getFlowContainer() { + return flowContainer; + } + + public void setFlowContainer(FlowElementsContainer flowContainer) { + this.flowContainer = flowContainer; + } + } +} \ No newline at end of file diff --git "a/JeeSpringCloud/jeespring-framework/src/main/resources/Dubbo\350\257\264\346\230\216.txt" "b/JeeSpringCloud/jeespring-framework/src/main/resources/Dubbo\350\257\264\346\230\216.txt" new file mode 100644 index 0000000..bc25133 --- /dev/null +++ "b/JeeSpringCloud/jeespring-framework/src/main/resources/Dubbo\350\257\264\346\230\216.txt" @@ -0,0 +1,12 @@ +1. +JeeSpringDubboProviderĿڵ +provider˷ +ע:@com.alibaba.dubbo.config.annotation.Service(interfaceClass = IXXXXService.class,version = "1.0.0", timeout = 60000) +JeeSpringCloudĿڵ +consumer˿Ʋ +ע:@Reference(version = "1.0.0") +2.application.yml(˺͵ö˵òһ) +3.zookeeper +4.dubbo provider +5.dubbo consumer +6.ʹserverģԡ \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/bootstrap.yml b/JeeSpringCloud/jeespring-framework/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..67a9c78 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/bootstrap.yml @@ -0,0 +1,14 @@ +spring: + application: + name: jeespring-spring-boot + http: + encoding: { charset: UTF-8, enable: true, force: true } +#产品信息设置 +productName: 智能服务云平台 +#产品版本 +version: jeespring-2.0 +#静态文件后缀 +web: + staticFile: .css,.js,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.htm,.html,.crx,.xpi,.exe,.ipa,.apk +#演示模式: 不能操作和保存的模块: sys: area/office/user/role/menu/dict +demoMode: false \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/logback-spring.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..c0c52e6 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/logback-spring.xml @@ -0,0 +1,81 @@ + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} %5level --- [%thread] %logger{36} : %msg%n + UTF-8 + + + + DEBUG + + + + + /data/jeespring/logs/sys.log + + + /data/jeespring/logs/sys-%d{yyyyMMdd}.log + + 30 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} %5level --- [%thread] %logger{36} : %msg%n + UTF-8 + + + INFO + + + + + /data/jeespring/logs/jeespring-info.log + + + /data/jeespring/logs/jy-info-%d{yyyyMMdd}.log + + 30 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} %5level --- [%thread] %logger{36} : %msg%n + UTF-8 + + + INFO + ACCEPT + DENY + + + + + /data/jeespring/logs/jeespring-severe.log + + + /data/jeespring/logs/jeespring-severe-%d{yyyyMMdd}.log + + 30 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} %5level --- [%thread] %logger{36} : %msg%n + UTF-8 + + + + WARN + + + + + + + + + + + + + diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenDataBaseDictDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenDataBaseDictDao.xml new file mode 100644 index 0000000..9afc7ec --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenDataBaseDictDao.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenSchemeDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenSchemeDao.xml new file mode 100644 index 0000000..19af643 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenSchemeDao.xml @@ -0,0 +1,121 @@ + + + + + + a.*, + a.gen_table_id AS "genTable.id" + + + + + + + + + + + + + + INSERT INTO gen_scheme( + id, + name, + category, + package_name, + module_name, + sub_module_name, + function_name, + function_name_simple, + function_author, + gen_table_id, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag + ) VALUES ( + #{id}, + #{name}, + #{category}, + #{packageName}, + #{moduleName}, + #{subModuleName}, + #{functionName}, + #{functionNameSimple}, + #{functionAuthor}, + #{genTable.id}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE gen_scheme SET + name = #{name}, + category = #{category}, + package_name = #{packageName}, + module_name = #{moduleName}, + sub_module_name = #{subModuleName}, + function_name = #{functionName}, + function_name_simple = #{functionNameSimple}, + function_author = #{functionAuthor}, + gen_table_id = #{genTable.id}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks} + WHERE id = #{id} + + + + DELETE FROM gen_scheme + WHERE id = #{id} + + + + UPDATE gen_scheme SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTableColumnDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTableColumnDao.xml new file mode 100644 index 0000000..c9ea8fe --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTableColumnDao.xml @@ -0,0 +1,151 @@ + + + + + + a.*, + b.id AS "genTable.id", + b.name AS "genTable.name", + b.comments AS "genTable.comments", + b.class_name AS "genTable.className", + b.parent_table AS "genTable.parentTable", + b.parent_table_fk AS "genTable.parentTableFk" + + + + JOIN gen_table b ON b.id = a.gen_table_id + + + + + + + + + + INSERT INTO gen_table_column( + id, + gen_table_id, + name, + comments, + jdbc_type, + java_type, + java_field, + is_pk, + is_null, + is_insert, + is_edit, + is_list, + is_query, + query_type, + show_type, + dict_type, + sort, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag + ) VALUES ( + #{id}, + #{genTable.id}, + #{name}, + #{comments}, + #{jdbcType}, + #{javaType}, + #{javaField}, + #{isPk}, + #{isNull}, + #{isInsert}, + #{isEdit}, + #{isList}, + #{isQuery}, + #{queryType}, + #{showType}, + #{dictType}, + #{sort}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE gen_table_column SET + comments = #{comments}, + jdbc_type = #{jdbcType}, + java_type = #{javaType}, + java_field = #{javaField}, + is_pk = #{isPk}, + is_null = #{isNull}, + is_insert = #{isInsert}, + is_edit = #{isEdit}, + is_list = #{isList}, + is_query = #{isQuery}, + query_type = #{queryType}, + show_type = #{showType}, + dict_type = #{dictType}, + sort = #{sort}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + del_flag = #{delFlag} + WHERE id = #{id} + + + + DELETE FROM gen_table_column + WHERE id = #{id} + + + + UPDATE gen_table_column SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + DELETE FROM gen_table_column + WHERE gen_table_id = #{id} + + + + UPDATE gen_table_column SET + del_flag = '1' + WHERE gen_table_id = #{id} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTableDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTableDao.xml new file mode 100644 index 0000000..a47ecb3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTableDao.xml @@ -0,0 +1,142 @@ + + + + + + a.* + + + + + + + + + + + + + INSERT INTO gen_table( + id, + name, + pk, + comments, + table_type, + class_name, + parent_table, + parent_table_fk, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag, + issync + ) VALUES ( + #{id}, + #{name}, + #{pk}, + #{comments}, + #{tableType}, + #{className}, + #{parentTable}, + #{parentTableFk}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag}, + #{isSync} + ) + + + + UPDATE gen_table SET + pk= #{pk}, + comments = #{comments}, + table_type = #{tableType}, + class_name = #{className}, + parent_table = #{parentTable}, + parent_table_fk = #{parentTableFk}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + issync = #{isSync} + WHERE id = #{id} + + + + DELETE FROM gen_table + WHERE id = #{id} + + + + UPDATE gen_table SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + ${sql} + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTemplateDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTemplateDao.xml new file mode 100644 index 0000000..2ad84f6 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/gen/GenTemplateDao.xml @@ -0,0 +1,105 @@ + + + + + + a.* + + + + + + + + + + + + + + INSERT INTO gen_template( + id, + name, + category, + file_path, + file_name, + content, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag + ) VALUES ( + #{id}, + #{name}, + #{category}, + #{filePath}, + #{fileName}, + #{content}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE gen_template SET + name = #{name}, + category = #{category}, + file_path = #{filePath}, + file_name = #{fileName}, + content = #{content}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks} + WHERE id = #{id} + + + + DELETE FROM gen_template + WHERE id = #{id} + + + + UPDATE gen_template SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/ChatHistoryDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/ChatHistoryDao.xml new file mode 100644 index 0000000..60e9ef1 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/ChatHistoryDao.xml @@ -0,0 +1,133 @@ + + + + + + a.id AS "id", + a.userid1 AS "userid1", + a.userid2 AS "userid2", + a.msg AS "msg", + a.status AS "status", + a.create_date AS "createDate" + + + + + + + + + + + + + + + INSERT INTO iim_chat_history( + id, + userid1, + userid2, + msg, + status, + create_date + ) VALUES ( + #{id}, + #{userid1}, + #{userid2}, + #{msg}, + #{status}, + #{createDate} + ) + + + + UPDATE iim_chat_history SET + userid1 = #{userid1}, + userid2 = #{userid2}, + msg = #{msg}, + status = #{status}, + create_date = #{createDate} + WHERE id = #{id} + + + + DELETE FROM iim_chat_history + WHERE id = #{id} + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailBoxDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailBoxDao.xml new file mode 100644 index 0000000..f0393ce --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailBoxDao.xml @@ -0,0 +1,151 @@ + + + + + + a.id AS "id", + a.readstatus AS "readstatus", + a.senderid AS "sender.id", + a.receiverid AS "receiver.id", + a.sendtime AS "sendtime", + a.mailid AS "mail.id", + receiver.name AS "receiver.name", + sender.name AS "sender.name", + sender.photo AS "sender.photo", + mail.title AS "mail.title", + mail.overview AS "mail.overview", + mail.content AS "mail.content" + + + + LEFT JOIN iim_mail mail ON mail.id = a.mailid + LEFT JOIN sys_user receiver ON receiver.id = a.receiverid + LEFT JOIN sys_user sender ON sender.id = a.senderid + + + + + + + + + + + + INSERT INTO iim_mail_box( + id, + readstatus, + senderid, + receiverid, + sendtime, + mailid + ) VALUES ( + #{id}, + #{readstatus}, + #{sender.id}, + #{receiver.id}, + #{sendtime}, + #{mail.id} + ) + + + + UPDATE iim_mail_box SET + readstatus = #{readstatus}, + senderid = #{sender.id}, + receiverid = #{receiver.id}, + sendtime = #{sendtime}, + mailid = #{mail.id} + WHERE id = #{id} + + + + DELETE FROM iim_mail_box + + + WHERE id = #{id} + + + WHERE mailid = #{mail.id} + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailComposeDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailComposeDao.xml new file mode 100644 index 0000000..8826781 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailComposeDao.xml @@ -0,0 +1,150 @@ + + + + + + a.id AS "id", + a.status AS "status", + a.readstatus AS "readstatus", + a.senderid AS "sender.id", + a.receiverid AS "receiver.id", + a.sendtime AS "sendtime", + a.mailid AS "mail.id", + receiver.name AS "receiver.name", + mail.title AS "mail.title", + mail.overview AS "mail.overview", + mail.content AS "mail.content" + + + + LEFT JOIN iim_mail mail ON mail.id = a.mailid + LEFT JOIN sys_user receiver ON receiver.id = a.receiverid + + + + + + + + + + + + INSERT INTO iim_mail_compose( + id, + status, + readstatus, + senderid, + receiverid, + sendtime, + mailid + ) VALUES ( + #{id}, + #{status}, + #{readstatus}, + #{sender.id}, + #{receiver.id}, + #{sendtime}, + #{mail.id} + ) + + + + UPDATE iim_mail_compose SET + status = #{status}, + readstatus = #{readstatus}, + senderid = #{sender.id}, + receiverid = #{receiver.id}, + sendtime = #{sendtime}, + mailid = #{mail.id} + WHERE id = #{id} + + + + DELETE FROM iim_mail_compose + + + WHERE id = #{id} + + + WHERE mailid = #{mail.id} + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailDao.xml new file mode 100644 index 0000000..039f760 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MailDao.xml @@ -0,0 +1,95 @@ + + + + + + a.id AS "id", + a.title AS "title", + a.overview AS "overview", + a.content AS "content" + + + + + + + + + + + + + INSERT INTO iim_mail( + id, + title, + overview, + content + ) VALUES ( + #{id}, + #{title}, + #{overview}, + #{content} + ) + + + + UPDATE iim_mail SET + title = #{title}, + overview = #{overview}, + content = #{content} + WHERE id = #{id} + + + + DELETE FROM iim_mail + WHERE id = #{id} + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MyCalendarDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MyCalendarDao.xml new file mode 100644 index 0000000..2b321a0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/iim/MyCalendarDao.xml @@ -0,0 +1,115 @@ + + + + + + a.id AS "id", + a.title AS "title", + a.starttime AS "start", + a.endtime AS "end", + a.allday AS "adllDay", + a.color AS "color", + a.userid AS "user.id", + user.name AS "user.name" + + + + LEFT JOIN sys_user user ON user.id = a.userid + + + + + + + + + + INSERT INTO calendar( + id, + title, + starttime, + endtime, + allday, + color, + userid + ) VALUES ( + #{id}, + #{title}, + #{start}, + #{end}, + #{adllDay}, + #{color}, + #{user.id} + ) + + + + UPDATE calendar SET + title = #{title}, + starttime = #{start}, + endtime = #{end}, + allday = #{adllDay}, + color = #{color}, + userid = #{user.id} + WHERE id = #{id} + + + + + + DELETE FROM calendar + WHERE id = #{id} + + + + + UPDATE calendar SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/act/ActDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/act/ActDao.xml new file mode 100644 index 0000000..c1ac4f9 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/act/ActDao.xml @@ -0,0 +1,11 @@ + + + + + + UPDATE ${businessTable} SET + proc_ins_id = #{procInsId} + WHERE id = #{businessId} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/echarts/ChinaWeatherDataBeanDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/echarts/ChinaWeatherDataBeanDao.xml new file mode 100644 index 0000000..2ec7520 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/echarts/ChinaWeatherDataBeanDao.xml @@ -0,0 +1,147 @@ + + + + + + a.id AS "id", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remarks AS "remarks", + a.del_flag AS "delFlag", + a.datestr AS "datestr", + a.beijing_maxtemp AS "beijingMaxTemp", + a.beijing_mintemp AS "beijingMinTemp", + a.changchun_maxtemp AS "changchunMaxTemp", + a.changchun_mintemp AS "changchunMinTemp", + a.shenyang_maxtemp AS "shenyangMaxTemp", + a.shenyang_mintemp AS "shenyangMinTemp", + a.haerbin_maxtemp AS "haerbinMaxTemp", + a.haerbin_mintemp AS "haerbinMinTemp" + + + + + + + + + + + + + + INSERT INTO test_line_weather_main_city( + id, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag, + datestr, + beijing_maxtemp, + beijing_mintemp, + changchun_maxtemp, + changchun_mintemp, + shenyang_maxtemp, + shenyang_mintemp, + haerbin_maxtemp, + haerbin_mintemp + ) VALUES ( + #{id}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag}, + #{datestr}, + #{beijingMaxTemp}, + #{beijingMinTemp}, + #{changchunMaxTemp}, + #{changchunMinTemp}, + #{shenyangMaxTemp}, + #{shenyangMinTemp}, + #{haerbinMaxTemp}, + #{haerbinMinTemp} + ) + + + + UPDATE test_line_weather_main_city SET + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + datestr = #{datestr}, + beijing_maxtemp = #{beijingMaxTemp}, + beijing_mintemp = #{beijingMinTemp}, + changchun_maxtemp = #{changchunMaxTemp}, + changchun_mintemp = #{changchunMinTemp}, + shenyang_maxtemp = #{shenyangMaxTemp}, + shenyang_mintemp = #{shenyangMinTemp}, + haerbin_maxtemp = #{haerbinMaxTemp}, + haerbin_mintemp = #{haerbinMinTemp} + WHERE id = #{id} + + + + + + DELETE FROM test_line_weather_main_city + WHERE id = #{id} + + + + + UPDATE test_line_weather_main_city SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/echarts/PieClassDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/echarts/PieClassDao.xml new file mode 100644 index 0000000..ca9d79f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/echarts/PieClassDao.xml @@ -0,0 +1,125 @@ + + + + + + a.id AS "id", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remarks AS "remarks", + a.del_flag AS "delFlag", + a.class_name AS "className", + a.num AS "num" + + + + + + + + + + + + + + INSERT INTO test_pie_class( + id, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag, + class_name, + num + ) VALUES ( + #{id}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag}, + #{className}, + #{num} + ) + + + + UPDATE test_pie_class SET + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + class_name = #{className}, + num = #{num} + WHERE id = #{id} + + + + + + DELETE FROM test_pie_class + WHERE id = #{id} + + + + + UPDATE test_pie_class SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/job/SysJobDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/job/SysJobDao.xml new file mode 100644 index 0000000..762dfc0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/job/SysJobDao.xml @@ -0,0 +1,299 @@ + + + + + + a.job_id AS "id", + a.job_name AS "jobName", + a.job_group AS "jobGroup", + a.method_name AS "methodName", + a.method_params AS "methodParams", + a.cron_expression AS "cronExpression", + a.misfire_policy AS "misfirePolicy", + a.status AS "status", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remark AS "remark", + a.del_flag AS "delFlag" + + + + a.job_id AS "id", + a.job_name AS "jobName", + a.job_group AS "jobGroup", + a.method_name AS "methodName", + a.method_params AS "methodParams", + a.cron_expression AS "cronExpression", + a.misfire_policy AS "misfirePolicy", + a.status AS "status", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remark AS "remark", + a.del_flag AS "delFlag" + + + + + + + + + + + + + + select LAST_INSERT_ID() + + INSERT INTO sys_job( + job_name, + job_group, + method_name, + method_params, + cron_expression, + misfire_policy, + status, + create_by, + create_date, + update_by, + update_date, + remark, + del_flag + ) VALUES ( + #{jobName}, + #{jobGroup}, + #{methodName}, + #{methodParams}, + #{cronExpression}, + #{misfirePolicy}, + #{status}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remark}, + #{delFlag} + ) + + + + UPDATE sys_job SET + job_id = #{id}, + job_name = #{jobName}, + job_group = #{jobGroup}, + method_name = #{methodName}, + method_params = #{methodParams}, + cron_expression = #{cronExpression}, + misfire_policy = #{misfirePolicy}, + status = #{status}, + create_date = #{createDate}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remark = #{remark}, + del_flag = #{delFlag} + WHERE job_id = #{id} + + + + + + DELETE FROM sys_job + WHERE job_id = #{id} + + + + + UPDATE sys_job SET + del_flag = #{DEL_FLAG_DELETE} + WHERE job_id = #{id} + + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/job/SysJobLogDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/job/SysJobLogDao.xml new file mode 100644 index 0000000..70ab0cc --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/job/SysJobLogDao.xml @@ -0,0 +1,283 @@ + + + + + + a.job_log_id AS "id", + a.job_name AS "jobName", + a.job_group AS "jobGroup", + a.method_name AS "methodName", + a.method_params AS "methodParams", + a.job_message AS "jobMessage", + a.status AS "status", + a.exception_info AS "exceptionInfo", + a.create_date AS "createDate", + a.create_by AS "createBy", + a.update_date AS "updateDate", + a.update_by AS "updateBy", + a.del_flag AS "delFlag" + + + + a.job_log_id AS "id", + a.job_name AS "jobName", + a.job_group AS "jobGroup", + a.method_name AS "methodName", + a.method_params AS "methodParams", + a.job_message AS "jobMessage", + a.status AS "status", + substr(a.exception_info,1,30) AS "exceptionInfo", + a.create_date AS "createDate", + a.create_by AS "createBy", + a.update_date AS "updateDate", + a.update_by AS "updateBy", + a.del_flag AS "delFlag" + + + + + + + + + + + + + + select LAST_INSERT_ID() + + INSERT INTO sys_job_log( + job_name, + job_group, + method_name, + method_params, + job_message, + status, + exception_info, + create_date, + create_by, + update_date, + update_by, + del_flag + ) VALUES ( + #{jobName}, + #{jobGroup}, + #{methodName}, + #{methodParams}, + #{jobMessage}, + #{status}, + #{exceptionInfo}, + #{createDate}, + #{createBy}, + #{updateDate}, + #{updateBy}, + #{delFlag} + ) + + + + UPDATE sys_job_log SET + job_log_id = #{id}, + job_name = #{jobName}, + job_group = #{jobGroup}, + method_name = #{methodName}, + method_params = #{methodParams}, + job_message = #{jobMessage}, + status = #{status}, + exception_info = #{exceptionInfo}, + create_date = #{createDate}, + create_by = #{createBy}, + update_date = #{updateDate}, + update_by = #{updateBy}, + del_flag = #{delFlag} + WHERE job_log_id = #{id} + + + + + + DELETE FROM sys_job_log + WHERE job_log_id = #{id} + + + + + UPDATE sys_job_log SET + del_flag = #{DEL_FLAG_DELETE} + WHERE job_log_id = #{id} + + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/monitor/MonitorDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/monitor/MonitorDao.xml new file mode 100644 index 0000000..cd8905c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/monitor/MonitorDao.xml @@ -0,0 +1,102 @@ + + + + + + a.id AS "id", + a.cpu AS "cpu", + a.jvm AS "jvm", + a.ram AS "ram", + a.toemail AS "toEmail" + + + + + + + + + + + + + INSERT INTO monitor( + id, + cpu, + jvm, + ram, + toemail + ) VALUES ( + #{id}, + #{cpu}, + #{jvm}, + #{ram}, + #{toEmail} + ) + + + + UPDATE monitor SET + cpu = #{cpu}, + jvm = #{jvm}, + ram = #{ram}, + toemail = #{toEmail} + WHERE id = #{id} + + + + + + DELETE FROM monitor + WHERE id = #{id} + + + + + UPDATE monitor SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/mvvmoa/FormLeavemDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/mvvmoa/FormLeavemDao.xml new file mode 100644 index 0000000..0f1355f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/mvvmoa/FormLeavemDao.xml @@ -0,0 +1,138 @@ + + + + + + a.id AS "id", + a.user_id AS "user.id", + a.office_id AS "office.id", + a.area_id AS "area.id", + a.begin_date AS "beginDate", + a.end_date AS "endDate", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remarks AS "remarks", + a.del_flag AS "delFlag", + user.name AS "user.name", + office.name AS "office.name", + area.name AS "area.name" + + + + LEFT JOIN sys_user user ON user.id = a.user_id + LEFT JOIN sys_office office ON office.id = a.office_id + LEFT JOIN sys_area area ON area.id = a.area_id + + + + + + + + + + INSERT INTO form_leave( + id, + user_id, + office_id, + area_id, + begin_date, + end_date, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag + ) VALUES ( + #{id}, + #{user.id}, + #{office.id}, + #{area.id}, + #{beginDate}, + #{endDate}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE form_leave SET + user_id = #{user.id}, + office_id = #{office.id}, + area_id = #{area.id}, + begin_date = #{beginDate}, + end_date = #{endDate}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks} + WHERE id = #{id} + + + + + + DELETE FROM form_leave + WHERE id = #{id} + + + + + UPDATE form_leave SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysConfigTreeDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysConfigTreeDao.xml new file mode 100644 index 0000000..e369da2 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysConfigTreeDao.xml @@ -0,0 +1,194 @@ + + + + + + a.id AS "id", + a.type AS "type", + a.value AS "value", + a.label AS "label", + a.label AS "name", + a.description AS "description", + a.sort AS "sort", + a.parent_id AS "parent.id", + a.parent_ids AS "parentIds", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remarks AS "remarks", + a.del_flag AS "delFlag", + a.picture AS "picture" + + + + + + + + + + + + + + + INSERT INTO sys_config( + id, + type, + value, + label, + description, + sort, + parent_id, + parent_ids, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag, + picture + ) VALUES ( + #{id}, + #{type}, + #{value}, + #{label}, + #{description}, + #{sort}, + #{parent.id}, + #{parentIds}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag}, + #{picture} + ) + + + + UPDATE sys_config SET + type = #{type}, + value = #{value}, + label = #{label}, + description = #{description}, + sort = #{sort}, + parent_id = #{parent.id}, + parent_ids = #{parentIds}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + picture = #{picture} + WHERE id = #{id} + + + + UPDATE sys_config SET + parent_id = #{parent.id}, + parent_ids = #{parentIds} + WHERE id = #{id} + + + + + DELETE FROM sys_config + WHERE id = #{id} OR parent_ids LIKE + '%'||#{id}||'%' + '%'+#{id}+'%' + concat('%',#{id},'%') + + + + + UPDATE sys_config SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} OR parent_ids LIKE + '%'||#{id}||'%' + '%'+#{id}+'%' + concat('%',#{id},'%') + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysDictTreeDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysDictTreeDao.xml new file mode 100644 index 0000000..f7f5e33 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysDictTreeDao.xml @@ -0,0 +1,194 @@ + + + + + + a.id AS "id", + a.value AS "value", + a.label AS "label", + a.label AS "name", + a.type AS "type", + a.description AS "description", + a.sort AS "sort", + a.parent_id AS "parent.id", + a.parent_ids AS "parentIds", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remarks AS "remarks", + a.del_flag AS "delFlag", + a.picture AS "picture" + + + + + + + + + + + + + + + INSERT INTO sys_dict( + id, + value, + label, + type, + description, + sort, + parent_id, + parent_ids, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag, + picture + ) VALUES ( + #{id}, + #{value}, + #{label}, + #{type}, + #{description}, + #{sort}, + #{parent.id}, + #{parentIds}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag}, + #{picture} + ) + + + + UPDATE sys_dict SET + value = #{value}, + label = #{label}, + type = #{type}, + description = #{description}, + sort = #{sort}, + parent_id = #{parent.id}, + parent_ids = #{parentIds}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + picture = #{picture} + WHERE id = #{id} + + + + UPDATE sys_dict SET + parent_id = #{parent.id}, + parent_ids = #{parentIds} + WHERE id = #{id} + + + + + DELETE FROM sys_dict + WHERE id = #{id} OR parent_ids LIKE + '%'||#{id}||'%' + '%'+#{id}+'%' + concat('%',#{id},'%') + + + + + UPDATE sys_dict SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} OR parent_ids LIKE + '%'||#{id}||'%' + '%'+#{id}+'%' + concat('%',#{id},'%') + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysServerDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysServerDao.xml new file mode 100644 index 0000000..d060490 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysServerDao.xml @@ -0,0 +1,319 @@ + + + + + + a.id AS "id", + a.server_number AS "serverNumber", + a.server_address AS "serverAddress", + a.name AS "name", + a.label AS "label", + a.picture AS "picture", + a.type AS "type", + a.sort AS "sort", + a.description AS "description", + a.remarks AS "remarks", + a.html AS "html", + a.status AS "status", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.del_flag AS "delFlag" + + + + a.id AS "id", + a.server_number AS "serverNumber", + a.server_address AS "serverAddress", + a.name AS "name", + a.label AS "label", + a.picture AS "picture", + a.type AS "type", + a.sort AS "sort", + a.description AS "description", + a.remarks AS "remarks", + substr(a.html,1,30) AS "html", + a.status AS "status", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.del_flag AS "delFlag" + + + + + + + + + + + + + INSERT INTO sys_server( + id, + server_number, + server_address, + name, + label, + picture, + type, + sort, + description, + remarks, + html, + status, + create_by, + create_date, + update_by, + update_date, + del_flag + ) VALUES ( + #{id}, + #{serverNumber}, + #{serverAddress}, + #{name}, + #{label}, + #{picture}, + #{type}, + #{sort}, + #{description}, + #{remarks}, + #{html}, + #{status}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{delFlag} + ) + + + + UPDATE sys_server SET + server_number = #{serverNumber}, + server_address = #{serverAddress}, + name = #{name}, + label = #{label}, + picture = #{picture}, + type = #{type}, + sort = #{sort}, + description = #{description}, + remarks = #{remarks}, + html = #{html}, + status = #{status}, + update_by = #{updateBy.id}, + update_date = #{updateDate} + WHERE id = #{id} + + + + + + DELETE FROM sys_server + WHERE id = #{id} + + + + + UPDATE sys_server SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysUserOnlineDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysUserOnlineDao.xml new file mode 100644 index 0000000..d62b9cc --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/sys/SysUserOnlineDao.xml @@ -0,0 +1,309 @@ + + + + + + a.sessionid AS "id", + a.login_name AS "loginName", + a.dept_name AS "deptName", + a.ipaddr AS "ipaddr", + a.login_location AS "loginLocation", + a.browser AS "browser", + a.os AS "os", + a.status AS "status", + a.start_timestsamp AS "startTimestsamp", + a.last_access_time AS "lastAccessTime", + a.expire_time AS "expireTime", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.del_flag AS "delFlag" + + + + a.sessionid AS "id", + a.login_name AS "loginName", + a.dept_name AS "deptName", + a.ipaddr AS "ipaddr", + a.login_location AS "loginLocation", + a.browser AS "browser", + a.os AS "os", + a.status AS "status", + a.start_timestsamp AS "startTimestsamp", + a.last_access_time AS "lastAccessTime", + a.expire_time AS "expireTime", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.del_flag AS "delFlag" + + + + + + + + + + + + + INSERT INTO sys_user_online( + sessionid, + login_name, + dept_name, + ipaddr, + login_location, + browser, + os, + status, + start_timestsamp, + last_access_time, + expire_time, + create_by, + create_date, + update_by, + update_date, + del_flag + ) VALUES ( + #{id}, + #{loginName}, + #{deptName}, + #{ipaddr}, + #{loginLocation}, + #{browser}, + #{os}, + #{status}, + #{startTimestsamp}, + #{lastAccessTime}, + #{expireTime}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{delFlag} + ) + + + + UPDATE sys_user_online SET + sessionid = #{id}, + login_name = #{loginName}, + dept_name = #{deptName}, + ipaddr = #{ipaddr}, + login_location = #{loginLocation}, + browser = #{browser}, + os = #{os}, + status = #{status}, + start_timestsamp = #{startTimestsamp}, + last_access_time = #{lastAccessTime}, + expire_time = #{expireTime}, + update_by = #{updateBy.id}, + update_date = #{updateDate} + WHERE sessionid = #{id} + + + + + + DELETE FROM sys_user_online + WHERE sessionid = #{id} + + + + + UPDATE sys_user_online SET + del_flag = #{DEL_FLAG_DELETE} + WHERE sessionid = #{id} + + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/usercenter/SysUserCenterDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/usercenter/SysUserCenterDao.xml new file mode 100644 index 0000000..d891fb5 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/modules/usercenter/SysUserCenterDao.xml @@ -0,0 +1,197 @@ + + + + + + a.id AS "id", + a.user_id AS "userId", + a.user_name AS "userName", + a.user_phone AS "userPhone", + a.lat AS "lat", + a.lng AS "lng", + a.city AS "city", + a.address AS "address", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.del_flag AS "delFlag", + a.ip AS "ip" + + + + a.id AS "id", + a.user_id AS "userId", + CONCAT(a.user_name,'(使用',count(*),'次)') AS "userName", + a.user_phone AS "userPhone", + a.lat AS "lat", + a.lng AS "lng", + a.city AS "city", + a.address AS "address", + a.create_by AS "createBy.id", + max(a.create_date) AS "createDate", + a.update_by AS "updateBy.id", + max(a.update_date) AS "updateDate", + a.del_flag AS "delFlag", + a.ip AS "ip" + + + + + + + + + + + + + INSERT INTO sys_user_center( + id, + user_id, + user_name, + user_phone, + lat, + lng, + city, + address, + create_by, + create_date, + update_by, + update_date, + del_flag, + ip + ) VALUES ( + #{id}, + #{userId}, + #{userName}, + #{userPhone}, + #{lat}, + #{lng}, + #{city}, + #{address}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{delFlag}, + #{ip} + ) + + + + UPDATE sys_user_center SET + user_id = #{userId}, + user_phone = #{userPhone}, + lat = #{lat}, + lng = #{lng}, + city = #{city}, + address = #{address}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + ip=#{ip} + WHERE id = #{id} + + + + + + DELETE FROM sys_user_center + WHERE id = #{id} + + + + + UPDATE sys_user_center SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/OaNotifyDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/OaNotifyDao.xml new file mode 100644 index 0000000..5b95b18 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/OaNotifyDao.xml @@ -0,0 +1,152 @@ + + + + + + a.ID AS "id", + a.TYPE AS "type", + a.TITLE AS "title", + a.CONTENT AS "content", + a.FILES AS "files", + a.STATUS AS "status", + a.CREATE_BY AS "createBy.id", + a.CREATE_DATE AS "createDate", + a.UPDATE_BY AS "updateBy.id", + a.UPDATE_DATE AS "updateDate", + a.REMARKS AS "remarks", + a.DEL_FLAG AS "delFlag", + b.read_num, + b.un_read_num + + + + + LEFT JOIN ( + SELECT r.oa_notify_id, + sum(case when r.read_flag = '1' then 1 else 0 end) read_num, + sum(case when r.read_flag != '1' then 1 else 0 end) un_read_num + FROM oa_notify_record r GROUP BY r.oa_notify_id + ) b ON b.oa_notify_id = a.id + + + + + + + + + + + + INSERT INTO oa_notify( + ID, + TYPE, + TITLE, + CONTENT, + FILES, + STATUS, + CREATE_BY, + CREATE_DATE, + UPDATE_BY, + UPDATE_DATE, + REMARKS, + DEL_FLAG + ) VALUES ( + #{id}, + #{type}, + #{title}, + #{content}, + #{files}, + #{status}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE oa_notify SET + TYPE = #{type}, + TITLE = #{title}, + CONTENT = #{content}, + FILES = #{files}, + STATUS = #{status}, + UPDATE_BY = #{updateBy.id}, + UPDATE_DATE = #{updateDate}, + REMARKS = #{remarks} + WHERE id = #{id} + + + + DELETE FROM oa_notify + WHERE id = #{id} + + + + UPDATE oa_notify SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/OaNotifyRecordDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/OaNotifyRecordDao.xml new file mode 100644 index 0000000..39dcba4 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/OaNotifyRecordDao.xml @@ -0,0 +1,103 @@ + + + + + + a.ID AS "id", + a.OA_NOTIFY_ID AS "oaNotify.id", + a.USER_ID AS "user.id", + a.READ_FLAG AS "readFlag", + a.READ_DATE AS "readDate", + u.name AS "user.name", + o.name AS "user.office.name" + + + + JOIN sys_user u ON u.id = a.user_id + JOIN sys_office o ON o.id = u.office_id + + + + + + + + + + INSERT INTO oa_notify_record( + ID, + OA_NOTIFY_ID, + USER_ID, + READ_FLAG, + READ_DATE + ) VALUES ( + #{id}, + #{oaNotify.id}, + #{user.id}, + #{readFlag}, + #{readDate} + ) + + + + INSERT INTO oa_notify_record( + ID, + OA_NOTIFY_ID, + USER_ID, + READ_FLAG, + READ_DATE + ) + + SELECT + #{e.id}, + #{e.oaNotify.id}, + #{e.user.id}, + #{e.readFlag}, + #{e.readDate} + FROM dual + + + + + UPDATE oa_notify_record SET + READ_FLAG = #{readFlag}, + READ_DATE = #{readDate} + WHERE OA_NOTIFY_ID = #{oaNotify.id} + AND USER_ID = #{user.id} + AND READ_FLAG != '1' + + + + DELETE FROM oa_notify_record + WHERE id = #{id} + + + + DELETE FROM oa_notify_record + WHERE oa_notify_id = #{oaNotifyId} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/TestAuditDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/TestAuditDao.xml new file mode 100644 index 0000000..3bb10d1 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/oa/TestAuditDao.xml @@ -0,0 +1,188 @@ + + + + + + a.id, + a.post, + a.age, + a.edu, + a.content, + a.olda, + a.oldb, + a.oldc, + a.newa, + a.newb, + a.newc, + a.add_num, + a.exe_date, + a.hr_text, + a.lead_text, + a.main_lead_text, + a.proc_ins_id, + u.id AS "user.id", + u.name AS "user.name", + o.id AS "office.id", + o.name AS "office.name", + a.create_by AS "createBy.id", + a.create_date, + a.update_by AS "updateBy.id", + a.update_date, + a.remarks, + a.del_flag + + + + JOIN sys_user u ON u.id=a.user_id + JOIN sys_office o ON o.id=a.office_id + + + + + + + + + + + + INSERT INTO oa_test_audit( + id, + user_id, + office_id, + post, + age, + edu, + content, + olda, + oldb, + oldc, + newa, + newb, + newc, + add_num, + exe_date, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag + ) VALUES ( + #{id}, + #{user.id}, + #{office.id}, + #{post}, + #{age}, + #{edu}, + #{content}, + #{olda}, + #{oldb}, + #{oldc}, + #{newa}, + #{newb}, + #{newc}, + #{addNum}, + #{exeDate}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE oa_test_audit SET + user_id = #{user.id}, + office_id = #{office.id}, + post = #{post}, + age = #{age}, + edu = #{edu}, + content = #{content}, + olda = #{olda}, + oldb = #{oldb}, + oldc = #{oldc}, + newa = #{newa}, + newb = #{newb}, + newc = #{newc}, + add_num = #{addNum}, + exe_date = #{exeDate}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks} + WHERE id = #{id} + + + + UPDATE oa_test_audit SET + proc_ins_id = #{procInsId}, + update_by = #{updateBy.id}, + update_date = #{updateDate} + WHERE id = #{id} + + + + UPDATE oa_test_audit SET + hr_text = #{hrText}, + update_by = #{updateBy.id}, + update_date = #{updateDate} + WHERE id = #{id} + + + + UPDATE oa_test_audit SET + lead_text = #{leadText}, + update_by = #{updateBy.id}, + update_date = #{updateDate} + WHERE id = #{id} + + + + UPDATE oa_test_audit SET + main_lead_text = #{mainLeadText}, + update_by = #{updateBy.id}, + update_date = #{updateDate} + WHERE id = #{id} + + + + UPDATE oa_test_audit SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/AreaDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/AreaDao.xml new file mode 100644 index 0000000..e8d3aa0 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/AreaDao.xml @@ -0,0 +1,133 @@ + + + + + + a.id, + a.parent_id AS "parent.id", + a.parent_ids, + a.code, + a.name, + a.sort, + a.type, + a.remarks, + a.create_by AS "createBy.id", + a.create_date, + a.update_by AS "updateBy.id", + a.update_date, + a.del_flag, + p.name AS "parent.name" + + + + LEFT JOIN sys_office p ON p.id = a.parent_id + + + + + + + + + + + + INSERT INTO sys_area( + id, + parent_id, + parent_ids, + code, + name, + sort, + type, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag + ) VALUES ( + #{id}, + #{parent.id}, + #{parentIds}, + #{code}, + #{name}, + #{sort}, + #{type}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE sys_area SET + parent_id = #{parent.id}, + parent_ids = #{parentIds}, + code = #{code}, + name = #{name}, + sort = #{sort}, + type = #{type}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks} + WHERE id = #{id} + + + + UPDATE sys_area SET + parent_id = #{parent.id}, + parent_ids = #{parentIds} + WHERE id = #{id} + + + + DELETE FROM sys_area + WHERE id = #{id} OR parent_ids LIKE + '%,'||#{id}||',%' + CONCAT('%,', #{id}, ',%') + + + + UPDATE sys_area SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} OR parent_ids LIKE + '%,'||#{id}||',%' + CONCAT('%,', #{id}, ',%') + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/DictDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/DictDao.xml new file mode 100644 index 0000000..ec0b98a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/DictDao.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + INSERT INTO sys_dict( + id, + value, + label, + type, + description, + sort, + picture, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag + ) VALUES ( + #{id}, + #{value}, + #{label}, + #{type}, + #{description}, + #{sort}, + #{picture}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE sys_dict SET + value = #{value}, + label = #{label}, + type = #{type}, + description = #{description}, + sort = #{sort}, + picture = #{picture}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks} + WHERE id = #{id} + + + + DELETE FROM sys_dict + WHERE id = #{id} + + + + UPDATE sys_dict SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/LogDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/LogDao.xml new file mode 100644 index 0000000..1b2a671 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/LogDao.xml @@ -0,0 +1,80 @@ + + + + + + + + + + DELETE FROM sys_log + WHERE id = #{id} + + + + DELETE FROM sys_log + + + + INSERT INTO sys_log( + id, + type, + title, + create_by, + create_date, + remote_addr, + user_agent, + request_uri, + method, + params, + exception + ) VALUES ( + #{id}, + #{type}, + #{title}, + #{createBy.id}, + #{createDate}, + #{remoteAddr}, + #{userAgent}, + #{requestUri}, + #{method}, + #{params}, + #{exception} + ) + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/MenuDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/MenuDao.xml new file mode 100644 index 0000000..7218577 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/MenuDao.xml @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + a.id, + a.parent_id AS "parent.id", + a.parent_ids, + a.name, + a.href, + a.target, + a.icon, + a.sort, + a.is_show as "isShow", + a.permission, + a.remarks, + a.create_by AS "createBy.id", + a.create_date, + a.update_by AS "updateBy.id", + a.update_date, + a.del_flag, + p.name AS "parent.name" + + + + LEFT JOIN sys_menu p ON p.id = a.parent_id + + + + + + + + + + + + + + + INSERT INTO sys_menu( + id, + parent_id, + parent_ids, + name, + href, + target, + icon, + sort, + is_show, + permission, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag + ) VALUES ( + #{id}, + #{parent.id}, + #{parentIds}, + #{name}, + #{href}, + #{target}, + #{icon}, + #{sort}, + #{isShow}, + #{permission}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag} + ) + + + + UPDATE sys_menu SET + parent_id = #{parent.id}, + parent_ids = #{parentIds}, + name = #{name}, + href = #{href}, + target = #{target}, + icon = #{icon}, + sort = #{sort}, + is_show = #{isShow}, + permission = #{permission}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks} + WHERE id = #{id} + + + + UPDATE sys_menu SET + parent_id = #{parent.id}, + parent_ids = #{parentIds} + WHERE id = #{id} + + + + UPDATE sys_menu SET + sort = #{sort} + WHERE id = #{id} + + + + DELETE FROM sys_menu + WHERE id = #{id} OR parent_ids LIKE + '%,'||#{id}||',%' + CONCAT('%,', #{id}, ',%') + + + + UPDATE sys_menu SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} OR parent_ids LIKE + '%,'||#{id}||',%' + CONCAT('%,', #{id}, ',%') + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/OfficeDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/OfficeDao.xml new file mode 100644 index 0000000..b75da5a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/OfficeDao.xml @@ -0,0 +1,190 @@ + + + + + + a.id, + a.parent_id AS "parent.id", + a.parent_ids, + a.area_id AS "area.id", + a.code, + a.name, + a.sort, + a.type, + a.grade, + a.address, + a.zip_code, + a.master, + a.phone, + a.fax, + a.email, + a.remarks, + a.create_by AS "createBy.id", + a.create_date, + a.update_by AS "updateBy.id", + a.update_date, + a.del_flag, + a.useable AS useable, + a.primary_person AS "primaryPerson.id", + a.deputy_person AS "deputyPerson.id", + p.name AS "parent.name", + ar.name AS "area.name", + ar.parent_ids AS "area.parentIds", + pp.name AS "primaryPerson.name", + dp.name AS "deputyPerson.name" + + + + LEFT JOIN sys_office p ON p.id = a.parent_id + LEFT JOIN sys_area ar ON ar.id = a.area_id + LEFT JOIN sys_user pp ON pp.id = a.primary_person + LEFT JOIN sys_user dp ON dp.id = a.deputy_person + + + + + + + + + + + + + INSERT INTO sys_office( + id, + parent_id, + parent_ids, + area_id, + code, + name, + sort, + type, + grade, + address, + zip_code, + master, + phone, + fax, + email, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag, + useable, + primary_person, + deputy_person + ) VALUES ( + #{id}, + #{parent.id}, + #{parentIds}, + #{area.id}, + #{code}, + #{name}, + #{sort}, + #{type}, + #{grade}, + #{address}, + #{zipCode}, + #{master}, + #{phone}, + #{fax}, + #{email}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag}, + #{useable}, + #{primaryPerson.id}, + #{deputyPerson.id} + ) + + + + UPDATE sys_office SET + parent_id = #{parent.id}, + parent_ids = #{parentIds}, + area_id = #{area.id}, + code = #{code}, + name = #{name}, + type = #{type}, + grade = #{grade}, + address = #{address}, + zip_code = #{zipCode}, + master = #{master}, + phone = #{phone}, + fax = #{fax}, + email = #{email}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + useable=#{useable}, + primary_person=#{primaryPerson.id}, + deputy_person=#{deputyPerson.id} + WHERE id = #{id} + + + + UPDATE sys_office SET + parent_id = #{parent.id}, + parent_ids = #{parentIds} + WHERE id = #{id} + + + + DELETE FROM sys_office + WHERE id = #{id} OR parent_ids LIKE + '%,'||#{id}||',%' + CONCAT('%,', #{id}, ',%') + + + + UPDATE sys_office SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} OR parent_ids LIKE + '%,'||#{id}||',%' + CONCAT('%,', #{id}, ',%') + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/RoleDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/RoleDao.xml new file mode 100644 index 0000000..5fa68ba --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/RoleDao.xml @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + a.id, + a.office_id AS "office.id", + a.name, + a.enname, + a.role_type AS roleType, + a.data_scope AS dataScope, + a.remarks, + a.create_by AS "createBy.id", + a.create_date, + a.update_by AS "updateBy.id", + a.update_date, + a.del_flag, + o.name AS "office.name", + o.code, + a.useable AS useable, + a.is_sys AS sysData + + + + + + + + + + + + + + INSERT INTO sys_role( + id, + office_id, + name, + enname, + role_type, + data_scope, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag, + is_sys, + useable + ) VALUES ( + #{id}, + #{office.id}, + #{name}, + #{enname}, + #{roleType}, + #{dataScope}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag}, + #{sysData}, + #{useable} + ) + + + + UPDATE sys_role SET + office_id = #{office.id}, + name = #{name}, + enname = #{enname}, + role_type = #{roleType}, + data_scope = #{dataScope}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + is_sys = #{sysData}, + useable = #{useable} + WHERE id = #{id} + + + + DELETE FROM sys_role_menu WHERE role_id = #{id} + + + + INSERT INTO sys_role_menu(role_id, menu_id) + + SELECT #{id}, #{menu.id} FROM dual + + + + + DELETE FROM sys_role_office WHERE role_id = #{id} + + + + INSERT INTO sys_role_office(role_id, office_id) + + SELECT #{id}, #{office.id} FROM dual + + + + + DELETE FROM sys_role + WHERE id = #{id} + + + + UPDATE sys_role SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/SysConfigDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/SysConfigDao.xml new file mode 100644 index 0000000..820ef48 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/SysConfigDao.xml @@ -0,0 +1,185 @@ + + + + + + a.id AS "id", + a.type AS "type", + a.value AS "value", + a.label AS "label", + a.description AS "description", + a.sort AS "sort", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remarks AS "remarks", + a.del_flag AS "delFlag", + a.picture AS "picture" + + + + a.id AS "id", + a.type AS "type", + a.value AS "value", + a.label AS "label", + a.description AS "description", + a.sort AS "sort", + a.create_by AS "createBy.id", + a.create_date AS "createDate", + a.update_by AS "updateBy.id", + a.update_date AS "updateDate", + a.remarks AS "remarks", + a.del_flag AS "delFlag", + a.picture AS "picture" + + + + + + + + + + + + + INSERT INTO sys_config( + id, + type, + value, + label, + description, + sort, + create_by, + create_date, + update_by, + update_date, + remarks, + del_flag, + picture + ) VALUES ( + #{id}, + #{type}, + #{value}, + #{label}, + #{description}, + #{sort}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{delFlag}, + #{picture} + ) + + + + UPDATE sys_config SET + type = #{type}, + value = #{value}, + label = #{label}, + description = #{description}, + sort = #{sort}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + picture = #{picture} + WHERE id = #{id} + + + + + + DELETE FROM sys_config + WHERE id = #{id} + + + + + UPDATE sys_config SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/SystemConfigDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/SystemConfigDao.xml new file mode 100644 index 0000000..2eb6671 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/SystemConfigDao.xml @@ -0,0 +1,110 @@ + + + + + + a.id AS "id", + a.smtp AS "smtp", + a.port AS "port", + a.mailname AS "mailName", + a.mailpassword AS "mailPassword", + a.smsname AS "smsName", + a.smspassword AS "smsPassword" + + + + + + + + + + + + + INSERT INTO systemconfig( + id, + smtp, + port, + mailname, + mailpassword, + smsname, + smspassword + ) VALUES ( + #{id}, + #{smtp}, + #{port}, + #{mailName}, + #{mailPassword}, + #{smsName}, + #{smsPassword} + ) + + + + UPDATE systemconfig SET + smtp = #{smtp}, + port = #{port}, + mailname = #{mailName}, + mailpassword = #{mailPassword}, + smsname = #{smsName}, + smspassword = #{smsPassword} + WHERE id = #{id} + + + + + + DELETE FROM systemconfig + WHERE id = #{id} + + + + + UPDATE systemconfig SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/UserDao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/UserDao.xml new file mode 100644 index 0000000..12a8a0a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/mappings/sys/UserDao.xml @@ -0,0 +1,443 @@ + + + + + + + + a.id, + a.company_id AS "company.id", + a.office_id AS "office.id", + a.login_name, + a.password, + a.no, + a.name, + a.email, + a.phone, + a.mobile, + a.user_type, + a.login_ip, + a.login_date, + a.remarks, + a.login_flag, + a.photo, + a.qrcode, + a.create_by AS "createBy.id", + a.create_date, + a.update_by AS "updateBy.id", + a.update_date, + a.del_flag, + c.name AS "company.name", + c.parent_id AS "company.parent.id", + c.parent_ids AS "company.parentIds", + ca.id AS "company.area.id", + ca.name AS "company.area.name", + ca.parent_id AS "company.area.parent.id", + ca.parent_ids AS "company.area.parentIds", + o.name AS "office.name", + o.parent_id AS "office.parent.id", + o.parent_ids AS "office.parentIds", + oa.id AS "office.area.id", + oa.name AS "office.area.name", + oa.parent_id AS "office.area.parent.id", + oa.parent_ids AS "office.area.parentIds", + cu.id AS "company.primaryPerson.id", + cu.name AS "company.primaryPerson.name", + cu2.id AS "company.deputyPerson.id", + cu2.name AS "company.deputyPerson.name", + ou.id AS "office.primaryPerson.id", + ou.name AS "office.primaryPerson.name", + ou2.id AS "office.deputyPerson.id", + ou2.name AS "office.deputyPerson.name" + + + + LEFT JOIN sys_office c ON c.id = a.company_id + LEFT JOIN sys_area ca ON ca.id = c.area_id + LEFT JOIN sys_office o ON o.id = a.office_id + LEFT JOIN sys_area oa ON oa.id = o.area_id + LEFT JOIN sys_user cu ON cu.id = c.primary_person + LEFT JOIN sys_user cu2 ON cu2.id = c.deputy_person + LEFT JOIN sys_user ou ON ou.id = o.primary_person + LEFT JOIN sys_user ou2 ON ou2.id = o.deputy_person + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO sys_user( + id, + company_id, + office_id, + login_name, + password, + no, + name, + email, + phone, + mobile, + user_type, + create_by, + create_date, + update_by, + update_date, + remarks, + login_flag, + photo, + qrcode, + del_flag + ) VALUES ( + #{id}, + #{company.id}, + #{office.id}, + #{loginName}, + #{password}, + #{no}, + #{name}, + #{email}, + #{phone}, + #{mobile}, + #{userType}, + #{createBy.id}, + #{createDate}, + #{updateBy.id}, + #{updateDate}, + #{remarks}, + #{loginFlag}, + #{photo}, + #{qrCode}, + #{delFlag} + ) + + + + + UPDATE sys_user SET + company_id = #{company.id}, + office_id = #{office.id}, + login_name = #{loginName}, + password = #{password}, + no = #{no}, + name = #{name}, + email = #{email}, + phone = #{phone}, + mobile = #{mobile}, + user_type = #{userType}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + login_flag = #{loginFlag}, + photo = #{photo}, + qrcode = #{qrCode} + WHERE id = #{id} + + + + + DELETE FROM sys_user_role WHERE user_id = #{id} + + + + + INSERT INTO sys_user_role(user_id, role_id) + + SELECT #{id}, #{role.id} FROM dual + + + + + + UPDATE sys_user SET + name = #{name}, + email = #{email}, + phone = #{phone}, + mobile = #{mobile}, + update_by = #{updateBy.id}, + update_date = #{updateDate}, + remarks = #{remarks}, + photo = #{photo}, + qrcode = #{qrCode} + WHERE id = #{id} + + + + + UPDATE sys_user SET + password = #{password} + WHERE id = #{id} + + + + + UPDATE sys_user SET + login_ip = #{loginIp}, + login_Date = #{loginDate} + WHERE id = #{id} + + + + + DELETE FROM sys_user + WHERE id = #{id} + + + + + UPDATE sys_user SET + del_flag = #{DEL_FLAG_DELETE} + WHERE id = #{id} + + + + + + + INSERT INTO sys_user_friend( + id, + userId, + friendId + ) VALUES ( + #{id}, + #{userId}, + #{friendId} + ) + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/config.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/config.xml new file mode 100644 index 0000000..cdff21e --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/config.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/IService.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/IService.xml new file mode 100644 index 0000000..d2d13fa --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/IService.xml @@ -0,0 +1,25 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/controller.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/controller.xml new file mode 100644 index 0000000..b0781d6 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/controller.xml @@ -0,0 +1,344 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/service.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/service.xml new file mode 100644 index 0000000..ef05d52 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/service.xml @@ -0,0 +1,174 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/serviceMany.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/serviceMany.xml new file mode 100644 index 0000000..226f4c3 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/serviceMany.xml @@ -0,0 +1,226 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewForm.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewForm.xml new file mode 100644 index 0000000..05d0c2a --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewForm.xml @@ -0,0 +1,132 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormCSS.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormCSS.xml new file mode 100644 index 0000000..e270294 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormCSS.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormJS.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormJS.xml new file mode 100644 index 0000000..2e6e393 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormJS.xml @@ -0,0 +1,87 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormMany.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormMany.xml new file mode 100644 index 0000000..a704f30 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormMany.xml @@ -0,0 +1,338 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormManyTwo.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormManyTwo.xml new file mode 100644 index 0000000..9a3d291 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormManyTwo.xml @@ -0,0 +1,340 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormTwo.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormTwo.xml new file mode 100644 index 0000000..c4a90a4 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewFormTwo.xml @@ -0,0 +1,134 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewList.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewList.xml new file mode 100644 index 0000000..a4be5de --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewList.xml @@ -0,0 +1,219 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListCSS.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListCSS.xml new file mode 100644 index 0000000..e248f59 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListCSS.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListJS.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListJS.xml new file mode 100644 index 0000000..db007df --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListJS.xml @@ -0,0 +1,33 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListVue.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListVue.xml new file mode 100644 index 0000000..abe0906 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewListVue.xml @@ -0,0 +1,176 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewSelect.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewSelect.xml new file mode 100644 index 0000000..daeafa7 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewSelect.xml @@ -0,0 +1,272 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotal.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotal.xml new file mode 100644 index 0000000..24b5a29 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotal.xml @@ -0,0 +1,166 @@ + + diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalCSS.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalCSS.xml new file mode 100644 index 0000000..52ed01d --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalCSS.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalJS.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalJS.xml new file mode 100644 index 0000000..f029966 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalJS.xml @@ -0,0 +1,59 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalMap.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalMap.xml new file mode 100644 index 0000000..5d4adda --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/curd/viewTotalMap.xml @@ -0,0 +1,250 @@ + + diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/dao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/dao.xml new file mode 100644 index 0000000..71c6d72 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/dao.xml @@ -0,0 +1,26 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/entity.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/entity.xml new file mode 100644 index 0000000..2972014 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/entity.xml @@ -0,0 +1,224 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/mapper.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/mapper.xml new file mode 100644 index 0000000..33a28ec --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dao/mapper.xml @@ -0,0 +1,372 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dubbo/serviceDubbo.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dubbo/serviceDubbo.xml new file mode 100644 index 0000000..85a63d5 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dubbo/serviceDubbo.xml @@ -0,0 +1,37 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dubbo/serviceImplDubbo.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dubbo/serviceImplDubbo.xml new file mode 100644 index 0000000..78503a7 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/dubbo/serviceImplDubbo.xml @@ -0,0 +1,85 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/gen.txt b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/gen.txt new file mode 100644 index 0000000..e69de29 diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/rest/restController.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/rest/restController.xml new file mode 100644 index 0000000..dce7a08 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/rest/restController.xml @@ -0,0 +1,311 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/controller.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/controller.xml new file mode 100644 index 0000000..35a9b98 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/controller.xml @@ -0,0 +1,146 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/dao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/dao.xml new file mode 100644 index 0000000..da26d2f --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/dao.xml @@ -0,0 +1,27 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/entity.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/entity.xml new file mode 100644 index 0000000..163803c --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/entity.xml @@ -0,0 +1,142 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/mapper.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/mapper.xml new file mode 100644 index 0000000..3c69b94 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/mapper.xml @@ -0,0 +1,239 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/service.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/service.xml new file mode 100644 index 0000000..6f76a74 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/service.xml @@ -0,0 +1,54 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/viewForm.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/viewForm.xml new file mode 100644 index 0000000..518b4b4 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/viewForm.xml @@ -0,0 +1,113 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/viewList.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/viewList.xml new file mode 100644 index 0000000..9b3c2fe --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/tree/viewList.xml @@ -0,0 +1,184 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/controller.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/controller.xml new file mode 100644 index 0000000..5d3e181 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/controller.xml @@ -0,0 +1,146 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/dao.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/dao.xml new file mode 100644 index 0000000..6b8a951 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/dao.xml @@ -0,0 +1,27 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/entity.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/entity.xml new file mode 100644 index 0000000..a5978bf --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/entity.xml @@ -0,0 +1,139 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/mapper.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/mapper.xml new file mode 100644 index 0000000..6e9ae68 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/mapper.xml @@ -0,0 +1,239 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/service.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/service.xml new file mode 100644 index 0000000..64860be --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/service.xml @@ -0,0 +1,54 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/viewForm.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/viewForm.xml new file mode 100644 index 0000000..261d982 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/viewForm.xml @@ -0,0 +1,113 @@ + + \ No newline at end of file diff --git a/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/viewList.xml b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/viewList.xml new file mode 100644 index 0000000..b473749 --- /dev/null +++ b/JeeSpringCloud/jeespring-framework/src/main/resources/templates/modules/gen/treetable/viewList.xml @@ -0,0 +1,184 @@ + + \ No newline at end of file -- GitLab